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