44#include " surchem.h"
55
66
7- static void local_grad_rho_vel (const UnitCell& ucell,
8- const ModulePW::PW_Basis* rho_basis,
9- const std::complex <double >* rho_G,
10- ModuleBase::Vector3<double >* grad_R,
11- std::complex <double >* aux_G,
12- double * aux_R)
13- {
14- for (int i = 0 ; i < 3 ; ++i)
15- {
16- // 1. iG * rho(G)
17- for (int ig = 0 ; ig < rho_basis->npw ; ig++) {
18- aux_G[ig] = ModuleBase::IMAG_UNIT * rho_G[ig] * rho_basis->gcar [ig][i];
19- }
20-
21- // 2. FFT: G -> R
22- rho_basis->recip2real (aux_G, aux_R);
23-
24- // 3. 2pi/a
25- for (int ir = 0 ; ir < rho_basis->nrxx ; ir++) {
26- grad_R[ir][i] = aux_R[ir] * ucell.tpiba ;
27- }
28- }
29- }
307
318void shape_gradn (const double * PS_TOTN_real, const ModulePW::PW_Basis* rho_basis, double * eprime)
329{
@@ -40,24 +17,6 @@ void shape_gradn(const double* PS_TOTN_real, const ModulePW::PW_Basis* rho_basis
4017 }
4118}
4219
43- static void local_grad_rho_vel_tpiba (const double tpiba,
44- const ModulePW::PW_Basis* rho_basis,
45- const std::complex <double >* rho_G,
46- ModuleBase::Vector3<double >* grad_R,
47- std::complex <double >* aux_G,
48- double * aux_R)
49- {
50- for (int i = 0 ; i < 3 ; ++i)
51- {
52- for (int ig = 0 ; ig < rho_basis->npw ; ig++) {
53- aux_G[ig] = ModuleBase::IMAG_UNIT * rho_G[ig] * rho_basis->gcar [ig][i];
54- }
55- rho_basis->recip2real (aux_G, aux_R);
56- for (int ir = 0 ; ir < rho_basis->nrxx ; ir++) {
57- grad_R[ir][i] = aux_R[ir] * tpiba;
58- }
59- }
60- }
6120
6221void eps_pot (const double * PS_TOTN_real,
6322 const double & tpiba,
@@ -80,17 +39,7 @@ void eps_pot(const double* PS_TOTN_real,
8039 double *phisq = new double [rho_basis->nrxx ];
8140
8241
83-
84- std::complex <double > *aux_G = new std::complex <double >[rho_basis->npw ];
85- double *aux_R = new double [rho_basis->nrxx ];
86-
87-
88- local_grad_rho_vel_tpiba (tpiba, rho_basis, phi, nabla_phi, aux_G, aux_R);
89-
90-
91- delete[] aux_G;
92- delete[] aux_R;
93-
42+ XC_Functional::grad_rho (phi, nabla_phi, rho_basis, tpiba);
9443
9544
9645 for (int ir = 0 ; ir < rho_basis->nrxx ; ir++)
@@ -174,7 +123,6 @@ void surchem::cal_vel(const UnitCell& cell,
174123 this ->Ael *= cell.omega / rho_basis->nxyz ;
175124
176125 // the 2nd item of tmp_Vel
177- // eps_pot internally calls shape_gradn and now the SAFE local_grad_rho_vel_tpiba
178126 eps_pot (PS_TOTN_real, cell.tpiba , Sol_phi, rho_basis, epsilon, epspot);
179127
180128 for (int i = 0 ; i < rho_basis->nrxx ; i++)
0 commit comments