def test_md_trajectory(): structures = md_trajectory_from_vasprun('test_files/test_vasprun.xml') assert len(structures) == 2 for struct in structures: assert struct.forces.shape == (6, 3) assert struct.energy is not None assert struct.stress.shape == (3, 3) structures = md_trajectory_from_vasprun('test_files/test_vasprun.xml', ionic_step_skips=2) assert len(structures) == 1
def test_read_write_trajectory(): structures = md_trajectory_from_vasprun('test_files/test_vasprun.xml') fname = 'tst_traj.json' md_trajectory_to_file(fname, structures) fstructures = md_trajectory_from_file(fname) for s, f in zip(structures, fstructures): assert np.isclose(s.forces, f.forces).all() assert np.isclose(s.positions, f.positions).all() os.system('rm tst_traj.json')