Skip to content

Commit 6c346f3

Browse files
committed
change ucell in module_io/td_current_io.cpp
1 parent 268f39f commit 6c346f3

File tree

3 files changed

+18
-15
lines changed

3 files changed

+18
-15
lines changed

source/module_esolver/esolver_ks_lcao_tddft.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -357,7 +357,8 @@ void ESolver_KS_LCAO_TDDFT::after_scf(UnitCell& ucell, const int istep)
357357
elecstate::DensityMatrix<std::complex<double>, double>* tmp_DM
358358
= dynamic_cast<elecstate::ElecStateLCAO<std::complex<double>>*>(this->pelec)->get_DM();
359359

360-
ModuleIO::write_current(istep,
360+
ModuleIO::write_current(ucell,
361+
istep,
361362
this->psi,
362363
pelec,
363364
kv,

source/module_io/td_current_io.cpp

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,8 @@ void ModuleIO::cal_tmp_DM(elecstate::DensityMatrix<std::complex<double>, double>
117117
ModuleBase::timer::tick("ModuleIO", "cal_tmp_DM");
118118
}
119119

120-
void ModuleIO::write_current(const int istep,
120+
void ModuleIO::write_current(const UnitCell& ucell,
121+
const int istep,
121122
const psi::Psi<std::complex<double>>* psi,
122123
const elecstate::ElecState* pelec,
123124
const K_Vectors& kv,
@@ -133,7 +134,7 @@ void ModuleIO::write_current(const int istep,
133134
std::vector<hamilt::HContainer<std::complex<double>>*> current_term = {nullptr, nullptr, nullptr};
134135
if (!TD_Velocity::tddft_velocity)
135136
{
136-
cal_current = new TD_current(&GlobalC::ucell, &GlobalC::GridD, pv, orb, intor);
137+
cal_current = new TD_current(&ucell, &GlobalC::GridD, pv, orb, intor);
137138
cal_current->calculate_vcomm_r();
138139
cal_current->calculate_grad_term();
139140
for (int dir = 0; dir < 3; dir++)
@@ -163,8 +164,8 @@ void ModuleIO::write_current(const int istep,
163164
elecstate::cal_dm_psi(DM_real.get_paraV_pointer(), pelec->wg, psi[0], DM_real);
164165

165166
// init DMR
166-
DM_real.init_DMR(ra, &GlobalC::ucell);
167-
DM_imag.init_DMR(ra, &GlobalC::ucell);
167+
DM_real.init_DMR(ra, &ucell);
168+
DM_imag.init_DMR(ra, &ucell);
168169

169170
int nks = DM_real.get_DMK_nks();
170171
if (PARAM.inp.nspin == 2)
@@ -197,27 +198,27 @@ void ModuleIO::write_current(const int istep,
197198
#ifdef _OPENMP
198199
#pragma omp for schedule(dynamic)
199200
#endif
200-
for (int iat = 0; iat < GlobalC::ucell.nat; iat++)
201+
for (int iat = 0; iat < ucell.nat; iat++)
201202
{
202-
const int T1 = GlobalC::ucell.iat2it[iat];
203-
Atom* atom1 = &GlobalC::ucell.atoms[T1];
204-
const int I1 = GlobalC::ucell.iat2ia[iat];
203+
const int T1 = ucell.iat2it[iat];
204+
Atom* atom1 = &ucell.atoms[T1];
205+
const int I1 = ucell.iat2ia[iat];
205206
// get iat1
206-
int iat1 = GlobalC::ucell.itia2iat(T1, I1);
207+
int iat1 = ucell.itia2iat(T1, I1);
207208

208209
int irr = pv->nlocstart[iat];
209-
const int start1 = GlobalC::ucell.itiaiw2iwt(T1, I1, 0);
210+
const int start1 = ucell.itiaiw2iwt(T1, I1, 0);
210211
for (int cb = 0; cb < ra.na_each[iat]; ++cb)
211212
{
212213
const int T2 = ra.info[iat][cb][3];
213214
const int I2 = ra.info[iat][cb][4];
214215

215-
const int start2 = GlobalC::ucell.itiaiw2iwt(T2, I2, 0);
216+
const int start2 = ucell.itiaiw2iwt(T2, I2, 0);
216217

217-
Atom* atom2 = &GlobalC::ucell.atoms[T2];
218+
Atom* atom2 = &ucell.atoms[T2];
218219

219220
// get iat2
220-
int iat2 = GlobalC::ucell.itia2iat(T2, I2);
221+
int iat2 = ucell.itia2iat(T2, I2);
221222
double Rx = ra.info[iat][cb][0];
222223
double Ry = ra.info[iat][cb][1];
223224
double Rz = ra.info[iat][cb][2];

source/module_io/td_current_io.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@ namespace ModuleIO
1010
{
1111
#ifdef __LCAO
1212
/// @brief func to output current, only used in tddft
13-
void write_current(const int istep,
13+
void write_current(const UnitCell& ucell,
14+
const int istep,
1415
const psi::Psi<std::complex<double>>* psi,
1516
const elecstate::ElecState* pelec,
1617
const K_Vectors& kv,

0 commit comments

Comments
 (0)