ABACUS develop
Atomic-orbital Based Ab-initio Computation at UStc
Loading...
Searching...
No Matches
Ions_Move_Basic Namespace Reference

Basic utilities and shared state for ionic relaxation algorithms. More...

Functions

void setup_gradient (const UnitCell &ucell, const ModuleBase::matrix &force, double *pos, double *grad, std::ofstream &ofs)
 Setup gradient from atomic forces.
void move_atoms (UnitCell &ucell, double *move, double *pos, std::ofstream &ofs, const int test_relax_method)
 Move atoms according to displacement vector.
bool check_converged (const UnitCell &ucell, const double *grad, int &update_iter, std::ofstream &ofs, std::vector< double > &etot_info, const double &force_thr, const double &force_thr_ev, const std::string &out_level, const int test_relax_method)
 Check convergence based on gradient threshold.
void terminate (const bool converged, const int update_iter, const UnitCell &ucell, const int istep, std::ofstream &ofs)
 Terminate geometry optimization and output results.
void setup_etot (const double &energy_in, const int istep, std::vector< double > &etot_info)
 Update energy values and compute energy difference.
double dot_func (const double *a, const double *b, const int &dim_in)
 Compute dot product of two vectors.
void third_order ()
 Third-order polynomial interpolation for line search.

Variables

double trust_radius = 0.0
 Current trust radius.
double trust_radius_old = 0.0
 Previous trust radius.
double relax_bfgs_rmax = -1.0
 Maximum trust radius (default: 0.8 Bohr).
double relax_bfgs_rmin = -1.0
 Minimum trust radius (default: 1e-5 Bohr).
double relax_bfgs_init = -1.0
 Initial trust radius (default: 0.5 Bohr).
double best_xxx = 1.0
 Last step length from CG, used as BFGS initial guess.

Detailed Description

Basic utilities and shared state for ionic relaxation algorithms.

This namespace provides common functions and parameters used by all ion movement methods (BFGS, CG, SD, etc.). It shares core state variables through references to Relax_Data, ensuring consistent data across different optimization algorithms.

Function Documentation

◆ check_converged()

bool Ions_Move_Basic::check_converged ( const UnitCell & ucell,
const double * grad,
int & update_iter,
std::ofstream & ofs,
std::vector< double > & etot_info,
const double & force_thr,
const double & force_thr_ev,
const std::string & out_level,
const int test_relax_method )

Check convergence based on gradient threshold.

Parameters
ucellUnit cell containing lattice information
gradGradient array (dimension: dim)
update_iterNumber of successfully updated iterations (will be incremented if converged)
ofsOutput stream for logging
etot_infoEnergy information array [etot, etot_p, ediff]
force_thrForce convergence threshold in Ry/Bohr
force_thr_evThe same threshold in eV/Angstrom, as reconciled by ReadInput
out_levelOutput verbosity level ("ie" prints per-step energy to stdout)
test_relax_methodVerbosity level for relaxation debug output
Returns
true if converged, false otherwise
Here is the call graph for this function:
Here is the caller graph for this function:

◆ dot_func()

double Ions_Move_Basic::dot_func ( const double * a,
const double * b,
const int & dim_in )

Compute dot product of two vectors.

Parameters
aFirst vector
bSecond vector
dim_inDimension of vectors
Returns
Dot product value
Here is the caller graph for this function:

◆ move_atoms()

void Ions_Move_Basic::move_atoms ( UnitCell & ucell,
double * move,
double * pos,
std::ofstream & ofs,
const int test_relax_method )

Move atoms according to displacement vector.

Parameters
ucellUnit cell to update
moveDisplacement vector (dimension: dim)
posCurrent position array (dimension: dim)
ofsOutput stream for logging
test_relax_methodVerbosity level for relaxation debug output
Here is the call graph for this function:
Here is the caller graph for this function:

◆ setup_etot()

void Ions_Move_Basic::setup_etot ( const double & energy_in,
const int istep,
std::vector< double > & etot_info )

Update energy values and compute energy difference.

Parameters
energy_inInput energy value
judgementFlag for SD method (true) or BFGS (false)
istepCurrent ionic step index
etot_infoEnergy information array [etot, etot_p, ediff]
Here is the caller graph for this function:

◆ setup_gradient()

void Ions_Move_Basic::setup_gradient ( const UnitCell & ucell,
const ModuleBase::matrix & force,
double * pos,
double * grad,
std::ofstream & ofs )

Setup gradient from atomic forces.

Parameters
ucellUnit cell containing atomic information
forceForce matrix (nat x 3)
posOutput position array (dimension: dim)
gradOutput gradient array (dimension: dim)
ofsOutput stream for logging
Here is the call graph for this function:
Here is the caller graph for this function:

◆ terminate()

void Ions_Move_Basic::terminate ( const bool converged,
const int update_iter,
const UnitCell & ucell,
const int istep,
std::ofstream & ofs )

Terminate geometry optimization and output results.

Parameters
convergedConvergence flag
update_iterNumber of successfully updated iterations
ucellUnit cell to output
istepCurrent ionic step index
ofsOutput stream for logging
Here is the call graph for this function:
Here is the caller graph for this function:

◆ third_order()

void Ions_Move_Basic::third_order ( )

Third-order polynomial interpolation for line search.

Variable Documentation

◆ best_xxx

double Ions_Move_Basic::best_xxx = 1.0
extern

Last step length from CG, used as BFGS initial guess.

◆ relax_bfgs_init

double Ions_Move_Basic::relax_bfgs_init = -1.0
extern

Initial trust radius (default: 0.5 Bohr).

◆ relax_bfgs_rmax

double Ions_Move_Basic::relax_bfgs_rmax = -1.0
extern

Maximum trust radius (default: 0.8 Bohr).

◆ relax_bfgs_rmin

double Ions_Move_Basic::relax_bfgs_rmin = -1.0
extern

Minimum trust radius (default: 1e-5 Bohr).

◆ trust_radius

double Ions_Move_Basic::trust_radius = 0.0
extern

Current trust radius.

◆ trust_radius_old

double Ions_Move_Basic::trust_radius_old = 0.0
extern

Previous trust radius.