@@ -149,85 +149,26 @@ void hamilt::DeePKS<hamilt::OperatorLCAO<TK, TR>>::initialize_HR(const Grid_Driv
149149}
150150#endif
151151
152- template <>
153- void DeePKS<OperatorLCAO<double , double >>::contributeHR()
154- {
155- ModuleBase::TITLE (" DeePKS" , " contributeHR" );
156- #ifdef __DEEPKS
157- if (GlobalC::ld.get_hr_cal ())
158- {
159- ModuleBase::timer::tick (" DeePKS" , " contributeHR" );
160- const Parallel_Orbitals* pv = this ->hsk ->get_pv ();
161- GlobalC::ld.cal_projected_DM <double >(this ->DM , *this ->ucell , *ptr_orb_, *(this ->gd ));
162- GlobalC::ld.cal_descriptor (this ->ucell ->nat );
163- GlobalC::ld.cal_gedm (this ->ucell ->nat );
164- // recalculate the H_V_delta
165- this ->H_V_delta ->set_zero ();
166- this ->calculate_HR ();
167-
168- GlobalC::ld.set_hr_cal (false );
169-
170- ModuleBase::timer::tick (" DeePKS" , " contributeHR" );
171- }
172- // save H_V_delta to hR
173- this ->hR ->add (*this ->H_V_delta );
174- #endif
175- }
176-
177- template <>
178- void DeePKS<OperatorLCAO<std::complex <double >, double >>::contributeHR()
179- {
180- #ifdef __DEEPKS
181- ModuleBase::TITLE (" DeePKS" , " contributeHR" );
182- // if DM_K changed, HR of DeePKS need to refresh.
183- // the judgement is based on the status of HR in GlobalC::ld
184- // this operator should be informed that DM_K has changed and HR need to recalculate.
185- if (GlobalC::ld.get_hr_cal ())
186- {
187- ModuleBase::timer::tick (" DeePKS" , " contributeHR" );
188-
189- GlobalC::ld.cal_projected_DM <std::complex <double >>(this ->DM , *this ->ucell , *ptr_orb_, *this ->gd );
190- GlobalC::ld.cal_descriptor (this ->ucell ->nat );
191- // calculate dE/dD
192- GlobalC::ld.cal_gedm (this ->ucell ->nat );
193-
194- // recalculate the H_V_delta
195- if (this ->H_V_delta == nullptr )
196- {
197- this ->H_V_delta = new hamilt::HContainer<double >(*this ->hR );
198- }
199- this ->H_V_delta ->set_zero ();
200- this ->calculate_HR ();
201-
202- GlobalC::ld.set_hr_cal (false );
203-
204- ModuleBase::timer::tick (" DeePKS" , " contributeHR" );
205- }
206- // save H_V_delta to hR
207- this ->hR ->add (*this ->H_V_delta );
208- #endif
209- }
210- template <>
211- void DeePKS<OperatorLCAO<std::complex <double >, std::complex <double >>>::contributeHR()
152+ template <typename TK, typename TR>
153+ void hamilt::DeePKS<hamilt::OperatorLCAO<TK, TR>>::contributeHR()
212154{
213155#ifdef __DEEPKS
214156 ModuleBase::TITLE (" DeePKS" , " contributeHR" );
215- // if DM_K changed, HR of DeePKS need to refresh.
157+ // if DM changed, HR of DeePKS need to refresh.
216158 // the judgement is based on the status of HR in GlobalC::ld
217- // this operator should be informed that DM_K has changed and HR need to recalculate.
159+ // this operator should be informed that DM has changed and HR need to recalculate.
218160 if (GlobalC::ld.get_hr_cal ())
219161 {
220162 ModuleBase::timer::tick (" DeePKS" , " contributeHR" );
221163
222- GlobalC::ld.cal_projected_DM <std:: complex < double >> (this ->DM , *this ->ucell , *ptr_orb_, *this ->gd );
164+ GlobalC::ld.cal_projected_DM <TK> (this ->DM , *this ->ucell , *ptr_orb_, *( this ->gd ) );
223165 GlobalC::ld.cal_descriptor (this ->ucell ->nat );
224- // calculate dE/dD
225166 GlobalC::ld.cal_gedm (this ->ucell ->nat );
226167
227168 // recalculate the H_V_delta
228169 if (this ->H_V_delta == nullptr )
229170 {
230- this ->H_V_delta = new hamilt::HContainer<std:: complex < double > >(*this ->hR );
171+ this ->H_V_delta = new hamilt::HContainer<TR >(*this ->hR );
231172 }
232173 this ->H_V_delta ->set_zero ();
233174 this ->calculate_HR ();
@@ -238,7 +179,6 @@ void DeePKS<OperatorLCAO<std::complex<double>, std::complex<double>>>::contribut
238179 }
239180 // save H_V_delta to hR
240181 this ->hR ->add (*this ->H_V_delta );
241-
242182#endif
243183}
244184
@@ -537,9 +477,7 @@ void hamilt::DeePKS<hamilt::OperatorLCAO<TK, TR>>::contributeHk(int ik)
537477#endif
538478
539479template class DeePKS <OperatorLCAO<double , double >>;
540-
541480template class DeePKS <OperatorLCAO<std::complex <double >, double >>;
542-
543481template class DeePKS <OperatorLCAO<std::complex <double >, std::complex <double >>>;
544482
545483} // namespace hamilt
0 commit comments