Skip to content

Commit

Permalink
write initial and final structure if save_full is false
Browse files Browse the repository at this point in the history
  • Loading branch information
lbluque committed Aug 22, 2024
1 parent c693829 commit 4a51006
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -92,14 +92,17 @@ def run(self, fmax, steps):
iteration = 0
max_forces = self.optimizable.get_max_forces(apply_constraint=True)
logging.info("Step Fmax(eV/A)")

while iteration < steps and not self.optimizable.converged(
forces=None, fmax=self.fmax, max_forces=max_forces
):
logging.info(
f"{iteration} " + " ".join(f"{x:0.3f}" for x in max_forces.tolist())
)

if self.trajectories is not None and self.save_full is True:
if self.trajectories is not None and (
self.save_full is True or iteration == 0
):
self.write()

self.step(iteration)
Expand Down
4 changes: 3 additions & 1 deletion tests/core/common/test_lbfgs_torch.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,9 @@ def test_lbfgs_write_trajectory(save_full_traj, steps, batch, calculator, tmp_pa
traj_files = list(tmp_path.glob("*.traj"))
assert len(traj_files) == len(batch)

traj_length = 0 if steps == 0 else steps + 1 if save_full_traj else 1
traj_length = (
0 if steps == 0 else steps + 1 if save_full_traj else 2
) # first and final frame
for file in traj_files:
traj = read(file, ":")
assert len(traj) == traj_length

0 comments on commit 4a51006

Please sign in to comment.