Skip to content

Commit acf0156

Browse files
authored
Merge pull request #1729 from pyiron/ase_velo
Fix ASE compatibility for transferring velocities
2 parents fb4f738 + 1aaca5e commit acf0156

File tree

1 file changed

+9
-0
lines changed
  • pyiron_atomistics/atomistics/structure

1 file changed

+9
-0
lines changed

pyiron_atomistics/atomistics/structure/atoms.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3088,6 +3088,13 @@ def ase_to_pyiron(ase_obj):
30883088
)
30893089
else:
30903090
warnings.warn("Unsupported ASE constraint: " + constraint_dict["name"])
3091+
if not np.all(
3092+
np.isclose(
3093+
ase_obj.get_velocities(),
3094+
np.array([[0.0, 0.0, 0.0]] * len(ase_obj)),
3095+
)
3096+
):
3097+
pyiron_atoms.set_velocities(ase_obj.get_velocities())
30913098
return pyiron_atoms
30923099

30933100

@@ -3156,6 +3163,8 @@ def pyiron_to_ase(pyiron_obj):
31563163
"Selective Dynamics Error: " + str(k) + ": " + str(v)
31573164
)
31583165
atoms.set_constraint(constraints_lst)
3166+
if pyiron_obj.velocities is not None:
3167+
atoms.set_velocities(pyiron_obj.velocities)
31593168
return atoms
31603169

31613170

0 commit comments

Comments
 (0)