forked from abacusmodeling/abacus-develop
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstress_func_kin.cpp
More file actions
135 lines (117 loc) · 2.35 KB
/
stress_func_kin.cpp
File metadata and controls
135 lines (117 loc) · 2.35 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
#include"stress_func.h"
#include "global.h"
//calculate the kinetic stress in PW base
void Stress_Func::stress_kin(ModuleBase::matrix& sigma, const psi::Psi<complex<double>>* psi_in)
{
double **gk;
gk=new double* [3];
int npw;
double s_kin[3][3];
for(int l=0;l<3;l++)
{
for(int m=0;m<3;m++)
{
s_kin[l][m]=0.0;
}
}
int npwx=0;
for(int ik=0; ik<GlobalC::kv.nks; ik++)
{
if(npwx<GlobalC::kv.ngk[ik])npwx=GlobalC::kv.ngk[ik];
}
gk[0]= new double[npwx];
gk[1]= new double[npwx];
gk[2]= new double[npwx];
double factor=ModuleBase::TWO_PI/GlobalC::ucell.lat0;
for(int ik=0;ik<GlobalC::kv.nks;ik++)
{
npw = GlobalC::kv.ngk[ik];
for(int i=0;i<npw;i++)
{
gk[0][i] = GlobalC::wfcpw->getgpluskcar(ik,i)[0] * factor;
gk[1][i] = GlobalC::wfcpw->getgpluskcar(ik,i)[1] * factor;
gk[2][i] = GlobalC::wfcpw->getgpluskcar(ik,i)[2] * factor;
}
//kinetic contribution
for(int l=0;l<3;l++)
{
for(int m=0;m<l+1;m++)
{
for(int ibnd=0;ibnd<GlobalV::NBANDS;ibnd++)
{
const std::complex<double>* ppsi=nullptr;
if(psi_in!=nullptr)
{
ppsi = &(psi_in[0](ik, ibnd, 0));
}
else
{
ppsi = &(GlobalC::wf.evc[ik](ibnd, 0));
}
for(int i=0;i<npw;i++)
{
s_kin[l][m] +=
GlobalC::wf.wg(ik, ibnd)*gk[l][i]*gk[m][i]
*(double((conj(ppsi[i]) * ppsi[i]).real()));
}
}
}
}
//contribution from the nonlocal part
//stres_us(ik, gk, npw);
}
//add the US term from augmentation charge derivatives
// addussstres(sigmanlc);
//mp_cast
for(int l=0;l<3;l++)
{
for(int m=0;m<l;m++)
{
s_kin[m][l]=s_kin[l][m];
}
}
if(INPUT.gamma_only)
{
for(int l=0;l<3;l++)
{
for(int m=0;m<3;m++)
{
s_kin[l][m] *= 2.0*ModuleBase::e2/GlobalC::ucell.omega;
}
}
}
else
{
for(int l=0;l<3;l++)
{
for(int m=0;m<3;m++)
{
s_kin[l][m] *= ModuleBase::e2/GlobalC::ucell.omega;
}
}
}
for(int l=0;l<3;l++)
{
for(int m=0;m<3;m++)
{
Parallel_Reduce::reduce_double_all( s_kin[l][m] ); //qianrui fix a bug for kpar > 1
}
}
for(int l=0;l<3;l++)
{
for(int m=0;m<3;m++)
{
sigma(l,m) = s_kin[l][m];
}
}
//do symmetry
if(ModuleSymmetry::Symmetry::symm_flag)
{
GlobalC::symm.stress_symmetry(sigma, GlobalC::ucell);
}//end symmetry
delete[] gk[0];
delete[] gk[1];
delete[] gk[2];
delete[] gk;
return;
}