|
ABACUS develop
Atomic-orbital Based Ab-initio Computation at UStc
|
Driver class for geometry relaxation calculations. More...
#include <relax_driver.h>
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). | |
Driver class for geometry relaxation calculations.
This class manages the main relaxation loop, including energy solving, force/stress calculation, and structure optimization steps.
|
strongprivate |
|
inline |
|
inline |
|
private |
Perform energy solving for the current step.
| istep | Current iteration step. |
| p_esolver | Pointer to the energy solver. |
| ucell | Reference to the unit cell. |
| inp | Input parameters for the calculation. |
| force | Output matrix for calculated forces. |
| stress | Output matrix for calculated stress. |
| etot | Output total energy. |
|
private |
Output final results after relaxation.
| istep | Final iteration step. |
| stop_reason | Reason why the calculation stopped. |
| ucell | Reference to the unit cell. |
| inp | Input parameters for the calculation. |
| etot | Total energy of the final step. |
| stress | Stress tensor of the final step. |
| force | Force matrix of the final step. |
| geometry_evaluated | false when the final geometry was proposed by the optimizer but never evaluated; forces and stress are then omitted / marked N/A. |
|
private |
Initialize the relaxation optimizer.
| nat | Number of atoms in the unit cell. |
| inp | Input parameters for the calculation. |
|
private |
Print iteration information to screen.
| steps | Vector containing step counters: steps[0]=istep, steps[1]=force_step, steps[2]=stress_step. |
| inp | Input parameters for the calculation. |
|
private |
Output JSON format results.
| p_esolver | Pointer to the energy solver. |
| ucell | Reference to the unit cell. |
| inp | Input parameters for the calculation. |
| force | Matrix of calculated forces. |
| stress | Matrix of calculated stress. |
|
private |
Print the dry-run success message to screen.
|
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.
| ionic_steps | Number of evaluated ionic steps. |
| inp | Input parameters (selects the active optimizer and relax_nmax). |
| ofs_running | Output stream for the running log. |
| 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.
| p_esolver | Pointer to the energy solver. |
| ucell | Reference to the unit cell to be relaxed. |
| inp | Input parameters for the calculation. |
| ofs_running | Output stream for running log. |
|
private |
Perform one relaxation step.
| steps | Vector containing step counters (modified in place): steps[0]=istep, steps[1]=force_step, steps[2]=stress_step. |
| p_esolver | Pointer to the energy solver. |
| ucell | Reference to the unit cell. |
| inp | Input parameters for the calculation. |
| force | Matrix of calculated forces. |
| stress | Matrix of calculated stress. |
| etot | Total energy. |
| ofs_running | Output stream for running log. |
|
private |
Output structure files before relaxation move.
| istep | Current iteration step. |
| ucell | Reference to the unit cell. |
| inp | Input parameters for the calculation. |
| etot | Total energy in Ry corresponding to this structure. |
| stress | Stress matrix (3x3) in Ry/Bohr^3 corresponding to this structure. |
| ofs_running | Running log shared with the relaxation driver. |
|
private |
Cached DeePKS setorb flag (read once from PARAM at relax_driver entry).
|
private |
Cached MPI rank (read once at relax_driver entry).
|
private |
Cached global output directory (read once from PARAM at relax_driver entry).
|
private |
Old relaxation optimizer (IonCellOptimizer class).