FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
abacus-develop/source/source_io/cal_pdos_multik.cpp at develop · pplab/abacus-develop · GitHub
pplab
/
abacus-develop
Public
forked from
deepmodeling/abacus-develop
Notifications
You must be signed in to change notification settings
Fork
0
Star
1
Code
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
abacus-develop
/
source
/
source_io
/
cal_pdos_multik.cpp
Copy path
More file actions
More file actions
Latest commit
History
History
History
318 lines (270 loc) · 7.99 KB
Breadcrumbs
abacus-develop
/
source
/
source_io
/
cal_pdos_multik.cpp
Copy path
File metadata and controls
318 lines (270 loc) · 7.99 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
#
include
"
cal_pdos_multik.h
"
#
include
"
source_base/parallel_reduce.h
"
#
include
"
source_base/module_external/blas_connector.h
"
#
include
"
source_base/module_external/scalapack_connector.h
"
#
include
"
write_orb_info.h
"
#
include
"
source_base/global_function.h
"
#
include
"
source_base/global_variable.h
"
#
include
"
source_pw/module_pwdft/global.h
"
#
include
"
source_lcao/hamilt_lcao.h
"
void
ModuleIO::cal_pdos
(
const
psi::Psi<std::
complex
<
double
>>* psi,
hamilt::Hamilt<std::
complex
<
double
>>* p_ham,
const
Parallel_Orbitals& pv,
const
UnitCell& ucell,
const
K_Vectors& kv,
const
int
nspin0,
const
int
nbands,
const
ModuleBase::matrix& ekb,
const
double
& emax,
const
double
& emin,
const
double
& dos_edelta_ev,
const
double
& bcoeff)
{
ModuleBase::TITLE
(
"
ModuleIO
"
,
"
cal_pdos_multik
"
);
assert
(nspin0>
0
);
assert
(emax>=emin);
assert
(dos_edelta_ev>
0.0
);
const
int
npoints =
static_cast
<
int
>(
std::floor
((emax - emin) / dos_edelta_ev));
const
int
nlocal =
PARAM
.
globalv
.
nlocal
;
ModuleBase::matrix* pdosk =
new
ModuleBase::matrix[nspin0];
for
(
int
is =
0
; is < nspin0; ++is)
{
pdosk[is].
create
(nlocal, npoints,
true
);
}
ModuleBase::matrix* pdos =
new
ModuleBase::matrix[nspin0];
for
(
int
is =
0
; is < nspin0; ++is)
{
pdos[is].
create
(nlocal, npoints,
true
);
}
const
double
a = bcoeff;
const
double
b =
sqrt
(ModuleBase::
TWO_PI
) * a;
std::
complex
<
double
>* waveg =
new
std::
complex
<
double
>[nlocal];
double
* Gauss =
new
double
[npoints]();
for
(
int
is =
0
; is < nspin0; ++is)
{
std::vector<ModuleBase::ComplexMatrix> mulk;
mulk.
resize
(
1
);
mulk[
0
].
create
(pv.
ncol
, pv.
nrow
);
for
(
int
ik =
0
; ik < kv.
get_nks
(); ik++)
{
if
(is == kv.
isk
[ik])
{
//
calculate SK for current k point
const
std::
complex
<
double
>* sk =
nullptr
;
//
collumn-major matrix
const
int
hk_type =
1
;
if
(
PARAM
.
inp
.
nspin
==
4
)
{
dynamic_cast
<hamilt::HamiltLCAO<std::
complex
<
double
>, std::
complex
<
double
>>*>(p_ham)
->
updateSk
(ik, hk_type);
sk =
dynamic_cast
<
const
hamilt::HamiltLCAO<std::
complex
<
double
>, std::
complex
<
double
>>*>(p_ham)
->
getSk
();
}
else
{
dynamic_cast
<hamilt::HamiltLCAO<std::
complex
<
double
>,
double
>*>(p_ham)
->
updateSk
(ik, hk_type);
sk =
dynamic_cast
<
const
hamilt::HamiltLCAO<std::
complex
<
double
>,
double
>*>(p_ham)
->
getSk
();
}
psi->
fix_k
(ik);
psi::Psi<std::
complex
<
double
>>
Dwfc
(
1
,
psi->
get_nbands
(),
psi->
get_nbasis
(),
psi->
get_nbasis
(),
true
);
std::
complex
<
double
>* p_dwfc = Dwfc.
get_pointer
();
for
(
int
index =
0
; index < Dwfc.
size
(); ++index)
{
p_dwfc[index] =
conj
(psi->
get_pointer
()[index]);
}
for
(
int
i =
0
; i < nbands; ++i)
{
ModuleBase::GlobalFunc::ZEROS
(waveg, nlocal);
ModuleBase::GlobalFunc::ZEROS
(Gauss, npoints);
for
(
int
n =
0
; n < npoints; ++n)
{
double
en = emin + n * dos_edelta_ev;
double
en0 =
ekb
(ik, i) * ModuleBase::Ry_to_eV;
double
de = en - en0;
double
de2 =
0.5
* de * de;
Gauss[n] = kv.
wk
[ik] *
exp
(-de2 / a / a) / b;
}
const
int
nb = i +
1
;
#
ifdef
__MPI
const
double
one_float[
2
] = {
1.0
,
0.0
};
const
double
zero_float[
2
] = {
0.0
,
0.0
};
const
int
one_int =
1
;
const
char
T_char =
'
T
'
;
pzgemv_
(&T_char,
&
PARAM
.
globalv
.
nlocal
,
&
PARAM
.
globalv
.
nlocal
,
&one_float[
0
],
sk,
&one_int,
&one_int,
pv.
desc
,
p_dwfc,
&one_int,
&nb,
pv.
desc
,
&one_int,
&zero_float[
0
],
mulk[
0
].
c
,
&one_int,
&nb,
pv.
desc
,
&one_int);
#
endif
for
(
int
j =
0
; j <
PARAM
.
globalv
.
nlocal
; ++j)
{
if
(pv.
in_this_processor
(j, i))
{
const
int
ir = pv.
global2local_row
(j);
const
int
ic = pv.
global2local_col
(i);
waveg[j] = mulk[
0
](ic, ir) * psi[
0
](ic, ir);
const
double
x = waveg[j].
real
();
BlasConnector::axpy
(npoints, x, Gauss,
1
, pdosk[is].
c
+ j * pdosk[is].
nc
,
1
);
}
}
}
//
ib
}
//
if
}
//
ik
#
ifdef
__MPI
//
reduce the results into pdos[is].c
const
int
num =
PARAM
.
globalv
.
nlocal
* npoints;
MPI_Reduce
(pdosk[is].
c
, pdos[is].
c
, num,
MPI_DOUBLE
,
MPI_SUM
,
0
,
MPI_COMM_WORLD
);
#
endif
}
//
is
delete[]
pdosk;
delete[]
waveg;
delete[]
Gauss;
if
(GlobalV::
MY_RANK
==
0
)
{
print_tdos_multik
(pdos, nlocal, npoints, emin, dos_edelta_ev);
print_pdos_multik
(ucell, pdos, nlocal, npoints, emin, dos_edelta_ev);
ModuleIO::write_orb_info
(&ucell);
}
delete[]
pdos;
}
void
ModuleIO::print_tdos_multik
(
const
ModuleBase::matrix* pdos,
const
int
nlocal,
const
int
npoints,
const
double
& emin,
const
double
& dos_edelta_ev)
{
std::stringstream ps;
ps <<
PARAM
.
globalv
.
global_out_dir
<<
"
TDOS.dat
"
;
std::ofstream
ofs1
(ps.
str
().
c_str
());
if
(
PARAM
.
inp
.
nspin
==
1
||
PARAM
.
inp
.
nspin
==
4
)
{
for
(
int
n =
0
; n < npoints; ++n)
{
double
y =
0.0
;
double
en = emin + n * dos_edelta_ev;
for
(
int
i =
0
; i < nlocal; i++)
{
y += pdos[
0
](i, n);
}
ofs1 <<
std::setw
(
20
) << en <<
std::setw
(
30
) << y << std::endl;
}
}
else
if
(
PARAM
.
inp
.
nspin
==
2
)
{
for
(
int
n =
0
; n < npoints; ++n)
{
double
y =
0.0
;
double
z =
0.0
;
double
en = emin + n * dos_edelta_ev;
for
(
int
i =
0
; i < nlocal; i++)
{
y += pdos[
0
](i, n);
z += pdos[
1
](i, n);
}
ofs1 <<
std::setw
(
20
) << en <<
std::setw
(
30
) << y <<
std::setw
(
30
) << z << std::endl;
}
}
ofs1.
close
();
}
void
ModuleIO::print_pdos_multik
(
const
UnitCell& ucell,
const
ModuleBase::matrix* pdos,
const
int
nlocal,
const
int
npoints,
const
double
& emin,
const
double
& dos_edelta_ev)
{
ModuleBase::TITLE
(
"
ModuleIO
"
,
"
print_pdos_multik
"
);
std::stringstream as;
as <<
PARAM
.
globalv
.
global_out_dir
<<
"
PDOS.dat
"
;
std::ofstream
ofs2
(as.
str
().
c_str
());
ofs2 <<
"
<pdos>
"
<< std::endl;
ofs2 <<
"
<nspin>
"
<<
PARAM
.
inp
.
nspin
<<
"
</nspin>
"
<< std::endl;
if
(
PARAM
.
inp
.
nspin
==
4
)
{
ofs2 <<
"
<norbitals>
"
<<
std::setw
(
2
) << nlocal /
2
<<
"
</norbitals>
"
<< std::endl;
}
else
{
ofs2 <<
"
<norbitals>
"
<<
std::setw
(
2
) << nlocal <<
"
</norbitals>
"
<< std::endl;
}
ofs2 <<
"
<energy_values units=
\"
eV
\"
>
"
<< std::endl;
for
(
int
n =
0
; n < npoints; ++n)
{
double
y =
0.0
;
double
en = emin + n * dos_edelta_ev;
ofs2 <<
std::setw
(
20
) << en << std::endl;
}
ofs2 <<
"
</energy_values>
"
<< std::endl;
for
(
int
i =
0
; i < ucell.
nat
; i++)
{
int
a = ucell.
iat2ia
[i];
int
t = ucell.
iat2it
[i];
Atom* atom1 = &ucell.
atoms
[t];
const
int
s0 = ucell.
itiaiw2iwt
(t, a,
0
);
for
(
int
j =
0
; j < atom1->
nw
; ++j)
{
const
int
L1
= atom1->
iw2l
[j];
const
int
N1
= atom1->
iw2n
[j];
const
int
m1 = atom1->
iw2m
[j];
const
int
w = ucell.
itiaiw2iwt
(t, a, j);
ofs2 <<
"
<orbital
"
<< std::endl;
ofs2 <<
std::setw
(
6
) <<
"
index=
\"
"
<<
std::setw
(
40
) << w +
1
<<
"
\"
"
<< std::endl;
ofs2 <<
std::setw
(
5
) <<
"
atom_index=
\"
"
<<
std::setw
(
40
) << i +
1
<<
"
\"
"
<< std::endl;
ofs2 <<
std::setw
(
8
) <<
"
species=
\"
"
<< ucell.
atoms
[t].
label
<<
"
\"
"
<< std::endl;
ofs2 <<
std::setw
(
2
) <<
"
l=
\"
"
<<
std::setw
(
40
) <<
L1
<<
"
\"
"
<< std::endl;
ofs2 <<
std::setw
(
2
) <<
"
m=
\"
"
<<
std::setw
(
40
) << m1 <<
"
\"
"
<< std::endl;
ofs2 <<
std::setw
(
2
) <<
"
z=
\"
"
<<
std::setw
(
40
) <<
N1
+
1
<<
"
\"
"
<< std::endl;
ofs2 <<
"
>
"
<< std::endl;
ofs2 <<
"
<data>
"
<< std::endl;
if
(
PARAM
.
inp
.
nspin
==
1
)
{
for
(
int
n =
0
; n < npoints; ++n)
{
ofs2 <<
std::setw
(
13
) << pdos[
0
](w, n) << std::endl;
}
}
else
if
(
PARAM
.
inp
.
nspin
==
2
)
{
for
(
int
n =
0
; n < npoints; ++n)
{
ofs2 <<
std::setw
(
20
) << pdos[
0
](w, n) <<
std::setw
(
30
) << pdos[
1
](w, n) << std::endl;
}
}
else
if
(
PARAM
.
inp
.
nspin
==
4
)
{
int
w0 = w - s0;
for
(
int
n =
0
; n < npoints; ++n)
{
ofs2 <<
std::setw
(
20
) << pdos[
0
](s0 +
2
* w0, n) + pdos[
0
](s0 +
2
* w0 +
1
, n) << std::endl;
}
}
ofs2 <<
"
</data>
"
<< std::endl;
ofs2 <<
"
</orbital>
"
<< std::endl;
}
//
end j
}
//
end i
ofs2 <<
"
</pdos>
"
<< std::endl;
ofs2.
close
();
}
Back
|
FazBrowse Home
|
New Git URL