@@ -26,7 +26,7 @@ ModuleBase::matrix surchem::v_correction(const UnitCell &cell,
2626 complex <double > *Porter_g = new complex <double >[rho_basis->npw ];
2727 ModuleBase::GlobalFunc::ZEROS (Porter_g, rho_basis->npw );
2828
29- GlobalC::UFFT. ToReciSpace (Porter, Porter_g, rho_basis );
29+ rho_basis-> real2recip (Porter, Porter_g);
3030
3131 complex <double > *N = new complex <double >[rho_basis->npw ];
3232 complex <double > *TOTN = new complex <double >[rho_basis->npw ];
@@ -57,7 +57,8 @@ void surchem::add_comp_chg(const UnitCell &cell,
5757 double l,
5858 double center,
5959 complex <double > *NG,
60- int dim)
60+ int dim,
61+ bool flag)
6162{
6263 // x dim
6364 double tmp_q = 0.0 ;
@@ -70,7 +71,10 @@ void surchem::add_comp_chg(const UnitCell &cell,
7071 {
7172 if (ig == rho_basis->ig_gge0 )
7273 {
73- NG[ig] = complex <double >(tmp_q * l / L, 0.0 );
74+ if (flag)
75+ {
76+ NG[ig] = complex <double >(tmp_q * l / L, 0.0 );
77+ }
7478 continue ;
7579 }
7680 double GX = rho_basis->gcar [ig][0 ];
@@ -94,7 +98,10 @@ void surchem::add_comp_chg(const UnitCell &cell,
9498 {
9599 if (ig == rho_basis->ig_gge0 )
96100 {
97- NG[ig] = complex <double >(tmp_q * l / L, 0.0 );
101+ if (flag)
102+ {
103+ NG[ig] = complex <double >(tmp_q * l / L, 0.0 );
104+ }
98105 continue ;
99106 }
100107 double GX = rho_basis->gcar [ig][0 ];
@@ -118,7 +125,10 @@ void surchem::add_comp_chg(const UnitCell &cell,
118125 {
119126 if (ig == rho_basis->ig_gge0 )
120127 {
121- NG[ig] = complex <double >(tmp_q * l / L, 0.0 );
128+ if (flag)
129+ {
130+ NG[ig] = complex <double >(tmp_q * l / L, 0.0 );
131+ }
122132 continue ;
123133 }
124134 double GX = rho_basis->gcar [ig][0 ];
@@ -154,7 +164,7 @@ ModuleBase::matrix surchem::v_compensating(const UnitCell &cell,
154164 complex <double > *Porter_g = new complex <double >[rho_basis->npw ];
155165 ModuleBase::GlobalFunc::ZEROS (Porter_g, rho_basis->npw );
156166
157- GlobalC::UFFT. ToReciSpace (Porter, Porter_g, rho_basis );
167+ rho_basis-> real2recip (Porter, Porter_g);
158168
159169 this ->Porter_g_anchor = Porter_g[rho_basis->ig_gge0 ];
160170
@@ -164,7 +174,7 @@ ModuleBase::matrix surchem::v_compensating(const UnitCell &cell,
164174 cal_totn (cell, rho_basis, Porter_g, N, TOTN);
165175
166176 // save TOTN in real space
167- GlobalC::UFFT. ToRealSpace (TOTN, this ->TOTN_real , rho_basis );
177+ rho_basis-> recip2real (TOTN, this ->TOTN_real );
168178
169179 complex <double > *comp_reci = new complex <double >[rho_basis->npw ];
170180 complex <double > *phi_comp_G = new complex <double >[rho_basis->npw ];
@@ -174,9 +184,9 @@ ModuleBase::matrix surchem::v_compensating(const UnitCell &cell,
174184 ModuleBase::GlobalFunc::ZEROS (phi_comp_G, rho_basis->npw );
175185 ModuleBase::GlobalFunc::ZEROS (phi_comp_R, rho_basis->nrxx );
176186 // get compensating charge in reci space
177- add_comp_chg (cell, rho_basis, comp_q, comp_l, comp_center, comp_reci, comp_dim);
187+ add_comp_chg (cell, rho_basis, comp_q, comp_l, comp_center, comp_reci, comp_dim, true );
178188 // save compensating charge in real space
179- GlobalC::UFFT. ToRealSpace (comp_reci, this ->comp_real , rho_basis );
189+ rho_basis-> recip2real (comp_reci, this ->comp_real );
180190
181191 // test sum of comp_real -> 0
182192 // for (int i = 0; i < rho_basis->nz;i++)
@@ -186,7 +196,7 @@ ModuleBase::matrix surchem::v_compensating(const UnitCell &cell,
186196 // double sum = 0;
187197 // for (int i = 0; i < rho_basis->nxyz; i++)
188198 // {
189- // sum += comp_real [i];
199+ // sum += TOTN_real [i];
190200 // }
191201 // sum = sum * cell.omega / rho_basis->nxyz;
192202 // cout << "sum:" << sum << endl;
@@ -240,7 +250,7 @@ void surchem::cal_comp_force(ModuleBase::matrix &force_comp, ModulePW::PW_Basis
240250 std::complex <double > *N = new std::complex <double >[rho_basis->npw ];
241251 std::complex <double > *phi_comp_G = new complex <double >[rho_basis->npw ];
242252 std::complex <double > *vloc_at = new std::complex <double >[rho_basis->npw ];
243- GlobalC::UFFT. ToReciSpace (phi_comp_R, phi_comp_G, rho_basis );
253+ rho_basis-> real2recip (phi_comp_R, phi_comp_G);
244254
245255 for (int it = 0 ; it < GlobalC::ucell.ntype ; it++)
246256 {
0 commit comments