Skip to content

Commit 39d4672

Browse files
committed
fix contribute
1 parent 5678c0f commit 39d4672

File tree

4 files changed

+25
-25
lines changed

4 files changed

+25
-25
lines changed

src/elecond_contribute.cpp

+11-15
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,11 @@ void Elecond_contribute::cal_contribute()
125125
}
126126
cout<<"nband: "<<nband<<endl;
127127
double factor2=factor*pow(WF.factor,2)/INPUT.vol;
128+
// More electrons, smaller vmatrix
129+
// Since vmatrix means the transition probability,
130+
// more electrons, more choices, smaller probability for one choice.
131+
// Here we mutiple vmatrix by nele to normalize it.
132+
double vfact = pow(WF.factor,2)*INPUT.nele;
128133
//loop of band
129134
#ifdef _OPENMP
130135
#pragma omp parallel for reduction(+:tot_sum, sigma_all[:NMAX], L12_all[:NMAX], L22_all[:NMAX], v11_all[:NMAX], v12_all[:NMAX], v22_all[:NMAX], vweight[:NMAX]) schedule(dynamic)
@@ -150,17 +155,8 @@ void Elecond_contribute::cal_contribute()
150155
double v11fact, v12fact, v22fact;
151156
double Eij_F=(energyj+energyi)/2-INPUT.fermiE;
152157

153-
if(INPUT.smearinvw)
154-
{
155-
L11fact=factor2/w*docc*corr2;
156-
v11fact=factor2/w*WF.wk*corr2;
157-
158-
}
159-
else
160-
{
161-
L11fact=factor2*docc*corr2;
162-
v11fact=factor2*WF.wk*corr2;
163-
}
158+
L11fact=factor2*docc*corr2;
159+
v11fact=vfact*corr2;
164160

