FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
abacus-develop/source/source_esolver/lcao_before_scf.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_esolver
/
lcao_before_scf.cpp
Copy path
More file actions
More file actions
Latest commit
History
History
History
286 lines (257 loc) · 10.1 KB
Breadcrumbs
abacus-develop
/
source
/
source_esolver
/
lcao_before_scf.cpp
Copy path
File metadata and controls
286 lines (257 loc) · 10.1 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
#
include
"
source_estate/module_charge/symmetry_rho.h
"
#
include
"
source_esolver/esolver_ks_lcao.h
"
#
include
"
source_lcao/hamilt_lcao.h
"
#
include
"
source_lcao/module_dftu/dftu.h
"
#
include
"
source_pw/module_pwdft/global.h
"
//
#
include
"
source_base/timer.h
"
#
include
"
source_cell/module_neighbor/sltk_atom_arrange.h
"
#
include
"
source_cell/module_neighbor/sltk_grid_driver.h
"
#
include
"
source_io/berryphase.h
"
#
include
"
source_io/get_pchg_lcao.h
"
#
include
"
source_io/get_wf_lcao.h
"
#
include
"
source_io/io_npz.h
"
#
include
"
source_io/to_wannier90_lcao.h
"
#
include
"
source_io/to_wannier90_lcao_in_pw.h
"
#
include
"
source_io/write_HS_R.h
"
#
include
"
source_io/module_parameter/parameter.h
"
#
include
"
source_estate/elecstate_tools.h
"
#
ifdef
__MLALGO
#
include
"
source_lcao/module_deepks/LCAO_deepks.h
"
#
endif
#
include
"
source_base/formatter.h
"
#
include
"
source_estate/elecstate_lcao.h
"
#
include
"
source_estate/module_dm/cal_dm_psi.h
"
#
include
"
source_lcao/LCAO_domain.h
"
#
include
"
source_lcao/module_operator_lcao/op_exx_lcao.h
"
#
include
"
source_lcao/module_operator_lcao/operator_lcao.h
"
#
include
"
source_lcao/module_deltaspin/spin_constrain.h
"
#
include
"
source_io/cube_io.h
"
#
include
"
source_io/write_elecstat_pot.h
"
#
ifdef
__EXX
#
include
"
source_io/restart_exx_csr.h
"
#
endif
namespace
ModuleESolver
{
template
<
typename
TK
,
typename
TR
>
void
ESolver_KS_LCAO<
TK
,
TR
>::before_scf(UnitCell& ucell,
const
int
istep)
{
ModuleBase::TITLE
(
"
ESolver_KS_LCAO
"
,
"
before_scf
"
);
ModuleBase::timer::tick
(
"
ESolver_KS_LCAO
"
,
"
before_scf
"
);
//
! 1) call before_scf() of ESolver_KS.
ESolver_KS<
TK
>::
before_scf
(ucell, istep);
//
! 2) find search radius
double
search_radius =
atom_arrange::set_sr_NL
(GlobalV::ofs_running,
PARAM
.
inp
.
out_level
,
orb_.
get_rcutmax_Phi
(),
ucell.
infoNL
.
get_rcutmax_Beta
(),
PARAM
.
globalv
.
gamma_only_local
);
//
! 3) use search_radius to search adj atoms
atom_arrange::search
(
PARAM
.
globalv
.
search_pbc
,
GlobalV::ofs_running,
this
->
gd
,
ucell,
search_radius,
PARAM
.
inp
.
test_atom_input
);
//
! 4) initialize NAO basis set
#
ifdef
__OLD_GINT
double
dr_uniform =
0.001
;
std::vector<
double
> rcuts;
std::vector<std::vector<
double
>> psi_u;
std::vector<std::vector<
double
>> dpsi_u;
std::vector<std::vector<
double
>> d2psi_u;
Gint_Tools::init_orb
(dr_uniform, rcuts, ucell, orb_, psi_u, dpsi_u, d2psi_u);
//
! 5) set periodic boundary conditions
this
->
GridT
.
set_pbc_grid
(
this
->
pw_rho
->
nx
,
this
->
pw_rho
->
ny
,
this
->
pw_rho
->
nz
,
this
->
pw_big
->
bx
,
this
->
pw_big
->
by
,
this
->
pw_big
->
bz
,
this
->
pw_big
->
nbx
,
this
->
pw_big
->
nby
,
this
->
pw_big
->
nbz
,
this
->
pw_big
->
nbxx
,
this
->
pw_big
->
nbzp_start
,
this
->
pw_big
->
nbzp
,
this
->
pw_rho
->
ny
,
this
->
pw_rho
->
nplane
,
this
->
pw_rho
->
startz_current
,
ucell,
this
->
gd
,
dr_uniform,
rcuts,
psi_u,
dpsi_u,
d2psi_u,
PARAM
.
inp
.
nstream
);
psi_u.
clear
();
psi_u.
shrink_to_fit
();
dpsi_u.
clear
();
dpsi_u.
shrink_to_fit
();
d2psi_u.
clear
();
d2psi_u.
shrink_to_fit
();
LCAO_domain::grid_prepare
(
this
->
GridT
,
this
->
GG
,
this
->
GK
, ucell, orb_, *
this
->
pw_rho
, *
this
->
pw_big
);
//
! 6) prepare grid integral
#
else
gint_info_.
reset
(
new
ModuleGint::GintInfo
(
this
->
pw_big
->
nbx
,
this
->
pw_big
->
nby
,
this
->
pw_big
->
nbz
,
this
->
pw_rho
->
nx
,
this
->
pw_rho
->
ny
,
this
->
pw_rho
->
nz
,
0
,
0
,
this
->
pw_big
->
nbzp_start
,
this
->
pw_big
->
nbx
,
this
->
pw_big
->
nby
,
this
->
pw_big
->
nbzp
,
orb_.
Phi
,
ucell,
this
->
gd
));
ModuleGint::Gint::set_gint_info
(gint_info_.
get
());
#
endif
//
7) For each atom, calculate the adjacent atoms in different cells
//
and allocate the space for H(R) and S(R).
//
If k point is used here, allocate HlocR after atom_arrange.
this
->
RA
.
for_2d
(ucell,
this
->
gd
,
this
->
pv
,
PARAM
.
globalv
.
gamma_only_local
, orb_.
cutoffs
());
//
8) initialize the Hamiltonian operators
//
if atom moves, then delete old pointer and add a new one
if
(
this
->
p_hamilt
!=
nullptr
)
{
delete
this
->
p_hamilt
;
this
->
p_hamilt
=
nullptr
;
}
if
(
this
->
p_hamilt
==
nullptr
)
{
elecstate::DensityMatrix<
TK
,
double
>*
DM
=
dynamic_cast
<elecstate::ElecStateLCAO<
TK
>*>(
this
->
pelec
)->
get_DM
();
this
->
p_hamilt
=
new
hamilt::HamiltLCAO<
TK
,
TR
>(
PARAM
.
globalv
.
gamma_only_local
? &(
this
->
GG
) :
nullptr
,
PARAM
.
globalv
.
gamma_only_local
?
nullptr
: &(
this
->
GK
),
ucell,
this
->
gd
,
&
this
->
pv
,
this
->
pelec
->
pot
,
this
->
kv
,
two_center_bundle_,
orb_,
DM
#
ifdef
__MLALGO
,
&
this
->
ld
#
endif
#
ifdef
__EXX
,
istep,
GlobalC::exx_info.
info_ri
.
real_number
? &
this
->
exd
->
two_level_step
: &
this
->
exc
->
two_level_step
,
GlobalC::exx_info.
info_ri
.
real_number
? &
this
->
exd
->
get_Hexxs
() :
nullptr
,
GlobalC::exx_info.
info_ri
.
real_number
?
nullptr
: &
this
->
exc
->
get_Hexxs
()
#
endif
);
}
#
ifdef
__MLALGO
//
9) for each ionic step, the overlap <phi|alpha> must be rebuilt
//
since it depends on ionic positions
if
(
PARAM
.
globalv
.
deepks_setorb
)
{
const
Parallel_Orbitals* pv = &
this
->
pv
;
//
allocate <phi(0)|alpha(R)>, phialpha is different every ion step, so it is allocated here
DeePKS_domain::allocate_phialpha
(
PARAM
.
inp
.
cal_force
, ucell, orb_,
this
->
gd
, pv,
this
->
ld
.
phialpha
);
//
build and save <phi(0)|alpha(R)> at beginning
DeePKS_domain::build_phialpha
(
PARAM
.
inp
.
cal_force
,
ucell,
orb_,
this
->
gd
,
pv,
*(two_center_bundle_.
overlap_orb_alpha
),
this
->
ld
.
phialpha
);
if
(
PARAM
.
inp
.
deepks_out_unittest
)
{
DeePKS_domain::check_phialpha
(
PARAM
.
inp
.
cal_force
,
ucell,
orb_,
this
->
gd
,
pv,
this
->
ld
.
phialpha
,
GlobalV::
MY_RANK
);
}
}
#
endif
//
10) prepare sc calculation
if
(
PARAM
.
inp
.
sc_mag_switch
)
{
spinconstrain::SpinConstrain<
TK
>& sc = spinconstrain::SpinConstrain<
TK
>::
getScInstance
();
sc.
init_sc
(
PARAM
.
inp
.
sc_thr
,
PARAM
.
inp
.
nsc
,
PARAM
.
inp
.
nsc_min
,
PARAM
.
inp
.
alpha_trial
,
PARAM
.
inp
.
sccut
,
PARAM
.
inp
.
sc_drop_thr
,
ucell,
&(
this
->
pv
),
PARAM
.
inp
.
nspin
,
this
->
kv
,
this
->
p_hamilt
,
this
->
psi
,
this
->
pelec
);
}
//
11) set xc type before the first cal of xc in pelec->init_scf
//
Peize Lin add 2016-12-03
#
ifdef
__EXX
if
(
PARAM
.
inp
.
calculation
!=
"
nscf
"
)
{
if
(GlobalC::exx_info.
info_ri
.
real_number
)
{
this
->
exd
->
exx_beforescf
(istep,
this
->
kv
, *
this
->
p_chgmix
, ucell, orb_);
}
else
{
this
->
exc
->
exx_beforescf
(istep,
this
->
kv
, *
this
->
p_chgmix
, ucell, orb_);
}
}
#
endif
//
12) init_scf, should be before_scf? mohan add 2025-03-10
this
->
pelec
->
init_scf
(istep, ucell,
this
->
Pgrid
,
this
->
sf
.
strucFac
,
this
->
locpp
.
numeric
, ucell.
symm
);
//
13) initalize DMR
//
DMR should be same size with Hamiltonian(R)
dynamic_cast
<elecstate::ElecStateLCAO<
TK
>*>(
this
->
pelec
)
->
get_DM
()
->
init_DMR
(*(
dynamic_cast
<hamilt::HamiltLCAO<
TK
,
TR
>*>(
this
->
p_hamilt
)->
getHR
()));
#
ifdef
__MLALGO
//
initialize DMR of DeePKS
this
->
ld
.
init_DMR
(ucell, orb_,
this
->
pv
,
this
->
gd
);
#
endif
//
14) two cases are considered:
//
1. DMK in DensityMatrix is not empty (istep > 0), then DMR is initialized by DMK
//
2. DMK in DensityMatrix is empty (istep == 0), then DMR is initialized by zeros
if
(istep >
0
)
{
dynamic_cast
<elecstate::ElecStateLCAO<
TK
>*>(
this
->
pelec
)->
get_DM
()->
cal_DMR
();
}
//
15) the electron charge density should be symmetrized,
//
here is the initialization
Symmetry_rho srho;
for
(
int
is =
0
; is <
PARAM
.
inp
.
nspin
; is++)
{
srho.
begin
(is,
this
->
chr
,
this
->
pw_rho
, ucell.
symm
);
}
//
16) why we need to set this sentence? mohan add 2025-03-10
this
->
p_hamilt
->
non_first_scf
= istep;
//
17) update of RDMFT, added by jghan
if
(
PARAM
.
inp
.
rdmft
==
true
)
{
//
necessary operation of these parameters have be done with p_esolver->Init() in source/source_main/driver_run.cpp
rdmft_solver.
update_ion
(ucell,
*(
this
->
pw_rho
),
this
->
locpp
.
vloc
,
this
->
sf
.
strucFac
);
}
ModuleBase::timer::tick
(
"
ESolver_KS_LCAO
"
,
"
before_scf
"
);
return
;
}
template
class
ESolver_KS_LCAO
<
double
,
double
>;
template
class
ESolver_KS_LCAO
<std::
complex
<
double
>,
double
>;
template
class
ESolver_KS_LCAO
<std::
complex
<
double
>, std::
complex
<
double
>>;
}
//
namespace ModuleESolver
Back
|
FazBrowse Home
|
New Git URL