2
2
// Author: Jingang Han
3
3
// DATE : 2024-03-11
4
4
// ==========================================================
5
-
6
5
#include " module_rdmft/rdmft_tools.h"
7
6
#include " module_hamilt_pw/hamilt_pwdft/global.h"
8
7
// used by class Veff_rdmft
21
20
#include < sstream>
22
21
#include < cassert>
23
22
24
-
25
23
namespace rdmft
26
24
{
27
25
28
-
29
26
template <>
30
27
void conj_psi<double >(psi::Psi<double >& wfc) {}
31
28
32
-
33
29
template <>
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)
35
34
{
36
35
const int one_int = 1 ;
37
36
const double one_double = 1.0 ;
@@ -52,8 +51,11 @@ void HkPsi<double>(const Parallel_Orbitals* ParaV, const double& HK, const doubl
52
51
53
52
54
53
template <>
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)
57
59
{
58
60
const int one_int = 1 ;
59
61
const double one_double = 1.0 ;
@@ -85,8 +87,10 @@ void occNum_Mul_wfcHwfc(const ModuleBase::matrix& occ_number,
85
87
{
86
88
for (int ir=0 ; ir<occ_number.nr ; ++ ir)
87
89
{
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
+ }
90
94
}
91
95
}
92
96
@@ -111,13 +115,16 @@ void add_occNum(const K_Vectors& kv,
111
115
// consider W_k for dE/d_occNum
112
116
for (int ik=0 ; ik<occ_number.nr ; ++ik)
113
117
{
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
+ }
116
122
}
117
123
}
118
124
119
125
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
121
128
void add_wfcHwfc (const ModuleBase::matrix& wg,
122
129
const ModuleBase::matrix& wk_fun_occNum,
123
130
const ModuleBase::matrix& wfcHwfc_TV_in,
@@ -134,28 +141,31 @@ void add_wfcHwfc(const ModuleBase::matrix& wg,
134
141
}
135
142
136
143
137
- // give certain occNum_wfcHwfc, get the corresponding energy
144
+ // ! give certain occNum_wfcHwfc, get the corresponding energy
138
145
double getEnergy (const ModuleBase::matrix& occNum_wfcHwfc)
139
146
{
140
147
double energy = 0.0 ;
141
148
for (int ir=0 ; ir<occNum_wfcHwfc.nr ; ++ ir)
142
149
{
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
+ }
145
154
}
146
155
return energy;
147
156
}
148
157
149
158
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
153
162
double occNum_func (const double eta, const int symbol, const std::string XC_func_rdmft, double alpha)
154
163
{
155
164
// if( XC_func_rdmft == "hf" || XC_func_rdmft == "default" || XC_func_rdmft == "pbe0" ) alpha = 1.0;
156
165
// else if( XC_func_rdmft == "muller" ) alpha = 0.5;
157
166
// else if( XC_func_rdmft == "power" || XC_func_rdmft == "wp22" || XC_func_rdmft == "cwp22" ) ;
158
167
// else alpha = 1.0;
168
+
159
169
if ( XC_func_rdmft == " power" || XC_func_rdmft == " wp22" || XC_func_rdmft == " cwp22" ) { ; }
160
170
else if ( XC_func_rdmft == " muller" ) { alpha = 0.5 ; }
161
171
else { alpha = 1.0 ; }
@@ -173,8 +183,6 @@ double occNum_func(const double eta, const int symbol, const std::string XC_func
173
183
}
174
184
175
185
176
-
177
-
178
186
template class Veff_rdmft <double , double >;
179
187
180
188
template class Veff_rdmft <std::complex<double >, double >;
@@ -185,7 +193,7 @@ template class Veff_rdmft<std::complex<double>, std::complex<double>>;
185
193
// initialize_HR()
186
194
template <typename TK, typename TR>
187
195
void Veff_rdmft<TK, TR>::initialize_HR(const UnitCell* ucell_in,
188
- Grid_Driver* GridD)
196
+ Grid_Driver* GridD)
189
197
{
190
198
ModuleBase::TITLE (" Veff" , " initialize_HR" );
191
199
ModuleBase::timer::tick (" Veff" , " initialize_HR" );
@@ -304,7 +312,10 @@ void Veff_rdmft<TK, TR>::contributeHR()
304
312
// this->GK->transfer_pvpR(this->hR);
305
313
this ->GK ->transfer_pvpR (this ->hR ,this ->ucell ,this ->gd );
306
314
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
+ }
308
319
309
320
ModuleBase::timer::tick (" Veff" , " contributeHR" );
310
321
return ;
@@ -387,13 +398,14 @@ void Veff_rdmft<double, double>::contributeHR()
387
398
388
399
this ->new_e_iteration = false ;
389
400
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
+ }
391
405
392
406
return ;
393
407
}
394
408
395
-
396
-
397
409
}
398
410
399
411
0 commit comments