Skip to content

Commit 2393c48

Browse files
author
wenfei-li
committed
gint : removed obsolete code for k point force
1 parent 45c69bc commit 2393c48

File tree

3 files changed

+10
-203
lines changed

3 files changed

+10
-203
lines changed

source/src_lcao/FORCE_k.cpp

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1139,11 +1139,7 @@ void Force_LCAO_k::cal_fvl_dphi_k(
11391139
// fvl_dphi can not be set to zero here if Vna is used
11401140
if(isstress||isforce)
11411141
{
1142-
this->UHM->GK.svl_k_RealSpace(isforce, isstress, fvl_dphi,svl_dphi,GlobalC::pot.vr_eff1);
1143-
}
1144-
else if(isforce)
1145-
{
1146-
this->UHM->GK.fvl_k_RealSpace(fvl_dphi,GlobalC::pot.vr_eff1);
1142+
this->UHM->GK.fvl_k_RealSpace(isforce, isstress, fvl_dphi,svl_dphi,GlobalC::pot.vr_eff1);
11471143
}
11481144
}
11491145

source/src_lcao/gint_k.h

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -101,17 +101,16 @@ class Gint_k : public Gint_k_init
101101
//------------------------------------------------------
102102
// in gint_k_fvl.cpp
103103
//------------------------------------------------------
104-
// calculate the force (many k-points).
105-
void fvl_k_RealSpace(
106-
ModuleBase::matrix& fvl_dphi,
107-
const double* vl);//mohan add 2011-06-19
104+
// calculate force & stress (many k-points).
108105

109-
void svl_k_RealSpace(
106+
void fvl_k_RealSpace(
110107
const bool isforce,
111108
const bool isstress,
112109
ModuleBase::matrix& fvl_dphi,
113110
ModuleBase::matrix& svl_dphi,
114-
const double* vl);//zhengdy add 2016-10-18
111+
const double* vl);
112+
//mohan add 2011-06-19
113+
//zhengdy add 2016-10-18
115114

116115
private:
117116

source/src_lcao/gint_k_fvl.cpp

Lines changed: 4 additions & 192 deletions
Original file line numberDiff line numberDiff line change
@@ -5,203 +5,15 @@
55
#include "../module_base/ylm.h"
66
#include "../module_base/timer.h"
77

