Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ strict = [
"atomate2[cclib, phonons, lobster, openmm, mp, defects, ase, ase-ext]",
"numpy<3.0",
"numba>=0.60.0", # needed to get numpy >2,<3 installed
"pymatgen==2026.3.23",
]

[project.scripts]
Expand Down
37 changes: 27 additions & 10 deletions src/atomate2/forcefields/flows/elastic.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
_DEFAULT_RELAX_KWARGS: dict[str, Any] = {
"force_field_name": "CHGNet",
"relax_kwargs": {"fmax": 0.00001},
"fix_symmetry": True,
}


Expand Down Expand Up @@ -106,6 +107,7 @@ def from_force_field_name(
cls,
force_field_name: str | MLFF | dict,
calculator_kwargs: dict | None = None,
relax_initial_structure: bool = True,
**kwargs,
) -> Self:
"""
Expand All @@ -117,13 +119,24 @@ def from_force_field_name(
The name of the force field.
calculator_kwargs : dict or None (default)
calculator_kwargs to pass to `ForceFieldRelaxMaker`.
relax_initial_structure : bool = True (default)
Whether to relax the structure before computing
the elastic tensor.
**kwargs
Additional kwargs to pass to ElasticMaker.

Returns
-------
ElasticMaker
"""
warnings.warn(
"Fixed symmetry relaxations are automatically enabled "
"to improve elastic tensor stability. To disable this "
"specify ForceFieldRelaxMaker objects explicitly. ",
category=UserWarning,
stacklevel=2,
)

if (mlff_kwargs := kwargs.pop("mlff_kwargs", None)) is not None:
warnings.warn(
"`mlff_kwargs` has been marked for deprecation. "
Expand All @@ -148,18 +161,22 @@ def from_force_field_name(
"force_field_name": force_field_name,
"calculator_kwargs": calculator_kwargs or {},
}
bulk_relax_maker = ForceFieldRelaxMaker(
relax_cell=True,

elastic_relax_maker = ForceFieldRelaxMaker(
relax_cell=False,
**default_kwargs,
)
kwargs.update(
bulk_relax_maker=bulk_relax_maker,
elastic_relax_maker=ForceFieldRelaxMaker(
relax_cell=False,
**default_kwargs,
),
)

return cls(
name=f"{bulk_relax_maker.mlff.name} elastic",
name=f"{elastic_relax_maker.mlff.name} elastic",
**kwargs,
bulk_relax_maker=(
ForceFieldRelaxMaker(
relax_cell=True,
**default_kwargs,
)
if relax_initial_structure
else None
),
elastic_relax_maker=elastic_relax_maker,
)
6 changes: 3 additions & 3 deletions tests/forcefields/flows/test_elastic.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def test_elastic_wf_with_mace(
si_prim = SpacegroupAnalyzer(si_structure).get_primitive_standard_structure()
model_path = f"{test_dir}/forcefields/mace/MACE.model"
common_kwds = {
"force_field_name": "MACE",
"force_field_name": "MACE-MP-0",
"calculator_kwargs": {"model": model_path, "default_dtype": "float64"},
"relax_kwargs": {"fmax": 0.00001},
}
Expand All @@ -29,7 +29,7 @@ def test_elastic_wf_with_mace(
ValueError, match="You have specified both `calculator_kwargs` and"
):
ElasticMaker.from_force_field_name(
force_field_name="MACE",
force_field_name="MACE-MP-0",
mlff_kwargs=common_kwds,
calculator_kwargs=common_kwds,
)
Expand All @@ -38,7 +38,7 @@ def test_elastic_wf_with_mace(
UserWarning, match="`mlff_kwargs` has been marked for deprecation."
):
maker = ElasticMaker.from_force_field_name(
force_field_name="MACE",
force_field_name="MACE-MP-0",
mlff_kwargs=common_kwds,
)
assert all(
Expand Down
Loading