Skip to content

Commit

Permalink
Merge pull request #355 from matthewkuner/allow_elastically_unstable_…
Browse files Browse the repository at this point in the history
…structures

allow elastically unstable structures
  • Loading branch information
utf authored Jun 14, 2023
2 parents 51946bf + 0861f26 commit 4e46b73
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/atomate2/common/schemas/elastic.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ def from_stresses(
order: Optional[int] = None,
equilibrium_stress: Optional[Matrix3D] = None,
symprec: float = SETTINGS.SYMPREC,
allow_elastically_unstable_structs: bool = True,
):
"""
Create an elastic document from strains and stresses.
Expand Down Expand Up @@ -177,6 +178,9 @@ 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_structs : bool
Whether to allow the ElasticDocument to still complete in the event that
the structure is elastically unstable.
"""
if symprec is not None:
deformations, stresses, uuids, job_dirs = _expand_deformations(
Expand Down Expand Up @@ -212,7 +216,12 @@ 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)

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
4 changes: 4 additions & 0 deletions src/atomate2/vasp/flows/elastic.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,8 @@ class ElasticMaker(Maker):
Keyword arguments passed to :obj:`generate_elastic_deformations`.
fit_elastic_tensor_kwargs : dict
Keyword arguments passed to :obj:`fit_elastic_tensor`.
task_document_kwargs : dict
Additional keyword args passed to :obj:`.ElasticDocument.from_stresses()`.
"""

name: str = "elastic"
Expand All @@ -78,6 +80,7 @@ class ElasticMaker(Maker):
elastic_relax_maker: BaseVaspMaker = field(default_factory=ElasticRelaxMaker)
generate_elastic_deformations_kwargs: dict = field(default_factory=dict)
fit_elastic_tensor_kwargs: dict = field(default_factory=dict)
task_document_kwargs: dict = field(default_factory=dict)

def make(
self,
Expand Down Expand Up @@ -128,6 +131,7 @@ def make(
order=self.order,
symprec=self.symprec if self.sym_reduce else None,
**self.fit_elastic_tensor_kwargs,
**self.task_document_kwargs,
)

# allow some of the deformations to fail
Expand Down
5 changes: 5 additions & 0 deletions src/atomate2/vasp/jobs/elastic.py
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,7 @@ def fit_elastic_tensor(
order: int = 2,
fitting_method: str = SETTINGS.ELASTIC_FITTING_METHOD,
symprec: float = SETTINGS.SYMPREC,
allow_elastically_unstable_structs: bool = True,
):
"""
Analyze stress/strain data to fit the elastic tensor and related properties.
Expand All @@ -265,6 +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.
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 @@ -292,4 +296,5 @@ def fit_elastic_tensor(
order=order,
equilibrium_stress=equilibrium_stress,
symprec=symprec,
allow_elastically_unstable_structs=allow_elastically_unstable_structs,
)

0 comments on commit 4e46b73

Please sign in to comment.