1313#include " module_base/lapack_connector.h"
1414#include " module_base/scalapack_connector.h"
1515#include " module_elecstate/module_charge/symmetry_rho.h"
16+ #include " module_elecstate/module_dm/cal_dm_psi.h"
1617#include " module_elecstate/module_dm/cal_edm_tddft.h"
18+ #include " module_elecstate/module_dm/density_matrix.h"
1719#include " module_elecstate/occupy.h"
1820#include " module_hamilt_lcao/hamilt_lcaodft/LCAO_domain.h" // need divide_HS_in_frag
1921#include " module_hamilt_lcao/module_tddft/evolve_elec.h"
2325
2426// -----HSolver ElecState Hamilt--------
2527#include " module_elecstate/elecstate_lcao.h"
26- #include " module_elecstate/elecstate_lcao_tddft.h"
2728#include " module_hamilt_lcao/hamilt_lcaodft/hamilt_lcao.h"
2829#include " module_hsolver/hsolver_lcao.h"
2930#include " module_parameter/parameter.h"
@@ -70,7 +71,7 @@ void ESolver_KS_LCAO_TDDFT::before_all_runners(const Input_para& inp, UnitCell&
7071 ESolver_KS_LCAO<std::complex <double >, double >::before_all_runners (inp, ucell);
7172
7273 // this line should be optimized
73- this ->pelec_td = dynamic_cast <elecstate::ElecStateLCAO_TDDFT*>(this ->pelec );
74+ // this->pelec = dynamic_cast<elecstate::ElecStateLCAO_TDDFT*>(this->pelec);
7475}
7576
7677void ESolver_KS_LCAO_TDDFT::hamilt2density_single (const int istep, const int iter, const double ethr)
@@ -88,13 +89,13 @@ void ESolver_KS_LCAO_TDDFT::hamilt2density_single(const int istep, const int ite
8889 this ->psi_laststep ,
8990 this ->Hk_laststep ,
9091 this ->Sk_laststep ,
91- this ->pelec_td ->ekb ,
92+ this ->pelec ->ekb ,
9293 td_htype,
9394 PARAM.inp .propagator ,
9495 kv.get_nks ());
95- this ->pelec_td -> psiToRho_td ( this -> psi [ 0 ] );
96+ this ->weight_dm_rho ( );
9697 }
97- this ->pelec_td -> psiToRho_td ( this -> psi [ 0 ] );
98+ this ->weight_dm_rho ( );
9899 }
99100 else if (istep >= 2 )
100101 {
@@ -107,11 +108,11 @@ void ESolver_KS_LCAO_TDDFT::hamilt2density_single(const int istep, const int ite
107108 this ->psi_laststep ,
108109 this ->Hk_laststep ,
109110 this ->Sk_laststep ,
110- this ->pelec_td ->ekb ,
111+ this ->pelec ->ekb ,
111112 td_htype,
112113 PARAM.inp .propagator ,
113114 kv.get_nks ());
114- this ->pelec_td -> psiToRho_td ( this -> psi [ 0 ] );
115+ this ->weight_dm_rho ( );
115116 }
116117 else
117118 {
@@ -122,7 +123,7 @@ void ESolver_KS_LCAO_TDDFT::hamilt2density_single(const int istep, const int ite
122123 {
123124 bool skip_charge = PARAM.inp .calculation == " nscf" ? true : false ;
124125 hsolver::HSolverLCAO<std::complex <double >> hsolver_lcao_obj (&this ->pv , PARAM.inp .ks_solver );
125- hsolver_lcao_obj.solve (this ->p_hamilt , this ->psi [0 ], this ->pelec_td , skip_charge);
126+ hsolver_lcao_obj.solve (this ->p_hamilt , this ->psi [0 ], this ->pelec , skip_charge);
126127 }
127128 }
128129
@@ -157,8 +158,7 @@ void ESolver_KS_LCAO_TDDFT::iter_finish(const int istep, int& iter)
157158 for (int ib = 0 ; ib < PARAM.inp .nbands ; ib++)
158159 {
159160 std::setprecision (6 );
160- GlobalV::ofs_running << ik + 1 << " " << ib + 1 << " " << this ->pelec_td ->wg (ik, ib)
161- << std::endl;
161+ GlobalV::ofs_running << ik + 1 << " " << ib + 1 << " " << this ->pelec ->wg (ik, ib) << std::endl;
162162 }
163163 }
164164 GlobalV::ofs_running << std::endl;
@@ -333,7 +333,7 @@ void ESolver_KS_LCAO_TDDFT::update_pot(const int istep, const int iter)
333333 for (int ib = 0 ; ib < PARAM.inp .nbands ; ib++)
334334 {
335335 GlobalV::ofs_running << ik + 1 << " " << ib + 1 << " "
336- << this ->pelec_td ->ekb (ik, ib) * ModuleBase::Ry_to_eV << std::endl;
336+ << this ->pelec ->ekb (ik, ib) * ModuleBase::Ry_to_eV << std::endl;
337337 }
338338 }
339339 GlobalV::ofs_running << std::endl;
@@ -371,4 +371,21 @@ void ESolver_KS_LCAO_TDDFT::after_scf(const int istep)
371371 ESolver_KS_LCAO<std::complex <double >, double >::after_scf (istep);
372372}
373373
374+ void ESolver_KS_LCAO_TDDFT::weight_dm_rho ()
375+ {
376+ if (PARAM.inp .ocp == 1 )
377+ {
378+ this ->pelec ->fixed_weights (PARAM.inp .ocp_kb , PARAM.inp .nbands , PARAM.inp .nelec );
379+ }
380+ this ->pelec ->calEBand ();
381+
382+ ModuleBase::GlobalFunc::NOTE (" Calculate the density matrix." );
383+
384+ auto _pes = dynamic_cast <elecstate::ElecStateLCAO<std::complex <double >>*>(this ->pelec );
385+ elecstate::cal_dm_psi (_pes->DM ->get_paraV_pointer (), _pes->wg , this ->psi [0 ], *(_pes->DM ));
386+ _pes->DM ->cal_DMR ();
387+
388+ this ->pelec ->psiToRho (this ->psi [0 ]);
389+ }
390+
374391} // namespace ModuleESolver
0 commit comments