1+ #include " ctrl_output_td.h"
2+
3+ #include " source_base/parallel_global.h"
4+ #include " source_io/dipole_io.h"
5+ #include " source_io/module_parameter/parameter.h"
6+ #include " source_io/td_current_io.h"
7+
8+ namespace ModuleIO
9+ {
10+
11+ template <typename TR>
12+ void ctrl_output_td (const UnitCell& ucell,
13+ double ** rho_save,
14+ const ModulePW::PW_Basis* rhopw,
15+ const int istep,
16+ const psi::Psi<std::complex <double >>* psi,
17+ const elecstate::ElecState* pelec,
18+ const K_Vectors& kv,
19+ const TwoCenterIntegrator* intor,
20+ const Parallel_Orbitals* pv,
21+ const LCAO_Orbitals& orb,
22+ const Velocity_op<TR>* velocity_mat,
23+ Record_adj& RA,
24+ TD_info* td_p)
25+ {
26+ ModuleBase::TITLE (" ModuleIO" , " ctrl_output_td" );
27+
28+ // Original code commented out, might need reference later
29+
30+ // // (1) Write dipole information
31+ // for (int is = 0; is < PARAM.inp.nspin; is++)
32+ // {
33+ // if (PARAM.inp.out_dipole == 1)
34+ // {
35+ // std::stringstream ss_dipole;
36+ // ss_dipole << PARAM.globalv.global_out_dir << "dipole_s" << is + 1 << ".txt";
37+ // ModuleIO::write_dipole(ucell, this->chr.rho_save[is], this->chr.rhopw, is, istep, ss_dipole.str());
38+ // }
39+ // }
40+
41+ // // (2) Write current information
42+ // elecstate::DensityMatrix<std::complex<double>, double>* tmp_DM
43+ // = dynamic_cast<elecstate::ElecStateLCAO<std::complex<double>>*>(this->pelec)->get_DM();
44+ // if (TD_info::out_current)
45+ // {
46+ // if (TD_info::out_current_k)
47+ // {
48+ // ModuleIO::write_current_eachk(ucell,
49+ // istep,
50+ // this->psi,
51+ // this->pelec,
52+ // this->kv,
53+ // this->two_center_bundle_.overlap_orb.get(),
54+ // tmp_DM->get_paraV_pointer(),
55+ // this->orb_,
56+ // this->velocity_mat,
57+ // this->RA);
58+ // }
59+ // else
60+ // {
61+ // ModuleIO::write_current(ucell,
62+ // istep,
63+ // this->psi,
64+ // this->pelec,
65+ // this->kv,
66+ // this->two_center_bundle_.overlap_orb.get(),
67+ // tmp_DM->get_paraV_pointer(),
68+ // this->orb_,
69+ // this->velocity_mat,
70+ // this->RA);
71+ // }
72+ // }
73+
74+ // // (3) Output file for restart
75+ // if (PARAM.inp.out_freq_ion > 0) // default value of out_freq_ion is 0
76+ // {
77+ // if (istep % PARAM.inp.out_freq_ion == 0)
78+ // {
79+ // td_p->out_restart_info(istep, elecstate::H_TDDFT_pw::At, elecstate::H_TDDFT_pw::At_laststep);
80+ // }
81+ // }
82+
83+ // (1) Write dipole information
84+ for (int is = 0 ; is < PARAM.inp .nspin ; ++is)
85+ {
86+ if (PARAM.inp .out_dipole == 1 )
87+ {
88+ std::stringstream ss_dipole;
89+ ss_dipole << PARAM.globalv .global_out_dir << " dipole_s" << is + 1 << " .txt" ;
90+ ModuleIO::write_dipole (ucell, rho_save[is], rhopw, is, istep, ss_dipole.str ());
91+ }
92+ }
93+
94+ // (2) Write current information
95+ const elecstate::ElecStateLCAO<std::complex <double >>* pelec_lcao
96+ = dynamic_cast <const elecstate::ElecStateLCAO<std::complex <double >>*>(pelec);
97+
98+ if (!pelec_lcao)
99+ {
100+ ModuleBase::WARNING_QUIT (" ModuleIO::ctrl_output_td" , " Failed to cast ElecState to ElecStateLCAO" );
101+ }
102+
103+ if (TD_info::out_current)
104+ {
105+ if (TD_info::out_current_k)
106+ {
107+ ModuleIO::write_current_eachk<TR>(ucell, istep, psi, pelec, kv, intor, pv, orb, velocity_mat, RA);
108+ }
109+ else
110+ {
111+ ModuleIO::write_current<TR>(ucell, istep, psi, pelec, kv, intor, pv, orb, velocity_mat, RA);
112+ }
113+ }
114+
115+ // (3) Output file for restart
116+ if (PARAM.inp .out_freq_ion > 0 ) // default value of out_freq_ion is 0
117+ {
118+ if (istep % PARAM.inp .out_freq_ion == 0 )
119+ {
120+ if (td_p != nullptr )
121+ {
122+ td_p->out_restart_info (istep, elecstate::H_TDDFT_pw::At, elecstate::H_TDDFT_pw::At_laststep);
123+ }
124+ else
125+ {
126+ ModuleBase::WARNING_QUIT (" ModuleIO::ctrl_output_td" ,
127+ " TD_info pointer is null, cannot output restart info." );
128+ }
129+ }
130+ }
131+ }
132+
133+ template void ctrl_output_td<double >(const UnitCell&,
134+ double **,
135+ const ModulePW::PW_Basis*,
136+ const int ,
137+ const psi::Psi<std::complex <double >>*,
138+ const elecstate::ElecState*,
139+ const K_Vectors&,
140+ const TwoCenterIntegrator*,
141+ const Parallel_Orbitals*,
142+ const LCAO_Orbitals&,
143+ const Velocity_op<double >*,
144+ Record_adj&,
145+ TD_info*);
146+
147+ template void ctrl_output_td<std::complex <double >>(const UnitCell&,
148+ double **,
149+ const ModulePW::PW_Basis*,
150+ const int ,
151+ const psi::Psi<std::complex <double >>*,
152+ const elecstate::ElecState*,
153+ const K_Vectors&,
154+ const TwoCenterIntegrator*,
155+ const Parallel_Orbitals*,
156+ const LCAO_Orbitals&,
157+ const Velocity_op<std::complex <double >>*,
158+ Record_adj&,
159+ TD_info*);
160+
161+ } // namespace ModuleIO
0 commit comments