From cbb013cbd8841ab8a1c3a610189aef0b06fabc00 Mon Sep 17 00:00:00 2001 From: ElliottKasoar Date: Thu, 4 Apr 2024 14:56:54 +0100 Subject: [PATCH] Update stats headers --- janus_core/md.py | 17 ++++++++--------- tests/test_md.py | 4 ++-- tests/test_md_cli.py | 2 +- 3 files changed, 11 insertions(+), 12 deletions(-) diff --git a/janus_core/md.py b/janus_core/md.py index c1134574..5e3357c5 100644 --- a/janus_core/md.py +++ b/janus_core/md.py @@ -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 @@ -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 @@ -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} " @@ -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): @@ -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): @@ -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): diff --git a/tests/test_md.py b/tests/test_md.py index ad009b34..afcbfe4d 100644 --- a/tests/test_md.py +++ b/tests/test_md.py @@ -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) @@ -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]) diff --git a/tests/test_md_cli.py b/tests/test_md_cli.py index f722342a..4b116053 100644 --- a/tests/test_md_cli.py +++ b/tests/test_md_cli.py @@ -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