Skip to content

Commit

Permalink
change to use built-in pymatgen method for ignoring unphysical elasti…
Browse files Browse the repository at this point in the history
…c properties
  • Loading branch information
matthewkuner committed May 23, 2023
1 parent cc67a77 commit 0861f26
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 14 deletions.
18 changes: 8 additions & 10 deletions src/atomate2/common/schemas/elastic.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ def from_stresses(
order: Optional[int] = None,
equilibrium_stress: Optional[Matrix3D] = None,
symprec: float = SETTINGS.SYMPREC,
allow_elastically_unstable_materials: bool = True
allow_elastically_unstable_structs: bool = True,
):
"""
Create an elastic document from strains and stresses.
Expand Down Expand Up @@ -178,7 +178,7 @@ def from_stresses(
symprec : float
Symmetry precision for deriving symmetry equivalent deformations. If
``symprec=None``, then no symmetry operations will be applied.
allow_elastically_unstable_materials : bool
allow_elastically_unstable_structs : bool
Whether to allow the ElasticDocument to still complete in the event that
the structure is elastically unstable.
"""
Expand Down Expand Up @@ -216,15 +216,13 @@ def from_stresses(

ieee = result.convert_to_ieee(structure)
property_tensor = ieee if order == 2 else ElasticTensor(ieee[0])
property_dict = property_tensor.get_structure_property_dict(structure)

if allow_elastically_unstable_materials:
try: # try to get Derived Properties
derived_properties = DerivedProperties(**property_dict)
except: # allow this method to error for elastically unstable structures
derived_properties = None
else:
derived_properties = DerivedProperties(**property_dict)
ignore_errors = bool(allow_elastically_unstable_structs)
property_dict = property_tensor.get_structure_property_dict(
structure, ignore_errors=ignore_errors
)

derived_properties = DerivedProperties(**property_dict)

eq_stress = eq_stress.tolist() if eq_stress is not None else eq_stress

Expand Down
9 changes: 5 additions & 4 deletions src/atomate2/vasp/jobs/elastic.py
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ def fit_elastic_tensor(
order: int = 2,
fitting_method: str = SETTINGS.ELASTIC_FITTING_METHOD,
symprec: float = SETTINGS.SYMPREC,
task_document_kwargs: dict = field(default_factory=dict),
allow_elastically_unstable_structs: bool = True,
):
"""
Analyze stress/strain data to fit the elastic tensor and related properties.
Expand All @@ -266,8 +266,9 @@ def fit_elastic_tensor(
symprec : float
Symmetry precision for deriving symmetry equivalent deformations. If
``symprec=None``, then no symmetry operations will be applied.
task_document_kwargs : dict
Additional keyword args passed to :obj:`.ElasticDocument.from_stresses()`.
allow_elastically_unstable_structs : bool
Whether to allow the ElasticDocument to still complete in the event that
the structure is elastically unstable.
"""
stresses = []
deformations = []
Expand Down Expand Up @@ -295,5 +296,5 @@ def fit_elastic_tensor(
order=order,
equilibrium_stress=equilibrium_stress,
symprec=symprec,
**task_document_kwargs,
allow_elastically_unstable_structs=allow_elastically_unstable_structs,
)

0 comments on commit 0861f26

Please sign in to comment.