165161
L12fact=Eij_F*L11fact;
166162
L22fact=pow(Eij_F,2)*L11fact;
@@ -201,8 +197,8 @@ void Elecond_contribute::cal_contribute()
201197
double Lpre, vpre;
202198
if(INPUT.smearinvw)
203199
{
204-
Lpre = invsmearpre;
205-
vpre = smearpre*WF.wk;
200+
Lpre = invsmearpre/w;
201+
vpre = smearpre/w*WF.wk;
206202
}
207203
else
208204
{
@@ -260,8 +256,8 @@ void Elecond_contribute::cal_contribute()
260256
{
261257
ofstream ofs1("contribute.txt");
262258
ofstream ofs2("vmatrix.txt");
263-
ofs1<<setw(10)<<"#E-mu (eV)"<<setw(20)<<"L11"<<setw(20)<<"L12"<<setw(20)<<"L22"<<endl;
264-
ofs2<<setw(10)<<"#E-mu (eV)"<<setw(20)<<"v11"<<setw(20)<<"v12"<<setw(20)<<"v22"<<setw(20)<<"weight"<<endl;
259+
ofs1<<setw(10)<<"#E-mu (eV)"<<setw(20)<<"L11"<<setw(20)<<"L12/e"<<setw(20)<<"L22/e^2"<<endl;
260+
ofs2<<setw(10)<<"#E-mu (eV)"<<setw(20)<<"v11"<<setw(20)<<"v12/e"<<setw(20)<<"v22/e^2"<<setw(20)<<"weight"<<endl;
265261
double sum_sigma=0, sum_L12=0, sum_L22=0;
266262
for(int ie = 0 ; ie < NMAX; ++ie)
267263
{

src/wavefunc.h

+4
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,10 @@ class Wavefunc
2222
void print(int );
2323
void checknorm(int,int);
2424
public:
25+
//For ABACUS, QE:
26+
// <Wavegg|Wavegg> = 1
27+
//For PWmat:
28+
// <Wavegg|Wavegg>*volume = 1
2529
complex <double> * Wavegg = nullptr; //in bohr^-3/2 or 1
2630
double factor;// in unit 1 or bohr^3
2731
//Wavegg^2*factor in unit 1

test/101_ele-contribute/contribute.ref

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#E-mu (eV) L11 L12 L22
1+
#E-mu (eV) L11 L12/e L22/e^2
22
-19.99 0 0 0
33
-19.97 0 0 0
44
-19.95 0 0 0

test/101_ele-contribute/vmatrix.ref

+9-9
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#E-mu (eV) v11 v12 v22 weight
1+
#E-mu (eV) v11 v12/e v22/e^2 weight
22
-19.99 0 0 0 0
33
-19.97 0 0 0 0
44
-19.95 0 0 0 0
@@ -839,7 +839,7 @@
839839
-3.25 0 0 0 0
840840
-3.23 0 0 0 0
841841
-3.21 0 0 0 0
842-
-3.19 2.62433e+08 5.19119e+08 1.02687e+09 0.238162
842+
-3.19 36.7901 72.7745 143.955 0.238162
843843
-3.17 0 0 0 0
844844
-3.15 0 0 0 0
845845
-3.13 0 0 0 0
@@ -961,7 +961,7 @@
961961
-0.81 0 0 0 0
962962
-0.79 0 0 0 0
963963
-0.77 0 0 0 0
964-
-0.75 2.62433e+08 5.19119e+08 1.02687e+09 0.238162
964+
-0.75 36.7901 72.7745 143.955 0.238162
965965
-0.73 0 0 0 0
966966
-0.71 0 0 0 0
967967
-0.69 0 0 0 0
@@ -1582,7 +1582,7 @@
15821582
11.61 0 0 0 0
15831583
11.63 0 0 0 0
15841584
11.65 0 0 0 0
1585-
11.67 2.65228e+08 -3.19103e+09 3.83989e+10 3.46642
1585+
11.67 37.1819 -447.345 5383.09 3.46642
15861586
11.69 0 0 0 0
15871587
11.71 0 0 0 0
15881588
11.73 0 0 0 0
@@ -1617,7 +1617,7 @@
16171617
12.31 0 0 0 0
16181618
12.33 0 0 0 0
16191619
12.35 0 0 0 0
1620-
12.37 3.03369e+08 -3.64742e+09 4.38532e+10 3.02267
1620+
12.37 42.5288 -511.327 6147.72 3.02267
16211621
12.39 0 0 0 0
16221622
12.41 0 0 0 0
16231623
12.43 0 0 0 0
@@ -1719,7 +1719,7 @@
17191719
14.35 0 0 0 0
17201720
14.37 0 0 0 0
17211721
14.39 0 0 0 0
1722-
14.41 4.46692e+08 -6.55527e+09 9.63263e+10 1.14318
1722+
14.41 62.6211 -918.973 13503.8 1.14318
17231723
14.43 0 0 0 0
17241724
14.45 0 0 0 0
17251725
14.47 0 0 0 0
@@ -1731,7 +1731,7 @@
17311731
14.59 0 0 0 0
17321732
14.61 0 0 0 0
17331733
14.63 0 0 0 0
1734-
14.65 4.53065e+08 -6.58441e+09 9.56927e+10 1.05073
1734+
14.65 63.5145 -923.059 13415 1.05073
17351735
14.67 0 0 0 0
17361736
14.69 0 0 0 0
17371737
14.71 0 0 0 0
@@ -1931,13 +1931,13 @@
19311931
18.59 0 0 0 0
19321932
18.61 0 0 0 0
19331933
18.63 0 0 0 0
1934-
18.65 1.13808e+08 -1.72487e+09 2.61421e+10 0.0211494
1934+
18.65 15.9546 -241.807 3664.83 0.0211494
19351935
18.67 0 0 0 0
19361936
18.69 0 0 0 0
19371937
18.71 0 0 0 0
19381938
18.73 0 0 0 0
19391939
18.75 0 0 0 0
1940-
18.77 3.01802e+08 -5.9425e+09 1.17313e+11 1.39403
1940+
18.77 42.3091 -833.07 16446 1.39403
19411941
18.79 0 0 0 0
19421942
18.81 0 0 0 0
19431943
18.83 0 0 0 0

0 commit comments

Comments
 (0)