Skip to content

Commit 702cb01

Browse files
committed
2 parents 23526d0 + 5dbe07a commit 702cb01

File tree

12 files changed

+436
-283
lines changed

12 files changed

+436
-283
lines changed

source/src_lcao/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ list(APPEND objects
1212
FORCE_gamma_edm.cpp
1313
FORCE_gamma_tvnl.cpp
1414
FORCE_gamma_vl.cpp
15+
FORCE_gamma_vl_new.cpp
1516
FORCE_k.cpp
1617
LCAO_diago.cpp
1718
LCAO_evolve.cpp
@@ -33,6 +34,7 @@ list(APPEND objects
3334
gint_gamma_common.cpp
3435
gint_gamma_env.cpp
3536
gint_gamma_fvl.cpp
37+
gint_gamma_fvl_new.cpp
3638
gint_gamma_mull.cpp
3739
gint_gamma_rho.cpp
3840
gint_gamma_vl.cpp

source/src_lcao/FORCE_gamma.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,8 @@ void Force_LCAO_gamma::ftable_gamma (
5252
this->calFvnlDbeta(loc.dm_gamma, isforce, isstress, fvnl_dbeta, svnl_dbeta, GlobalV::vnl_method);
5353
this->cal_fvl_dphi(loc.dm_gamma, isforce, isstress, fvl_dphi, svl_dphi);
5454

55+
//this->cal_fvl_dphi_new(loc.DM, isforce, isstress, fvl_dphi, svl_dphi);
56+
5557
//caoyu add for DeePKS
5658
#ifdef __DEEPKS
5759
if (GlobalV::deepks_scf)

source/src_lcao/FORCE_gamma.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,13 @@ class Force_LCAO_gamma
128128
ModuleBase::matrix& fvl_dphi,
129129
ModuleBase::matrix& svl_dphi);
130130

131+
void cal_fvl_dphi_new(
132+
double*** DM_in,
133+
const bool isforce,
134+
const bool isstress,
135+
ModuleBase::matrix& fvl_dphi,
136+
ModuleBase::matrix& svl_dphi);
137+
131138
void calFvnlDbeta(
132139
const std::vector<ModuleBase::matrix> &dm2d,
133140
const bool &isforce,

source/src_lcao/FORCE_gamma_vl.cpp

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,6 @@ void Force_LCAO_gamma::cal_fvl_dphi(
4040
tmpDHx[i] = this->UHM->LM->DHloc_fixed_x[i];
4141
tmpDHy[i] = this->UHM->LM->DHloc_fixed_y[i];
4242
tmpDHz[i] = this->UHM->LM->DHloc_fixed_z[i];
43-
//std::cout << " this->UHM->LM->DHloc_fixed_x=" << this->UHM->LM->DHloc_fixed_x[i] << std::endl;
44-
//std::cout << " this->UHM->LM->DHloc_fixed_y=" << this->UHM->LM->DHloc_fixed_y[i] << std::endl;
45-
//std::cout << " this->UHM->LM->DHloc_fixed_z=" << this->UHM->LM->DHloc_fixed_z[i] << std::endl;
4643
}
4744

4845
//calculate dVL
@@ -65,13 +62,8 @@ void Force_LCAO_gamma::cal_fvl_dphi(
6562
GlobalC::pot.vr_eff1[ir] = GlobalC::pot.vr_eff(GlobalV::CURRENT_SPIN, ir);
6663
}
6764

68-
// should not be set zero if VNA is used.
69-
// ModuleBase::GlobalFunc::ZEROS(this->UHM->LM->DHloc_fixed_x,this->ParaV->nloc);
70-
// ModuleBase::GlobalFunc::ZEROS(this->UHM->LM->DHloc_fixed_y,this->ParaV->nloc);
71-
// ModuleBase::GlobalFunc::ZEROS(this->UHM->LM->DHloc_fixed_z,this->ParaV->nloc);
7265
this->UHM->GG.cal_force(GlobalC::pot.vr_eff1);
7366

74-
7567
for(int i=0; i<GlobalV::NLOCAL; i++)
7668
{
7769
const int iat = GlobalC::ucell.iwt2iat[i];
@@ -102,26 +94,10 @@ void Force_LCAO_gamma::cal_fvl_dphi(
10294
svl_dphi(1,2) += dm2d2 * this->UHM->LM->DHloc_fixed_23[index];
10395
svl_dphi(2,2) += dm2d2 * this->UHM->LM->DHloc_fixed_33[index];
10496
}
105-
// std::cout << std::setw(5) << iat << std::setw(5) << iat2
106-
// << std::setw(5) << mu << std::setw(5) << nu
107-
// << std::setw(15) << this->UHM->LM->DHloc_fixed_z[index] << std::endl;
10897
}
10998
}
11099
}
111-
112-
// std::cout << "fvl_dphi:" << std::endl;
113-
// for(int iat=0; iat<GlobalC::ucell.nat; ++iat)
114-
// {
115-
// std::cout << std::setw(5) << iat << std::setw(15) << fvl_dphi[iat][0]
116-
// << std::setw(15) << fvl_dphi[iat][1]
117-
// << std::setw(15) << fvl_dphi[iat][2] << std::endl;
118-
// }
119-
120-
121100
} // end spin
122-
// test mohan tmp
123-
// test_gamma(this->UHM->LM->DHloc_fixed_x,"this->UHM->LM->DHloc_fixed_x");
124-
125101
if(isstress)
126102
{
127103
for(int i=0;i<3;i++)
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
#include "FORCE_gamma.h"
2+
#include "../src_pw/global.h"
3+
#include "../module_base/timer.h"
4+
5+
void Force_LCAO_gamma::cal_fvl_dphi_new(
6+
double*** DM_in,
7+
const bool isforce,
8+
const bool isstress,
9+
ModuleBase::matrix& fvl_dphi,
10+
ModuleBase::matrix& svl_dphi)
11+
{
12+
ModuleBase::TITLE("Force_LCAO_gamma","cal_fvl_dphi_new");
13+
ModuleBase::timer::tick("Force_LCAO_gamma","cal_fvl_dphi_new");
14+
int istep = 1;
15+
GlobalC::pot.init_pot(istep, GlobalC::pw.strucFac);
16+
fvl_dphi.zero_out();
17+
for(int is=0; is<GlobalV::NSPIN; ++is)
18+
{
19+
GlobalV::CURRENT_SPIN = is;
20+
for(int ir=0; ir<GlobalC::pw.nrxx; ++ir)
21+
{
22+
GlobalC::pot.vr_eff1[ir] = GlobalC::pot.vr_eff(GlobalV::CURRENT_SPIN, ir);
23+
}
24+
25+
this->UHM->GG.cal_force_new(DM_in[is], GlobalC::pot.vr_eff1, fvl_dphi);
26+
}
27+
ModuleBase::timer::tick("Force_LCAO_gamma","cal_fvl_dphi_new");
28+
}

source/src_lcao/LCAO_nnr.cpp

Lines changed: 0 additions & 114 deletions
Original file line numberDiff line numberDiff line change
@@ -86,52 +86,7 @@ void Grid_Technique::cal_nnrg()
8686
this->nlocdimg[iat] += nelement;
8787
this->nad[iat]++;
8888
++count;
89-
90-
/*
91-
ofs << std::setw(10) << iat << std::setw(10) << iat2
92-
<< std::setw(10) << GlobalC::GridD.getBox(ad).x
93-
<< std::setw(10) << GlobalC::GridD.getBox(ad).y
94-
<< std::setw(10) << GlobalC::GridD.getBox(ad).z
95-
<< std::setw(20) << distance << std::endl;
96-
*/
9789
}
98-
// there is another possibility that i and j are adjacent atoms.
99-
// which is that <i|beta> are adjacents while <beta|j> are also
100-
// adjacents, these considerations are only considered in k-point
101-
// algorithm,
102-
// mohan fix bug 2012-07-03
103-
/*
104-
else if(distance >= rcut)
105-
{
106-
for (int ad0 = 0; ad0 < GlobalC::GridD.getAdjacentNum()+1; ++ad0)
107-
{
108-
const int T0 = GlobalC::GridD.getType(ad0);
109-
const int I0 = GlobalC::GridD.getNatom(ad0);
110-
const int iat0 = GlobalC::ucell.itia2iat(T0, I0);
111-
const int start0 = GlobalC::ucell.itiaiw2iwt(T0, I0, 0);
112-
113-
tau0 = GlobalC::GridD.getAdjacentTau(ad0);
114-
dtau1 = tau0 - tau1;
115-
dtau2 = tau0 - tau2;
116-
117-
double distance1 = dtau1.norm() * GlobalC::ucell.lat0;
118-
double distance2 = dtau2.norm() * GlobalC::ucell.lat0;
119-
120-
double rcut1 = GlobalC::ORB.Phi[T1].getRcut() + GlobalC::ucell.infoNL.Beta[T0].get_rcut_max();
121-
double rcut2 = GlobalC::ORB.Phi[T2].getRcut() + GlobalC::ucell.infoNL.Beta[T0].get_rcut_max();
122-
123-
if( distance1 < rcut1 && distance2 < rcut2 )
124-
{
125-
const int nelement = atom1->nw * atom2->nw;
126-
this->nnrg += nelement;
127-
this->nlocdimg[iat] += nelement;
128-
this->nad[iat]++;
129-
++count;
130-
break;
131-
} // dis1, dis2
132-
}//ad0
133-
}//distance
134-
*/
13590
}// end iat2
13691
}// end ad
13792
// GlobalV::ofs_running << " iat=" << iat << " nlocstartg=" << nlocstartg[iat] << " nad=" << nad[iat] << std::endl;
@@ -181,9 +136,6 @@ void Grid_Technique::cal_nnrg()
181136
}
182137
allocate_find_R2 = true;
183138

