11#include " td_current_io.h"
22
3- #include " module_parameter/parameter.h"
43#include " module_base/global_function.h"
54#include " module_base/global_variable.h"
65#include " module_base/libm/libm.h"
1110#include " module_elecstate/module_dm/cal_dm_psi.h"
1211#include " module_elecstate/potentials/H_TDDFT_pw.h"
1312#include " module_hamilt_lcao/hamilt_lcaodft/LCAO_domain.h"
14- #include " module_hamilt_lcao/module_tddft/td_velocity.h"
1513#include " module_hamilt_lcao/module_tddft/td_current.h"
14+ #include " module_hamilt_lcao/module_tddft/td_velocity.h"
1615#include " module_hamilt_pw/hamilt_pwdft/global.h"
16+ #include " module_parameter/parameter.h"
1717
1818#ifdef __LCAO
1919
@@ -138,7 +138,7 @@ void ModuleIO::write_current(const int istep,
138138 cal_current->calculate_grad_term ();
139139 for (int dir = 0 ; dir < 3 ; dir++)
140140 {
141- current_term[dir]= cal_current->get_current_term_pointer (dir);
141+ current_term[dir] = cal_current->get_current_term_pointer (dir);
142142 }
143143 }
144144 else
@@ -149,11 +149,10 @@ void ModuleIO::write_current(const int istep,
149149 }
150150 for (int dir = 0 ; dir < 3 ; dir++)
151151 {
152- current_term[dir]= TD_Velocity::td_vel_op->get_current_term_pointer (dir);
152+ current_term[dir] = TD_Velocity::td_vel_op->get_current_term_pointer (dir);
153153 }
154154 }
155155
156-
157156 // construct a DensityMatrix object
158157 // Since the function cal_dm_psi do not suport DMR in complex type, I replace it with two DMR in double type. Should
159158 // be refactored in the future.
@@ -224,12 +223,17 @@ void ModuleIO::write_current(const int istep,
224223 // std::cout<< "iat1: " << iat1 << " iat2: " << iat2 << " Rx: " << Rx << " Ry: " << Ry << " Rz:
225224 // " << Rz << std::endl;
226225 // get BaseMatrix
227- hamilt::BaseMatrix<double >* tmp_matrix_real = DM_real.get_DMR_pointer (is)->find_matrix (iat1, iat2, Rx, Ry, Rz);
228- hamilt::BaseMatrix<double >* tmp_matrix_imag = DM_imag.get_DMR_pointer (is)->find_matrix (iat1, iat2, Rx, Ry, Rz);
226+ hamilt::BaseMatrix<double >* tmp_matrix_real
227+ = DM_real.get_DMR_pointer (is)->find_matrix (iat1, iat2, Rx, Ry, Rz);
228+ hamilt::BaseMatrix<double >* tmp_matrix_imag
229+ = DM_imag.get_DMR_pointer (is)->find_matrix (iat1, iat2, Rx, Ry, Rz);
229230 // refactor
230- hamilt::BaseMatrix<std::complex <double >>* tmp_m_rvx = current_term[0 ]->find_matrix (iat1, iat2, Rx, Ry, Rz);
231- hamilt::BaseMatrix<std::complex <double >>* tmp_m_rvy = current_term[1 ]->find_matrix (iat1, iat2, Rx, Ry, Rz);
232- hamilt::BaseMatrix<std::complex <double >>* tmp_m_rvz = current_term[2 ]->find_matrix (iat1, iat2, Rx, Ry, Rz);
231+ hamilt::BaseMatrix<std::complex <double >>* tmp_m_rvx
232+ = current_term[0 ]->find_matrix (iat1, iat2, Rx, Ry, Rz);
233+ hamilt::BaseMatrix<std::complex <double >>* tmp_m_rvy
234+ = current_term[1 ]->find_matrix (iat1, iat2, Rx, Ry, Rz);
235+ hamilt::BaseMatrix<std::complex <double >>* tmp_m_rvz
236+ = current_term[2 ]->find_matrix (iat1, iat2, Rx, Ry, Rz);
233237 if (tmp_matrix_real == nullptr )
234238 {
235239 continue ;
@@ -254,16 +258,16 @@ void ModuleIO::write_current(const int istep,
254258 rvy = tmp_m_rvy->get_value (mu, nu);
255259 rvz = tmp_m_rvz->get_value (mu, nu);
256260 }
257- local_current_ik[0 ] -= dm2d1_real * rvx.real () - dm2d1_imag * rvx.imag ();
261+ local_current_ik[0 ] -= dm2d1_real * rvx.real () - dm2d1_imag * rvx.imag ();
258262 local_current_ik[1 ] -= dm2d1_real * rvy.real () - dm2d1_imag * rvy.imag ();
259263 local_current_ik[2 ] -= dm2d1_real * rvz.real () - dm2d1_imag * rvz.imag ();
260-
264+
261265 ++local_total_irr;
262266 ++irr;
263267 } // end kk
264- } // end jj
265- } // end cb
266- } // end iat
268+ } // end jj
269+ } // end cb
270+ } // end iat
267271#ifdef _OPENMP
268272#pragma omp critical(cal_current_k_reduce)
269273 {
@@ -293,9 +297,8 @@ void ModuleIO::write_current(const int istep,
293297 fout.close ();
294298 }
295299 // write end
296- ModuleBase::timer::tick (" ModuleIO" , " write_current" );
297300 } // end nks
298- } // end is
301+ } // end is
299302 if (GlobalV::MY_RANK == 0 )
300303 {
301304 std::string filename = PARAM.globalv .global_out_dir + " current_total.dat" ;
@@ -306,10 +309,12 @@ void ModuleIO::write_current(const int istep,
306309 fout << istep << " " << current_total[0 ] << " " << current_total[1 ] << " " << current_total[2 ] << std::endl;
307310 fout.close ();
308311 }
309- if (!TD_Velocity::tddft_velocity)
312+ if (!TD_Velocity::tddft_velocity)
310313 {
311314 delete cal_current;
312315 }
316+
317+ ModuleBase::timer::tick (" ModuleIO" , " write_current" );
313318 return ;
314319}
315320#endif // __LCAO
0 commit comments