Skip to content

Commit

Permalink
fix nasty ipi inconsistency in trajectory naming
Browse files Browse the repository at this point in the history
  • Loading branch information
svandenhaute committed Jun 27, 2024
1 parent ddfa2f3 commit fe09240
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 8 deletions.
24 changes: 17 additions & 7 deletions psiflow/tools/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -387,16 +387,26 @@ def cleanup(args):
i = 0
while True:
assert i <= len(states)
path = Path("walker-{}_output.trajectory_0.ase".format(i))
if path.exists() and not states[i].periodic: # load and replace cell
traj = read(path, index=":", format="xyz")
path.unlink()
# try all formattings of bead index (i-PI inconsistency)
paths = [
Path("walker-{}_output.trajectory_0.ase".format(i)),
Path("walker-{}_output.trajectory_00.ase".format(i)),
Path("walker-{}_output.trajectory_000.ase".format(i)),
Path("walker-{}_output.trajectory_0000.ase".format(i)),
]
path = None
for path in paths:
if path.exists():
break
if path is None:
break
traj = read(path, index=":", format="xyz")
path.unlink()
if not states[i].periodic: # load and replace cell
for atoms in traj:
atoms.pbc = False
atoms.cell = None
write(path, traj, format="xyz")
else:
break
write(paths[0], traj, format="xyz") # always the same path
i += 1


Expand Down
3 changes: 2 additions & 1 deletion tests/test_sampling.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ def test_sample(dataset, mace_config):
temperature=200,
pressure=None,
hamiltonian=einstein,
nbeads=4,
nbeads=11,
)
output = sample([walker], steps=10, step=5)[0]
for state in output.trajectory.geometries().result():
Expand Down Expand Up @@ -289,6 +289,7 @@ def test_npt(dataset):
einstein,
temperature=600,
pressure=0,
nbeads=2
)
output = sample([walker], steps=30)[0]
assert output.status.result() == 0
Expand Down

0 comments on commit fe09240

Please sign in to comment.