@@ -80,8 +80,8 @@ ModuleBase::matrix surchem::cal_vel(const UnitCell &cell,
8080 complex <double > *Sol_phi0 = new complex <double >[pwb.ngmc ];
8181 int ncgsol = 0 ;
8282
83- double *Vel = new double [pwb.nrxx ];
84- ModuleBase::GlobalFunc::ZEROS (Vel , pwb.nrxx );
83+ double *tmp_Vel = new double [pwb.nrxx ];
84+ ModuleBase::GlobalFunc::ZEROS (tmp_Vel , pwb.nrxx );
8585
8686 // Calculate Sol_phi with epsilon.
8787 ncgsol = 0 ;
@@ -98,34 +98,35 @@ ModuleBase::matrix surchem::cal_vel(const UnitCell &cell,
9898 GlobalC::UFFT.ToRealSpace (Sol_phi, phi_tilda_R);
9999 GlobalC::UFFT.ToRealSpace (Sol_phi0, phi_tilda_R0);
100100
101- // the 1st item of Vel
101+ // the 1st item of tmp_Vel
102102 for (int i = 0 ; i < pwb.nrxx ; i++)
103103 {
104104 delta_phi[i] = phi_tilda_R[i] - phi_tilda_R0[i];
105- Vel [i] += delta_phi[i];
105+ tmp_Vel [i] += delta_phi[i];
106106 }
107107
108108 // calculate Ael
109109 double Ael = cal_Ael (cell, pwb, TOTN_real, delta_phi);
110110
111- // the 2nd item of Vel
111+ // the 2nd item of tmp_Vel
112112 double *Vel2 = new double [pwb.nrxx ];
113113 ModuleBase::GlobalFunc::ZEROS (Vel2, pwb.nrxx );
114114
115115 eps_pot (PS_TOTN_real, Sol_phi, pwb, epsilon, Vel2);
116116
117117 for (int i = 0 ; i < pwb.nrxx ; i++)
118118 {
119- Vel [i] += Vel2[i];
119+ tmp_Vel [i] += Vel2[i];
120120 }
121121
122- ModuleBase::matrix v (nspin, pwb.nrxx );
122+ // ModuleBase::matrix v(nspin, pwb.nrxx);
123+ ModuleBase::GlobalFunc::ZEROS (Vel.c , nspin * pwb.nrxx );
123124
124125 if (nspin == 4 )
125126 {
126127 for (int ir = 0 ; ir < pwb.nrxx ; ir++)
127128 {
128- v (0 , ir) += Vel [ir];
129+ Vel (0 , ir) += tmp_Vel [ir];
129130 }
130131 }
131132 else
@@ -134,7 +135,7 @@ ModuleBase::matrix surchem::cal_vel(const UnitCell &cell,
134135 {
135136 for (int ir = 0 ; ir < pwb.nrxx ; ir++)
136137 {
137- v (is, ir) += Vel [ir];
138+ Vel (is, ir) += tmp_Vel [ir];
138139 }
139140 }
140141 }
@@ -145,13 +146,13 @@ ModuleBase::matrix surchem::cal_vel(const UnitCell &cell,
145146 delete[] B;
146147 delete[] epsilon;
147148 delete[] epsilon0;
148- delete[] Vel ;
149+ delete[] tmp_Vel ;
149150 delete[] Vel2;
150151 // delete[] TOTN_real;
151152 delete[] phi_tilda_R;
152153 delete[] phi_tilda_R0;
153154 // delete[] delta_phi_R;
154155
155156 ModuleBase::timer::tick (" surchem" , " cal_vel" );
156- return v ;
157+ return Vel ;
157158}
0 commit comments