@@ -54,13 +54,13 @@ void ESolver_SDFT_PW<T, Device>::before_all_runners(const Input_para& inp, UnitC
5454
5555 // 3) initialize the pointer for electronic states of SDFT
5656 this ->pelec = new elecstate::ElecStatePW_SDFT<T, Device>(this ->pw_wfc ,
57- &(this ->chr ),
58- &(this ->kv ),
59- &ucell,
60- &(GlobalC::ppcell),
61- this ->pw_rhod ,
62- this ->pw_rho ,
63- this ->pw_big );
57+ &(this ->chr ),
58+ &(this ->kv ),
59+ &ucell,
60+ &(GlobalC::ppcell),
61+ this ->pw_rhod ,
62+ this ->pw_rho ,
63+ this ->pw_big );
6464
6565 // 4) inititlize the charge density.
6666 this ->pelec ->charge ->allocate (PARAM.inp .nspin );
@@ -80,11 +80,11 @@ void ESolver_SDFT_PW<T, Device>::before_all_runners(const Input_para& inp, UnitC
8080
8181 // 6) prepare some parameters for electronic wave functions initilization
8282 this ->p_wf_init = new psi::WFInit<T, Device>(PARAM.inp .init_wfc ,
83- PARAM.inp .ks_solver ,
84- PARAM.inp .basis_type ,
85- PARAM.inp .psi_initializer ,
86- &this ->wf ,
87- this ->pw_wfc );
83+ PARAM.inp .ks_solver ,
84+ PARAM.inp .basis_type ,
85+ PARAM.inp .psi_initializer ,
86+ &this ->wf ,
87+ this ->pw_wfc );
8888 // 7) set occupatio, redundant?
8989 if (PARAM.inp .ocp )
9090 {
@@ -95,42 +95,38 @@ void ESolver_SDFT_PW<T, Device>::before_all_runners(const Input_para& inp, UnitC
9595 this ->Init_GlobalC (inp, ucell, GlobalC::ppcell); // temporary
9696
9797 // 9) initialize the stochastic wave functions
98- stowf.init (&this ->kv , this ->pw_wfc ->npwk_max );
98+ this -> stowf .init (&this ->kv , this ->pw_wfc ->npwk_max );
9999 if (inp.nbands_sto != 0 )
100100 {
101101 if (inp.initsto_ecut < inp.ecutwfc )
102102 {
103- Init_Sto_Orbitals ( this ->stowf , inp.seed_sto );
103+ this ->stowf . init_sto_orbitals ( inp.seed_sto );
104104 }
105105 else
106106 {
107- Init_Sto_Orbitals_Ecut ( this ->stowf , inp.seed_sto , this ->kv , *this ->pw_wfc , inp.initsto_ecut );
107+ this ->stowf . init_sto_orbitals_Ecut ( inp.seed_sto , this ->kv , *this ->pw_wfc , inp.initsto_ecut );
108108 }
109109 }
110110 else
111111 {
112- Init_Com_Orbitals ( this ->stowf );
112+ this ->stowf . init_com_orbitals ( );
113113 }
114114 if (this ->method_sto == 2 )
115115 {
116- stowf.allocate_chiallorder (this ->nche_sto );
116+ this -> stowf .allocate_chiallorder (this ->nche_sto );
117117 }
118+ this ->stowf .sync_chi0 ();
118119
120+ // 10) allocate spaces for \sqrt(f(H))|chi> and |\tilde{chi}>
119121 size_t size = stowf.chi0 ->size ();
120-
121- this ->stowf .shchi = new psi::Psi<T>(this ->kv .get_nks (),
122- this ->stowf .nchip_max ,
123- this ->wf .npwx ,
124- this ->kv .ngk .data ());
125-
122+ this ->stowf .shchi
123+ = new psi::Psi<T, Device>(this ->kv .get_nks (), this ->stowf .nchip_max , this ->wf .npwx , this ->kv .ngk .data ());
126124 ModuleBase::Memory::record (" SDFT::shchi" , size * sizeof (T));
127125
128126 if (PARAM.inp .nbands > 0 )
129127 {
130- this ->stowf .chiortho = new psi::Psi<T>(this ->kv .get_nks (),
131- this ->stowf .nchip_max ,
132- this ->wf .npwx ,
133- this ->kv .ngk .data ());
128+ this ->stowf .chiortho
129+ = new psi::Psi<T, Device>(this ->kv .get_nks (), this ->stowf .nchip_max , this ->wf .npwx , this ->kv .ngk .data ());
134130 ModuleBase::Memory::record (" SDFT::chiortho" , size * sizeof (T));
135131 }
136132
@@ -143,16 +139,16 @@ void ESolver_SDFT_PW<T, Device>::before_scf(const int istep)
143139 ESolver_KS_PW<T, Device>::before_scf (istep);
144140 delete reinterpret_cast <hamilt::HamiltPW<double >*>(this ->p_hamilt );
145141 this ->p_hamilt = new hamilt::HamiltSdftPW<T, Device>(this ->pelec ->pot ,
146- this ->pw_wfc ,
147- &this ->kv ,
148- PARAM.globalv .npol ,
149- &this ->stoche .emin_sto ,
150- &this ->stoche .emax_sto );
142+ this ->pw_wfc ,
143+ &this ->kv ,
144+ PARAM.globalv .npol ,
145+ &this ->stoche .emin_sto ,
146+ &this ->stoche .emax_sto );
151147 this ->p_hamilt_sto = static_cast <hamilt::HamiltSdftPW<T, Device>*>(this ->p_hamilt );
152148
153149 if (istep > 0 && PARAM.inp .nbands_sto != 0 && PARAM.inp .initsto_freq > 0 && istep % PARAM.inp .initsto_freq == 0 )
154150 {
155- Update_Sto_Orbitals ( this ->stowf , PARAM.inp .seed_sto );
151+ this ->stowf . update_sto_orbitals ( PARAM.inp .seed_sto );
156152 }
157153}
158154
@@ -192,24 +188,23 @@ void ESolver_SDFT_PW<T, Device>::hamilt2density(int istep, int iter, double ethr
192188 hsolver::DiagoIterAssist<T, Device>::PW_DIAG_NMAX = PARAM.inp .pw_diag_nmax ;
193189
194190 // hsolver only exists in this function
195- hsolver::HSolverPW_SDFT<T, Device> hsolver_pw_sdft_obj (
196- &this ->kv ,
197- this ->pw_wfc ,
198- &this ->wf ,
199- this ->stowf ,
200- this ->stoche ,
201- this ->p_hamilt_sto ,
202- PARAM.inp .calculation ,
203- PARAM.inp .basis_type ,
204- PARAM.inp .ks_solver ,
205- PARAM.inp .use_paw ,
206- PARAM.globalv .use_uspp ,
207- PARAM.inp .nspin ,
208- hsolver::DiagoIterAssist<T, Device>::SCF_ITER,
209- hsolver::DiagoIterAssist<T, Device>::PW_DIAG_NMAX,
210- hsolver::DiagoIterAssist<T, Device>::PW_DIAG_THR,
211- hsolver::DiagoIterAssist<T, Device>::need_subspace,
212- this ->init_psi );
191+ hsolver::HSolverPW_SDFT<T, Device> hsolver_pw_sdft_obj (&this ->kv ,
192+ this ->pw_wfc ,
193+ &this ->wf ,
194+ this ->stowf ,
195+ this ->stoche ,
196+ this ->p_hamilt_sto ,
197+ PARAM.inp .calculation ,
198+ PARAM.inp .basis_type ,
199+ PARAM.inp .ks_solver ,
200+ PARAM.inp .use_paw ,
201+ PARAM.globalv .use_uspp ,
202+ PARAM.inp .nspin ,
203+ hsolver::DiagoIterAssist<T, Device>::SCF_ITER,
204+ hsolver::DiagoIterAssist<T, Device>::PW_DIAG_NMAX,
205+ hsolver::DiagoIterAssist<T, Device>::PW_DIAG_THR,
206+ hsolver::DiagoIterAssist<T, Device>::need_subspace,
207+ this ->init_psi );
213208
214209 hsolver_pw_sdft_obj.solve (this ->p_hamilt , this ->psi [0 ], this ->pelec , this ->pw_wfc , this ->stowf , istep, iter, false );
215210 this ->init_psi = true ;
0 commit comments