|
12 | 12 | from typing import Any |
13 | 13 | from warnings import warn |
14 | 14 |
|
15 | | -from ase import Atoms, units |
| 15 | +from ase import Atoms |
16 | 16 | from ase.geometry.analysis import Analysis |
17 | 17 | from ase.io import read |
18 | 18 | from ase.md.langevin import Langevin |
|
23 | 23 | ZeroRotation, |
24 | 24 | ) |
25 | 25 | from ase.md.verlet import VelocityVerlet |
| 26 | +from ase.units import create_units |
26 | 27 | import numpy as np |
27 | 28 | import yaml |
28 | 29 |
|
| 30 | +from janus_core.calculations.base import UNITS as JANUS_UNITS |
29 | 31 | from janus_core.calculations.base import BaseCalculation |
30 | 32 | from janus_core.calculations.geom_opt import GeomOpt |
31 | 33 | from janus_core.helpers.janus_types import ( |
|
43 | 45 | from janus_core.processing.correlator import Correlation |
44 | 46 | from janus_core.processing.post_process import compute_rdf, compute_vaf |
45 | 47 |
|
| 48 | +units = create_units("2014") |
46 | 49 | DENS_FACT = (units.m / 1.0e2) ** 3 / units.mol |
47 | 50 |
|
48 | 51 |
|
@@ -525,7 +528,7 @@ def _set_info(self) -> None: |
525 | 528 | """Set time in fs, current dynamics step, and density to info.""" |
526 | 529 | time = (self.offset * self.timestep + self.dyn.get_time()) / units.fs |
527 | 530 | step = self.offset + self.dyn.nsteps |
528 | | - self.dyn.atoms.info["time_fs"] = time |
| 531 | + self.dyn.atoms.info["time"] = time |
529 | 532 | self.dyn.atoms.info["step"] = step |
530 | 533 | try: |
531 | 534 | density = ( |
@@ -772,7 +775,7 @@ def get_stats(self) -> dict[str, float]: |
772 | 775 | return { |
773 | 776 | "Step": self.dyn.atoms.info["step"], |
774 | 777 | "Real_Time": real_time.total_seconds(), |
775 | | - "Time": self.dyn.atoms.info["time_fs"], |
| 778 | + "Time": self.dyn.atoms.info["time"], |
776 | 779 | "Epot/N": e_pot, |
777 | 780 | "EKin/N": e_kin, |
778 | 781 | "T": current_temp, |
@@ -800,21 +803,21 @@ def unit_info(self) -> dict[str, str]: |
800 | 803 | """ |
801 | 804 | return { |
802 | 805 | "Step": None, |
803 | | - "Real_Time": "s", |
804 | | - "Time": "fs", |
805 | | - "Epot/N": "eV", |
806 | | - "EKin/N": "eV", |
807 | | - "T": "K", |
808 | | - "ETot/N": "eV", |
809 | | - "Density": "g/cm^3", |
810 | | - "Volume": "A^3", |
811 | | - "P": "GPa", |
812 | | - "Pxx": "GPa", |
813 | | - "Pyy": "GPa", |
814 | | - "Pzz": "GPa", |
815 | | - "Pyz": "GPa", |
816 | | - "Pxz": "GPa", |
817 | | - "Pxy": "GPa", |
| 806 | + "Real_Time": JANUS_UNITS["real_time"], |
| 807 | + "Time": JANUS_UNITS["time"], |
| 808 | + "Epot/N": JANUS_UNITS["energy"], |
| 809 | + "EKin/N": JANUS_UNITS["energy"], |
| 810 | + "T": JANUS_UNITS["temperature"], |
| 811 | + "ETot/N": JANUS_UNITS["energy"], |
| 812 | + "Density": JANUS_UNITS["density"], |
| 813 | + "Volume": JANUS_UNITS["volume"], |
| 814 | + "P": JANUS_UNITS["pressure"], |
| 815 | + "Pxx": JANUS_UNITS["pressure"], |
| 816 | + "Pyy": JANUS_UNITS["pressure"], |
| 817 | + "Pzz": JANUS_UNITS["pressure"], |
| 818 | + "Pyz": JANUS_UNITS["pressure"], |
| 819 | + "Pxz": JANUS_UNITS["pressure"], |
| 820 | + "Pxy": JANUS_UNITS["pressure"], |
818 | 821 | } |
819 | 822 |
|
820 | 823 | @property |
@@ -1024,6 +1027,19 @@ def _write_restart(self) -> None: |
1024 | 1027 |
|
1025 | 1028 | def run(self) -> None: |
1026 | 1029 | """Run molecular dynamics simulation and/or temperature ramp.""" |
| 1030 | + unit_keys = ( |
| 1031 | + "energy", |
| 1032 | + "forces", |
| 1033 | + "stress", |
| 1034 | + "time", |
| 1035 | + "real_time", |
| 1036 | + "temperature", |
| 1037 | + "pressure", |
| 1038 | + "density", |
| 1039 | + "momenta", |
| 1040 | + ) |
| 1041 | + self._set_info_units(unit_keys) |
| 1042 | + |
1027 | 1043 | if not self.restart: |
1028 | 1044 | if self.minimize: |
1029 | 1045 | self._optimize_structure() |
@@ -1265,7 +1281,10 @@ def unit_info(self) -> dict[str, str]: |
1265 | 1281 | dict[str, str] |
1266 | 1282 | Units attached to statistical properties. |
1267 | 1283 | """ |
1268 | | - return super().unit_info | {"Target_P": "GPa", "Target_T": "K"} |
| 1284 | + return super().unit_info | { |
| 1285 | + "Target_P": JANUS_UNITS["pressure"], |
| 1286 | + "Target_T": JANUS_UNITS["temperature"], |
| 1287 | + } |
1269 | 1288 |
|
1270 | 1289 | @property |
1271 | 1290 | def default_formats(self) -> dict[str, str]: |
@@ -1362,7 +1381,7 @@ def unit_info(self) -> dict[str, str]: |
1362 | 1381 | dict[str, str] |
1363 | 1382 | Units attached to statistical properties. |
1364 | 1383 | """ |
1365 | | - return super().unit_info | {"Target_T": "K"} |
| 1384 | + return super().unit_info | {"Target_T": JANUS_UNITS["temperature"]} |
1366 | 1385 |
|
1367 | 1386 | @property |
1368 | 1387 | def default_formats(self) -> dict[str, str]: |
@@ -1505,7 +1524,7 @@ def unit_info(self) -> dict[str, str]: |
1505 | 1524 | dict[str, str] |
1506 | 1525 | Units attached to statistical properties. |
1507 | 1526 | """ |
1508 | | - return super().unit_info | {"Target_T": "K"} |
| 1527 | + return super().unit_info | {"Target_T": JANUS_UNITS["temperature"]} |
1509 | 1528 |
|
1510 | 1529 | @property |
1511 | 1530 | def default_formats(self) -> dict[str, str]: |
|
0 commit comments