forked from deepmodeling/abacus-develop
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathatom_pseudo.cpp
More file actions
277 lines (247 loc) · 8.92 KB
/
atom_pseudo.cpp
File metadata and controls
277 lines (247 loc) · 8.92 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
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
#include "atom_pseudo.h"
#include "source_io/module_parameter/parameter.h"
#include "source_io/module_parameter/parameter.h"
Atom_pseudo::Atom_pseudo()
{
}
Atom_pseudo::~Atom_pseudo()
{
}
// mohan add 2021-05-07
void Atom_pseudo::set_d_so(ModuleBase::ComplexMatrix& d_so_in,
const int& nproj_in,
const int& nproj_in_so,
const bool has_so)
{
if (this->lmax < -1 || this->lmax > 20)
{
ModuleBase::WARNING_QUIT("Numerical_Nonlocal", "bad input of lmax : should be between -1 and 20");
}
this->nproj = nproj_in;
this->nproj_soc = nproj_in_so;
int spin_dimension = 4;
// optimize
for (int is = 0; is < spin_dimension; is++)
{
this->non_zero_count_soc[is] = 0;
this->index1_soc[is] = std::vector<int>(nproj_soc * nproj_soc, 0);
this->index2_soc[is] = std::vector<int>(nproj_soc * nproj_soc, 0);
}
if (!has_so)
{
this->d_real.create(nproj_soc + 1, nproj_soc + 1);
this->d_so.create(spin_dimension, nproj_soc + 1, nproj_soc + 1); // for noncollinear-spin only case
// calculate the number of non-zero elements in dion
for (int L1 = 0; L1 < nproj_soc; L1++)
{
for (int L2 = 0; L2 < nproj_soc; L2++)
{
this->d_real(L1, L2) = d_so_in(L1, L2).real();
if (std::fabs(d_real(L1, L2)) > 1.0e-8)
{
this->index1_soc[0][non_zero_count_soc[0]] = L1;
this->index2_soc[0][non_zero_count_soc[0]] = L2;
this->non_zero_count_soc[0]++;
}
// for noncollinear-spin only case
this->d_so(0, L1, L2) = d_so_in(L1, L2);
this->d_so(3, L1, L2) = d_so_in(L1, L2);
if (std::fabs(d_real(L1, L2)) > 1.0e-8)
{
this->index1_soc[3][non_zero_count_soc[3]] = L1;
this->index2_soc[3][non_zero_count_soc[3]] = L2;
this->non_zero_count_soc[3]++;
}
}
}
}
else // zhengdy-soc
{
this->d_so.create(spin_dimension, nproj_soc + 1, nproj_soc + 1);
// std::cout << "lmax=" << lmax << std::endl;
if (this->lmax > -1)
{
if (PARAM.inp.lspinorb)
{
int is = 0;
for (int is1 = 0; is1 < 2; is1++)
{
for (int is2 = 0; is2 < 2; is2++)
{
for (int L1 = 0; L1 < nproj_soc; L1++)
{
for (int L2 = 0; L2 < nproj_soc; L2++)
{
this->d_so(is, L1, L2) = d_so_in(L1 + nproj_soc * is1, L2 + nproj_soc * is2);
if (fabs(this->d_so(is, L1, L2).real()) > 1.0e-8
|| fabs(this->d_so(is, L1, L2).imag()) > 1.0e-8)
{
// std::cout << "tt in atom is=" << is << " L1=" <<
//L1
//<< " L2="
// << L2 << " " << d_so(is, L1, L2) << std::endl;
this->index1_soc[is][non_zero_count_soc[is]] = L1;
this->index2_soc[is][non_zero_count_soc[is]] = L2;
this->non_zero_count_soc[is]++;
}
}
}
is++;
}
}
}
else
{
int is = 0;
for (int is1 = 0; is1 < 2; is1++)
{
for (int is2 = 0; is2 < 2; is2++)
{
if (is >= PARAM.inp.nspin) {
break;
}
for (int L1 = 0; L1 < nproj_soc; L1++)
{
for (int L2 = 0; L2 < nproj_soc; L2++)
{
if (is == 1 || is == 2)
{
this->d_so(is, L1, L2) = std::complex<double>(0.0, 0.0);
}
else
{
this->d_so(is, L1, L2) = d_so_in(L1 + nproj_soc * is1, L2 + nproj_soc * is2);
}
if (std::abs(this->d_so(is, L1, L2).real()) > 1.0e-8
|| std::abs(this->d_so(is, L1, L2).imag()) > 1.0e-8)
{
this->index1_soc[is][non_zero_count_soc[is]] = L1;
this->index2_soc[is][non_zero_count_soc[is]] = L2;
this->non_zero_count_soc[is]++;
}
}
}
is++;
}
}
}
}
}
// 2016-07-19 end, LiuXh
return;
}
#include "source_base/parallel_common.h"
#ifdef __MPI
void Atom_pseudo::bcast_atom_pseudo()
{
ModuleBase::TITLE("Atom_pseudo", "bcast_atom_pseudo");
// == pseudo_h ==
// int
Parallel_Common::bcast_int(lmax);
Parallel_Common::bcast_int(mesh);
Parallel_Common::bcast_int(nchi);
Parallel_Common::bcast_int(nbeta);
Parallel_Common::bcast_int(nv);
Parallel_Common::bcast_double(zv);
// double
Parallel_Common::bcast_double(etotps);
Parallel_Common::bcast_double(ecutwfc);
Parallel_Common::bcast_double(ecutrho);
// bool
Parallel_Common::bcast_bool(tvanp);
Parallel_Common::bcast_bool(nlcc);
Parallel_Common::bcast_bool(has_so);
// std::string
Parallel_Common::bcast_string(psd);
Parallel_Common::bcast_string(pp_type);
Parallel_Common::bcast_string(xc_func);
if (GlobalV::MY_RANK != 0)
{
jjj = std::vector<double>(nbeta, 0.0);
els = std::vector<std::string>(nchi, "");
lchi = std::vector<int>(nchi, 0);
oc = std::vector<double>(nchi, 0.0);
jchi = std::vector<double>(nchi, 0.0);
nn = std::vector<int>(nchi, 0);
}
Parallel_Common::bcast_double(jjj.data(), nbeta);
Parallel_Common::bcast_string(els.data(), nchi);
Parallel_Common::bcast_int(lchi.data(), nchi);
Parallel_Common::bcast_double(oc.data(), nchi);
Parallel_Common::bcast_double(jchi.data(), nchi);
Parallel_Common::bcast_int(nn.data(), nchi);
// == end of pseudo_h
// == pseudo_atom ==
Parallel_Common::bcast_int(msh);
Parallel_Common::bcast_double(rcut);
if (GlobalV::MY_RANK != 0)
{
assert(mesh != 0);
r = std::vector<double>(mesh, 0.0);
rab = std::vector<double>(mesh, 0.0);
rho_atc = std::vector<double>(mesh, 0.0);
rho_at = std::vector<double>(mesh, 0.0);
chi.create(nchi, mesh);
}
Parallel_Common::bcast_double(r.data(), mesh);
Parallel_Common::bcast_double(rab.data(), mesh);
Parallel_Common::bcast_double(rho_atc.data(), mesh);
Parallel_Common::bcast_double(rho_at.data(), mesh);
Parallel_Common::bcast_double(chi.c, nchi * mesh);
// == end of pseudo_atom ==
// == pseudo_vl ==
if (GlobalV::MY_RANK != 0)
{
vloc_at = std::vector<double>(mesh, 0.0);
}
Parallel_Common::bcast_double(vloc_at.data(), mesh);
// == end of pseudo_vl ==
// == pseudo ==
if (nbeta == 0) {
return;
}
if (GlobalV::MY_RANK != 0)
{
lll = std::vector<int>(nbeta, 0);
}
Parallel_Common::bcast_int(lll.data(), nbeta);
Parallel_Common::bcast_int(kkbeta);
Parallel_Common::bcast_int(nh);
int nr, nc;
if (GlobalV::MY_RANK == 0)
{
nr = betar.nr;
nc = betar.nc;
}
Parallel_Common::bcast_int(nr);
Parallel_Common::bcast_int(nc);
if (GlobalV::MY_RANK != 0)
{
betar.create(nr, nc);
dion.create(nbeta, nbeta);
}
// below two 'bcast_double' lines of codes seem to have bugs,
// on some computers, the code will stuck here for ever.
// mohan note 2021-04-28
Parallel_Common::bcast_double(dion.c, nbeta * nbeta);
Parallel_Common::bcast_double(betar.c, nr * nc);
// == end of psesudo_nc ==
// uspp liuyu 2023-10-03
if (tvanp)
{
Parallel_Common::bcast_int(nqlc);
if (GlobalV::MY_RANK != 0)
{
qfuncl.create(nqlc, nbeta * (nbeta + 1) / 2, mesh);
}
const int dim = nqlc * nbeta * (nbeta + 1) / 2 * mesh;
Parallel_Common::bcast_double(qfuncl.ptr, dim);
if (GlobalV::MY_RANK != 0)
{
qqq.create(nbeta, nbeta);
}
Parallel_Common::bcast_double(qqq.c, nbeta * nbeta);
}
return;
}
#endif