ABACUS develop
Atomic-orbital Based Ab-initio Computation at UStc
Loading...
Searching...
No Matches
lambda_loop_helper.h
Go to the documentation of this file.
1#ifndef LAMBDA_LOOP_HELPER_H
2#define LAMBDA_LOOP_HELPER_H
3
4#include <ostream>
5#include <vector>
6
8#include "spin_constrain.h"
9
25
26namespace spinconstrain
27{
28
35template <typename TK>
36void print_termination(const SpinConstrain<TK>& sc, std::ostream& ofs_running);
37
51template <typename TK>
53 int outer_step,
54 int i_step,
55 double rms_error,
56 double duration,
57 double total_duration,
58 std::ostream& ofs_running);
59
66template <typename TK>
67void print_header(const SpinConstrain<TK>& sc, std::ostream& ofs_running);
68
81template <typename TK>
83 const std::vector<ModuleBase::Vector3<double>>& search,
84 double& alpha_trial,
85 std::ostream& ofs_running);
86
102template <typename TK>
103double cal_alpha_opt(const SpinConstrain<TK>& sc,
104 std::vector<ModuleBase::Vector3<double>> spin,
105 std::vector<ModuleBase::Vector3<double>> spin_plus,
106 const double alpha_trial);
107
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,
134 bool print,
135 std::ostream& ofs_running);
136
147template <typename TK>
148void print_Mi(const SpinConstrain<TK>& sc, std::ostream& ofs_running);
149
160template <typename TK>
161void print_Mag_Force(const SpinConstrain<TK>& sc, std::ostream& ofs_running);
162
163} // namespace spinconstrain
164
165#endif // LAMBDA_LOOP_HELPER_H
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.