33#include " module_base/formatter.h"
44#include " module_base/global_variable.h"
55#include " module_base/tool_title.h"
6+ #include " module_elecstate/elecstate_tools.h"
67#include " module_elecstate/module_dm/cal_dm_psi.h"
78#include " module_hamilt_lcao/module_deltaspin/spin_constrain.h"
89#include " module_hamilt_lcao/module_dftu/dftu.h"
1718#include " module_io/output_mat_sparse.h"
1819#include " module_io/output_mulliken.h"
1920#include " module_io/output_sk.h"
21+ #include " module_io/read_wfc_nao.h"
2022#include " module_io/to_qo.h"
2123#include " module_io/to_wannier90_lcao.h"
2224#include " module_io/to_wannier90_lcao_in_pw.h"
2729#include " module_io/write_proj_band_lcao.h"
2830#include " module_io/write_wfc_nao.h"
2931#include " module_parameter/parameter.h"
30- #include " module_elecstate/elecstate_tools.h"
3132
3233// be careful of hpp, there may be multiple definitions of functions, 20250302, mohan
3334#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
133134 two_center_bundle_,
134135 orb_);
135136
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
137175 // DensityMatrix is allocated here, DMK is also initialized here
138176 // DMR is not initialized here, it will be constructed in each before_scf
139177 dynamic_cast <elecstate::ElecStateLCAO<TK>*>(this ->pelec )->init_DM (&this ->kv , &(this ->pv ), PARAM.inp .nspin );
140178
141- // 5 ) initialize exact exchange calculations
179+ // 7 ) initialize exact exchange calculations
142180#ifdef __EXX
143181 if (PARAM.inp .calculation == " scf"
144182 || PARAM.inp .calculation == " relax"
@@ -163,22 +201,22 @@ void ESolver_KS_LCAO<TK, TR>::before_all_runners(UnitCell& ucell, const Input_pa
163201 }
164202#endif
165203
166- // 6 ) initialize DFT+U
204+ // 8 ) initialize DFT+U
167205 if (PARAM.inp .dft_plus_u )
168206 {
169207 auto * dftu = ModuleDFTU::DFTU::get_instance ();
170208 dftu->init (ucell, &this ->pv , this ->kv .get_nks (), &orb_);
171209 }
172210
173- // 7 ) initialize local pseudopotentials
211+ // 9 ) initialize local pseudopotentials
174212 this ->locpp .init_vloc (ucell, this ->pw_rho );
175213 ModuleBase::GlobalFunc::DONE (GlobalV::ofs_running, " LOCAL POTENTIAL" );
176214
177- // 8 ) inititlize the charge density
215+ // 10 ) inititlize the charge density
178216 this ->chr .allocate (PARAM.inp .nspin );
179217 this ->pelec ->omega = ucell.omega ;
180218
181- // 9 ) initialize the potential
219+ // 11 ) initialize the potential
182220 if (this ->pelec ->pot == nullptr )
183221 {
184222 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
191229 &(this ->pelec ->f_en .vtxc ));
192230 }
193231
194-
195- // 10) initialize deepks
232+ // 12) initialize deepks
196233#ifdef __DEEPKS
197234 LCAO_domain::DeePKS_init (ucell, pv, this ->kv .get_nks (), orb_, this ->ld , GlobalV::ofs_running);
198235 if (PARAM.inp .deepks_scf )
@@ -212,7 +249,7 @@ void ESolver_KS_LCAO<TK, TR>::before_all_runners(UnitCell& ucell, const Input_pa
212249 }
213250#endif
214251
215- // 11 ) set occupations
252+ // 13 ) set occupations
216253 // tddft does not need to set occupations in the first scf
217254 if (PARAM.inp .ocp && inp.esolver_type != " tddft" )
218255 {
@@ -224,7 +261,7 @@ void ESolver_KS_LCAO<TK, TR>::before_all_runners(UnitCell& ucell, const Input_pa
224261 this ->pelec ->skip_weights );
225262 }
226263
227- // 12 ) if kpar is not divisible by nks, print a warning
264+ // 14 ) if kpar is not divisible by nks, print a warning
228265 if (PARAM.globalv .kpar_lcao > 1 )
229266 {
230267 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
245282 }
246283 }
247284
248- // 13 ) initialize rdmft, added by jghan
285+ // 15 ) initialize rdmft, added by jghan
249286 if (PARAM.inp .rdmft == true )
250287 {
251288 rdmft_solver.init (this ->GG ,
0 commit comments