Skip to content

Commit

Permalink
Merge pull request #205 from pyiron/ase_stress_not_implemented
Browse files Browse the repository at this point in the history
ASE: not all calculators implement the get_stress() function
  • Loading branch information
jan-janssen authored Feb 14, 2024
2 parents bb9e8a7 + b54495e commit ddf3cd2
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions atomistics/calculators/ase.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from ase.md.npt import NPT
from ase.md.velocitydistribution import MaxwellBoltzmannDistribution
from ase.constraints import UnitCellFilter
from ase.calculators.calculator import PropertyNotImplementedError
import numpy as np
from typing import TYPE_CHECKING

Expand Down Expand Up @@ -45,10 +46,16 @@ def energy_tot(self):
)

def stress(self):
return self.structure.get_stress(voigt=False)
try:
return self.structure.get_stress(voigt=False)
except PropertyNotImplementedError:
return None

def pressure(self):
return self.structure.get_stress(voigt=False)
try:
return self.structure.get_stress(voigt=False)
except PropertyNotImplementedError:
return None

def cell(self):
return self.structure.get_cell()
Expand Down

0 comments on commit ddf3cd2

Please sign in to comment.