Source code for scm.glompo.exitconditions.maxoptimizersconverged

from .baseexitcondition import BaseExitCondition
from ...plams.core.settings import Settings

__all__ = ("MaxOptimizersConverged",)


[docs]class MaxOptimizersConverged(BaseExitCondition): """Returns ``True`` when ``nconv`` optimizers have converged normally. 'Normally' here is defined as exiting the minimization loop according to the optimizer's own internal convergence criteria, rather than any GloMPO intervention. """ def __init__(self, nconv: int): super().__init__() self.nconv = nconv def __amssettings__(self, s: Settings) -> Settings: s.input.ams.ExitCondition.Type = "MaxOptimizersConverged" s.input.ams.ExitCondition.MaxOptimizersConverged = self.nconv return s def __call__(self, manager: "GloMPOManager") -> bool: self.last_result = manager.conv_counter >= self.nconv return self.last_result