Skip to content

Commit 976cf16

Browse files
authored
Update ase.py: To avoid errors in writing to the .extxyz format from an Atom object coverted from .npy with dpdata. (#717)
1 parent e393a8c commit 976cf16

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

dpdata/plugins/ase.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,17 @@ def to_labeled_system(self, data, *args, **kwargs) -> list[ase.Atoms]:
181181
# v_pref = 1 * 1e4 / 1.602176621e6
182182
vol = structure.get_volume()
183183
# results['stress'] = data["virials"][ii] / (v_pref * vol)
184-
results["stress"] = -data["virials"][ii] / vol
184+
stress33 = -data["virials"][ii] / vol
185+
results["stress"] = np.array(
186+
[
187+
stress33[0][0],
188+
stress33[1][1],
189+
stress33[2][2],
190+
stress33[1][2],
191+
stress33[0][2],
192+
stress33[0][1],
193+
]
194+
)
185195

186196
structure.calc = SinglePointCalculator(structure, **results)
187197
structures.append(structure)

0 commit comments

Comments
 (0)