Skip to content

Commit

Permalink
Try to not parallel v(r) and m(r) in gga_grad = 2
Browse files Browse the repository at this point in the history
  • Loading branch information
dyzheng committed Dec 21, 2024
1 parent 687bc78 commit 5bda87e
Showing 1 changed file with 19 additions and 5 deletions.
24 changes: 19 additions & 5 deletions source/module_hamilt_general/module_xc/xc_functional_gradcorr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -622,6 +622,8 @@ void XC_Functional::gradcorr(double& etxc,
}
vtxcgc -= sum;

sum = 0.0;

for(int is=1;is<4;is++)
{
const double* mag_part_is = &mag_part[(is - 1) * rhopw->nrxx];
Expand All @@ -632,26 +634,38 @@ void XC_Functional::gradcorr(double& etxc,
XC_Functional::grad_dot(tmp_h, dh, rhopw, ucell->tpiba);
for(int ir=0;ir<rhopw->nrxx;ir++)
{
dh1[ir] += dh[ir] * mag_part_is[ir];
//double v_is_ir = 0.0;
//double m_norm = rhotmp1[ir] - rhotmp2[ir];
//if(m_norm > epsr)
//for(int t=0;t<3;t++)
//{
//v_is_ir += 0.5 * (gdr_mag[ir + (is-1) * rhopw->nrxx][t] / m_norm * (h1[ir] + h2[ir])[t] - mag_part_is[ir] / m_norm * (h1[ir] - h2[ir])[t] * (gdr1[ir][t] - gdr2[ir][t]));
//std::cout<<__FILE__<<__LINE__<<" "<<is<<" "<<ir<<" "<<t<<" "<<v_is_ir<<std::endl;
//}
//std::cout<<__FILE__<<__LINE__<<" "<<is<<" "<<ir<<" "<<v_is_ir<<" "<<dh[ir]<<std::endl;
//v_is_ir -= dh[ir];
//v(is,ir) += v_is_ir;
v(is,ir) -= dh[ir];
sum -= dh[ir] * chr->rho[is][ir];
//dh1[ir] += dh[ir] * mag_part_is[ir];
}
}
for(int is=1;is<4;is++)
/*for(int is=1;is<4;is++)
{
const double* mag_part_is = &mag_part[(is - 1) * rhopw->nrxx];
for(int ir=0;ir<rhopw->nrxx;ir++)
{
v(is,ir) -= dh1[ir] * mag_part_is[ir];
}
}
sum = 0.0;
#ifdef _OPENMP
#pragma omp parallel for reduction(+ : sum) schedule(static, 256)
#endif
for (int ir = 0; ir < rhopw->nrxx; ir++)
{
sum += dh1[ir] * (rhotmp1[ir] - rhotmp2[ir]);
}
vtxcgc -= sum;
}*/
vtxcgc += sum;

delete[] dh;
delete[] dh1;
Expand Down

0 comments on commit 5bda87e

Please sign in to comment.