- class matlantis_features.ase_ext.optimize.FIRELBFGS(atoms: Union[Atoms, Filter, NEB], logfile: Optional[str] = ‘-‘, trajectory: Optional[str] = None, master: Optional[bool] = None, append_trajectory: bool = False, force_consistent: Optional[bool] = None, switch: float = 0.05, switch_decrease_rate: float = 0.9, switch_patience_fire: int = 10, switch_patience_lbfgs: int = 10, maxstep_fire: float = 0.2, maxstep_lbfgs: float = 0.2)#
-
Bases:
Optimizer
A optimization method that combine FIRE and LBFGS algorithm.
In this method, a threshold value is define. The FIRE (LBFGS) optimization is used when
the maximum force is larger (smaller) than the switch hold. If the force and potential energy
increase is observed after switching to LBFGS, the optimization methid is be switch
back to FIRE and the threshold value will be reduced by certain ratio.Methods
__init__
(atoms[, logfile, trajectory, …])Initialize an instance.
attach
(function[, interval])Attach callback function.
close
()closelater
(fd)converged
([forces])Did the optimization converge?
dump
(data)insert_observer
(function[, position, interval])Insert an observer.
irun
([fmax, steps])Run optimizer as generator.
load
()log
([forces])a dummy function as placeholder for a real logger, e.g.
openfile
(file, comm[, mode])read
()run
([fmax, steps])Run optimizer.
step
()Take a single step.
todict
()- __init__(atoms: Union[Atoms, Filter, NEB], logfile: Optional[str] = ‘-‘, trajectory: Optional[str] = None, master: Optional[bool] = None, append_trajectory: bool = False, force_consistent: Optional[bool] = None, switch: float = 0.05, switch_decrease_rate: float = 0.9, switch_patience_fire: int = 10, switch_patience_lbfgs: int = 10, maxstep_fire: float = 0.2, maxstep_lbfgs: float = 0.2) None #
-
Initialize an instance.
- Parameters
-
-
atoms (AtomsLike) – The input structure.
-
logfile (str or None, optional) – Filename for log file. If ‘-’ is used, stdout is used. Defaults to ‘-‘.
-
trajectory (str or None, optional) – Filename for trajectory file. If None, no trajectory file will be saved. Defaults
to None. -
master (bool or None, optional) – If True, the current rank will save files. If None, only rank 0 will save files.
Defaults to None. -
append_trajectory (bool, optional) – If True and trajectory file exists, trajectory will be
appended to the existing file. Defaults to False. Defaults to False. -
force_consistent (bool or None, optional) – Use force-consistent energy calls. Defaults to False.
-
switch (float, optional) – The initial value of algorithm switch force threshold value. Defaults to 0.05.
-
switch_decrease_rate (float, optional) – The ratio of threshold value decreasing. Defaults to 0.9.
-
switch_patience_fire (int, optional) – Number of optimization steps without switching to LBFGS after maximum force lower
than the threshold value. Defaults to 10. -
switch_patience_lbfgs (int, optional) – Number of optimization steps without switching to FIRE after the energy increase is
observed. Defaults to 10. -
maxstep_fire (float, optional) – The maximum distance an atom can move per iteration when using FIRE.
Defaults to 0.2. -
maxstep_lbfgs (float, optional) – The maximum distance an atom can move per iteration when using LBFGS.
Defaults to 0.2.
-
- attach(function, interval=1, *args, **kwargs)#
-
Attach callback function.
If interval > 0, at every interval steps, call function with
arguments args and keyword arguments kwargs.If interval <= 0, after step interval, call function with
arguments args and keyword arguments kwargs. This is
currently zero indexed.
- call_observers()#
- close()#
- closelater(fd)#
- converged(forces=None)#
-
Did the optimization converge?
- dump(data)#
- get_number_of_steps()#
- initialize()#
- insert_observer(function, position=0, interval=1, *args, **kwargs)#
-
Insert an observer.
This can be used for pre-processing before logging and dumping.
Examples
>>> from ase.build import bulk >>> from ase.calculators.emt import EMT >>> from ase.optimize import BFGS ... ... >>> def update_info(atoms, opt): ... atoms.info["nsteps"] = opt.nsteps ... ... >>> atoms = bulk("Cu", cubic=True) * 2 >>> atoms.rattle() >>> atoms.calc = EMT() >>> with BFGS(atoms, logfile=None, trajectory="opt.traj") as opt: ... opt.insert_observer(update_info, atoms=atoms, opt=opt) ... opt.run(fmax=0.05, steps=10) True
- irun(fmax=0.05, steps=100000000)#
-
Run optimizer as generator.
- Parameters
-
-
fmax (float) – Convergence criterion of the forces on atoms.
-
steps (int, default=DEFAULT_MAX_STEPS) – Number of optimizer steps to be run.
-
- Yields
-
converged (bool) – True if the forces on atoms are converged.
- load()#
- log(forces=None)#
-
a dummy function as placeholder for a real logger, e.g. in
Optimizer
- openfile(file, comm, mode=‘w’)#
- read()#
- run(fmax=0.05, steps=100000000)#
-
Run optimizer.
- Parameters
-
-
fmax (float) – Convergence criterion of the forces on atoms.
-
steps (int, default=DEFAULT_MAX_STEPS) – Number of optimizer steps to be run.
-
- Returns
-
converged – True if the forces on atoms are converged.
- Return type
-
bool
- step() None #
-
Take a single step.
- todict()#
Resource Library
matlantis_features.ase_ext.optimize.FIRELBFGS