Skip to content

Commit 9bbbb9e

Browse files
authored
cover cases where optimizer does additional steps even though step is set to 0 or 1 for writing xyz files (#1207)
* add file output to ase and forcefield jobs * remove useless file * cover situation where optimizer might take additional steps * fix input_atoms copy * fix linting
1 parent e2968b0 commit 9bbbb9e

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

src/atomate2/ase/utils.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -367,6 +367,8 @@ def relax(
367367

368368
if isinstance(atoms, Structure | Molecule):
369369
atoms = self.ase_adaptor.get_atoms(atoms)
370+
371+
input_atoms = atoms.copy()
370372
if self.fix_symmetry:
371373
atoms.set_constraint(FixSymmetry(atoms, symprec=self.symprec))
372374
atoms.calc = self.calculator
@@ -393,8 +395,14 @@ def relax(
393395
np.linalg.norm(traj.frame_properties[-1]["forces"][idx]) < abs(fmax)
394396
for idx in range(len(struct))
395397
)
398+
396399
if final_atoms_object_file is not None:
397-
write(final_atoms_object_file, atoms, format="extxyz", append=True)
400+
if steps <= 1:
401+
write_atoms = input_atoms
402+
write_atoms.calc = self.calculator
403+
else:
404+
write_atoms = atoms
405+
write(final_atoms_object_file, write_atoms, format="extxyz", append=True)
398406

399407
return AseResult(
400408
final_mol_or_struct=struct,

0 commit comments

Comments
 (0)