184-
// GlobalV::ofs_running << std::setw(5) << "b1" << std::setw(5) << "b2" << std::setw(5) << "b3"
185-
// << std::setw(8) << "iat" << std::setw(8) << "ad" << std::setw(8) << "iat2"
186-
// << std::setw(8) << "find_R2" << std::setw(8) << "find_R2st" << std::setw(8) << "dis" << std::endl;
187139
for (int T1 = 0; T1 < GlobalC::ucell.ntype; T1++)
188140
{
189141
for (int I1 = 0; I1 < GlobalC::ucell.atoms[T1].na; I1++)
@@ -203,7 +155,6 @@ void Grid_Technique::cal_nnrg()
203155
const int I2 = GlobalC::GridD.getNatom(ad);
204156
const int iat2 = GlobalC::ucell.itia2iat(T2,I2);
205157

206-
207158
// if this atom is in this processor.
208159
if(this->in_this_processor[iat])
209160
{
@@ -216,28 +167,6 @@ void Grid_Technique::cal_nnrg()
216167
const int b1 = GlobalC::GridD.getBox(ad).x;
217168
const int b2 = GlobalC::GridD.getBox(ad).y;
218169
const int b3 = GlobalC::GridD.getBox(ad).z;
219-
220-
// for test
221-
/*
222-
if( this->cal_RindexAtom(b1, b2, b3, iat2) == 232 )
223-
{
224-
std::cout << " ====== nnrg =========" << std::endl;
225-
std::cout << " index=" << cal_RindexAtom(b1, b2, b3, iat2) << std::endl;
226-
std::cout << " iat=" << iat << " iat2=" << iat2 << std::endl;
227-
std::cout << " R1 = " << tau1.x << " " << tau1.y << " " << tau1.z << std::endl;
228-
std::cout << " R2 = " << GlobalC::GridD.getAdjacentTau(ad).x
229-
<< " " << GlobalC::GridD.getAdjacentTau(ad).y
230-
<< " " << GlobalC::GridD.getAdjacentTau(ad).z << std::endl;
231-
std::cout << std::setprecision(25);
232-
std::cout << " distance = " << distance << std::endl;
233-
std::cout << " box = " << b1 << " " << b2 << " " << b3 << std::endl;
234-
std::cout << " rcut = " << rcut << std::endl;
235-
}
236-
*/
237-
238-
239-
//std::cout << " iat=" << iat << " find_R2=" << this->cal_RindexAtom(b1, b2, b3, iat2) <<
240-
// " b1=" << b1 << " b2=" << b2 << " b3=" << b3 << " iat2=" << iat2 << " distance=" << distance << std::endl;
241170

242171
// mohan fix bug 2011-06-26, should be '<', not '<='
243172
// if(distance < rcut)
@@ -258,19 +187,6 @@ void Grid_Technique::cal_nnrg()
258187
find_R2[iat][count] = this->cal_RindexAtom(b1, b2, b3, iat2);
259188

260189

261-
/*if(iat==50 && iat2==96)
262-
{
263-
GlobalV::ofs_running << " ************** iat=" << iat << " count=" << count << " find_R2=" << find_R2[iat][count] <<
264-
" b1=" << b1 << " b2=" << b2 << " b3=" << b3 << " iat2=" << iat2 << " distance=" << distance
265-
<< " rcut=" << rcut <<std::endl;
266-
}
267-
else if(find_R2[iat][count]==10536)
268-
{
269-
GlobalV::ofs_running << " ************** iat=" << iat << " count=" << count << " find_R2=" << find_R2[iat][count] <<
270-
" b1=" << b1 << " b2=" << b2 << " b3=" << b3 << " iat2=" << iat2 << " distance=" << distance
271-
<< " rcut=" << rcut <<std::endl;
272-
}*/
273-
274190
// find_R2st
275191
// note: the first must be zero.
276192
// find_R2st: start position of each adjacen atom.
@@ -287,21 +203,6 @@ void Grid_Technique::cal_nnrg()
287203
}
288204
}
289205

