Skip to content

Commit

Permalink
Merge pull request #111 from nomad-coe/108-add-support-for-mole-in-en…
Browse files Browse the repository at this point in the history
…ergy-quantities-in-h5md-parser

Support for energy per mole in H5MD
  • Loading branch information
JFRudzinski authored Jun 20, 2024
2 parents 7e2734d + 80f4a7a commit 26395a3
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions atomisticparsers/h5md/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -536,11 +536,20 @@ def parse_calculation(self):
if (
"energ" in observable_name
): # TODO check for energies or energy when matching name
if hasattr(Energy, observable_label):
data["energy"][observable_label] = dict(value=val)
# check for usage of energy/mole and convert to energy
if val.check("[energy]/[substance]") and "mole" in str(val.units):
val = val * MOL * ureg.mole

if val.check("[energy]"):
if hasattr(Energy, observable_label):
data["energy"][observable_label] = dict(value=val)
else:
data_h5md["x_h5md_energy_contributions"].append(
EnergyEntry(kind=key, value=val)
)
else:
data_h5md["x_h5md_energy_contributions"].append(
EnergyEntry(kind=key, value=val)
self.logger.warning(
"Energy value not in energy units. Skipping entry."
)
else:
if hasattr(BaseCalculation, observable_label):
Expand Down

0 comments on commit 26395a3

Please sign in to comment.