本文整理汇总了Python中ase.optimize.optimize.Optimizer.__init__方法的典型用法代码示例。如果您正苦于以下问题:Python Optimizer.__init__方法的具体用法?Python Optimizer.__init__怎么用?Python Optimizer.__init__使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ase.optimize.optimize.Optimizer
的用法示例。
在下文中一共展示了Optimizer.__init__方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from ase.optimize.optimize import Optimizer [as 别名]
# 或者: from ase.optimize.optimize.Optimizer import __init__ [as 别名]
def __init__(self, atoms, restart=None, logfile='-', trajectory=None,
maxstep=0.04, master=None):
"""BFGS optimizer.
Parameters:
atoms: Atoms object
The Atoms object to relax.
restart: string
Pickle file used to store hessian matrix. If set, file with
such a name will be searched and hessian matrix stored will
be used, if the file exists.
trajectory: string
Pickle file used to store trajectory of atomic movement.
logfile: file object or str
If *logfile* is a string, a file with that name will be opened.
Use '-' for stdout.
maxstep: float
Used to set the maximum distance an atom can move per
iteration (default value is 0.04 Å).
master: boolean
Defaults to None, which causes only rank 0 to save files. If
set to true, this rank will save files.
"""
if maxstep > 1.0:
warnings.warn('You are using a much too large value for '
'the maximum step size: %.1f Å' % maxstep)
self.maxstep = maxstep
Optimizer.__init__(self, atoms, restart, logfile, trajectory, master)
示例2: __init__
# 需要导入模块: from ase.optimize.optimize import Optimizer [as 别名]
# 或者: from ase.optimize.optimize.Optimizer import __init__ [as 别名]
def __init__(self, atoms, restart=None, logfile='-', trajectory=None,
dt=None, master=None):
"""Parameters:
atoms: Atoms object
The Atoms object to relax.
restart: string
Pickle file used to store hessian matrix. If set, file with
such a name will be searched and hessian matrix stored will
be used, if the file exists.
trajectory: string
Pickle file used to store trajectory of atomic movement.
maxstep: float
Used to set the maximum distance an atom can move per
iteration (default value is 0.2 Angstroms).
logfile: string
Text file used to write summary information.
master: boolean
Defaults to None, which causes only rank 0 to save files. If
set to true, this rank will save files.
"""
Optimizer.__init__(self, atoms, restart, logfile, trajectory, master)
if dt is not None:
self.dt = dt
示例3: __init__
# 需要导入模块: from ase.optimize.optimize import Optimizer [as 别名]
# 或者: from ase.optimize.optimize.Optimizer import __init__ [as 别名]
def __init__(self, atoms, logfile="-", trajectory=None, callback_always=False, alpha=70.0, master=None):
"""Initialize object
Parameters:
atoms: Atoms object
The Atoms object to relax.
trajectory: string
Pickle file used to store trajectory of atomic movement.
logfile: file object or str
If *logfile* is a string, a file with that name will be opened.
Use '-' for stdout.
callback_always: book
Should the callback be run after each force call (also in the
linesearch)
alpha: float
Initial guess for the Hessian (curvature of energy surface). A
conservative value of 70.0 is the default, but number of needed
steps to converge might be less if a lower value is used. However,
a lower value also means risk of instability.
master: boolean
Defaults to None, which causes only rank 0 to save files. If
set to true, this rank will save files.
"""
restart = None
Optimizer.__init__(self, atoms, restart, logfile, trajectory, master)
self.force_calls = 0
self.callback_always = callback_always
self.H0 = alpha
示例4: __init__
# 需要导入模块: from ase.optimize.optimize import Optimizer [as 别名]
# 或者: from ase.optimize.optimize.Optimizer import __init__ [as 别名]
def __init__(self, atoms, restart=None, logfile='-', trajectory=None,
dt=0.1, maxmove=0.2, dtmax=1.0, Nmin=5, finc=1.1, fdec=0.5,
astart=0.1, fa=0.99, a=0.1, master=None, downhill_check=False,
position_reset_callback=None, force_consistent=None):
"""Parameters:
atoms: Atoms object
The Atoms object to relax.
restart: string
Pickle file used to store hessian matrix. If set, file with
such a name will be searched and hessian matrix stored will
be used, if the file exists.
trajectory: string
Pickle file used to store trajectory of atomic movement.
logfile: file object or str
If *logfile* is a string, a file with that name will be opened.
Use '-' for stdout.
master: boolean
Defaults to None, which causes only rank 0 to save files. If
set to true, this rank will save files.
downhill_check: boolean
Downhill check directly compares potential energies of subsequent
steps of the FIRE algorithm rather than relying on the current
product v*f that is positive if the FIRE dynamics moves downhill.
This can detect numerical issues where at large time steps the step
is uphill in energy even though locally v*f is positive, i.e. the
algorithm jumps over a valley because of a too large time step.
position_reset_callback: function(atoms, r, e, e_last)
Function that takes current *atoms* object, an array of position
*r* that the optimizer will revert to, current energy *e* and
energy of last step *e_last*. This is only called if e > e_last.
force_consistent: boolean or None
Use force-consistent energy calls (as opposed to the energy
extrapolated to 0 K). By default (force_consistent=None) uses
force-consistent energies if available in the calculator, but
falls back to force_consistent=False if not. Only meaningful
when downhill_check is True.
"""
Optimizer.__init__(self, atoms, restart, logfile, trajectory,
master, force_consistent=force_consistent)
self.dt = dt
self.Nsteps = 0
self.maxmove = maxmove
self.dtmax = dtmax
self.Nmin = Nmin
self.finc = finc
self.fdec = fdec
self.astart = astart
self.fa = fa
self.a = a
self.downhill_check = downhill_check
self.position_reset_callback = position_reset_callback
示例5: __init__
# 需要导入模块: from ase.optimize.optimize import Optimizer [as 别名]
# 或者: from ase.optimize.optimize.Optimizer import __init__ [as 别名]
def __init__(self, atoms, restart=None, logfile='-', maxstep=.2,
trajectory=None, c1=0.23, c2=0.46, alpha=10.0, stpmax=50.0,
master=None, force_consistent=None):
"""Optimize atomic positions in the BFGSLineSearch algorithm, which
uses both forces and potential energy information.
Parameters:
atoms: Atoms object
The Atoms object to relax.
restart: string
Pickle file used to store hessian matrix. If set, file with
such a name will be searched and hessian matrix stored will
be used, if the file exists.
trajectory: string
Pickle file used to store trajectory of atomic movement.
maxstep: float
Used to set the maximum distance an atom can move per
iteration (default value is 0.2 Angstroms).
logfile: file object or str
If *logfile* is a string, a file with that name will be opened.
Use '-' for stdout.
master: boolean
Defaults to None, which causes only rank 0 to save files. If
set to true, this rank will save files.
force_consistent: boolean or None
Use force-consistent energy calls (as opposed to the energy
extrapolated to 0 K). By default (force_consistent=None) uses
force-consistent energies if available in the calculator, but
falls back to force_consistent=False if not.
"""
self.maxstep = maxstep
self.stpmax = stpmax
self.alpha = alpha
self.H = None
self.c1 = c1
self.c2 = c2
self.force_calls = 0
self.function_calls = 0
self.r0 = None
self.g0 = None
self.e0 = None
self.load_restart = False
self.task = 'START'
self.rep_count = 0
self.p = None
self.alpha_k = None
self.no_update = False
self.replay = False
Optimizer.__init__(self, atoms, restart, logfile, trajectory,
master, force_consistent)
示例6: __init__
# 需要导入模块: from ase.optimize.optimize import Optimizer [as 别名]
# 或者: from ase.optimize.optimize.Optimizer import __init__ [as 别名]
def __init__(self, atoms, restart=None, logfile='-', trajectory=None,
maxstep=None, memory=100, damping=1.0, alpha=70.0,
use_line_search=False):
"""
Parameters:
restart: string
Pickle file used to store vectors for updating the inverse of
Hessian matrix. If set, file with such a name will be searched
and information stored will be used, if the file exists.
logfile: string
Where should output go. None for no output, '-' for stdout.
trajectory: string
Pickle file used to store trajectory of atomic movement.
maxstep: float
How far is a single atom allowed to move. This is useful for DFT
calculations where wavefunctions can be reused if steps are small.
Default is 0.04 Angstrom.
memory: int
Number of steps to be stored. Default value is 100. Three numpy
arrays of this length containing floats are stored.
damping: float
The calculated step is multiplied with this number before added to
the positions.
alpha: float
Initial guess for the Hessian (curvature of energy surface). A
conservative value of 70.0 is the default, but number of needed
steps to converge might be less if a lower value is used. However,
a lower value also means risk of instability.
"""
Optimizer.__init__(self, atoms, restart, logfile, trajectory)
if maxstep is not None:
if maxstep > 1.0:
raise ValueError('You are using a much too large value for ' +
'the maximum step size: %.1f Angstrom' %
maxstep)
self.maxstep = maxstep
else:
self.maxstep = 0.04
self.memory = memory
self.H0 = 1. / alpha # Initial approximation of inverse Hessian
# 1./70. is to emulate the behaviour of BFGS
# Note that this is never changed!
self.damping = damping
self.use_line_search = use_line_search
self.p = None
self.function_calls = 0
self.force_calls = 0
示例7: __init__
# 需要导入模块: from ase.optimize.optimize import Optimizer [as 别名]
# 或者: from ase.optimize.optimize.Optimizer import __init__ [as 别名]
def __init__(self, atoms, logfile='-', trajectory=None,
callback_always=False):
"""Parameters:
callback_always: book
Should the callback be run after each force call (also in the
linesearch)
"""
restart = None
Optimizer.__init__(self, atoms, restart, logfile, trajectory)
self.function_calls = 0
self.callback_always = callback_always
示例8: __init__
# 需要导入模块: from ase.optimize.optimize import Optimizer [as 别名]
# 或者: from ase.optimize.optimize.Optimizer import __init__ [as 别名]
def __init__(self, atoms, restart=None, logfile='-', trajectory=None,
dt=0.1, maxmove=0.2, dtmax=1.0, Nmin=5, finc=1.1, fdec=0.5,
astart=0.1, fa=0.99, a=0.1, theta=0.1, master=None,
precon=None, use_armijo=True, variable_cell=False):
"""
Preconditioned version of the FIRE optimizer
Parameters:
atoms: Atoms object
The Atoms object to relax.
restart: string
Pickle file used to store hessian matrix. If set, file with
such a name will be searched and hessian matrix stored will
be used, if the file exists.
trajectory: string
Pickle file used to store trajectory of atomic movement.
logfile: file object or str
If *logfile* is a string, a file with that name will be opened.
Use '-' for stdout.
master: bool
Defaults to None, which causes only rank 0 to save files. If
set to true, this rank will save files.
variable_cell: bool
If True, wrap atoms in UnitCellFilter to relax cell and positions.
In time this implementation is expected to replace
ase.optimize.fire.FIRE.
"""
if variable_cell:
atoms = UnitCellFilter(atoms)
Optimizer.__init__(self, atoms, restart, logfile, trajectory, master)
self.dt = dt
self.Nsteps = 0
self.maxmove = maxmove
self.dtmax = dtmax
self.Nmin = Nmin
self.finc = finc
self.fdec = fdec
self.astart = astart
self.fa = fa
self.a = a
self.theta = theta
self.precon = precon
self.use_armijo = use_armijo
示例9: __init__
# 需要导入模块: from ase.optimize.optimize import Optimizer [as 别名]
# 或者: from ase.optimize.optimize.Optimizer import __init__ [as 别名]
def __init__(self, atoms, restart=None, logfile=None, trajectory=None,
seed=None,
verbose=False):
Optimizer.__init__(self, atoms, restart, logfile, trajectory)
atoms.get_forces()
atoms.get_potential_energy()
if seed is None:
seed = np.random.randint(0, 2 ** 31)
self.verbose = verbose
self.random_state = RandomState(seed)
self.starting_atoms = dc(atoms)
self.traj = [dc(atoms)]
self.pe = []
self.metadata = {'seed': seed}
示例10: __init__
# 需要导入模块: from ase.optimize.optimize import Optimizer [as 别名]
# 或者: from ase.optimize.optimize.Optimizer import __init__ [as 别名]
def __init__(self, atoms, restart=None, logfile='-', trajectory=None,
dt=0.1, maxmove=0.2, dtmax=1.0, Nmin=5, finc=1.1, fdec=0.5,
astart=0.1, fa=0.99, a=0.1):
Optimizer.__init__(self, atoms, restart, logfile, trajectory)
self.dt = dt
self.Nsteps = 0
self.maxmove = maxmove
self.dtmax = dtmax
self.Nmin = Nmin
self.finc = finc
self.fdec = fdec
self.astart = astart
self.fa = fa
self.a = a
示例11: __init__
# 需要导入模块: from ase.optimize.optimize import Optimizer [as 别名]
# 或者: from ase.optimize.optimize.Optimizer import __init__ [as 别名]
def __init__(self, atoms, logfile='-', trajectory=None):
Optimizer.__init__(self, atoms, None, logfile, trajectory)
self.control = atoms.get_control()
# Make a header for the log
if self.logfile is not None:
l = ''
if isinstance(self.control, DimerControl):
l = 'MinModeTranslate: STEP TIME ENERGY ' + \
'MAX-FORCE STEPSIZE CURVATURE ROT-STEPS\n'
self.logfile.write(l)
self.logfile.flush()
# Load the relevant parameters from control
self.cg_on = self.control.get_parameter('cg_translation')
self.trial_step = self.control.get_parameter('trial_trans_step')
self.max_step = self.control.get_parameter('maximum_translation')
# Start conjugate gradient
if self.cg_on:
self.cg_init = True
示例12: __init__
# 需要导入模块: from ase.optimize.optimize import Optimizer [as 别名]
# 或者: from ase.optimize.optimize.Optimizer import __init__ [as 别名]
def __init__(self, atoms, restart=None, logfile='-', maxstep=.2,
trajectory=None, c1=0.23, c2=0.46, alpha=10.0, stpmax=50.0):
"""Optimize atomic positions in the BFGSLineSearch algorithm, which
uses both forces and potential energy information.
Parameters:
restart: string
Pickle file used to store hessian matrix. If set, file with
such a name will be searched and hessian matrix stored will
be used, if the file exists.
trajectory: string
Pickle file used to store trajectory of atomic movement.
maxstep: float
Used to set the maximum distance an atom can move per
iteration (default value is 0.2 Angstroms).
logfile: string
Text file used to write summary information.
"""
self.maxstep = maxstep
self.stpmax = stpmax
self.alpha = alpha
self.H = None
self.c1 = c1
self.c2 = c2
self.force_calls = 0
self.function_calls = 0
self.r0 = None
self.g0 = None
self.e0 = None
self.load_restart = False
self.task = 'START'
self.rep_count = 0
self.p = None
self.alpha_k = None
self.no_update = False
self.replay = False
Optimizer.__init__(self, atoms, restart, logfile, trajectory)
示例13: __init__
# 需要导入模块: from ase.optimize.optimize import Optimizer [as 别名]
# 或者: from ase.optimize.optimize.Optimizer import __init__ [as 别名]
def __init__(self, atoms, restart=None, logfile='-', maxstep=.2,
trajectory=None, c1=.23, c2=0.46, alpha=10., stpmax=50.,
use_free_energy=True):
"""Minimize a function using the BFGS algorithm.
Notes:
Optimize the function, f, whose gradient is given by fprime
using the quasi-Newton method of Broyden, Fletcher, Goldfarb,
and Shanno (BFGS) See Wright, and Nocedal 'Numerical
Optimization', 1999, pg. 198.
*See Also*:
scikits.openopt : SciKit which offers a unified syntax to call
this and other solvers.
"""
self.maxstep = maxstep
self.stpmax = stpmax
self.alpha = alpha
self.H = None
self.c1 = c1
self.c2 = c2
self.force_calls = 0
self.function_calls = 0
self.r0 = None
self.g0 = None
self.e0 = None
self.load_restart = False
self.task = 'START'
self.rep_count = 0
self.p = None
self.alpha_k = None
self.no_update = False
self.replay = False
self.use_free_energy = use_free_energy
Optimizer.__init__(self, atoms, restart, logfile, trajectory)
示例14: __init__
# 需要导入模块: from ase.optimize.optimize import Optimizer [as 别名]
# 或者: from ase.optimize.optimize.Optimizer import __init__ [as 别名]
def __init__(self, atoms, restart=None, logfile='-', trajectory=None,
fmax=None, converged=None,
hessianupdate='BFGS',hessian=None,forcemin=True,
verbosity=None,maxradius=None,
diagonal=20.,radius=None,
transitionstate = False):
Optimizer.__init__(self, atoms, restart, logfile, trajectory)
self.eps = 1e-12
self.hessianupdate = hessianupdate
self.forcemin = forcemin
self.verbosity = verbosity
self.diagonal = diagonal
self.atoms = atoms
n = len(self.atoms) * 3
if radius is None:
self.radius = 0.05*np.sqrt(n)/10.0
else:
self.radius = radius
if maxradius is None:
self.maxradius = 0.5*np.sqrt(n)
else:
self.maxradius = maxradius
# 0.01 < radius < maxradius
self.radius = max(min( self.radius, self.maxradius ), 0.0001)
self.transitionstate = transitionstate
# check if this is a nudged elastic band calculation
if hasattr(atoms,'springconstant'):
self.forcemin=False
self.t0 = time.time()
示例15: __init__
# 需要导入模块: from ase.optimize.optimize import Optimizer [as 别名]
# 或者: from ase.optimize.optimize.Optimizer import __init__ [as 别名]
def __init__(self, atoms, restart=None, logfile='-', trajectory=None,
maxstep=None):
"""BFGS optimizer.
Parameters:
restart: string
Pickle file used to store hessian matrix. If set, file with
such a name will be searched and hessian matrix stored will
be used, if the file exists.
trajectory: string
Pickle file used to store trajectory of atomic movement.
maxstep: float
Used to set the maximum distance an atom can move per
iteration (default value is 0.04 Å).
"""
Optimizer.__init__(self, atoms, restart, logfile, trajectory)
if maxstep is not None:
if maxstep > 1.0:
raise ValueError('You are using a much too large value for ' +
'the maximum step size: %.1f Å' % maxstep)
self.maxstep = maxstep