Skip to content

Commit e1958cb

Browse files
authored
Fix memory bug in XC_Functional_Libxc::cal_gdr() (#5208)
1 parent c212bdf commit e1958cb

File tree

3 files changed

+4
-3
lines changed

3 files changed

+4
-3
lines changed

source/module_hamilt_general/module_xc/xc_functional_libxc.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ namespace XC_Functional_Libxc
6868
// calculating grho
6969
extern std::vector<std::vector<ModuleBase::Vector3<double>>> cal_gdr(
7070
const int nspin,
71+
const std::size_t nrxx,
7172
const std::vector<double> &rho,
7273
const double tpiba,
7374
const Charge* const chr);

source/module_hamilt_general/module_xc/xc_functional_libxc_tools.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,12 +51,12 @@ XC_Functional_Libxc::convert_rho_amag_nspin4(
5151
std::vector<std::vector<ModuleBase::Vector3<double>>>
5252
XC_Functional_Libxc::cal_gdr(
5353
const int nspin,
54+
const std::size_t nrxx,
5455
const std::vector<double> &rho,
5556
const double tpiba,
5657
const Charge* const chr)
5758
{
5859
std::vector<std::vector<ModuleBase::Vector3<double>>> gdr(nspin);
59-
const std::size_t nrxx = rho.size();
6060
for( int is=0; is!=nspin; ++is )
6161
{
6262
std::vector<double> rhor(nrxx);

source/module_hamilt_general/module_xc/xc_functional_libxc_vxc.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ std::tuple<double,double,ModuleBase::matrix> XC_Functional_Libxc::v_xc_libxc( /
6868
std::vector<double> sigma;
6969
if(is_gga)
7070
{
71-
gdr = XC_Functional_Libxc::cal_gdr(nspin, rho, tpiba, chr);
71+
gdr = XC_Functional_Libxc::cal_gdr(nspin, nrxx, rho, tpiba, chr);
7272
sigma = XC_Functional_Libxc::convert_sigma(gdr);
7373
}
7474

@@ -183,7 +183,7 @@ std::tuple<double,double,ModuleBase::matrix,ModuleBase::matrix> XC_Functional_Li
183183

184184
const std::vector<double> rho = XC_Functional_Libxc::convert_rho(nspin, nrxx, chr);
185185
const std::vector<std::vector<ModuleBase::Vector3<double>>> gdr
186-
= XC_Functional_Libxc::cal_gdr(nspin, rho, tpiba, chr);
186+
= XC_Functional_Libxc::cal_gdr(nspin, nrxx, rho, tpiba, chr);
187187
const std::vector<double> sigma = XC_Functional_Libxc::convert_sigma(gdr);
188188

189189
//converting kin_r

0 commit comments

Comments
 (0)