ABACUS develop
Atomic-orbital Based Ab-initio Computation at UStc
Loading...
Searching...
No Matches
lambda_loop_helper.h File Reference

Free-function helpers for the DeltaSpin lambda optimization loop. More...

#include <ostream>
#include <vector>
#include "source_base/vector3.h"
#include "spin_constrain.h"
Include dependency graph for lambda_loop_helper.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Namespaces

namespace  spinconstrain

Functions

template<typename TK>
void spinconstrain::print_termination (const SpinConstrain< TK > &sc, std::ostream &ofs_running)
 Print final spin and lambda values when the lambda loop terminates.
template<typename TK>
bool spinconstrain::check_rms_stop (const SpinConstrain< TK > &sc, int outer_step, int i_step, double rms_error, double duration, double total_duration, std::ostream &ofs_running)
 Check if RMS error is below convergence threshold or max steps reached.
template<typename TK>
void spinconstrain::print_header (const SpinConstrain< TK > &sc, std::ostream &ofs_running)
 Print header at start of lambda optimization loop.
template<typename TK>
void spinconstrain::check_restriction (const SpinConstrain< TK > &sc, const std::vector< ModuleBase::Vector3< double > > &search, double &alpha_trial, std::ostream &ofs_running)
 Cap step size to prevent overshooting in lambda optimization.
template<typename TK>
double spinconstrain::cal_alpha_opt (const SpinConstrain< TK > &sc, std::vector< ModuleBase::Vector3< double > > spin, std::vector< ModuleBase::Vector3< double > > spin_plus, const double alpha_trial)
 Compute optimal step size via linear interpolation.
template<typename TK>
bool spinconstrain::check_gradient_decay (const SpinConstrain< TK > &sc, const std::vector< ModuleBase::Vector3< double > > &new_spin, const std::vector< ModuleBase::Vector3< double > > &spin, const std::vector< ModuleBase::Vector3< double > > &delta_lambda, const std::vector< ModuleBase::Vector3< double > > &dnu_last_step, bool print, std::ostream &ofs_running)
 Check if the magnetic susceptibility gradient dM/dlambda has decayed below threshold.
template<typename TK>
void spinconstrain::print_Mi (const SpinConstrain< TK > &sc, std::ostream &ofs_running)
 Print atomic magnetic moments Mi in a formatted table.
template<typename TK>
void spinconstrain::print_Mag_Force (const SpinConstrain< TK > &sc, std::ostream &ofs_running)
 Print the magnetic force (-lambda) per atom in eV/uB.

Detailed Description

Free-function helpers for the DeltaSpin lambda optimization loop.

Background
Originally these routines were member functions of SpinConstrain<TK>. They have been lifted to free functions in the spinconstrain namespace to shrink the SpinConstrain god class. Each helper takes the SpinConstrain instance as its first parameter and accesses internal state through the public getters (get_mi, get_sc_lambda, get_constrain, ...).
Template parameter TK
  • std::complex<double>: full implementation (nspin=2 and nspin=4)
  • double: stub specialization (no-ops) provided elsewhere