22// Author: Jingang Han
33// DATE : 2024-03-11
44// ==========================================================
5-
65#include " module_rdmft/rdmft_tools.h"
76#include " module_hamilt_pw/hamilt_pwdft/global.h"
87// used by class Veff_rdmft
2120#include < sstream>
2221#include < cassert>
2322
24-
2523namespace rdmft
2624{
2725
28-
2926template <>
3027void conj_psi<double >(psi::Psi<double >& wfc) {}
3128
32-
3329template <>
34- void HkPsi<double >(const Parallel_Orbitals* ParaV, const double & HK, const double & wfc, double & H_wfc)
30+ void HkPsi<double >(const Parallel_Orbitals* ParaV,
31+ const double & HK,
32+ const double & wfc,
33+ double & H_wfc)
3534{
3635 const int one_int = 1 ;
3736 const double one_double = 1.0 ;
@@ -52,8 +51,11 @@ void HkPsi<double>(const Parallel_Orbitals* ParaV, const double& HK, const doubl
5251
5352
5453template <>
55- void cal_bra_op_ket<double >(const Parallel_Orbitals* ParaV, const Parallel_2D& para_Eij_in,
56- const double & wfc, const double & H_wfc, std::vector<double >& Dmn)
54+ void cal_bra_op_ket<double >(const Parallel_Orbitals* ParaV,
55+ const Parallel_2D& para_Eij_in,
56+ const double & wfc,
57+ const double & H_wfc,
58+ std::vector<double >& Dmn)
5759{
5860 const int one_int = 1 ;
5961 const double one_double = 1.0 ;
@@ -85,8 +87,10 @@ void occNum_Mul_wfcHwfc(const ModuleBase::matrix& occ_number,
8587{
8688 for (int ir=0 ; ir<occ_number.nr ; ++ ir)
8789 {
88- for (int ic=0 ; ic<occ_number.nc ; ++ic) { occNum_wfcHwfc (ir, ic) += occNum_func (occ_number (ir, ic), symbol, XC_func_rdmft, alpha) * wfcHwfc (ir, ic);
89- }
90+ for (int ic=0 ; ic<occ_number.nc ; ++ic)
91+ {
92+ occNum_wfcHwfc (ir, ic) += occNum_func (occ_number (ir, ic), symbol, XC_func_rdmft, alpha) * wfcHwfc (ir, ic);
93+ }
9094 }
9195}
9296
@@ -111,13 +115,16 @@ void add_occNum(const K_Vectors& kv,
111115 // consider W_k for dE/d_occNum
112116 for (int ik=0 ; ik<occ_number.nr ; ++ik)
113117 {
114- for (int inb=0 ; inb<occ_number.nc ; ++inb) { occNum_wfcHwfc (ik, inb) *= kv.wk [ik];
115- }
118+ for (int inb=0 ; inb<occ_number.nc ; ++inb)
119+ {
120+ occNum_wfcHwfc (ik, inb) *= kv.wk [ik];
121+ }
116122 }
117123}
118124
119125
120- // do wk*g(occNum)*wfcHwfc and add for TV, hartree, XC. This function just use once, so it can be replace and delete
126+ // ! do wk*g(occNum)*wfcHwfc and add for TV, hartree, XC.
127+ // ! This function just use once, so it can be replace and delete
121128void add_wfcHwfc (const ModuleBase::matrix& wg,
122129 const ModuleBase::matrix& wk_fun_occNum,
123130 const ModuleBase::matrix& wfcHwfc_TV_in,
@@ -134,28 +141,31 @@ void add_wfcHwfc(const ModuleBase::matrix& wg,
134141}
135142
136143
137- // give certain occNum_wfcHwfc, get the corresponding energy
144+ // ! give certain occNum_wfcHwfc, get the corresponding energy
138145double getEnergy (const ModuleBase::matrix& occNum_wfcHwfc)
139146{
140147 double energy = 0.0 ;
141148 for (int ir=0 ; ir<occNum_wfcHwfc.nr ; ++ ir)
142149 {
143- for (int ic=0 ; ic<occNum_wfcHwfc.nc ; ++ic) { energy += occNum_wfcHwfc (ir, ic);
144- }
150+ for (int ic=0 ; ic<occNum_wfcHwfc.nc ; ++ic)
151+ {
152+ energy += occNum_wfcHwfc (ir, ic);
153+ }
145154 }
146155 return energy;
147156}
148157
149158
150- // for HF, Muller and power functional, g(eta) = eta, eta^0.5, eta^alpha respectively.
151- // when symbol = 0, 1, 2, 3, 4, 5, return eta, 0.5*eta, g(eta), 0.5*g(eta), d_g(eta)/d_eta, 1.0 respectively.
152- // Default symbol=0, XC_func_rdmft="HF", alpha=0.656
159+ // ! for HF, Muller and power functional, g(eta) = eta, eta^0.5, eta^alpha respectively.
160+ // ! when symbol = 0, 1, 2, 3, 4, 5, return eta, 0.5*eta, g(eta), 0.5*g(eta), d_g(eta)/d_eta, 1.0 respectively.
161+ // ! Default symbol=0, XC_func_rdmft="HF", alpha=0.656
153162double occNum_func (const double eta, const int symbol, const std::string XC_func_rdmft, double alpha)
154163{
155164 // if( XC_func_rdmft == "hf" || XC_func_rdmft == "default" || XC_func_rdmft == "pbe0" ) alpha = 1.0;
156165 // else if( XC_func_rdmft == "muller" ) alpha = 0.5;
157166 // else if( XC_func_rdmft == "power" || XC_func_rdmft == "wp22" || XC_func_rdmft == "cwp22" ) ;
158167 // else alpha = 1.0;
168+
159169 if ( XC_func_rdmft == " power" || XC_func_rdmft == " wp22" || XC_func_rdmft == " cwp22" ) { ; }
160170 else if ( XC_func_rdmft == " muller" ) { alpha = 0.5 ; }
161171 else { alpha = 1.0 ; }
@@ -173,8 +183,6 @@ double occNum_func(const double eta, const int symbol, const std::string XC_func
173183}
174184
175185
176-
177-
178186template class Veff_rdmft <double , double >;
179187
180188template class Veff_rdmft <std::complex <double >, double >;
@@ -185,7 +193,7 @@ template class Veff_rdmft<std::complex<double>, std::complex<double>>;
185193// initialize_HR()
186194template <typename TK, typename TR>
187195void Veff_rdmft<TK, TR>::initialize_HR(const UnitCell* ucell_in,
188- Grid_Driver* GridD)
196+ Grid_Driver* GridD)
189197{
190198 ModuleBase::TITLE (" Veff" , " initialize_HR" );
191199 ModuleBase::timer::tick (" Veff" , " initialize_HR" );
@@ -304,7 +312,10 @@ void Veff_rdmft<TK, TR>::contributeHR()
304312 // this->GK->transfer_pvpR(this->hR);
305313 this ->GK ->transfer_pvpR (this ->hR ,this ->ucell ,this ->gd );
306314
307- if (this ->nspin == 2 ) { this ->current_spin = 1 - this ->current_spin ; }
315+ if (this ->nspin == 2 )
316+ {
317+ this ->current_spin = 1 - this ->current_spin ;
318+ }
308319
309320 ModuleBase::timer::tick (" Veff" , " contributeHR" );
310321 return ;
@@ -387,13 +398,14 @@ void Veff_rdmft<double, double>::contributeHR()
387398
388399 this ->new_e_iteration = false ;
389400
390- if (this ->nspin == 2 ) this ->current_spin = 1 - this ->current_spin ;
401+ if (this ->nspin == 2 )
402+ {
403+ this ->current_spin = 1 - this ->current_spin ;
404+ }
391405
392406 return ;
393407}
394408
395-
396-
397409}
398410
399411
0 commit comments