diff --git a/src/pymatgen/core/structure.py b/src/pymatgen/core/structure.py index f64caf4b134..2c72af045a2 100644 --- a/src/pymatgen/core/structure.py +++ b/src/pymatgen/core/structure.py @@ -796,7 +796,21 @@ def _relax( self, calculator: Literal["M3GNet", "gfn2-xtb"] | Calculator, relax_cell: bool = True, - optimizer: str | Optimizer = "FIRE", + optimizer: Literal[ + "BFGS", + "BFGSLineSearch", + "CellAwareBFGS", + "FIRE", + "FIRE2", + "GPMin", + "GoodOldQuasiNewton", + "LBFGS", + "LBFGSLineSearch", + "MDMin", + "ODE12r", + "QuasiNewton", + ] + | Optimizer = "FIRE", steps: int = 500, fmax: float = 0.1, stress_weight: float = 0.01, @@ -825,7 +839,7 @@ def _relax( Structure | Molecule: Relaxed structure or molecule """ from ase import optimize - from ase.constraints import ExpCellFilter + from ase.filters import FrechetCellFilter from ase.io import read from ase.optimize.optimize import Optimizer @@ -874,7 +888,7 @@ def is_ase_optimizer(key): if relax_cell: if is_molecule: raise ValueError("Can't relax cell for a Molecule") - ecf = ExpCellFilter(atoms) + ecf = FrechetCellFilter(atoms) dyn = opt_class(ecf, **opt_kwargs) else: dyn = opt_class(atoms, **opt_kwargs) diff --git a/tests/core/test_structure.py b/tests/core/test_structure.py index 05ad8e9df50..62dbdac4d71 100644 --- a/tests/core/test_structure.py +++ b/tests/core/test_structure.py @@ -1785,7 +1785,7 @@ def test_relax_ase_return_traj(self): assert {*relaxed.calc.results} >= {"energy", "energies", "free_energy"} assert relaxed.calc.parameters == {"asap_cutoff": False} assert relaxed.dynamics["optimizer"] == "FIRE" - assert len(traj) == 7 + assert len(traj) == 15 assert traj[0] != traj[-1] os.remove("opt.traj") # fails if file missing