Skip to content

Commit

Permalink
ASE: not all calculators implement the get_stress() function
Browse files Browse the repository at this point in the history
  • Loading branch information
jan-janssen committed Feb 7, 2024
1 parent 0281e22 commit b54495e
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 b54495e

Please sign in to comment.