ABACUS develop
Atomic-orbital Based Ab-initio Computation at UStc
Loading...
Searching...
No Matches
Public Member Functions | Private Member Functions | Private Attributes | List of all members
LBFGS Class Reference

Implements L-BFGS optimization algorithm for structural relaxation. More...

#include <lbfgs.h>

Collaboration diagram for LBFGS:

Public Member Functions

void allocate (const int _size)
 Initialize L-BFGS parameters.
 
void relax_step (const ModuleBase::matrix _force, UnitCell &ucell, const double &etot)
 Perform one L-BFGS relaxation step.
 

Private Member Functions

void prepare_step (std::vector< std::vector< double > > &force, std::vector< std::vector< double > > &pos, std::vector< std::vector< double > > &H, std::vector< double > &pos0, std::vector< double > &force0, std::vector< std::vector< double > > &dpos, UnitCell &ucell, const double &etot)
 Prepare optimization step parameters.
 
void is_restrain (std::vector< std::vector< double > > &dpos)
 Judge if the cell is restrain.
 
void calculate_largest_grad (const ModuleBase::matrix &_force, UnitCell &ucell)
 Calculate maximum gradient component.
 
void get_pos (UnitCell &ucell, std::vector< std::vector< double > > &pos)
 Extract atomic positions from unit cell.
 
void get_pos_taud (UnitCell &ucell, std::vector< std::vector< double > > &pos_taud)
 Get fractional positions from unit cell.
 
void update (std::vector< std::vector< double > > &pos_taud, std::vector< double > &pos_taud0, std::vector< double > &force, std::vector< double > &force0, UnitCell &ucell, int iteration, int memory, std::vector< std::vector< double > > &s, std::vector< std::vector< double > > &y, std::vector< double > &rho)
 Update L-BFGS history buffers.
 
void determine_step (std::vector< double > &steplength, std::vector< std::vector< double > > &dpos, double &maxstep)
 Determine optimal step lengths.
 
void update_pos (UnitCell &ucell)
 Update atomic positions in unit cell.
 

Private Attributes

double alpha
 Initial Hessian diagonal element.
 
double maxstep
 Maximum allowed step length.
 
int size
 Number of atoms in system.
 
int memory
 Number of previous steps to store.
 
double H0
 Initial inverse Hessian approximation.
 
int iteration
 Current iteration count.
 
double energy
 Current system energy.
 
double alpha_k
 Step size parameter.
 
ModuleESolver::ESolversolver
 Structure solver.
 
std::vector< std::vector< double > > H
 Inverse Hessian approximation.
 
std::vector< double > force0
 Previous step forces.
 
std::vector< std::vector< double > > force
 Force history.
 
std::vector< double > pos0
 Previous positions.
 
std::vector< std::vector< double > > pos
 Position history.
 
std::vector< double > pos_taud0
 Previous fractional positions.
 
std::vector< std::vector< double > > pos_taud
 Fractional position history.
 
std::vector< std::vector< double > > dpos
 Position displacements.
 
std::vector< std::vector< double > > s
 Position difference vectors.
 
std::vector< std::vector< double > > y
 Force difference vectors.
 
std::vector< double > rho
 Scalar products for L-BFGS update.
 
std::vector< double > steplength
 Step lengths for each atom.
 

Detailed Description

Implements L-BFGS optimization algorithm for structural relaxation.

Member Function Documentation

◆ allocate()

void LBFGS::allocate ( const int  _size)

Initialize L-BFGS parameters.

Parameters
_sizeNumber of atoms in system
Here is the caller graph for this function:

◆ calculate_largest_grad()

void LBFGS::calculate_largest_grad ( const ModuleBase::matrix _force,
UnitCell ucell 
)
private

Calculate maximum gradient component.

Parameters
_forceCurrent force matrix
ucellUnit cell being optimized
Here is the caller graph for this function:

◆ determine_step()

void LBFGS::determine_step ( std::vector< double > &  steplength,
std::vector< std::vector< double > > &  dpos,
double &  maxstep 
)
private

Determine optimal step lengths.

Parameters
steplengthOutput step lengths
dposPosition displacements
maxstepMaximum allowed step length
Here is the caller graph for this function:

◆ get_pos()

void LBFGS::get_pos ( UnitCell ucell,
std::vector< std::vector< double > > &  pos 
)
private

