Skip to content

Commit 99afe4f

Browse files
committed
change ucell in module_io/write_dipole.cpp
1 parent 6387181 commit 99afe4f

File tree

3 files changed

+18
-16
lines changed

3 files changed

+18
-16
lines changed

source/module_esolver/esolver_ks_lcao_tddft.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -349,7 +349,7 @@ void ESolver_KS_LCAO_TDDFT::after_scf(UnitCell& ucell, const int istep)
349349
{
350350
std::stringstream ss_dipole;
351351
ss_dipole << PARAM.globalv.global_out_dir << "SPIN" << is + 1 << "_DIPOLE";
352-
ModuleIO::write_dipole(pelec->charge->rho_save[is], pelec->charge->rhopw, is, istep, ss_dipole.str());
352+
ModuleIO::write_dipole(ucell,pelec->charge->rho_save[is], pelec->charge->rhopw, is, istep, ss_dipole.str());
353353
}
354354
}
355355
if (TD_Velocity::out_current == true)

source/module_io/dipole_io.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@
77

88
namespace ModuleIO
99
{
10-
void write_dipole(const double* rho_save,
10+
void write_dipole(const UnitCell& ucell,
11+
const double* rho_save,
1112
const ModulePW::PW_Basis* rhopw,
1213
const int& is,
1314
const int& istep,

source/module_io/write_dipole.cpp

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55
#include "module_io/dipole_io.h"
66

77
// fuxiang add 2017-03-15
8-
void ModuleIO::write_dipole(const double* rho_save,
8+
void ModuleIO::write_dipole(const UnitCell& ucell,
9+
const double* rho_save,
910
const ModulePW::PW_Basis* rhopw,
1011
const int& is,
1112
const int& istep,
@@ -32,14 +33,14 @@ void ModuleIO::write_dipole(const double* rho_save,
3233
double bmod[3];
3334
for (int i = 0; i < 3; i++)
3435
{
35-
bmod[i] = prepare(GlobalC::ucell, i);
36+
bmod[i] = prepare(ucell, i);
3637
}
3738

3839
#ifndef __MPI
3940
double dipole_elec_x = 0.0, dipole_elec_y = 0.0, dipole_elec_z = 0.0;
40-
double lat_factor_x = GlobalC::ucell.lat0 * 0.529177 / rhopw->nx;
41-
double lat_factor_y = GlobalC::ucell.lat0 * 0.529177 / rhopw->ny;
42-
double lat_factor_z = GlobalC::ucell.lat0 * 0.529177 / rhopw->nz;
41+
double lat_factor_x = ucell.lat0 * 0.529177 / rhopw->nx;
42+
double lat_factor_y = ucell.lat0 * 0.529177 / rhopw->ny;
43+
double lat_factor_z = ucell.lat0 * 0.529177 / rhopw->nz;
4344

4445
for (int k = 0; k < rhopw->nz; k++)
4546
{
@@ -57,9 +58,9 @@ void ModuleIO::write_dipole(const double* rho_save,
5758
}
5859
}
5960

60-
dipole_elec_x *= GlobalC::ucell.omega / static_cast<double>(rhopw->nxyz);
61-
dipole_elec_y *= GlobalC::ucell.omega / static_cast<double>(rhopw->nxyz);
62-
dipole_elec_z *= GlobalC::ucell.omega / static_cast<double>(rhopw->nxyz);
61+
dipole_elec_x *= ucell.omega / static_cast<double>(rhopw->nxyz);
62+
dipole_elec_y *= ucell.omega / static_cast<double>(rhopw->nxyz);
63+
dipole_elec_z *= ucell.omega / static_cast<double>(rhopw->nxyz);
6364
Parallel_Reduce::reduce_pool(dipole_elec_x);
6465
Parallel_Reduce::reduce_pool(dipole_elec_y);
6566
Parallel_Reduce::reduce_pool(dipole_elec_z);
@@ -88,7 +89,7 @@ void ModuleIO::write_dipole(const double* rho_save,
8889
Parallel_Reduce::reduce_pool(dipole_elec[2]);
8990
for (int i = 0; i < 3; ++i)
9091
{
91-
dipole_elec[i] *= GlobalC::ucell.lat0 / bmod[i] * GlobalC::ucell.omega / rhopw->nxyz;
92+
dipole_elec[i] *= ucell.lat0 / bmod[i] * ucell.omega / rhopw->nxyz;
9293
}
9394

9495
std::cout << std::setprecision(15) << "dipole_elec_x: " << dipole_elec[0] << std::endl;
@@ -103,16 +104,16 @@ void ModuleIO::write_dipole(const double* rho_save,
103104

104105
for (int i = 0; i < 3; ++i)
105106
{
106-
for (int it = 0; it < GlobalC::ucell.ntype; ++it)
107+
for (int it = 0; it < ucell.ntype; ++it)
107108
{
108109
double sum = 0;
109-
for (int ia = 0; ia < GlobalC::ucell.atoms[it].na; ++ia)
110+
for (int ia = 0; ia < ucell.atoms[it].na; ++ia)
110111
{
111-
sum += GlobalC::ucell.atoms[it].taud[ia][i];
112+
sum += ucell.atoms[it].taud[ia][i];
112113
}
113-
dipole_ion[i] += sum * GlobalC::ucell.atoms[it].ncpp.zv;
114+
dipole_ion[i] += sum * ucell.atoms[it].ncpp.zv;
114115
}
115-
dipole_ion[i] *= GlobalC::ucell.lat0 / bmod[i]; //* ModuleBase::FOUR_PI / GlobalC::ucell.omega;
116+
dipole_ion[i] *= ucell.lat0 / bmod[i]; //* ModuleBase::FOUR_PI / ucell.omega;
116117
}
117118

118119
std::cout << std::setprecision(8) << "dipole_ion_x: " << dipole_ion[0] << std::endl;

0 commit comments

Comments
 (0)