1919#include < cmath>
2020#include < numeric>
2121
22+ namespace Singular_Value
23+ {
2224// for analytic integral of fq
23- double Singular_Value:: sum_for_solve_chi (const std::vector<ModuleBase::Vector3<double >>& kvec_c,
24- const T_cal_fq_type& func_cal_fq,
25- const double & fq_int)
25+ double sum_for_solve_chi (const std::vector<ModuleBase::Vector3<double >>& kvec_c,
26+ const T_cal_fq_type& func_cal_fq,
27+ const double & fq_int)
2628{
2729 const int nks = kvec_c.size ();
2830
@@ -37,13 +39,13 @@ double Singular_Value::sum_for_solve_chi(const std::vector<ModuleBase::Vector3<d
3739}
3840
3941// for numerical integral of fq
40- double Singular_Value:: solve_chi (const ModuleBase::Matrix3 & G,
41- const std::vector<ModuleBase::Vector3<double >>& kvec_c,
42- const T_cal_fq_type& func_cal_fq,
43- const std::array<int , 3 >& nq_arr,
44- const int & niter,
45- const double & eps,
46- const int & a_rate)
42+ double solve_chi (const ModuleBase::Matrix3& G,
43+ const std::vector<ModuleBase::Vector3<double >>& kvec_c,
44+ const T_cal_fq_type& func_cal_fq,
45+ const std::array<int , 3 >& nq_arr,
46+ const int & niter,
47+ const double & eps,
48+ const int & a_rate)
4749{
4850 // cal fq integral
4951 double fq_int = Iter_Integral (G, func_cal_fq, nq_arr, niter, eps, a_rate);
@@ -52,26 +54,26 @@ double Singular_Value::solve_chi(const ModuleBase::Matrix3 &G,
5254}
5355
5456// for analytic integral of fq
55- double Singular_Value:: solve_chi (const std::vector<ModuleBase::Vector3<double >>& kvec_c,
56- const T_cal_fq_type& func_cal_fq,
57- const double & fq_int)
57+ double solve_chi (const std::vector<ModuleBase::Vector3<double >>& kvec_c,
58+ const T_cal_fq_type& func_cal_fq,
59+ const double & fq_int)
5860{
5961 return sum_for_solve_chi (kvec_c, func_cal_fq, fq_int);
6062}
6163
6264// for analytic integral of fq with gaussian sum
63- double Singular_Value:: solve_chi (const int & nks, const T_cal_fq_type_no& func_cal_fq, const double & fq_int)
65+ double solve_chi (const int & nks, const T_cal_fq_type_no& func_cal_fq, const double & fq_int)
6466{
6567 double chi = fq_int * nks - func_cal_fq ();
6668
6769 return chi;
6870}
6971
70- double Singular_Value:: fq_type_0 (const double & tpiba,
71- const ModuleBase::Vector3<double >& qvec,
72- const int & qdiv,
73- std::vector<ModuleBase::Vector3<double >>& avec,
74- std::vector<ModuleBase::Vector3<double >>& bvec)
72+ double fq_type_0 (const double & tpiba,
73+ const ModuleBase::Vector3<double >& qvec,
74+ const int & qdiv,
75+ std::vector<ModuleBase::Vector3<double >>& avec,
76+ std::vector<ModuleBase::Vector3<double >>& bvec)
7577{
7678 assert (qvec.norm2 ());
7779
@@ -101,13 +103,13 @@ double Singular_Value::fq_type_0(const double& tpiba,
101103 return fq;
102104}
103105
104- double Singular_Value:: cal_type_0 (const UnitCell& ucell,
105- const std::vector<ModuleBase::Vector3<double >>& kvec_c,
106- const int & qdiv,
107- const double & qdense,
108- const int & niter,
109- const double & eps,
110- const int & a_rate)
106+ double cal_type_0 (const UnitCell& ucell,
107+ const std::vector<ModuleBase::Vector3<double >>& kvec_c,
108+ const int & qdiv,
109+ const double & qdense,
110+ const int & niter,
111+ const double & eps,
112+ const int & a_rate)
111113{
112114 ModuleBase::TITLE (" Singular_Value" , " cal_type_0" );
113115 ModuleBase::timer::tick (" Singular_Value" , " cal_type_0" );
@@ -136,14 +138,19 @@ double Singular_Value::cal_type_0(const UnitCell& ucell,
136138 int index = static_cast <int >(vec.norm () * qdense_tpiba);
137139 return index ? index - index % a_rate : a_rate;
138140 });
139- const T_cal_fq_type func_cal_fq_type_0 = std::bind (&fq_type_0, ucell.tpiba , std::placeholders::_1, qdiv, avec, bvec);
141+ const T_cal_fq_type func_cal_fq_type_0
142+ = std::bind (&fq_type_0, ucell.tpiba , std::placeholders::_1, qdiv, avec, bvec);
140143
141144 double val = solve_chi (ucell.G , kvec_c, func_cal_fq_type_0, nq_arr, niter, eps, a_rate);
142145 ModuleBase::timer::tick (" Singular_Value" , " cal_type_0" );
143146 return val;
144147}
145148
146- double Singular_Value::fq_type_1 (const double & tpiba, Gaussian_Abfs& gaussian_abfs, const int & qdiv, const double & lambda, const int & lmax)
149+ double fq_type_1 (const double & tpiba,
150+ Gaussian_Abfs& gaussian_abfs,
151+ const int & qdiv,
152+ const double & lambda,
153+ const int & lmax)
147154{
148155 const size_t ik = 0 ;
149156 const double qexpo = -abs (qdiv);
@@ -157,12 +164,12 @@ double Singular_Value::fq_type_1(const double& tpiba, Gaussian_Abfs& gaussian_ab
157164 return fq;
158165}
159166
160- double Singular_Value:: cal_type_1 (const UnitCell& ucell,
161- const std::array<int , 3 >& nmp,
162- const int & qdiv,
163- const double & start_lambda,
164- const int & niter,
165- const double & eps)
167+ double cal_type_1 (const UnitCell& ucell,
168+ const std::array<int , 3 >& nmp,
169+ const int & qdiv,
170+ const double & start_lambda,
171+ const int & niter,
172+ const double & eps)
166173{
167174 ModuleBase::TITLE (" Singular_Value" , " cal_type_1" );
168175 ModuleBase::timer::tick (" Singular_Value" , " cal_type_1" );
@@ -188,7 +195,8 @@ double Singular_Value::cal_type_1(const UnitCell& ucell,
188195 Gaussian_Abfs gaussian_abfs;
189196 const double exponent = 1 / lambda;
190197 gaussian_abfs.init (ucell, lmax, qvec, bvec, exponent);
191- const T_cal_fq_type_no func_cal_fq_type_1 = std::bind (&fq_type_1, ucell.tpiba , gaussian_abfs, qdiv, lambda, lmax);
198+ const T_cal_fq_type_no func_cal_fq_type_1
199+ = std::bind (&fq_type_1, ucell.tpiba , gaussian_abfs, qdiv, lambda, lmax);
192200 double prefactor
193201 = ModuleBase::TWO_PI * std::pow (lambda, -1.0 / qdiv) * ucell.omega / std::pow (ModuleBase::TWO_PI, 3 );
194202 double fq_int;
@@ -227,12 +235,12 @@ double Singular_Value::cal_type_1(const UnitCell& ucell,
227235 return val_extra;
228236}
229237
230- double Singular_Value:: Iter_Integral (const ModuleBase::Matrix3 & G,
231- const T_cal_fq_type& func_cal_fq,
232- const std::array<int , 3 >& nq_arr,
233- const int & niter,
234- const double & eps,
235- const int & a_rate)
238+ double Iter_Integral (const ModuleBase::Matrix3& G,
239+ const T_cal_fq_type& func_cal_fq,
240+ const std::array<int , 3 >& nq_arr,
241+ const int & niter,
242+ const double & eps,
243+ const int & a_rate)
236244{
237245 bool any_negative = std::any_of (nq_arr.begin (), nq_arr.end (), [](int i) { return i < 0 ; });
238246 bool any_nthree = std::any_of (nq_arr.begin (), nq_arr.end (), [&a_rate](int i) { return i % a_rate != 0 ; });
@@ -290,5 +298,6 @@ double Singular_Value::Iter_Integral(const ModuleBase::Matrix3 &G,
290298
291299 return integ;
292300}
301+ } // namespace Singular_Value
293302
294303#endif
0 commit comments