290-
//---------
291-
// for test
292-
//---------
293-
/*
294-
GlobalV::ofs_running << " print find_R2 " << std::endl;
295-
for(int i=0; i<GlobalC::ucell.nat; i++)
296-
{
297-
for(int j=0; j<nad[i]; j++)
298-
{
299-
GlobalV::ofs_running << " i=" << i << " j=" << j << " find_R2=" << find_R2[i][j] << std::endl;
300-
}
301-
}
302-
GlobalV::ofs_running << std::endl;
303-
*/
304-
305206
return;
306207
}
307208

@@ -330,25 +231,10 @@ void Grid_Technique::cal_max_box_index(void)
330231
}
331232
}
332233

333-
/*
334-
ModuleBase::GlobalFunc::OUT(GlobalV::ofs_running,"maxB1",maxB1);
335-
ModuleBase::GlobalFunc::OUT(GlobalV::ofs_running,"maxB2",maxB2);
336-
ModuleBase::GlobalFunc::OUT(GlobalV::ofs_running,"maxB3",maxB3);
337-
ModuleBase::GlobalFunc::OUT(GlobalV::ofs_running,"minB1",minB1);
338-
ModuleBase::GlobalFunc::OUT(GlobalV::ofs_running,"minB2",minB2);
339-
ModuleBase::GlobalFunc::OUT(GlobalV::ofs_running,"minB3",minB3);
340-
*/
341-
342234
nB1 = maxB1-minB1+1;
343235
nB2 = maxB2-minB2+1;
344236
nB3 = maxB3-minB3+1;
345237

