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

Optimizer for ionic position relaxation and cell parameter optimization. More...

#include <relax_nsync.h>

Collaboration diagram for IonCellOptimizer:

Public Member Functions

void init_relax (const int &natom, const Input_para &inp)
 Initialize relaxation algorithms.
bool relax_step (const int &istep, const double &energy, UnitCell &ucell, ModuleBase::matrix force, ModuleBase::matrix stress, int &force_step, int &stress_step, std::ofstream &ofs_running)
 Perform one step of relaxation (atomic and/or cell).
const std::vector< double > & get_max_force_history () const
 Read-only observers of the per-step convergence history, for the final summary.
const std::vector< double > & get_max_stress_history () const

Private Member Functions

void print_converged_summary (const int istep, const bool with_stress, std::ofstream &ofs_running) const
 Print the unified convergence summary to the running log.

Private Attributes

Ions_Move_Methods IMM
 Ionic movement methods for atom relaxation.
Lattice_Change_Methods LCM
 Lattice change methods for cell relaxation.
const Input_para * inp_ = nullptr
std::vector< double > max_force_history_
 Largest force of each ionic step (eV/Angstrom), kept across cell changes.
std::vector< double > max_stress_history_
 Largest stress of each cell step (kbar), only filled in cell-relax.

Detailed Description

Optimizer for ionic position relaxation and cell parameter optimization.

This class handles both atomic relaxation and cell relaxation calculations. It manages the geometry optimization process by coordinating between Ions_Move_Methods (for atomic position updates) and Lattice_Change_Methods (for cell parameter updates).

The optimization follows a sequential approach:

  1. First perform atomic relaxation until convergence
  2. Then perform cell relaxation (only in cell-relax mode)

Member Function Documentation

◆ get_max_force_history()

const std::vector< double > & IonCellOptimizer::get_max_force_history ( ) const
inline

Read-only observers of the per-step convergence history, for the final summary.

◆ get_max_stress_history()

const std::vector< double > & IonCellOptimizer::get_max_stress_history ( ) const
inline

◆ init_relax()

void IonCellOptimizer::init_relax ( const int & natom,
const Input_para & inp )

Initialize relaxation algorithms.

Initialize relaxation algorithms based on calculation type.

Parameters
natomNumber of atoms in the system

Allocates memory and initializes the appropriate relaxation methods:

Parameters
natomNumber of atoms in the system

◆ print_converged_summary()

void IonCellOptimizer::print_converged_summary ( const int istep,
const bool with_stress,
std::ofstream & ofs_running ) const
private

Print the unified convergence summary to the running log.

Shared by every exit path that reports a converged relaxation, so the ASE interface always finds the same set of lines (issue #6546).

Parameters
istepTotal ionic steps taken.
with_stressWhether the per-step stress history is printed (true for cell-relax with a movable lattice).
ofs_runningOutput stream for the running log.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ relax_step()

bool IonCellOptimizer::relax_step ( const int & istep,
const double & energy,
UnitCell & ucell,
ModuleBase::matrix force,
ModuleBase::matrix stress,
int & force_step,
int & stress_step,
std::ofstream & ofs_running )

Perform one step of relaxation (atomic and/or cell).

This is the main interface for relaxation. Depending on the calculation type ("relax" or "cell-relax"), it will perform atomic relaxation, cell relaxation, or both in sequence.

Parameters
istepCurrent total iteration step
energyTotal energy of the system
ucellUnit cell containing atomic positions and lattice vectors
forceIonic forces matrix
stressStress tensor matrix
force_stepCurrent step counter for force-based relaxation
stress_stepCurrent step counter for stress-based relaxation
ofs_runningOutput stream for running log
Returns
true if relaxation is converged, false otherwise

Main relaxation loop that coordinates atomic and cell relaxation:

  1. Determine calculation mode (relax vs cell-relax)
  2. Perform atomic relaxation if needed and atoms can move
  3. If in cell-relax mode and atomic relaxation converged, perform cell relaxation

Convergence behavior:

  • Returns false if relaxation is still in progress
  • Returns true if the current geometry has converged
Parameters
istepCurrent total iteration step
energyTotal energy of the system
ucellUnit cell containing atomic positions and lattice vectors
forceIonic forces matrix (natoms x 3)
stressStress tensor matrix (3 x 3)
force_stepCurrent step counter for force-based relaxation (output)
stress_stepCurrent step counter for stress-based relaxation (output)
Returns
true if relaxation is converged, false otherwise
Here is the call graph for this function:

Member Data Documentation

◆ IMM

Ions_Move_Methods IonCellOptimizer::IMM
private

Ionic movement methods for atom relaxation.

◆ inp_

const Input_para* IonCellOptimizer::inp_ = nullptr
private

◆ LCM

Lattice_Change_Methods IonCellOptimizer::LCM
private

Lattice change methods for cell relaxation.

◆ max_force_history_

std::vector<double> IonCellOptimizer::max_force_history_
private

Largest force of each ionic step (eV/Angstrom), kept across cell changes.

◆ max_stress_history_

std::vector<double> IonCellOptimizer::max_stress_history_
private

Largest stress of each cell step (kbar), only filled in cell-relax.


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