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

Driver class for geometry relaxation calculations. More...

#include <relax_driver.h>

Collaboration diagram for Relax_Driver:

Public Member Functions

 Relax_Driver ()
 ~Relax_Driver ()
void relax_driver (ModuleESolver::ESolver *p_esolver, UnitCell &ucell, const Input_para &inp, std::ofstream &ofs_running)
 Main driver function for relaxation calculations.

Private Types

enum class  RelaxStopReason {
  Converged , MaxSteps , UserExit , DryRun ,
  Finished
}

Private Member Functions

void init_relax (const int nat, const Input_para &inp)
 Initialize the relaxation optimizer.
void iter_info (const std::vector< int > &steps, const Input_para &inp)
 Print iteration information to screen.
void esolve (const int istep, ModuleESolver::ESolver *p_esolver, UnitCell &ucell, const Input_para &inp, ModuleBase::matrix &force, ModuleBase::matrix &stress, double &etot)
 Perform energy solving for the current step.
bool relax_step (std::vector< int > &steps, ModuleESolver::ESolver *p_esolver, UnitCell &ucell, const Input_para &inp, const ModuleBase::matrix &force, const ModuleBase::matrix &stress, const double etot, std::ofstream &ofs_running)
 Perform one relaxation step.
void stru_out (const int istep, UnitCell &ucell, const Input_para &inp, const double etot, const ModuleBase::matrix &stress, const ModuleBase::matrix &force, std::ofstream &ofs_running)
 Output structure files before relaxation move.
void json_out (ModuleESolver::ESolver *p_esolver, UnitCell &ucell, const Input_para &inp, const ModuleBase::matrix &force, const ModuleBase::matrix &stress)
 Output JSON format results.
void final_out (const int istep, const RelaxStopReason stop_reason, UnitCell &ucell, const Input_para &inp, const double etot, const ModuleBase::matrix &stress, const ModuleBase::matrix &force, const bool geometry_evaluated, std::ofstream &ofs_running)
 Output final results after relaxation.
void print_not_converged_summary (const int ionic_steps, const Input_para &inp, std::ofstream &ofs_running) const
 Print the unified not-converged summary to the running log.
void print_dry_run_message () const
 Print the dry-run success message to screen.

Private Attributes

Relax rl
 New relaxation optimizer (Relax class).
IonCellOptimizer rl_old
 Old relaxation optimizer (IonCellOptimizer class).
std::string out_dir_
 Cached global output directory (read once from PARAM at relax_driver entry).
bool deepks_setorb_ = false
 Cached DeePKS setorb flag (read once from PARAM at relax_driver entry).
int my_rank_ = 0
 Cached MPI rank (read once at relax_driver entry).

Detailed Description

Driver class for geometry relaxation calculations.

This class manages the main relaxation loop, including energy solving, force/stress calculation, and structure optimization steps.

Member Enumeration Documentation

◆ RelaxStopReason

enum class Relax_Driver::RelaxStopReason
strongprivate
Enumerator
Converged 
MaxSteps 
UserExit 
DryRun 
Finished 

Constructor & Destructor Documentation

◆ Relax_Driver()

Relax_Driver::Relax_Driver ( )
inline

◆ ~Relax_Driver()

Relax_Driver::~Relax_Driver ( )
inline

Member Function Documentation

◆ esolve()

void Relax_Driver::esolve ( const int istep,
ModuleESolver::ESolver * p_esolver,
UnitCell & ucell,
const Input_para & inp,
ModuleBase::matrix & force,
ModuleBase::matrix & stress,
double & etot )
private

Perform energy solving for the current step.

Parameters
istepCurrent iteration step.
p_esolverPointer to the energy solver.
ucellReference to the unit cell.
inpInput parameters for the calculation.
forceOutput matrix for calculated forces.
stressOutput matrix for calculated stress.
etotOutput total energy.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ final_out()

void Relax_Driver::final_out ( const int istep,
const RelaxStopReason stop_reason,
UnitCell & ucell,
const Input_para & inp,
const double etot,
const ModuleBase::matrix & stress,
const ModuleBase::matrix & force,
const bool geometry_evaluated,
std::ofstream & ofs_running )
private

Output final results after relaxation.

Parameters
istepFinal iteration step.
stop_reasonReason why the calculation stopped.
ucellReference to the unit cell.
inpInput parameters for the calculation.
etotTotal energy of the final step.
stressStress tensor of the final step.
forceForce matrix of the final step.
geometry_evaluatedfalse when the final geometry was proposed by the optimizer but never evaluated; forces and stress are then omitted / marked N/A.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ init_relax()

