Skip to content

Commit e373a3d

Browse files
wenfei-liwenfei-li
andauthored
Fix : dftu force and stress (#1868)
* Fix : force matrix not allocated but used * fix : calling finish_k after dftu force & stress --------- Co-authored-by: wenfei-li <[email protected]>
1 parent 3913b5f commit e373a3d

File tree

3 files changed

+5
-17
lines changed

3 files changed

+5
-17
lines changed

source/module_hamilt_lcao/hamilt_lcaodft/FORCE_STRESS.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,8 @@ void Force_Stress_LCAO::getForceStress(
196196
}
197197
GlobalC::dftu.force_stress(loc.dm_gamma, loc.dm_k, *uhm.LM, force_dftu, stress_dftu);
198198
}
199+
200+
if(!GlobalV::GAMMA_ONLY_LOCAL) this->flk.finish_k();
199201
#ifdef __EXX
200202
//Force and Stress contribution from exx
201203
ModuleBase::matrix force_exx;
@@ -583,7 +585,7 @@ void Force_Stress_LCAO::getForceStress(
583585
}
584586
if(GlobalV::dft_plus_u)
585587
{
586-
sc_pw.print_stress("DFTU STRESS",sigmaxc,GlobalV::TEST_STRESS,ry);
588+
sc_pw.print_stress("DFTU STRESS",stress_dftu,GlobalV::TEST_STRESS,ry);
587589
}
588590
sc_pw.print_stress("TOTAL STRESS",scs,GlobalV::TEST_STRESS,ry);
589591

source/module_hamilt_lcao/hamilt_lcaodft/FORCE_k.cpp

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -177,18 +177,6 @@ void Force_LCAO_k::ftable_k(const bool isforce,
177177
Parallel_Reduce::reduce_double_pool(svl_dphi.c, svl_dphi.nr * svl_dphi.nc);
178178
}
179179

180-
// test the force.
181-
/*
182-
std::cout << " overlap force" << std::endl;
183-
for(int iat=0; iat<GlobalC::ucell.nat; ++iat)
184-
{
185-
const double fac = ModuleBase::Ry_to_eV / 0.529177;
186-
std::cout << std::setw(5) << iat+1 << std::setw(15) << foverlap[iat][0] *fac<< std::setw(15) <<
187-
foverlap[iat][1]*fac << std::setw(15) << foverlap[iat][2]*fac << std::endl;
188-
}
189-
*/
190-
191-
this->finish_k();
192180

193181
ModuleBase::timer::tick("Force_LCAO_k", "ftable_k");
194182
return;

source/module_hamilt_lcao/module_dftu/dftu_folding.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -189,15 +189,13 @@ void DFTU::folding_matrix_k(const int ik, const int dim1, const int dim2, std::c
189189
// the index of orbitals in this processor
190190
const int iw1_all = start1 + ii;
191191
const int mu = this->LM->ParaV->trace_loc_row[iw1_all];
192-
if (mu < 0)
193-
continue;
192+
if (mu < 0) continue;
194193

195194
for (int jj = 0; jj < atom2->nw * GlobalV::NPOL; jj++)
196195
{
197196
int iw2_all = start2 + jj;
198197
const int nu = this->LM->ParaV->trace_loc_col[iw2_all];
199-
if (nu < 0)
200-
continue;
198+
if (nu < 0) continue;
201199

202200
int iic;
203201
if (ModuleBase::GlobalFunc::IS_COLUMN_MAJOR_KS_SOLVER())

0 commit comments

Comments
 (0)