346-
/*
347-
ModuleBase::GlobalFunc::OUT(GlobalV::ofs_running,"nB1",nB1);
348-
ModuleBase::GlobalFunc::OUT(GlobalV::ofs_running,"nB2",nB2);
349-
ModuleBase::GlobalFunc::OUT(GlobalV::ofs_running,"nB3",nB3);
350-
*/
351-
352238
nbox = nB1 * nB2 * nB3;
353239

354240
//ModuleBase::GlobalFunc::OUT(GlobalV::ofs_running,"nbox",nbox);

source/src_lcao/gint_gamma.h

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ class Gint_Gamma : public Grid_Base_Beta
3535

3636
// (3) calcualte the forces related to grid
3737
void cal_force( const double*const vlocal);
38+
void cal_force_new(double** DM_in, const double*const vlocal, ModuleBase::matrix& force);
3839

3940
// (4) calcualte the envelope function
4041
void cal_env(const double* wfc, double* rho);
@@ -106,6 +107,7 @@ class Gint_Gamma : public Grid_Base_Beta
106107
// for calculatin of < dphi_i | Vlocal | phi_j > for foce calculation
107108
// on regular FFT real space grid.
108109
void gamma_force(const double*const vlocal) const;
110+
void gamma_force_new(const double*const*const DM, const double*const vlocal, ModuleBase::matrix& force);
109111

110112
void cal_meshball_vlocal(
111113
const int na_grid, // how many atoms on this (i,j,k) grid
@@ -131,7 +133,22 @@ class Gint_Gamma : public Grid_Base_Beta
131133
const int*const vindex, // vindex[GlobalC::pw.bxyz]
132134
const double*const*const*const DM, // DM[GlobalV::NSPIN][lgd_now][lgd_now]
133135
Gint_Tools::Array_Pool<double> &rho) const; // rho[GlobalV::NSPIN][GlobalC::pw.nrxx]
134-
136+
137+
void cal_meshball_force(
138+
const int grid_index,
139+
const int na_grid, // how many atoms on this (i,j,k) grid
140+
const int LD_pool,
141+
const int*const block_iw, // block_iw[na_grid], index of wave functions for each block
142+
const int*const block_size, // block_size[na_grid], number of columns of a band
143+
const int*const block_index, // block_index[na_grid+1], count total number of atomis orbitals
144+
const bool*const*const cal_flag, // cal_flag[GlobalC::pw.bxyz][na_grid], whether the atom-grid distance is larger than cutoff
145+
const double*const*const psir_vlbr3, // psir_vlbr3[GlobalC::pw.bxyz][LD_pool]
146+
const double*const*const dpsir_x, // psir_vlbr3[GlobalC::pw.bxyz][LD_pool]
147+
const double*const*const dpsir_y, // psir_vlbr3[GlobalC::pw.bxyz][LD_pool]
148+
const double*const*const dpsir_z, // psir_vlbr3[GlobalC::pw.bxyz][LD_pool]
149+
const double*const*const DM,
150+
ModuleBase::matrix &force);
151+
135152
// extract the local potentials.
136153
// vldr3[GlobalC::pw.bxyz]
137154
double* get_vldr3(const double* const vlocal, const int ncyz, const int ibx, const int jby, const int kbz) const;

0 commit comments

Comments
 (0)