Skip to content

Commit 0917d4e

Browse files
committed
Update calculator.py
1 parent f44e5e1 commit 0917d4e

1 file changed

Lines changed: 10 additions & 9 deletions

File tree

deepmd/calculator.py

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -138,12 +138,13 @@ def calculate(
138138
self.results["virial"] = v[0].reshape(3, 3)
139139

140140
# convert virial into stress for lattice relaxation
141-
if "stress" in properties:
142-
if sum(atoms.get_pbc()) > 0:
143-
# the usual convention (tensile stress is positive)
144-
# stress = -virial / volume
145-
stress = -0.5 * (v[0].copy() + v[0].copy().T) / atoms.get_volume()
146-
# Voigt notation
147-
self.results["stress"] = stress.flat[[0, 4, 8, 5, 2, 1]]
148-
else:
149-
raise PropertyNotImplementedError
141+
if cell is not None:
142+
# the usual convention (tensile stress is positive)
143+
# stress = -virial / volume
144+
stress = -0.5 * (v[0].copy() + v[0].copy().T) / atoms.get_volume()
145+
# Voigt notation
146+
self.results["stress"] = stress.flat[[0, 4, 8, 5, 2, 1]]
147+
elif "stress" in properties:
148+
raise PropertyNotImplementedError
149+
else:
150+
pass

0 commit comments

Comments
 (0)