Extract atomic positions from unit cell.

Parameters
ucellUnit cell to read
posOutput position vector
Here is the caller graph for this function:

◆ get_pos_taud()

void LBFGS::get_pos_taud ( UnitCell ucell,
std::vector< std::vector< double > > &  pos_taud 
)
private

Get fractional positions from unit cell.

Parameters
ucellUnit cell to read
pos_taudOutput fractional positions
Here is the caller graph for this function:

◆ is_restrain()

void LBFGS::is_restrain ( std::vector< std::vector< double > > &  dpos)
private

Judge if the cell is restrain.

Parameters
dposPosition displacements to constrain
Here is the caller graph for this function:

◆ prepare_step()

void LBFGS::prepare_step ( std::vector< std::vector< double > > &  force,
std::vector< std::vector< double > > &  pos,
std::vector< std::vector< double > > &  H,
std::vector< double > &  pos0,
std::vector< double > &  force0,
std::vector< std::vector< double > > &  dpos,
UnitCell ucell,
const double &  etot 
)
private

Prepare optimization step parameters.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ relax_step()

void LBFGS::relax_step ( const ModuleBase::matrix  _force,
UnitCell ucell,
const double &  etot 
)

Perform one L-BFGS relaxation step.

Parameters
_forceCurrent force
ucellUnit cell to optimize
etotCurrent total energy
p_esolverStructure solver
Here is the call graph for this function:
Here is the caller graph for this function:

◆ update()

void LBFGS::update ( std::vector< std::vector< double > > &  pos_taud,
std::vector< double > &  pos_taud0,
std::vector< double > &  force,
std::vector< double > &  force0,
UnitCell ucell,
int  iteration,
int  memory,
std::vector< std::vector< double > > &  s,
std::vector< std::vector< double > > &  y,
std::vector< double > &  rho 
)
private

Update L-BFGS history buffers.

Parameters
pos_taudCurrent fractional positions
pos_taud0Previous fractional positions
forceCurrent forces
force0Previous forces
ucellUnit cell being optimized
iterationCurrent step number
memoryHistory buffer size
sPosition differences buffer
yForce differences buffer
rhoScalar products buffer
Here is the call graph for this function:
Here is the caller graph for this function:

◆ update_pos()

void LBFGS::update_pos ( UnitCell ucell)
private

Update atomic positions in unit cell.

Parameters
ucellUnit cell to update
Here is the call graph for this function:
Here is the caller graph for this function:

Member Data Documentation

◆ alpha

double LBFGS::alpha
private

Initial Hessian diagonal element.

◆ alpha_k

double LBFGS::alpha_k
private

Step size parameter.

◆ dpos

std::vector<std::vector<double> > LBFGS::dpos
private

Position displacements.

◆ energy

double LBFGS::energy
private

Current system energy.

◆ force

std::vector<std::vector<double> > LBFGS::force
private

Force history.

◆ force0

std::vector<double> LBFGS::force0
private

Previous step forces.

◆ H

std::vector<std::vector<double> > LBFGS::H
private

Inverse Hessian approximation.

◆ H0

double LBFGS::H0
private

Initial inverse Hessian approximation.

◆ iteration

int LBFGS::iteration
private

Current iteration count.

◆ maxstep

double LBFGS::maxstep
private

Maximum allowed step length.

◆ memory

int LBFGS::memory
private

Number of previous steps to store.

◆ pos

std::vector<std::vector<double> > LBFGS::pos
private

Position history.

◆ pos0

std::vector<double> LBFGS::pos0
private

Previous positions.

◆ pos_taud

std::vector<std::vector<double> > LBFGS::pos_taud
private

Fractional position history.

◆ pos_taud0

std::vector<double> LBFGS::pos_taud0
private

Previous fractional positions.

◆ rho

std::vector<double> LBFGS::rho
private

Scalar products for L-BFGS update.

◆ s

std::vector<std::vector<double> > LBFGS::s
private

Position difference vectors.

◆ size

int LBFGS::size
private

Number of atoms in system.

◆ solver

ModuleESolver::ESolver* LBFGS::solver
private

Structure solver.

◆ steplength

std::vector<double> LBFGS::steplength
private

Step lengths for each atom.

◆ y

std::vector<std::vector<double> > LBFGS::y
private

Force difference vectors.


The documentation for this class was generated from the following files: