Minimisers#
Directory: libfly/minimise
The minimise
folder contains a collection of potential energy minimisers. Everything is contained within the namespace fly::minimise
.
LBFGS#
Minimiser#
File: libfly/minimise/LBFGS/lbfgs.hpp
Find local minima of a potential energy surface using the Limited-memory BFGS method (LBFGS).
The LBFGS algorithm stores a portion of the history of a pathway through phase-space as it move towards a local minimum. This history is used to approximate the inverse hessian which is then used to compute the approximate newton step towards the minimum.
-
class LBFGS#
A minimiser that uses the LBFGS algorithm.
Public Functions
-
inline LBFGS(Options const &opt, system::Box const &box)#
Construct a new LBFGS object.
- Parameters:
opt – Options strut.
box – Description of simulation space.
-
auto minimise(system::SoA<Position&, PotentialGradient&> out, system::SoA<Position const&, TypeID const&, Frozen const&> in, potential::Generic &pot, int num_threads = 1) -> bool#
Find the nearest local minimum of a potential.
Todo
Currently there is a small but non negligible non-parallelised part of this workload in the LBFGS step function. If this is a bottleneck (require profiling in real workload) consider working on this.
- Parameters:
out – Write final position/gradient here (forwarded to potential).
in – Inputs required by potential and at-least Position.
pot – Potential to minimise.
num_threads – Number of openMP threads to use.
- Returns:
False if converged to a minima.
-
struct Options#
Used to configure the minimiser.
Public Members
-
bool debug = false#
Print out debug info.
-
double f2norm = 1e-6#
Force convergence criterion (eV/Angstroms).
-
io::BinaryFile *fout = nullptr#
If provided at each frame of the minimisation
out
will be written to this file.It is the users responsibility to ensure the lifetime of
fout
is at least as long as the lifetime of theLBFGS
object and ensure only a singleLBFGS
object writes tofout
at any one time. This really only exist for debugging purposes…
-
double grow_trust = 1.5#
Trust radius expansion rate.
-
int iter_max = 2000#
Number of steps before exit with failure.
-
double max_trust = 0.25#
Maximum trust radius e.g max steps size (Angstroms).
-
double min_trust = 0.05#
Minimum trust radius e.g initial step size (Angstroms).
-
int n = 10#
Number of previous steps held in memory.
-
double proj_tol = 0#
Trust tolerance, set larger to reduce trust radius change.
-
double shrink_trust = 0.5#
Trust radius contraction rate.
-
double skin_frac = 1.1#
Used to determine the skin size.
The skin thickness is determined such that the expected number of neighbours is skin_frac * (num_neighbours if no skin used). Hence skin_frac must be larger than one. Neighbour lists are built less often when skin_frac is higher but there will be more more non-neighbours in neighbour lists.
-
bool debug = false#
-
inline LBFGS(Options const &opt, system::Box const &box)#
Newton stepper#
File: libfly/minimise/LBFGS/lbfgs_core.hpp
Exposes the Newton-step calculation part of the L-BFGS algorithm for re-use.
-
class StepLBFGS#
Class for storing L-BFGS position/gradient history.
Public Functions
-
inline explicit StepLBFGS(int n)#
Construct a new StepLBFGS object.
- Parameters:
n – The number of steps to hold in the history.
-
inline auto clear() -> void#
Reset the history.
-
template<typename T1, typename T2>
inline auto newton_step(system::SoA<T1 const&> x, system::SoA<T2 const&> g) -> system::SoA<Delta>&# Compute the approximate Newton-step.
Important
It is expected that the user of this method will set \(x \gets x - \alpha q\) after calling this method and before the next call.
The Newton-step is:
\[q = \hat{H} g\]with \(g\) the gradient of the potential and \(\hat{H}\) the approximate inverse Hessian matrix of the potential calculated using the L-BFGS two-loop recursion. The Newton-step, \(q\), is such-that the optimal step towards the minimum from the current position \(x\) is:
\[x \gets x - \alpha q\]with \(\alpha = 1\) the best guess in the absence of a line-search.
This function accepts generic
SoA
’s to allow exotic notions of position/gradient.- Parameters:
g – The current ‘potential gradient’.
x – The current ‘position’ of the atoms.
- Returns:
A view of the approximate Newton-step (see above) (it is OK to modify this view it will be overwritten upon next call).
-
inline explicit StepLBFGS(int n)#