void Relax_Driver::init_relax ( const int nat,
const Input_para & inp )
private

Initialize the relaxation optimizer.

Parameters
natNumber of atoms in the unit cell.
inpInput parameters for the calculation.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ iter_info()

void Relax_Driver::iter_info ( const std::vector< int > & steps,
const Input_para & inp )
private

Print iteration information to screen.

Parameters
stepsVector containing step counters: steps[0]=istep, steps[1]=force_step, steps[2]=stress_step.
inpInput parameters for the calculation.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ json_out()

void Relax_Driver::json_out ( ModuleESolver::ESolver * p_esolver,
UnitCell & ucell,
const Input_para & inp,
const ModuleBase::matrix & force,
const ModuleBase::matrix & stress )
private

Output JSON format results.

Parameters
p_esolverPointer to the energy solver.
ucellReference to the unit cell.
inpInput parameters for the calculation.
forceMatrix of calculated forces.
stressMatrix of calculated stress.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ print_dry_run_message()

void Relax_Driver::print_dry_run_message ( ) const
private

Print the dry-run success message to screen.

Here is the caller graph for this function:

◆ print_not_converged_summary()

void Relax_Driver::print_not_converged_summary ( const int ionic_steps,
const Input_para & inp,
std::ofstream & ofs_running ) const
private

Print the unified not-converged summary to the running log.

Reports the relaxation method, the number of ionic steps taken and the per-step largest force / stress history, so ASE and users can diagnose why the relaxation stopped at relax_nmax.

Parameters
ionic_stepsNumber of evaluated ionic steps.
inpInput parameters (selects the active optimizer and relax_nmax).
ofs_runningOutput stream for the running log.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ relax_driver()

void Relax_Driver::relax_driver ( ModuleESolver::ESolver * p_esolver,
UnitCell & ucell,
const Input_para & inp,
std::ofstream & ofs_running )

Main driver function for relaxation calculations.

This function executes the main iteration loop for relaxation, calling energy solver and structure optimization steps until convergence or maximum steps reached.

Parameters
p_esolverPointer to the energy solver.
ucellReference to the unit cell to be relaxed.
inpInput parameters for the calculation.
ofs_runningOutput stream for running log.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ relax_step()

bool Relax_Driver::relax_step ( std::vector< int > & steps,
ModuleESolver::ESolver * p_esolver,
UnitCell & ucell,
const Input_para & inp,
const ModuleBase::matrix & force,
const ModuleBase::matrix & stress,
const double etot,
std::ofstream & ofs_running )
private

Perform one relaxation step.

Parameters
stepsVector containing step counters (modified in place): steps[0]=istep, steps[1]=force_step, steps[2]=stress_step.
p_esolverPointer to the energy solver.
ucellReference to the unit cell.
inpInput parameters for the calculation.
forceMatrix of calculated forces.
stressMatrix of calculated stress.
etotTotal energy.
ofs_runningOutput stream for running log.
Returns
True if relaxation converged, false otherwise.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ stru_out()

void Relax_Driver::stru_out ( const int istep,
UnitCell & ucell,
const Input_para & inp,
const double etot,
const ModuleBase::matrix & stress,
const ModuleBase::matrix & force,
std::ofstream & ofs_running )
private

Output structure files before relaxation move.

Parameters
istepCurrent iteration step.
ucellReference to the unit cell.
inpInput parameters for the calculation.
etotTotal energy in Ry corresponding to this structure.
stressStress matrix (3x3) in Ry/Bohr^3 corresponding to this structure.
ofs_runningRunning log shared with the relaxation driver.
Here is the call graph for this function:
Here is the caller graph for this function:

Member Data Documentation

◆ deepks_setorb_

bool Relax_Driver::deepks_setorb_ = false
private

Cached DeePKS setorb flag (read once from PARAM at relax_driver entry).

◆ my_rank_

int Relax_Driver::my_rank_ = 0
private

Cached MPI rank (read once at relax_driver entry).

◆ out_dir_

std::string Relax_Driver::out_dir_
private

Cached global output directory (read once from PARAM at relax_driver entry).

◆ rl

Relax Relax_Driver::rl
private

New relaxation optimizer (Relax class).

◆ rl_old

IonCellOptimizer Relax_Driver::rl_old
private

Old relaxation optimizer (IonCellOptimizer class).


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