3
3
#include " module_base/formatter.h"
4
4
#include " module_base/global_variable.h"
5
5
#include " module_base/tool_title.h"
6
+ #include " module_elecstate/elecstate_tools.h"
6
7
#include " module_elecstate/module_dm/cal_dm_psi.h"
7
8
#include " module_hamilt_lcao/module_deltaspin/spin_constrain.h"
8
9
#include " module_hamilt_lcao/module_dftu/dftu.h"
17
18
#include " module_io/output_mat_sparse.h"
18
19
#include " module_io/output_mulliken.h"
19
20
#include " module_io/output_sk.h"
21
+ #include " module_io/read_wfc_nao.h"
20
22
#include " module_io/to_qo.h"
21
23
#include " module_io/to_wannier90_lcao.h"
22
24
#include " module_io/to_wannier90_lcao_in_pw.h"
27
29
#include " module_io/write_proj_band_lcao.h"
28
30
#include " module_io/write_wfc_nao.h"
29
31
#include " module_parameter/parameter.h"
30
- #include " module_elecstate/elecstate_tools.h"
31
32
32
33
// be careful of hpp, there may be multiple definitions of functions, 20250302, mohan
33
34
#include " module_io/write_eband_terms.hpp"
@@ -133,12 +134,49 @@ void ESolver_KS_LCAO<TK, TR>::before_all_runners(UnitCell& ucell, const Input_pa
133
134
two_center_bundle_,
134
135
orb_);
135
136
136
- // 4) initialize the density matrix
137
+ // 4) initialize electronic wave function psi
138
+ if (this ->psi == nullptr )
139
+ {
140
+ int nsk = 0 ;
141
+ int ncol = 0 ;
142
+ if (PARAM.globalv .gamma_only_local )
143
+ {
144
+ nsk = PARAM.inp .nspin ;
145
+ ncol = this ->pv .ncol_bands ;
146
+ if (PARAM.inp .ks_solver == " genelpa" || PARAM.inp .ks_solver == " elpa" || PARAM.inp .ks_solver == " lapack"
147
+ || PARAM.inp .ks_solver == " pexsi" || PARAM.inp .ks_solver == " cusolver"
148
+ || PARAM.inp .ks_solver == " cusolvermp" )
149
+ {
150
+ ncol = this ->pv .ncol ;
151
+ }
152
+ }
153
+ else
154
+ {
155
+ nsk = this ->kv .get_nks ();
156
+ #ifdef __MPI
157
+ ncol = this ->pv .ncol_bands ;
158
+ #else
159
+ ncol = PARAM.inp .nbands ;
160
+ #endif
161
+ }
162
+ this ->psi = new psi::Psi<TK>(nsk, ncol, this ->pv .nrow , this ->kv .ngk , true );
163
+ }
164
+
165
+ // 5) read psi from file
166
+ if (PARAM.inp .init_wfc == " file" )
167
+ {
168
+ if (!ModuleIO::read_wfc_nao (PARAM.globalv .global_readin_dir , this ->pv , *(this ->psi ), this ->pelec ))
169
+ {
170
+ ModuleBase::WARNING_QUIT (" ESolver_KS_LCAO" , " read electronic wave functions failed" );
171
+ }
172
+ }
173
+
174
+ // 6) initialize the density matrix
137
175
// DensityMatrix is allocated here, DMK is also initialized here
138
176
// DMR is not initialized here, it will be constructed in each before_scf
139
177
dynamic_cast <elecstate::ElecStateLCAO<TK>*>(this ->pelec )->init_DM (&this ->kv , &(this ->pv ), PARAM.inp .nspin );
140
178
141
- // 5 ) initialize exact exchange calculations
179
+ // 7 ) initialize exact exchange calculations
142
180
#ifdef __EXX
143
181
if (PARAM.inp .calculation == " scf"
144
182
|| PARAM.inp .calculation == " relax"
@@ -163,22 +201,22 @@ void ESolver_KS_LCAO<TK, TR>::before_all_runners(UnitCell& ucell, const Input_pa
163
201
}
164
202
#endif
165
203
166
- // 6 ) initialize DFT+U
204
+ // 8 ) initialize DFT+U
167
205
if (PARAM.inp .dft_plus_u )
168
206
{
169
207
auto * dftu = ModuleDFTU::DFTU::get_instance ();
170
208
dftu->init (ucell, &this ->pv , this ->kv .get_nks (), &orb_);
171
209
}
172
210
173
- // 7 ) initialize local pseudopotentials
211
+ // 9 ) initialize local pseudopotentials
174
212
this ->locpp .init_vloc (ucell, this ->pw_rho );
175
213
ModuleBase::GlobalFunc::DONE (GlobalV::ofs_running, " LOCAL POTENTIAL" );
176
214
177
- // 8 ) inititlize the charge density
215
+ // 10 ) inititlize the charge density
178
216
this ->chr .allocate (PARAM.inp .nspin );
179
217
this ->pelec ->omega = ucell.omega ;
180
218
181
- // 9 ) initialize the potential
219
+ // 11 ) initialize the potential
182
220
if (this ->pelec ->pot == nullptr )
183
221
{
184
222
this ->pelec ->pot = new elecstate::Potential (this ->pw_rhod ,
@@ -191,8 +229,7 @@ void ESolver_KS_LCAO<TK, TR>::before_all_runners(UnitCell& ucell, const Input_pa
191
229
&(this ->pelec ->f_en .vtxc ));
192
230
}
193
231
194
-
195
- // 10) initialize deepks
232
+ // 12) initialize deepks
196
233
#ifdef __DEEPKS
197
234
LCAO_domain::DeePKS_init (ucell, pv, this ->kv .get_nks (), orb_, this ->ld , GlobalV::ofs_running);
198
235
if (PARAM.inp .deepks_scf )
@@ -212,7 +249,7 @@ void ESolver_KS_LCAO<TK, TR>::before_all_runners(UnitCell& ucell, const Input_pa
212
249
}
213
250
#endif
214
251
215
- // 11 ) set occupations
252
+ // 13 ) set occupations
216
253
// tddft does not need to set occupations in the first scf
217
254
if (PARAM.inp .ocp && inp.esolver_type != " tddft" )
218
255
{
@@ -224,7 +261,7 @@ void ESolver_KS_LCAO<TK, TR>::before_all_runners(UnitCell& ucell, const Input_pa
224
261
this ->pelec ->skip_weights );
225
262
}
226
263
227
- // 12 ) if kpar is not divisible by nks, print a warning
264
+ // 14 ) if kpar is not divisible by nks, print a warning
228
265
if (PARAM.globalv .kpar_lcao > 1 )
229
266
{
230
267
if (this ->kv .get_nks () % PARAM.globalv .kpar_lcao != 0 )
@@ -245,7 +282,7 @@ void ESolver_KS_LCAO<TK, TR>::before_all_runners(UnitCell& ucell, const Input_pa
245
282
}
246
283
}
247
284
248
- // 13 ) initialize rdmft, added by jghan
285
+ // 15 ) initialize rdmft, added by jghan
249
286
if (PARAM.inp .rdmft == true )
250
287
{
251
288
rdmft_solver.init (this ->GG ,
0 commit comments