-
Notifications
You must be signed in to change notification settings - Fork 69
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add test for CalcOutput.from_directory.
- Loading branch information
1 parent
b9eb651
commit 69b687e
Showing
5 changed files
with
55 additions
and
0 deletions.
There are no files selected for viewing
Empty file.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
from pathlib import Path | ||
|
||
import numpy as np | ||
from emmet.core.classical_md.openmm import CalculationOutput | ||
|
||
|
||
def test_calc_output_from_directory(test_dir): | ||
output_dir = test_dir / "classical_md" / "calc_output" | ||
# Call the from_directory function | ||
calc_out = CalculationOutput.from_directory( | ||
output_dir, | ||
"state.csv", | ||
"trajectory.dcd", | ||
elapsed_time=10.0, | ||
n_steps=1500, | ||
state_interval=100, | ||
) | ||
|
||
# Assert the expected attributes of the CalculationOutput object | ||
assert isinstance(calc_out, CalculationOutput) | ||
assert calc_out.dir_name == str(output_dir) | ||
assert calc_out.elapsed_time == 10.0 | ||
assert calc_out.traj_file == "trajectory.dcd" | ||
assert calc_out.state_file == "state.csv" | ||
|
||
# Assert the contents of the state data | ||
assert np.array_equal(calc_out.steps_reported[:3], [100, 200, 300]) | ||
assert np.allclose(calc_out.potential_energy[:3], [-26192.4, -25648.6, -25149.6]) | ||
assert np.allclose(calc_out.kinetic_energy[:3], [609.4, 1110.4, 1576.4], atol=0.1) | ||
assert np.allclose(calc_out.total_energy[:3], [-25583.1, -24538.1, -23573.2]) | ||
assert np.allclose(calc_out.temperature[:3], [29.6, 54.0, 76.6], atol=0.1) | ||
assert np.allclose(calc_out.volume[:3], [21.9, 21.9, 21.9], atol=0.1) | ||
assert np.allclose(calc_out.density[:3], [1.0, 0.99, 0.99], atol=0.1) | ||
|
||
# Assert the existence of the DCD and state files | ||
assert Path(calc_out.dir_name, calc_out.traj_file).exists() | ||
assert Path(calc_out.dir_name, calc_out.state_file).exists() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
#"Step","Potential Energy (kJ/mole)","Kinetic Energy (kJ/mole)","Total Energy (kJ/mole)","Temperature (K)","Box Volume (nm^3)","Density (g/mL)" | ||
1000,-26192.479795343505,609.4196914344211,-25583.060103909083,29.614683433627977,21.873459457163882,0.9954543820541577 | ||
2000,-25648.552310042112,1110.4255423058567,-24538.126767736256,53.96100811019054,21.896418997832697,0.9944105960647234 | ||
100,-26192.479795343505,609.4196914344211,-25583.060103909083,29.614683433627977,21.873459457163882,0.9954543820541577 | ||
200,-25648.552310042112,1110.4255423058567,-24538.126767736256,53.96100811019054,21.896418997832697,0.9944105960647234 | ||
300,-25149.615762218746,1576.3685252566356,-23573.24723696211,76.60345654458364,21.902472359270778,0.9941357628560747 | ||
400,-24737.794927124953,2048.908203465864,-22688.88672365909,99.5664706655355,22.025973627010902,0.988561569901083 | ||
500,-24236.83499597991,2362.5727053481387,-21874.26229063177,114.80896292197377,22.427603013306435,0.9708585912814258 | ||
600,-23952.5612414965,2744.7859341483563,-21207.775307348144,133.38257308612992,22.451255694017004,0.9698357795248072 | ||
700,-23561.24490686599,2981.7360809766687,-20579.508825889323,144.89713962623532,22.617654864431856,0.9627006512314953 | ||
800,-23257.599271389336,3263.6894834260456,-19993.90978796329,158.59863446457717,22.561532702010723,0.9650953840284621 | ||
900,-22989.069612634717,3515.5816009845585,-19473.48801165016,170.83930444254142,22.982310428217957,0.9474256792121007 | ||
1000,-22721.45251535368,3712.6360813537613,-19008.81643399992,180.4151454226322,23.05915218995153,0.9442685007650109 | ||
1100,-22390.948659398535,3880.3415879751556,-18510.60707142338,188.5647762246478,23.158223282091488,0.9402289114362175 | ||
1200,-22183.04180200165,4033.800234109862,-18149.24156789179,196.02208239526976,23.20718359651434,0.9382453056728586 | ||
1300,-22048.592668279394,4216.629234793596,-17831.9634334858,204.90663774167015,22.84203464974821,0.9532439382565145 | ||
1400,-21737.752101440245,4308.225194310769,-17429.526907129475,209.35773340370193,23.121043846718113,0.94174083193084 | ||
1500,-21603.87279039141,4662.04510079883,-16941.82768959258,226.55157316706197,23.185483890016233,0.9391234261318885 |
Binary file not shown.