Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions source/module_hamilt_general/module_xc/xc_functional_libxc.h
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ namespace XC_Functional_Libxc
std::vector<double> exc);

// converting vtxc and v from vrho and vsigma (libxc=>abacus)
extern double convert_vtxc_v(
extern std::pair<double,ModuleBase::matrix> convert_vtxc_v(
const xc_func_type &func,
const int nspin,
const std::size_t nrxx,
Expand All @@ -106,8 +106,7 @@ namespace XC_Functional_Libxc
const std::vector<double> &vrho,
const std::vector<double> &vsigma,
const double tpiba,
const Charge* const chr,
ModuleBase::matrix &v);
const Charge* const chr);

// dh for gga v
extern std::vector<std::vector<double>> cal_dh(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -163,8 +163,8 @@ double XC_Functional_Libxc::convert_etxc(
return etxc;
}

// converting etxc from exc (libxc=>abacus)
double XC_Functional_Libxc::convert_vtxc_v(
// converting vtxc and v from vrho and vsigma (libxc=>abacus)
std::pair<double,ModuleBase::matrix> XC_Functional_Libxc::convert_vtxc_v(
const xc_func_type &func,
const int nspin,
const std::size_t nrxx,
Expand All @@ -174,13 +174,10 @@ double XC_Functional_Libxc::convert_vtxc_v(
const std::vector<double> &vrho,
const std::vector<double> &vsigma,
const double tpiba,
const Charge* const chr,
ModuleBase::matrix &v)
const Charge* const chr)
{
assert(v.nr==nspin);
assert(v.nc==nrxx);

double vtxc = 0.0;
ModuleBase::matrix v(nspin, nrxx);

#ifdef _OPENMP
#pragma omp parallel for collapse(2) reduction(+:vtxc) schedule(static, 256)
Expand Down Expand Up @@ -215,7 +212,7 @@ double XC_Functional_Libxc::convert_vtxc_v(
vtxc -= rvtxc;
} // end if(func.info->family == XC_FAMILY_GGA || func.info->family == XC_FAMILY_HYB_GGA))

return vtxc;
return std::make_pair(vtxc, std::move(v));
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,12 +110,13 @@ std::tuple<double,double,ModuleBase::matrix> XC_Functional_Libxc::v_xc_libxc( /
}

etxc += XC_Functional_Libxc::convert_etxc(nspin, nrxx, sgn, rho, exc);
vtxc += XC_Functional_Libxc::convert_vtxc_v(
const std::pair<double,ModuleBase::matrix> vtxc_v = XC_Functional_Libxc::convert_vtxc_v(
func, nspin, nrxx,
sgn, rho, gdr,
vrho, vsigma,
tpiba, chr,
v);
tpiba, chr);
vtxc += std::get<0>(vtxc_v);
v += std::get<1>(vtxc_v);
} // end for( xc_func_type &func : funcs )

if(4==PARAM.inp.nspin)
Expand Down
Loading