1#ifndef LAMBDA_LOOP_HELPER_H
2#define LAMBDA_LOOP_HELPER_H
57 double total_duration,
58 std::ostream& ofs_running);
83 const std::vector<ModuleBase::Vector3<double>>& search,
85 std::ostream& ofs_running);
102template <
typename TK>
104 std::vector<ModuleBase::Vector3<double>> spin,
105 std::vector<ModuleBase::Vector3<double>> spin_plus,
106 const double alpha_trial);
128template <
typename TK>
130 const std::vector<ModuleBase::Vector3<double>>& new_spin,
131 const std::vector<ModuleBase::Vector3<double>>& spin,
132 const std::vector<ModuleBase::Vector3<double>>& delta_lambda,
133 const std::vector<ModuleBase::Vector3<double>>& dnu_last_step,
135 std::ostream& ofs_running);
147template <
typename TK>
160template <
typename TK>
Singleton class implementing spin-constrained DFT (DeltaSpin).
Definition spin_constrain.h:107
Definition deltaspin_init.cpp:32
void print_Mag_Force(const SpinConstrain< TK > &sc, std::ostream &ofs_running)
Print the magnetic force (-lambda) per atom in eV/uB.
Definition lambda_loop_helper.cpp:410
void print_termination(const SpinConstrain< TK > &sc, std::ostream &ofs_running)
Print final spin and lambda values when the lambda loop terminates.
Definition lambda_loop_helper.cpp:41
bool 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.
Definition lambda_loop_helper.cpp:236
bool 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.
Definition lambda_loop_helper.cpp:68
void print_header(const SpinConstrain< TK > &sc, std::ostream &ofs_running)
Print header at start of lambda optimization loop.
Definition lambda_loop_helper.cpp:104
void print_Mi(const SpinConstrain< TK > &sc, std::ostream &ofs_running)
Print atomic magnetic moments Mi in a formatted table.
Definition lambda_loop_helper.cpp:349
void 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.
Definition lambda_loop_helper.cpp:125
double 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.
Definition lambda_loop_helper.cpp:160
Core header for the DeltaSpin (spin-constrained DFT) module.