Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ coverage.xml

# Django stuff:
*.log
!tests/fixtures/nwchem/test-002/*.log
local_settings.py

# Flask stuff:
Expand Down
36 changes: 36 additions & 0 deletions express/parsers/apps/nwchem/formats/txt.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,3 +63,39 @@ def lumo_energy(self, text):
float | None
"""
return self._general_output_parser(text, **settings.REGEX["lumo_energy"])

def zero_point_energy(self, text):
"""
Extracts zero point energy.

Args:
text (str): text to extract data from.

Returns:
float | None
"""
return self._general_output_parser(text, **settings.REGEX["zero_point_energy"])

def thermal_correction_to_energy(self, text):
"""
Extracts thermal correction to energy.

Args:
text (str): text to extract data from.

Returns:
float | None
"""
return self._general_output_parser(text, **settings.REGEX["thermal_correction_to_energy"])

def thermal_correction_to_enthalpy(self, text):
"""
Extracts thermal correction to enthalpy.

Args:
text (str): text to extract data from.

Returns:
float | None
"""
return self._general_output_parser(text, **settings.REGEX["thermal_correction_to_enthalpy"])
29 changes: 29 additions & 0 deletions express/parsers/apps/nwchem/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ def __init__(self, *args, **kwargs):
self.stdout_file = self.kwargs["stdout_file"]
self.txt_parser = NwchemTXTParser(self.work_dir)

@staticmethod
def _kcal_per_mol_to_ev(value):
return value * Constant.kcal / Constant._Nav

def total_energy(self):
"""
Returns total energy.
Expand Down Expand Up @@ -65,6 +69,31 @@ def lumo_energy(self):
lumo_energy = self.txt_parser.lumo_energy(self._get_file_content(self.stdout_file))
return None if lumo_energy is None else Constant.HARTREE * lumo_energy

def zero_point_energy(self):
"""
Returns zero point energy.

Reference:
NWChem zero-point correction is printed in kcal/mol and converted to eV in this method.
"""
zero_point_energy = self.txt_parser.zero_point_energy(self._get_file_content(self.stdout_file))
return None if zero_point_energy is None else self._kcal_per_mol_to_ev(zero_point_energy)

def thermal_correction_to_energy(self):
"""
Returns thermal correction to energy.

Reference:
NWChem thermochemistry correction is parsed directly in kcal/mol.
"""
return self.txt_parser.thermal_correction_to_energy(self._get_file_content(self.stdout_file))

def thermal_correction_to_enthalpy(self):
"""
Returns thermal correction to enthalpy.
"""
return self.txt_parser.thermal_correction_to_enthalpy(self._get_file_content(self.stdout_file))

def _is_nwchem_output_file(self, path):
"""
Checks whether the given file is nwchem output file.
Expand Down
15 changes: 15 additions & 0 deletions express/parsers/apps/nwchem/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,21 @@
"total_energy": {"regex": COMMON_REGEX.format("Total DFT energy"), "occurrences": -1, "output_type": "float"},
"homo_energy": {"regex": COMMON_REGEX.format("HOMO"), "occurrences": -1, "output_type": "float"},
"lumo_energy": {"regex": COMMON_REGEX.format("LUMO"), "occurrences": -1, "output_type": "float"},
"zero_point_energy": {
"regex": COMMON_REGEX.format("Zero-Point correction to Energy"),
"occurrences": -1,
"output_type": "float",
},
"thermal_correction_to_energy": {
"regex": COMMON_REGEX.format("Thermal correction to Energy"),
"occurrences": -1,
"output_type": "float",
},
"thermal_correction_to_enthalpy": {
"regex": COMMON_REGEX.format("Thermal correction to Enthalpy"),
"occurrences": -1,
"output_type": "float",
},
}
TOTAL_ENERGY_CONTRIBUTIONS = {
"one_electron": {"regex": COMMON_REGEX.format("One electron energy"), "occurrences": -1, "output_type": "float"},
Expand Down
11 changes: 11 additions & 0 deletions express/properties/scalar/thermal_correction_to_energy.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
from express.properties.scalar import ScalarProperty


class ThermalCorrectionToEnergy(ScalarProperty):
"""
Thermal correction to energy property class.
"""

def __init__(self, name, parser, *args, **kwargs):
super(ThermalCorrectionToEnergy, self).__init__(name, parser, *args, **kwargs)
self.value = self.parser.thermal_correction_to_energy()
11 changes: 11 additions & 0 deletions express/properties/scalar/thermal_correction_to_enthalpy.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
from express.properties.scalar import ScalarProperty


class ThermalCorrectionToEnthalpy(ScalarProperty):
"""
Thermal correction to enthalpy property class.
"""

def __init__(self, name, parser, *args, **kwargs):
super(ThermalCorrectionToEnthalpy, self).__init__(name, parser, *args, **kwargs)
self.value = self.parser.thermal_correction_to_enthalpy()
6 changes: 6 additions & 0 deletions express/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,12 @@
"elemental_ratio": {"reference": "express.properties.scalar.elemental_ratio.ElementalRatio"},
"p-norm": {"reference": "express.properties.scalar.p_norm.PNorm"},
"zero_point_energy": {"reference": "express.properties.scalar.zero_point_energy.ZeroPointEnergy"},
"thermal_correction_to_energy": {
"reference": "express.properties.scalar.thermal_correction_to_energy.ThermalCorrectionToEnergy"
},
"thermal_correction_to_enthalpy": {
"reference": "express.properties.scalar.thermal_correction_to_enthalpy.ThermalCorrectionToEnthalpy"
},
"surface_energy": {"reference": "express.properties.scalar.scalar_property_context.ScalarPropertyFromContext"},
"reaction_energy_barrier": {"reference": "express.properties.scalar.reaction_energy_barrier.ReactionEnergyBarrier"},
"valence_band_offset": {"reference": "express.properties.scalar.scalar_property_context.ScalarPropertyFromContext"},
Expand Down
3 changes: 3 additions & 0 deletions tests/fixtures/nwchem/references.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@
TOTAL_ENERGY = -2079.18666382721904
HOMO_ENERGY = -12.800485418916242
LUMO_ENERGY = 3.1242763921882197
ZERO_POINT_ENERGY = 0.5748347036575007
THERMAL_CORRECTION_TO_ENERGY = 15.033
THERMAL_CORRECTION_TO_ENTHALPY = 15.626

TOTAL_ENERGY_CONTRIBUTION = {
"one_electron": {"name": "one_electron", "value": -3350.531714067630674},
Expand Down
Loading
Loading