diff --git a/source/source_lcao/FORCE_STRESS.cpp b/source/source_lcao/FORCE_STRESS.cpp index e0513e3663..dddfe9e24b 100644 --- a/source/source_lcao/FORCE_STRESS.cpp +++ b/source/source_lcao/FORCE_STRESS.cpp @@ -23,7 +23,7 @@ #include "source_lcao/module_operator_lcao/nonlocal_new.h" template -Force_Stress_LCAO::Force_Stress_LCAO(Record_adj& ra, const int nat_in) : RA(&ra), f_pw(nat_in), nat(nat_in) +Force_Stress_LCAO::Force_Stress_LCAO(Record_adj& ra, const int nat_in) : RA(&ra), nat(nat_in) { } template @@ -811,24 +811,39 @@ void Force_Stress_LCAO::calForcePwPart(UnitCell& ucell, const Structure_Factor& sf) { ModuleBase::TITLE("Force_Stress_LCAO", "calForcePwPart"); - //-------------------------------------------------------- - // local pseudopotential force: - // use charge density; plane wave; local pseudopotential; - //-------------------------------------------------------- - f_pw.cal_force_loc(ucell, fvl_dvl, rhopw, locpp.vloc, chr); - //-------------------------------------------------------- - // ewald force: use plane wave only. - //-------------------------------------------------------- - f_pw.cal_force_ew(ucell, fewalds, rhopw, &sf); // remain problem +#ifdef __CUDA + if(PARAM.inp.device == "gpu") + { + Forces f_pw(nat); + + //-------------------------------------------------------- + // local pseudopotential force: + // use charge density; plane wave; local pseudopotential; + //-------------------------------------------------------- + f_pw.cal_force_loc(ucell, fvl_dvl, rhopw, locpp.vloc, chr); + //-------------------------------------------------------- + // ewald force: use plane wave only. + //-------------------------------------------------------- + f_pw.cal_force_ew(ucell, fewalds, rhopw, &sf); // remain problem + + //-------------------------------------------------------- + // force due to core correlation. + //-------------------------------------------------------- + f_pw.cal_force_cc(fcc, rhopw, chr, locpp.numeric, ucell); + //-------------------------------------------------------- + // force due to self-consistent charge. + //-------------------------------------------------------- + f_pw.cal_force_scc(fscc, rhopw, vnew, vnew_exist, locpp.numeric, ucell); + } else +#endif + { + Forces f_pw(nat); + f_pw.cal_force_loc(ucell, fvl_dvl, rhopw, locpp.vloc, chr); + f_pw.cal_force_ew(ucell, fewalds, rhopw, &sf); // remain problem + f_pw.cal_force_cc(fcc, rhopw, chr, locpp.numeric, ucell); + f_pw.cal_force_scc(fscc, rhopw, vnew, vnew_exist, locpp.numeric, ucell); + } - //-------------------------------------------------------- - // force due to core correlation. - //-------------------------------------------------------- - f_pw.cal_force_cc(fcc, rhopw, chr, locpp.numeric, ucell); - //-------------------------------------------------------- - // force due to self-consistent charge. - //-------------------------------------------------------- - f_pw.cal_force_scc(fscc, rhopw, vnew, vnew_exist, locpp.numeric, ucell); return; } diff --git a/source/source_lcao/FORCE_STRESS.h b/source/source_lcao/FORCE_STRESS.h index 33207a56d7..d2400d7b69 100644 --- a/source/source_lcao/FORCE_STRESS.h +++ b/source/source_lcao/FORCE_STRESS.h @@ -63,7 +63,6 @@ class Force_Stress_LCAO Record_adj* RA; Force_LCAO flk; Stress_Func sc_pw; - Forces f_pw; void forceSymmetry(const UnitCell& ucell, ModuleBase::matrix& fcs, ModuleSymmetry::Symmetry* symm);