from asap3.optimize import FIRE
from asap3.md.nptberendsen import Inhomogeneous_NPTBerendsen
from ase import units
[docs]
def minimize_energy(atoms, nstep, pressure_interval=10, bulkmodulus = 140e9/1e5):
"""Minimize the energy of a nanocrystalline structure.
Minimizes the energy while eliminating the diagonal components of the
stress. The atomic positions are optimized using the FIRE algorithm, and
the stress is minimized using the Inhomogeneous_NPTBerendsen algorithm.
Parameters
----------
atoms : ase.Atoms
The atoms object to be energy-minimized.
nstep : int
Number of time steps in the FIRE algorithm.
pressure_interval : int, optional
How often to call the stress minimizer. The default is 10.
bulkmodulus : float, optional
The bulk modulus, in bar, used by the stress optimizer. The default
value is for Cu and is useful for all metals. The value is
uncritical, but the order of magnitude should be reasonable.
"""
dyn = FIRE(atoms)
unstress = Inhomogeneous_NPTBerendsen(atoms, 50*units.fs, 0,
taup=5000*units.fs,
compressibility=1/bulkmodulus)
dyn.attach(unstress.scale_positions_and_cell, interval=10)
dyn.run(steps=nstep)