Skip to content

Commit

Permalink
Update stats headers
Browse files Browse the repository at this point in the history
  • Loading branch information
ElliottKasoar committed Apr 4, 2024
1 parent b579947 commit 28f92bf
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 12 deletions.
17 changes: 8 additions & 9 deletions janus_core/md.py
Original file line number Diff line number Diff line change
Expand Up @@ -344,10 +344,9 @@ def get_log_header() -> str:
Header for molecular dynamics log.
"""
log_header = (
"Step | real time[s] | Time [fs] | Epot/N [eV] | Ekin/N [eV] | "
"c_T [eV/K] | Etot/N [eV] | Density [g/cm^3] | Volume [A^3] | "
"Pressure [bar] | Pxx [bar] | Pyy [bar] | Pzz[bar] | Pyz[bar] | "
"Pxz[bar] | Pxy[bar]"
"Step | Real Time [s] | Time [fs] | Epot/N [eV] | Ekin/N [eV] | "
"T [K] | Etot/N [eV] | Density [g/cm^3] | Volume [A^3] | P [bar] | "
"Pxx [bar] | Pyy [bar] | Pzz [bar] | Pyz [bar] | Pxz [bar] | Pxy [bar]"
)

return log_header
Expand All @@ -363,7 +362,7 @@ def get_log_stats(self) -> str:
"""
e_pot = self.dyn.atoms.get_potential_energy() / self.n_atoms
e_kin = self.dyn.atoms.get_kinetic_energy() / self.n_atoms
c_T = e_kin / (1.5 * units.kB) # pylint: disable=invalid-name
current_temp = e_kin / (1.5 * units.kB)

time = self.offset * self.timestep + self.dyn.get_time() / units.fs
step = self.offset + self.dyn.nsteps
Expand Down Expand Up @@ -401,7 +400,7 @@ def get_log_stats(self) -> str:

log_stats = (
f"{step:10d} {real_time.total_seconds():.3f} {time:13.2f} {e_pot:.3e} "
f"{e_kin:.3e} {c_T:.3f} {e_pot + e_kin:.3e} {density:.3f} "
f"{e_kin:.3e} {current_temp:.3f} {e_pot + e_kin:.3e} {density:.3f} "
f"{volume:.3e} {pressure:.3e} {pressure_tensor[0]:.3e} "
f"{pressure_tensor[1]:.3e} {pressure_tensor[2]:.3e} "
f"{pressure_tensor[3]:.3e} {pressure_tensor[4]:.3e} "
Expand Down Expand Up @@ -611,7 +610,7 @@ def get_log_header() -> str:
Header for molecular dynamics log.
"""
log_header = MolecularDynamics.get_log_header()
return log_header + " | Pressure[bar] | T [K]"
return log_header + " | Target P [bar] | Target T [K]"


class NVT(MolecularDynamics):
Expand Down Expand Up @@ -689,7 +688,7 @@ def get_log_header() -> str:
Header for molecular dynamics log.
"""
log_header = MolecularDynamics.get_log_header()
return log_header + " | T [K]"
return log_header + " | Target T [K]"


class NVE(MolecularDynamics):
Expand Down Expand Up @@ -800,7 +799,7 @@ def get_log_header() -> str:
Header for molecular dynamics log.
"""
log_header = MolecularDynamics.get_log_header()
return log_header + " | T [K]"
return log_header + " | Target T [K]"


class NPH(NPT):
Expand Down
4 changes: 2 additions & 2 deletions tests/test_md.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ def test_npt():

with open(stats_path, encoding="utf8") as stats_file:
lines = stats_file.readlines()
assert "Pressure[bar] | T [K]" in lines[0]
assert "Target P [bar] | Target T [K]" in lines[0]
assert len(lines) == 5
finally:
restart_path_1.unlink(missing_ok=True)
Expand Down Expand Up @@ -246,7 +246,7 @@ def test_restart(tmp_path):

with open(stats_path, encoding="utf8") as stats_file:
lines = stats_file.readlines()
assert " | T [K]" in lines[0]
assert " | Target T [K]" in lines[0]
# Includes step 0, and step 4 from restart
assert len(lines) == 11
assert 8 == int(lines[-1].split()[0])
Expand Down
2 changes: 1 addition & 1 deletion tests/test_md_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ def test_md_log(tmp_path, caplog):
assert init_volume == pytest.approx(final_volume)

# Test constant temperature
assert lines[0].split(" | ")[16] == "T [K]\n"
assert lines[0].split(" | ")[16] == "Target T [K]\n"
init_temp = float(lines[1].split()[16])
final_temp = float(lines[-1].split()[16])
assert init_temp == 300.0
Expand Down

0 comments on commit 28f92bf

Please sign in to comment.