8-
void Gint_k::fvl_k_RealSpace(ModuleBase::matrix& fvl_dphi, const double *vl)
9-
{
10-
ModuleBase::TITLE("Gint_k","cal_force");
11-
ModuleBase::timer::tick("Gint_k","cal_force");
12-
13-
int nnrg = GlobalC::GridT.nnrg;
14-
//xiaohui add "OUT_LEVEL", 2015-09-16
15-
if(GlobalV::OUT_LEVEL != "m") GlobalV::ofs_running << " LNNR.nnrg in cal_force_k = " << nnrg << std::endl;
16-
assert(nnrg>=0);
17-
18-
// just because to make thea arrys meaningful.
19-
if(nnrg == 0)
20-
{
21-
nnrg = 1;
22-
}
23-
24-
// to store < phi | vlocal | dphi>
25-
double* pvdpx = new double[nnrg];
26-
double* pvdpy = new double[nnrg];
27-
double* pvdpz = new double[nnrg];
28-
ModuleBase::GlobalFunc::ZEROS(pvdpx, nnrg);
29-
ModuleBase::GlobalFunc::ZEROS(pvdpy, nnrg);
30-
ModuleBase::GlobalFunc::ZEROS(pvdpz, nnrg);
31-
32-
const double delta_r = GlobalC::ORB.dr_uniform;
33-
// it's a uniform grid to save orbital values, so the delta_r is a constant.
34-
const int max_size = GlobalC::GridT.max_atom;
35-
// how many meshcells in bigcell.
36-
const int bxyz = GlobalC::GridT.bxyz;
37-
38-
double*** dr;// vectors between atom and grid: [bxyz, maxsize, 3]
39-
double** distance; // distance between atom and grid: [bxyz, maxsize]
40-
double*** psir_ylm;
41-
bool** cal_flag;
42-
double* ylma;
43-
double*** dphi_x;
44-
double*** dphi_y;
45-
double*** dphi_z;
46-
if(max_size!=0)
47-
{
48-
dr = new double**[bxyz];
49-
distance = new double*[bxyz];
50-
psir_ylm = new double**[bxyz];
51-
cal_flag = new bool*[bxyz];
52-
dphi_x = new double**[bxyz];
53-
dphi_y = new double**[bxyz];
54-
dphi_z = new double**[bxyz];
55-
56-
// mohan fix bug 2011-05-02
57-
int nn = 0;
58-
for(int it=0; it<GlobalC::ucell.ntype; it++)
59-
{
60-
nn = max(nn, (GlobalC::ucell.atoms[it].nwl+1)*(GlobalC::ucell.atoms[it].nwl+1));
61-
}
62-
ylma = new double[nn];
63-
ModuleBase::GlobalFunc::ZEROS(ylma, nn);
64-
65-
for(int i=0; i<bxyz; i++)
66-
{
67-
dr[i] = new double*[max_size];
68-
psir_ylm[i] = new double*[max_size];
69-
distance[i] = new double[max_size];
70-
cal_flag[i] = new bool[max_size];
71-
dphi_x[i] = new double*[max_size];
72-
dphi_y[i] = new double*[max_size];
73-
dphi_z[i] = new double*[max_size];
74-
75-
ModuleBase::GlobalFunc::ZEROS(distance[i], max_size);
76-
ModuleBase::GlobalFunc::ZEROS(cal_flag[i], max_size);
77-
78-
for(int j=0; j<max_size; j++)
79-
{
80-
dr[i][j] = new double[3];
81-
psir_ylm[i][j] = new double[GlobalC::ucell.nwmax];
82-
dphi_x[i][j] = new double[GlobalC::ucell.nwmax];
83-
dphi_y[i][j] = new double[GlobalC::ucell.nwmax];
84-
dphi_z[i][j] = new double[GlobalC::ucell.nwmax];
85-
ModuleBase::GlobalFunc::ZEROS(dr[i][j],3);
86-
ModuleBase::GlobalFunc::ZEROS(psir_ylm[i][j],GlobalC::ucell.nwmax);
87-
ModuleBase::GlobalFunc::ZEROS(dphi_x[i][j],GlobalC::ucell.nwmax);
88-
ModuleBase::GlobalFunc::ZEROS(dphi_y[i][j],GlobalC::ucell.nwmax);
89-
ModuleBase::GlobalFunc::ZEROS(dphi_z[i][j],GlobalC::ucell.nwmax);
90-
}
91-
}
92-
}
93-
94-
assert(this->ncxyz!=0);
95-
const double dv = GlobalC::ucell.omega/this->ncxyz;
96-
int vl_index=0;
97-
double* vldr3 = new double[bxyz];
98-
ModuleBase::GlobalFunc::ZEROS(vldr3, bxyz);
99-
100-
for(int i=0; i<nbx; i++)
101-
{
102-
for(int j=0; j<nby; j++)
103-
{
104-
for(int k=nbz_start; k<nbz_start+nbz; k++)
105-
{
106-
const int grid_index = (k-nbz_start) + j * nbz + i * nby * nbz;
107-
const int size = GlobalC::GridT.how_many_atoms[ grid_index ];
108-
if(size==0) continue;
109-
110-
//---------------------------------
111-
// get the wave functions in this
112-
// grid.
113-
//---------------------------------
114-
this->set_ijk_atom_force(grid_index, size,
115-
psir_ylm, dr, cal_flag,
116-
distance, ylma, delta_r,
117-
dphi_x, dphi_y, dphi_z);
118-
119-
int bindex = 0;
120-
// z is the fastest,
121-
for(int ii=0; ii<GlobalC::pw.bx; ii++)
122-
{
123-
for(int jj=0; jj<GlobalC::pw.by; jj++)
124-
{
125-
for(int kk=0; kk<GlobalC::pw.bz; kk++)
126-
{
127-
const int iii = i*GlobalC::pw.bx + ii;
128-
const int jjj = j*GlobalC::pw.by + jj;
129-
const int kkk = k*GlobalC::pw.bz + kk;
130-
vl_index = (kkk-GlobalC::pw.nczp_start) + jjj*GlobalC::pw.nczp + iii*GlobalC::pw.ncy*GlobalC::pw.nczp;
131-
vldr3[bindex] = vl[ vl_index ] * dv;
132-
//vldr3[bindex] = dv; // for overlap test
133-
134-
++bindex;
135-
}
136-
}
137-
}
138-
139-
this->evaluate_vl_force(grid_index, size,i,j,k,
140-
psir_ylm, cal_flag, vldr3, distance,
141-
dphi_x, dphi_y, dphi_z,
142-
pvdpx, pvdpy, pvdpz,GlobalC::GridT);
143-
144-
}// int k
145-
}// int j
146-
} // int i
147-
148-
149-
//---------------------------------------
150-
// Folding R here
151-
//---------------------------------------
152-
153-
154-
//this->LM->DHloc_fixedR_x
155-
this->folding_force(fvl_dphi,pvdpx, pvdpy, pvdpz);
156-
157-
delete[] pvdpx;
158-
delete[] pvdpy;
159-
delete[] pvdpz;
160-
161-
delete[] vldr3;
162-
if(max_size!=0)
163-
{
164-
for(int i=0; i<GlobalC::pw.bxyz; i++)
165-
{
166-
for(int j=0; j<max_size; j++)
167-
{
168-
delete[] dr[i][j];
169-
delete[] psir_ylm[i][j];
170-
delete[] dphi_x[i][j];
171-
delete[] dphi_y[i][j];
172-
delete[] dphi_z[i][j];
173-
}
174-
delete[] dr[i];
175-
delete[] distance[i];
176-
delete[] psir_ylm[i];
177-
delete[] cal_flag[i];
178-
delete[] dphi_x[i];
179-
delete[] dphi_y[i];
180-
delete[] dphi_z[i];
181-
}
182-
delete[] dr;
183-
delete[] distance;
184-
delete[] psir_ylm;
185-
delete[] dphi_x;
186-
delete[] dphi_y;
187-
delete[] dphi_z;
188-
delete[] cal_flag;
189-
190-
delete[] ylma;
191-
}
192-
ModuleBase::timer::tick("Gint_k","cal_force");
193-
return;
194-
}
195-
196-
void Gint_k::svl_k_RealSpace(
8+
void Gint_k::fvl_k_RealSpace(
1979
const bool isforce,
19810
const bool isstress,
19911
ModuleBase::matrix& fvl_dphi,
20012
ModuleBase::matrix& svl_dphi,
20113
const double *vl)
20214
{
203-
ModuleBase::TITLE("Gint_k","svl_k_RealSpace");
204-
ModuleBase::timer::tick("Gint_k","svl_k_RealSpace");
15+
ModuleBase::TITLE("Gint_k","fvl_k_RealSpace");
16+
ModuleBase::timer::tick("Gint_k","fvl_k_RealSpace");
20517

20618
int nnrg = GlobalC::GridT.nnrg;
20719

@@ -434,7 +246,7 @@ void Gint_k::svl_k_RealSpace(
434246

435247
delete[] ylma;
436248
}
437-
ModuleBase::timer::tick("Gint_k","svl_k_RealSpace");
249+
ModuleBase::timer::tick("Gint_k","fvl_k_RealSpace");
438250
return;
439251
}
440252

0 commit comments

Comments
 (0)