Skip to content

Commit

Permalink
Rename units for clarity
Browse files Browse the repository at this point in the history
  • Loading branch information
ElliottKasoar committed Jan 14, 2025
1 parent 154223f commit 48e014e
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 26 deletions.
4 changes: 3 additions & 1 deletion janus_core/calculations/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,9 @@ def __init__(
self.logger, self.track_carbon, **self.tracker_kwargs
)

def _set_units(self, keys: Sequence[str] = ("energy", "forces", "stress")) -> None:
def _set_info_units(
self, keys: Sequence[str] = ("energy", "forces", "stress")
) -> None:
"""
Save units to structure info.
Expand Down
2 changes: 1 addition & 1 deletion janus_core/calculations/eos.py
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ def run(self) -> EoSResults:
Dictionary containing equation of state ASE object, and the fitted minimum
bulk modulus, volume, and energy.
"""
self._set_units()
self._set_info_units()

if self.minimize:
if self.logger:
Expand Down
2 changes: 1 addition & 1 deletion janus_core/calculations/geom_opt.py
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,7 @@ def run(self) -> None:
if self.tracker:
self.tracker.start_task("Geometry optimization")

self._set_units()
self._set_info_units()

converged = self.dyn.run(fmax=self.fmax, steps=self.steps)

Expand Down
43 changes: 22 additions & 21 deletions janus_core/calculations/md.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@
import numpy as np
import yaml

from janus_core.calculations.base import UNITS, BaseCalculation
from janus_core.calculations.base import UNITS as JANUS_UNITS
from janus_core.calculations.base import BaseCalculation
from janus_core.calculations.geom_opt import GeomOpt
from janus_core.helpers.janus_types import (
Architectures,
Expand Down Expand Up @@ -799,21 +800,21 @@ def unit_info(self) -> dict[str, str]:
"""
return {
"Step": None,
"Real_Time": UNITS["real_time"],
"Time": UNITS["time"],
"Epot/N": UNITS["energy"],
"EKin/N": UNITS["energy"],
"T": UNITS["temperature"],
"ETot/N": UNITS["energy"],
"Density": UNITS["density"],
"Volume": UNITS["volume"],
"P": UNITS["pressure"],
"Pxx": UNITS["pressure"],
"Pyy": UNITS["pressure"],
"Pzz": UNITS["pressure"],
"Pyz": UNITS["pressure"],
"Pxz": UNITS["pressure"],
"Pxy": UNITS["pressure"],
"Real_Time": JANUS_UNITS["real_time"],
"Time": JANUS_UNITS["time"],
"Epot/N": JANUS_UNITS["energy"],
"EKin/N": JANUS_UNITS["energy"],
"T": JANUS_UNITS["temperature"],
"ETot/N": JANUS_UNITS["energy"],
"Density": JANUS_UNITS["density"],
"Volume": JANUS_UNITS["volume"],
"P": JANUS_UNITS["pressure"],
"Pxx": JANUS_UNITS["pressure"],
"Pyy": JANUS_UNITS["pressure"],
"Pzz": JANUS_UNITS["pressure"],
"Pyz": JANUS_UNITS["pressure"],
"Pxz": JANUS_UNITS["pressure"],
"Pxy": JANUS_UNITS["pressure"],
}

@property
Expand Down Expand Up @@ -1034,7 +1035,7 @@ def run(self) -> None:
"density",
"momenta",
)
self._set_units(unit_keys)
self._set_info_units(unit_keys)

if not self.restart:
if self.minimize:
Expand Down Expand Up @@ -1278,8 +1279,8 @@ def unit_info(self) -> dict[str, str]:
Units attached to statistical properties.
"""
return super().unit_info | {
"Target_P": UNITS["pressure"],
"Target_T": UNITS["temperature"],
"Target_P": JANUS_UNITS["pressure"],
"Target_T": JANUS_UNITS["temperature"],
}

@property
Expand Down Expand Up @@ -1377,7 +1378,7 @@ def unit_info(self) -> dict[str, str]:
dict[str, str]
Units attached to statistical properties.
"""
return super().unit_info | {"Target_T": UNITS["temperature"]}
return super().unit_info | {"Target_T": JANUS_UNITS["temperature"]}

@property
def default_formats(self) -> dict[str, str]:
Expand Down Expand Up @@ -1520,7 +1521,7 @@ def unit_info(self) -> dict[str, str]:
dict[str, str]
Units attached to statistical properties.
"""
return super().unit_info | {"Target_T": UNITS["temperature"]}
return super().unit_info | {"Target_T": JANUS_UNITS["temperature"]}

@property
def default_formats(self) -> dict[str, str]:
Expand Down
2 changes: 1 addition & 1 deletion janus_core/calculations/phonons.py
Original file line number Diff line number Diff line change
Expand Up @@ -435,7 +435,7 @@ def calc_force_constants(
if self.tracker:
self.tracker.start_task("Phonon calculation")

self._set_units()
self._set_info_units()

cell = self._ASE_to_PhonopyAtoms(self.struct)

Expand Down
2 changes: 1 addition & 1 deletion janus_core/calculations/single_point.py
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,7 @@ def run(self) -> CalcResults:
if self.tracker:
self.tracker.start_task("Single point")

self._set_units(self.properties)
self._set_info_units(self.properties)

if "energy" in self.properties:
self.results["energy"] = self._get_potential_energy()
Expand Down

0 comments on commit 48e014e

Please sign in to comment.