Skip to content

Commit 9256a90

Browse files
authored
remove unused variable
1 parent 32b673d commit 9256a90

2 files changed

Lines changed: 16 additions & 32 deletions

File tree

source/source_hamilt/module_surchem/minimize_cg.cpp

Lines changed: 14 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,7 @@ void surchem::minimize_cg(const UnitCell& ucell,
2424
std::complex<double> *gsqu = new std::complex<double>[rho_basis->npw];
2525
std::complex<double> *d = new std::complex<double>[rho_basis->npw];
2626

27-
std::complex<double> *gradphi_x = new std::complex<double>[rho_basis->npw];
28-
std::complex<double> *gradphi_y = new std::complex<double>[rho_basis->npw];
29-
std::complex<double> *gradphi_z = new std::complex<double>[rho_basis->npw];
27+
std::complex<double> *gradphi_G_work = new std::complex<double>[rho_basis->npw];
3028

3129
// Removed unused phi_work allocation
3230
// std::complex<double> *phi_work = new std::complex<double>[rho_basis->npw];
@@ -36,7 +34,6 @@ void surchem::minimize_cg(const UnitCell& ucell,
3634
// ==========================================================
3735
ModuleBase::Vector3<double> *aux_grad_phi = new ModuleBase::Vector3<double>[rho_basis->nrxx];
3836
std::complex<double> *aux_grad_grad_phi_G = new std::complex<double>[rho_basis->npw];
39-
ModuleBase::Vector3<double> *aux_tmp_vector3 = new ModuleBase::Vector3<double>[rho_basis->nrxx];
4037
double *aux_lp_real = new double[rho_basis->nrxx];
4138
double *aux_grad_grad_phi_real = new double[rho_basis->nrxx];
4239

@@ -45,10 +42,7 @@ void surchem::minimize_cg(const UnitCell& ucell,
4542
ModuleBase::GlobalFunc::ZEROS(lp, rho_basis->npw);
4643
ModuleBase::GlobalFunc::ZEROS(gsqu, rho_basis->npw);
4744
ModuleBase::GlobalFunc::ZEROS(d, rho_basis->npw);
48-
49-
ModuleBase::GlobalFunc::ZEROS(gradphi_x, rho_basis->npw);
50-
ModuleBase::GlobalFunc::ZEROS(gradphi_y, rho_basis->npw);
51-
ModuleBase::GlobalFunc::ZEROS(gradphi_z, rho_basis->npw);
45+
ModuleBase::GlobalFunc::ZEROS(gradphi_G_work, rho_basis->npw);
5246

5347
int count = 0;
5448
double gg = 0;
@@ -73,8 +67,8 @@ void surchem::minimize_cg(const UnitCell& ucell,
7367

7468
// call leps to calculate div ( epsilon * grad ) phi
7569
// Updated Leps2 call with new buffers
76-
Leps2(ucell, rho_basis, phi, d_eps, gradphi_x, gradphi_y, gradphi_z, lp,
77-
aux_grad_phi, aux_grad_grad_phi_G, aux_tmp_vector3, aux_lp_real, aux_grad_grad_phi_real);
70+
Leps2(ucell, rho_basis, phi, d_eps, gradphi_G_work, lp,
71+
aux_grad_phi, aux_grad_grad_phi_G, aux_lp_real, aux_grad_grad_phi_real);
7872

7973
// the residue
8074
// r = A*phi + (chtot + N)
@@ -111,8 +105,8 @@ void surchem::minimize_cg(const UnitCell& ucell,
111105
}
112106

113107
// Updated Leps2 call inside loop
114-
Leps2(ucell, rho_basis, d, d_eps, gradphi_x, gradphi_y, gradphi_z, lp,
115-
aux_grad_phi, aux_grad_grad_phi_G, aux_tmp_vector3, aux_lp_real, aux_grad_grad_phi_real);
108+
Leps2(ucell, rho_basis, d, d_eps, gradphi_G_work, lp,
109+
aux_grad_phi, aux_grad_grad_phi_G, aux_lp_real, aux_grad_grad_phi_real);
116110

117111
// calculate alpha
118112
alpha = -rinvLr / ModuleBase::GlobalFunc::ddot_real(rho_basis->npw, d, lp);
@@ -163,15 +157,11 @@ void surchem::minimize_cg(const UnitCell& ucell,
163157
delete[] lp;
164158
delete[] gsqu;
165159
delete[] d;
166-
delete[] gradphi_x;
167-
delete[] gradphi_y;
168-
delete[] gradphi_z;
169-
// delete[] phi_work; // Removed
160+
delete[] gradphi_G_work;
170161

171162
// Clean up auxiliary buffers
172163
delete[] aux_grad_phi;
173164
delete[] aux_grad_grad_phi_G;
174-
delete[] aux_tmp_vector3;
175165
delete[] aux_lp_real;
176166
delete[] aux_grad_grad_phi_real;
177167
}
@@ -181,13 +171,10 @@ void surchem::Leps2(const UnitCell& ucell,
181171
const ModulePW::PW_Basis* rho_basis,
182172
std::complex<double>* phi,
183173
double* epsilon, // epsilon from shapefunc, dim=nrxx
184-
std::complex<double>* gradphi_x,
185-
std::complex<double>* gradphi_y,
186-
std::complex<double>* gradphi_z,
174+
std::complex<double>* gradphi_G_work,
187175
std::complex<double>* lp,
188176
ModuleBase::Vector3<double>* grad_phi_R, // size: nrxx
189177
std::complex<double>* aux_G, // size: npw
190-
ModuleBase::Vector3<double>* tmp_vector3, // size: nrxx)
191178
double* lp_real, // size: nrxx
192179
double* aux_R) // size: nrxx
193180
{
@@ -207,11 +194,11 @@ void surchem::Leps2(const UnitCell& ucell,
207194

208195
// 1. R -> G
209196
for (int ir = 0; ir < rho_basis->nrxx; ir++) aux_R[ir] = grad_phi_R[ir].x;
210-
rho_basis->real2recip(aux_R, gradphi_x); //
197+
rho_basis->real2recip(aux_R, gradphi_G_work); //
211198

212199

213200
for(int ig=0; ig<rho_basis->npw; ig++) {
214-
aux_G[ig] = ModuleBase::IMAG_UNIT * gradphi_x[ig] * rho_basis->gcar[ig][0]; // 0 = x
201+
aux_G[ig] = ModuleBase::IMAG_UNIT * gradphi_G_work[ig] * rho_basis->gcar[ig][0]; // 0 = x
215202
}
216203
rho_basis->recip2real(aux_G, aux_R);
217204
for(int ir=0; ir<rho_basis->nrxx; ir++) {
@@ -220,10 +207,10 @@ void surchem::Leps2(const UnitCell& ucell,
220207

221208

222209
for (int ir = 0; ir < rho_basis->nrxx; ir++) aux_R[ir] = grad_phi_R[ir].y;
223-
rho_basis->real2recip(aux_R, gradphi_y);
210+
rho_basis->real2recip(aux_R, gradphi_G_work);
224211

225212
for(int ig=0; ig<rho_basis->npw; ig++) {
226-
aux_G[ig] = ModuleBase::IMAG_UNIT * gradphi_y[ig] * rho_basis->gcar[ig][1]; // 1 = y
213+
aux_G[ig] = ModuleBase::IMAG_UNIT * gradphi_G_work[ig] * rho_basis->gcar[ig][1]; // 1 = y
227214
}
228215
rho_basis->recip2real(aux_G, aux_R);
229216
for(int ir=0; ir<rho_basis->nrxx; ir++) {
@@ -232,10 +219,10 @@ void surchem::Leps2(const UnitCell& ucell,
232219

233220

234221
for (int ir = 0; ir < rho_basis->nrxx; ir++) aux_R[ir] = grad_phi_R[ir].z;
235-
rho_basis->real2recip(aux_R, gradphi_z);
222+
rho_basis->real2recip(aux_R, gradphi_G_work);
236223

237224
for(int ig=0; ig<rho_basis->npw; ig++) {
238-
aux_G[ig] = ModuleBase::IMAG_UNIT * gradphi_z[ig] * rho_basis->gcar[ig][2]; // 2 = z
225+
aux_G[ig] = ModuleBase::IMAG_UNIT * gradphi_G_work[ig] * rho_basis->gcar[ig][2]; // 2 = z
239226
}
240227
rho_basis->recip2real(aux_G, aux_R);
241228
for(int ir=0; ir<rho_basis->nrxx; ir++) {

source/source_hamilt/module_surchem/surchem.h

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -98,14 +98,11 @@ class surchem
9898
const ModulePW::PW_Basis* rho_basis,
9999
std::complex<double>* phi,
100100
double* epsilon, // epsilon from shapefunc, dim=nrxx
101-
std::complex<double>* gradphi_x, // dim=ngmc
102-
std::complex<double>* gradphi_y,
103-
std::complex<double>* gradphi_z,
101+
std::complex<double>* gradphi_G_work,
104102
std::complex<double>* lp,
105103
// New buffers
106-
ModuleBase::Vector3<double>* grad_phi,
104+
ModuleBase::Vector3<double>* grad_phi_R,
107105
std::complex<double>* grad_grad_phi_G,
108-
ModuleBase::Vector3<double>* tmp_vector3,
109106
double* lp_real,
110107
double* grad_grad_phi_real);
111108

0 commit comments

Comments
 (0)