@@ -39,13 +39,94 @@ namespace ModuleESolver
3939{
4040
4141template <typename TK, typename TR>
42- void ESolver_KS_LCAO<TK, TR>::beforesolver (const int istep)
42+ void ESolver_KS_LCAO<TK, TR>::before_scf (const int istep)
4343{
44- ModuleBase::TITLE (" ESolver_KS_LCAO" , " beforesolver" );
45- ModuleBase::timer::tick (" ESolver_KS_LCAO" , " beforesolver" );
44+ ModuleBase::TITLE (" ESolver_KS_LCAO" , " before_scf" );
45+
46+ // ! 1) call before_scf() of ESolver_FP
47+ ESolver_FP::before_scf (istep);
48+
49+ if (GlobalC::ucell.ionic_position_updated )
50+ {
51+ this ->CE .update_all_dis (GlobalC::ucell);
52+ this ->CE .extrapolate_charge (
53+ #ifdef __MPI
54+ &(GlobalC::Pgrid),
55+ #endif
56+ GlobalC::ucell,
57+ this ->pelec ->charge ,
58+ &(this ->sf ),
59+ GlobalV::ofs_running,
60+ GlobalV::ofs_warning);
61+ }
62+
63+ // ----------------------------------------------------------
64+ // about vdw, jiyy add vdwd3 and linpz add vdwd2
65+ // ----------------------------------------------------------
66+ auto vdw_solver = vdw::make_vdw (GlobalC::ucell, PARAM.inp , &(GlobalV::ofs_running));
67+ if (vdw_solver != nullptr )
68+ {
69+ this ->pelec ->f_en .evdw = vdw_solver->get_energy ();
70+ }
4671
4772 // 1. prepare HS matrices, prepare grid integral
48- this ->set_matrix_grid (this ->RA );
73+ // (1) Find adjacent atoms for each atom.
74+ double search_radius = atom_arrange::set_sr_NL (GlobalV::ofs_running,
75+ PARAM.inp .out_level ,
76+ orb_.get_rcutmax_Phi (),
77+ GlobalC::ucell.infoNL .get_rcutmax_Beta (),
78+ PARAM.globalv .gamma_only_local );
79+
80+ atom_arrange::search (PARAM.inp .search_pbc ,
81+ GlobalV::ofs_running,
82+ GlobalC::GridD,
83+ GlobalC::ucell,
84+ search_radius,
85+ PARAM.inp .test_atom_input );
86+
87+ // (3) Periodic condition search for each grid.
88+ double dr_uniform = 0.001 ;
89+ std::vector<double > rcuts;
90+ std::vector<std::vector<double >> psi_u;
91+ std::vector<std::vector<double >> dpsi_u;
92+ std::vector<std::vector<double >> d2psi_u;
93+
94+ Gint_Tools::init_orb (dr_uniform, rcuts, GlobalC::ucell, orb_, psi_u, dpsi_u, d2psi_u);
95+
96+ this ->GridT .set_pbc_grid (this ->pw_rho ->nx ,
97+ this ->pw_rho ->ny ,
98+ this ->pw_rho ->nz ,
99+ this ->pw_big ->bx ,
100+ this ->pw_big ->by ,
101+ this ->pw_big ->bz ,
102+ this ->pw_big ->nbx ,
103+ this ->pw_big ->nby ,
104+ this ->pw_big ->nbz ,
105+ this ->pw_big ->nbxx ,
106+ this ->pw_big ->nbzp_start ,
107+ this ->pw_big ->nbzp ,
108+ this ->pw_rho ->ny ,
109+ this ->pw_rho ->nplane ,
110+ this ->pw_rho ->startz_current ,
111+ GlobalC::ucell,
112+ GlobalC::GridD,
113+ dr_uniform,
114+ rcuts,
115+ psi_u,
116+ dpsi_u,
117+ d2psi_u,
118+ PARAM.inp .nstream );
119+ psi_u.clear ();
120+ psi_u.shrink_to_fit ();
121+ dpsi_u.clear ();
122+ dpsi_u.shrink_to_fit ();
123+ d2psi_u.clear ();
124+ d2psi_u.shrink_to_fit ();
125+
126+ // (2)For each atom, calculate the adjacent atoms in different cells
127+ // and allocate the space for H(R) and S(R).
128+ // If k point is used here, allocate HlocR after atom_arrange.
129+ this ->RA .for_2d (this ->pv , PARAM.globalv .gamma_only_local , orb_.cutoffs ());
49130
50131 // 2. density matrix extrapolation
51132
@@ -63,12 +144,10 @@ void ESolver_KS_LCAO<TK, TR>::beforesolver(const int istep)
63144 {
64145 nsk = PARAM.inp .nspin ;
65146 ncol = this ->pv .ncol_bands ;
66- if (PARAM.inp .ks_solver == " genelpa"
67- || PARAM.inp .ks_solver == " elpa"
68- || PARAM.inp .ks_solver == " lapack"
69- || PARAM.inp .ks_solver == " pexsi"
70- || PARAM.inp .ks_solver == " cusolver"
71- || PARAM.inp .ks_solver == " cusolvermp" ) {
147+ if (PARAM.inp .ks_solver == " genelpa" || PARAM.inp .ks_solver == " elpa" || PARAM.inp .ks_solver == " lapack"
148+ || PARAM.inp .ks_solver == " pexsi" || PARAM.inp .ks_solver == " cusolver"
149+ || PARAM.inp .ks_solver == " cusolvermp" )
150+ {
72151 ncol = this ->pv .ncol ;
73152 }
74153 }
@@ -85,12 +164,11 @@ void ESolver_KS_LCAO<TK, TR>::beforesolver(const int istep)
85164 }
86165
87166 // init wfc from file
88- if (istep == 0 && PARAM.inp .init_wfc == " file" )
167+ if (istep == 0 && PARAM.inp .init_wfc == " file" )
89168 {
90- if (! ModuleIO::read_wfc_nao (PARAM.globalv .global_readin_dir , this ->pv , *(this ->psi ), this ->pelec ))
169+ if (!ModuleIO::read_wfc_nao (PARAM.globalv .global_readin_dir , this ->pv , *(this ->psi ), this ->pelec ))
91170 {
92- ModuleBase::WARNING_QUIT (" ESolver_KS_LCAO<TK, TR>::beforesolver" ,
93- " read wfc nao failed" );
171+ ModuleBase::WARNING_QUIT (" ESolver_KS_LCAO<TK, TR>::beforesolver" , " read wfc nao failed" );
94172 }
95173 }
96174
@@ -116,10 +194,11 @@ void ESolver_KS_LCAO<TK, TR>::beforesolver(const int istep)
116194 orb_,
117195 DM
118196#ifdef __EXX
119- , istep
120- , GlobalC::exx_info.info_ri .real_number ? &this ->exd ->two_level_step : &this ->exc ->two_level_step
121- , GlobalC::exx_info.info_ri .real_number ? &exx_lri_double->Hexxs : nullptr
122- , GlobalC::exx_info.info_ri .real_number ? nullptr : &exx_lri_complex->Hexxs
197+ ,
198+ istep,
199+ GlobalC::exx_info.info_ri .real_number ? &this ->exd ->two_level_step : &this ->exc ->two_level_step ,
200+ GlobalC::exx_info.info_ri .real_number ? &exx_lri_double->Hexxs : nullptr ,
201+ GlobalC::exx_info.info_ri .real_number ? nullptr : &exx_lri_complex->Hexxs
123202#endif
124203 );
125204 }
@@ -169,41 +248,6 @@ void ESolver_KS_LCAO<TK, TR>::beforesolver(const int istep)
169248 {
170249 GlobalC::ucell.cal_ux ();
171250 }
172- ModuleBase::timer::tick (" ESolver_KS_LCAO" , " beforesolver" );
173- }
174-
175- template <typename TK, typename TR>
176- void ESolver_KS_LCAO<TK, TR>::before_scf(const int istep)
177- {
178- ModuleBase::TITLE (" ESolver_KS_LCAO" , " before_scf" );
179-
180- // ! 1) call before_scf() of ESolver_FP
181- ESolver_FP::before_scf (istep);
182-
183- if (GlobalC::ucell.ionic_position_updated )
184- {
185- this ->CE .update_all_dis (GlobalC::ucell);
186- this ->CE .extrapolate_charge (
187- #ifdef __MPI
188- &(GlobalC::Pgrid),
189- #endif
190- GlobalC::ucell,
191- this ->pelec ->charge ,
192- &(this ->sf ),
193- GlobalV::ofs_running,
194- GlobalV::ofs_warning);
195- }
196-
197- // ----------------------------------------------------------
198- // about vdw, jiyy add vdwd3 and linpz add vdwd2
199- // ----------------------------------------------------------
200- auto vdw_solver = vdw::make_vdw (GlobalC::ucell, PARAM.inp , &(GlobalV::ofs_running));
201- if (vdw_solver != nullptr )
202- {
203- this ->pelec ->f_en .evdw = vdw_solver->get_energy ();
204- }
205-
206- this ->beforesolver (istep);
207251
208252 // Peize Lin add 2016-12-03
209253#ifdef __EXX // set xc type before the first cal of xc in pelec->init_scf
0 commit comments