diff --git a/source/source_estate/module_pot/pot_xc.cpp b/source/source_estate/module_pot/pot_xc.cpp index 4888380f23..c456b0b206 100644 --- a/source/source_estate/module_pot/pot_xc.cpp +++ b/source/source_estate/module_pot/pot_xc.cpp @@ -2,6 +2,7 @@ #include "source_base/timer.h" #include "source_hamilt/module_xc/xc_functional.h" +#include "source_io/module_parameter/parameter.h" #ifdef USE_LIBXC #include "source_hamilt/module_xc/libxc_abacus.h" @@ -24,7 +25,8 @@ void PotXC::cal_v_eff(const Charge*const chg, const UnitCell*const ucell, Module { #ifdef USE_LIBXC const std::tuple etxc_vtxc_v - = XC_Functional_Libxc::v_xc_meta(XC_Functional::get_func_id(), nrxx_current, ucell->omega, ucell->tpiba, chg); + = XC_Functional_Libxc::v_xc_meta(XC_Functional::get_func_id(), nrxx_current, ucell->omega, ucell->tpiba, chg, + PARAM.inp.nspin); *(this->etxc_) = std::get<0>(etxc_vtxc_v); *(this->vtxc_) = std::get<1>(etxc_vtxc_v); v_eff += std::get<2>(etxc_vtxc_v); @@ -36,7 +38,10 @@ void PotXC::cal_v_eff(const Charge*const chg, const UnitCell*const ucell, Module else { const std::tuple etxc_vtxc_v - = XC_Functional::v_xc(nrxx_current, chg, ucell); + = XC_Functional::v_xc(nrxx_current, chg, ucell, + PARAM.inp.nspin, + PARAM.globalv.domag, + PARAM.globalv.domag_z); *(this->etxc_) = std::get<0>(etxc_vtxc_v); *(this->vtxc_) = std::get<1>(etxc_vtxc_v); v_eff += std::get<2>(etxc_vtxc_v); diff --git a/source/source_estate/module_pot/pot_xc_fdm.cpp b/source/source_estate/module_pot/pot_xc_fdm.cpp index d0a49cc101..aa950669d5 100644 --- a/source/source_estate/module_pot/pot_xc_fdm.cpp +++ b/source/source_estate/module_pot/pot_xc_fdm.cpp @@ -5,6 +5,7 @@ #include "pot_xc_fdm.h" #include "source_hamilt/module_xc/xc_functional.h" +#include "source_io/module_parameter/parameter.h" namespace elecstate { @@ -20,7 +21,10 @@ PotXC_FDM::PotXC_FDM( this->fixed_mode = false; const std::tuple etxc_vtxc_v_0 - = XC_Functional::v_xc(this->chg_0->nrxx, this->chg_0, ucell); + = XC_Functional::v_xc(this->chg_0->nrxx, this->chg_0, ucell, + PARAM.inp.nspin, + PARAM.globalv.domag, + PARAM.globalv.domag_z); this->v_xc_0 = std::get<2>(etxc_vtxc_v_0); } @@ -47,7 +51,10 @@ void PotXC_FDM::cal_v_eff( } const std::tuple etxc_vtxc_v_01 - = XC_Functional::v_xc(chg_01.nrxx, &chg_01, ucell); + = XC_Functional::v_xc(chg_01.nrxx, &chg_01, ucell, + PARAM.inp.nspin, + PARAM.globalv.domag, + PARAM.globalv.domag_z); const ModuleBase::matrix &v_xc_01 = std::get<2>(etxc_vtxc_v_01); v_eff += v_xc_01 - this->v_xc_0; diff --git a/source/source_hamilt/module_xc/libxc_abacus.h b/source/source_hamilt/module_xc/libxc_abacus.h index 652293cd22..984e34e539 100644 --- a/source/source_hamilt/module_xc/libxc_abacus.h +++ b/source/source_hamilt/module_xc/libxc_abacus.h @@ -60,7 +60,10 @@ namespace XC_Functional_Libxc const double &omega, // volume of cell const double tpiba, const Charge* const chr, // charge density - const std::map* scaling_factor = nullptr); // added by jghan, 2024-10-10 + const std::map* scaling_factor = nullptr, // added by jghan, 2024-10-10 + const int nspin = 1, + const bool domag = false, + const bool domag_z = false); // for mGGA functional extern std::tuple v_xc_meta( @@ -68,7 +71,8 @@ namespace XC_Functional_Libxc const int &nrxx, // number of real-space grid const double &omega, // volume of cell const double tpiba, - const Charge* const chr); + const Charge* const chr, + const int nspin = 1); //------------------- diff --git a/source/source_hamilt/module_xc/libxc_pot.cpp b/source/source_hamilt/module_xc/libxc_pot.cpp index 9ff7190764..60f6ee6a79 100644 --- a/source/source_hamilt/module_xc/libxc_pot.cpp +++ b/source/source_hamilt/module_xc/libxc_pot.cpp @@ -19,13 +19,16 @@ std::tuple XC_Functional_Libxc::v_xc_libxc( / const double &omega, // volume of cell const double tpiba, const Charge* const chr, - const std::map* scaling_factor) + const std::map* scaling_factor, + const int nspin_in, + const bool domag, + const bool domag_z) { ModuleBase::TITLE("XC_Functional_Libxc","v_xc_libxc"); ModuleBase::timer::start("XC_Functional_Libxc","v_xc_libxc"); const int nspin = - (PARAM.inp.nspin == 1 || ( PARAM.inp.nspin ==4 && !PARAM.globalv.domag && !PARAM.globalv.domag_z)) + (nspin_in == 1 || ( nspin_in ==4 && !domag && !domag_z)) ? 1 : 2; //---------------------------------------------------------- @@ -56,7 +59,7 @@ std::tuple XC_Functional_Libxc::v_xc_libxc( / // converting rho std::vector rho; std::vector amag; - if(1==nspin || 2==PARAM.inp.nspin) + if(1==nspin || 2==nspin_in) { rho = XC_Functional_Libxc::convert_rho(nspin, nrxx, chr); } @@ -167,7 +170,7 @@ std::tuple XC_Functional_Libxc::v_xc_libxc( / v += std::get<1>(vtxc_v) * factor; } // end for( xc_func_type &func : funcs ) - if(4==PARAM.inp.nspin) + if(4==nspin_in) { v = XC_Functional_Libxc::convert_v_nspin4(nrxx, chr, amag, v); } @@ -207,7 +210,8 @@ std::tuple XC_Functional_Li const int &nrxx, // number of real-space grid const double &omega, // volume of cell const double tpiba, - const Charge* const chr) + const Charge* const chr, + const int nspin) { ModuleBase::TITLE("XC_Functional_Libxc","v_xc_meta"); ModuleBase::timer::start("XC_Functional_Libxc","v_xc_meta"); @@ -217,8 +221,8 @@ std::tuple XC_Functional_Li //output of the subroutine double etxc = 0.0; double vtxc = 0.0; - ModuleBase::matrix v(PARAM.inp.nspin,nrxx); - ModuleBase::matrix vofk(PARAM.inp.nspin,nrxx); + ModuleBase::matrix v(nspin,nrxx); + ModuleBase::matrix vofk(nspin,nrxx); //---------------------------------------------------------- // xc_func_type is defined in Libxc package @@ -226,8 +230,6 @@ std::tuple XC_Functional_Li // use can check on website, for example: // https://www.tddft.org/programs/libxc/manual/libxc-5.1.x/ //---------------------------------------------------------- - - const int nspin = PARAM.inp.nspin; std::vector funcs = XC_Functional_Libxc::init_func( /* func_id = */ func_id, /* xc_polarized = */ (1==nspin) ? XC_UNPOLARIZED:XC_POLARIZED); diff --git a/source/source_hamilt/module_xc/test/test_xc3.cpp b/source/source_hamilt/module_xc/test/test_xc3.cpp index 96a67e785c..d12182c838 100644 --- a/source/source_hamilt/module_xc/test/test_xc3.cpp +++ b/source/source_hamilt/module_xc/test/test_xc3.cpp @@ -1,8 +1,5 @@ #include "gtest/gtest.h" #include "xctest.h" -#define private public -#include "source_io/module_parameter/parameter.h" -#undef private #include "../xc_functional.h" #include "../exx_info.h" #include "xc3_mock.h" @@ -82,19 +79,15 @@ class XCTest_GRADCORR : public XCTest v4.create(4,5); v4.zero_out(); - XC_Functional::set_xc_type("PBE"); + XC_Functional::set_xc_type("PBE", 1); - PARAM.input.nspin = 1; - XC_Functional::gradcorr(et1,vt1,v1,&chr,&rhopw,&ucell,stress1,false); - XC_Functional::gradcorr(et1,vt1,v1,&chr,&rhopw,&ucell,stress1,true); + XC_Functional::gradcorr(et1,vt1,v1,&chr,&rhopw,&ucell,stress1,false,1,false,false); + XC_Functional::gradcorr(et1,vt1,v1,&chr,&rhopw,&ucell,stress1,true,1,false,false); - PARAM.input.nspin = 2; - XC_Functional::gradcorr(et2,vt2,v2,&chr,&rhopw,&ucell,stress2,false); - XC_Functional::gradcorr(et2,vt2,v2,&chr,&rhopw,&ucell,stress2,true); + XC_Functional::gradcorr(et2,vt2,v2,&chr,&rhopw,&ucell,stress2,false,2,false,false); + XC_Functional::gradcorr(et2,vt2,v2,&chr,&rhopw,&ucell,stress2,true,2,false,false); - PARAM.input.nspin = 4; - PARAM.sys.domag = true; - XC_Functional::gradcorr(et4,vt4,v4,&chr,&rhopw,&ucell,stress4,false); + XC_Functional::gradcorr(et4,vt4,v4,&chr,&rhopw,&ucell,stress4,false,4,true,false); } }; diff --git a/source/source_hamilt/module_xc/test/test_xc5.cpp b/source/source_hamilt/module_xc/test/test_xc5.cpp index 469b3dcc20..ac85bed5dd 100644 --- a/source/source_hamilt/module_xc/test/test_xc5.cpp +++ b/source/source_hamilt/module_xc/test/test_xc5.cpp @@ -1,9 +1,6 @@ #include "../xc_functional.h" #include "../libxc_abacus.h" #include "gtest/gtest.h" -#define private public -#include "source_io/module_parameter/parameter.h" -#undef private #include "xctest.h" #include "../exx_info.h" #include "xc3_mock.h" @@ -73,18 +70,16 @@ class XCTest_VXC : public XCTest rhopw.gcar[i]= 1; } - XC_Functional::set_xc_type("PBE"); + XC_Functional::set_xc_type("PBE", 1); - PARAM.input.nspin = 1; std::tuple etxc_vtxc_v - = XC_Functional::v_xc(rhopw.nrxx,&chr,&ucell); + = XC_Functional::v_xc(rhopw.nrxx,&chr,&ucell,1,false,false); et1 = std::get<0>(etxc_vtxc_v); vt1 = std::get<1>(etxc_vtxc_v); v1 = std::get<2>(etxc_vtxc_v); - PARAM.input.nspin = 2; etxc_vtxc_v - = XC_Functional::v_xc(rhopw.nrxx,&chr,&ucell); + = XC_Functional::v_xc(rhopw.nrxx,&chr,&ucell,2,false,false); et2 = std::get<0>(etxc_vtxc_v); vt2 = std::get<1>(etxc_vtxc_v); v2 = std::get<2>(etxc_vtxc_v); @@ -171,18 +166,16 @@ class XCTest_VXC_Libxc : public XCTest rhopw.gcar[i]= 1; } - XC_Functional::set_xc_type("GGA_X_PBE+GGA_C_PBE"); + XC_Functional::set_xc_type("GGA_X_PBE+GGA_C_PBE", 1); - PARAM.input.nspin = 1; std::tuple etxc_vtxc_v - = XC_Functional::v_xc(rhopw.nrxx,&chr,&ucell); + = XC_Functional::v_xc(rhopw.nrxx,&chr,&ucell,1,false,false); et1 = std::get<0>(etxc_vtxc_v); vt1 = std::get<1>(etxc_vtxc_v); v1 = std::get<2>(etxc_vtxc_v); - PARAM.input.nspin = 2; etxc_vtxc_v - = XC_Functional::v_xc(rhopw.nrxx,&chr,&ucell); + = XC_Functional::v_xc(rhopw.nrxx,&chr,&ucell,2,false,false); et2 = std::get<0>(etxc_vtxc_v); vt2 = std::get<1>(etxc_vtxc_v); v2 = std::get<2>(etxc_vtxc_v); @@ -279,19 +272,17 @@ class XCTest_VXC_meta : public XCTest chr.kin_r[1][3] = 0.51340429824; chr.kin_r[1][4] = 0.51141731056; - XC_Functional::set_xc_type("SCAN"); + XC_Functional::set_xc_type("SCAN", 1); - PARAM.input.nspin = 1; std::tuple etxc_vtxc_v - = XC_Functional_Libxc::v_xc_meta(XC_Functional::get_func_id(), rhopw.nrxx,ucell.omega,ucell.tpiba,&chr); + = XC_Functional_Libxc::v_xc_meta(XC_Functional::get_func_id(), rhopw.nrxx,ucell.omega,ucell.tpiba,&chr,1); et1 = std::get<0>(etxc_vtxc_v); vt1 = std::get<1>(etxc_vtxc_v); v1 = std::get<2>(etxc_vtxc_v); vtau1 = std::get<3>(etxc_vtxc_v); - PARAM.input.nspin = 2; etxc_vtxc_v - = XC_Functional_Libxc::v_xc_meta(XC_Functional::get_func_id(), rhopw.nrxx,ucell.omega,ucell.tpiba,&chr); + = XC_Functional_Libxc::v_xc_meta(XC_Functional::get_func_id(), rhopw.nrxx,ucell.omega,ucell.tpiba,&chr,2); et2 = std::get<0>(etxc_vtxc_v); vt2 = std::get<1>(etxc_vtxc_v); v2 = std::get<2>(etxc_vtxc_v); diff --git a/source/source_hamilt/module_xc/test/xctest.h b/source/source_hamilt/module_xc/test/xctest.h index 07ae4512c3..608edbe72b 100644 --- a/source/source_hamilt/module_xc/test/xctest.h +++ b/source/source_hamilt/module_xc/test/xctest.h @@ -1,17 +1,9 @@ #ifndef XCTEST_H #define XCTEST_H #include "gtest/gtest.h" -#define private public -#include "source_io/module_parameter/parameter.h" -#undef private class XCTest: public testing::Test { public: - XCTest() - { - PARAM.input.basis_type = ""; - PARAM.input.cal_force = 0; - PARAM.input.cal_stress = 0; - } + XCTest() {} }; #endif \ No newline at end of file diff --git a/source/source_hamilt/module_xc/xc_functional.cpp b/source/source_hamilt/module_xc/xc_functional.cpp index a2042b6933..bb964ad7d9 100644 --- a/source/source_hamilt/module_xc/xc_functional.cpp +++ b/source/source_hamilt/module_xc/xc_functional.cpp @@ -57,7 +57,9 @@ method. */ // The setting values of functional id according to the index in LIBXC // for detail, refer to https://www.tddft.org/programs/libxc/functionals/ -void XC_Functional::set_xc_type(const std::string xc_func_in) +void XC_Functional::set_xc_type(const std::string xc_func_in, + const int nspin /*= 1*/, + const std::string basis_type /*= "pw"*/) { ModuleBase::TITLE("XC_Functional", "set_xc_type"); //Note : due to the separation of gcx_spin and gcc_spin, @@ -301,17 +303,17 @@ void XC_Functional::set_xc_type(const std::string xc_func_in) std::cerr << "\n OPTX untested please test,"; } - // if((func_type == 4 || func_type == 5) && PARAM.inp.basis_type == "pw") + // if((func_type == 4 || func_type == 5) && basis_type == "pw") // { // ModuleBase::WARNING_QUIT("set_xc_type","hybrid functional not realized for planewave yet"); // } - if((func_type == 3 || func_type == 5) && PARAM.inp.nspin==4) + if((func_type == 3 || func_type == 5) && nspin==4) { ModuleBase::WARNING_QUIT("set_xc_type","meta-GGA has not been implemented for nspin = 4 yet"); } #ifndef __EXX - if((func_type == 4 || func_type == 5) && PARAM.inp.basis_type == "lcao") + if((func_type == 4 || func_type == 5) && basis_type == "lcao") { ModuleBase::WARNING_QUIT("set_xc_type","compile with libri to use hybrid functional in lcao basis"); } diff --git a/source/source_hamilt/module_xc/xc_functional.h b/source/source_hamilt/module_xc/xc_functional.h index 37695900a9..715fcf1ca0 100644 --- a/source/source_hamilt/module_xc/xc_functional.h +++ b/source/source_hamilt/module_xc/xc_functional.h @@ -47,7 +47,10 @@ class XC_Functional static std::tuple v_xc( const int &nrxx, // number of real-space grid const Charge* const chr, - const UnitCell *ucell); // charge density + const UnitCell *ucell, // charge density + const int nspin, + const bool domag = false, + const bool domag_z = false); //------------------- // xc_functional.cpp @@ -67,7 +70,9 @@ class XC_Functional return func_type; }; - static void set_xc_type(const std::string xc_func_in); + static void set_xc_type(const std::string xc_func_in, + const int nspin = 1, + const std::string basis_type = "pw"); // For hybrid functional static void set_hybrid_alpha(const double alpha_in); @@ -206,7 +211,10 @@ class XC_Functional ModulePW::PW_Basis* rhopw, const UnitCell* ucell, std::vector& stress_gga, - const bool is_stress = false); + const bool is_stress = false, + const int nspin = 1, + const bool domag = false, + const bool domag_z = false); template ::type> diff --git a/source/source_hamilt/module_xc/xc_grad.cpp b/source/source_hamilt/module_xc/xc_grad.cpp index 0129662543..1044c9197b 100644 --- a/source/source_hamilt/module_xc/xc_grad.cpp +++ b/source/source_hamilt/module_xc/xc_grad.cpp @@ -32,7 +32,10 @@ void XC_Functional::gradcorr( ModulePW::PW_Basis* rhopw, const UnitCell *ucell, std::vector &stress_gga, - const bool is_stress) + const bool is_stress, + const int nspin, + const bool domag, + const bool domag_z) { ModuleBase::TITLE("XC_Functional","gradcorr"); @@ -47,12 +50,12 @@ void XC_Functional::gradcorr( igcc_is_lyp = true; } - int nspin0 = PARAM.inp.nspin; - if(PARAM.inp.nspin==4) + int nspin0 = nspin; + if(nspin==4) { nspin0 =1; } - if(PARAM.inp.nspin==4&&(PARAM.globalv.domag||PARAM.globalv.domag_z)) + if(nspin==4&&(domag||domag_z)) { nspin0 = 2; } @@ -71,7 +74,7 @@ void XC_Functional::gradcorr( // doing FFT to get rho in G space: rhog1 rhopw->real2recip(chr->rho[0], chr->rhog[0]); - if(PARAM.inp.nspin==2) + if(nspin==2) { rhopw->real2recip(chr->rho[1], chr->rhog[1]); } @@ -120,7 +123,7 @@ void XC_Functional::gradcorr( // for spin polarized case; // calculate the gradient of (rho_core+rho) in reciprocal space. - if(PARAM.inp.nspin==2) + if(nspin==2) { rhotmp2 = new double[rhopw->nrxx]; rhogsum2 = new std::complex[rhopw->npw]; @@ -148,7 +151,7 @@ void XC_Functional::gradcorr( XC_Functional::grad_rho( rhogsum2 , gdr2, rhopw, ucell->tpiba); } - if(PARAM.inp.nspin == 4&&(PARAM.globalv.domag||PARAM.globalv.domag_z)) + if(nspin == 4&&(domag||domag_z)) { rhotmp2 = new double[rhopw->nrxx]; rhogsum2 = new std::complex[rhopw->npw]; @@ -172,15 +175,15 @@ void XC_Functional::gradcorr( } if(!is_stress) { - vsave = new double* [PARAM.inp.nspin]; - for(int is = 0;isnrxx]; } #ifdef _OPENMP #pragma omp parallel for collapse(2) schedule(static, 1024) #endif - for(int is = 0;isnrxx;ir++) { @@ -445,7 +448,7 @@ void XC_Functional::gradcorr( else { double zeta = ( rhotmp1[ir] - rhotmp2[ir] ) / rh; - if(PARAM.inp.nspin==4&&(PARAM.globalv.domag||PARAM.globalv.domag_z)) + if(nspin==4&&(domag||domag_z)) { zeta = fabs(zeta) * neg[ir]; } @@ -606,12 +609,12 @@ void XC_Functional::gradcorr( vtxc += vtxcgc; etxc += etxcgc; - if(PARAM.inp.nspin == 4 && (PARAM.globalv.domag||PARAM.globalv.domag_z)) + if(nspin == 4 && (domag||domag_z)) { #ifdef _OPENMP #pragma omp parallel for collapse(2) schedule(static, 1024) #endif - for(int is=0;isnrxx;ir++) { @@ -648,7 +651,7 @@ void XC_Functional::gradcorr( delete[] h1; } - if(PARAM.inp.nspin==2) + if(nspin==2) { delete[] rhotmp2; delete[] rhogsum2; @@ -658,7 +661,7 @@ void XC_Functional::gradcorr( delete[] h2; } } - if(PARAM.inp.nspin == 4 && (PARAM.globalv.domag||PARAM.globalv.domag_z)) + if(nspin == 4 && (domag||domag_z)) { delete[] neg; if(!is_stress) @@ -668,7 +671,7 @@ void XC_Functional::gradcorr( delete[] vgg[i]; } delete[] vgg; - for(int i=0; i XC_Functional::v_xc( const int& nrxx, const Charge* const chr, - const UnitCell* ucell) + const UnitCell* ucell, + const int nspin, + const bool domag, + const bool domag_z) { ModuleBase::TITLE("XC_Functional", "v_xc"); @@ -29,7 +32,10 @@ std::tuple XC_Functional::v_xc( ucell->omega, ucell->tpiba, chr, - &(scaling_factor_xc)); + &(scaling_factor_xc), + nspin, + domag, + domag_z); #else ModuleBase::WARNING_QUIT("v_xc", "compile with LIBXC"); #endif @@ -40,14 +46,14 @@ std::tuple XC_Functional::v_xc( //Exchange-Correlation potential Vxc(r) from n(r) double etxc = 0.0; double vtxc = 0.0; - ModuleBase::matrix v(PARAM.inp.nspin, nrxx); + ModuleBase::matrix v(nspin, nrxx); // the square of the e charge // in Rydeberg unit, so * 2.0. double e2 = 2.0; double vanishing_charge = 1.0e-10; - if (PARAM.inp.nspin == 1 || ( PARAM.inp.nspin ==4 && !PARAM.globalv.domag && !PARAM.globalv.domag_z)) + if (nspin == 1 || ( nspin ==4 && !domag && !domag_z)) { // spin-unpolarized case #ifdef _OPENMP @@ -71,7 +77,7 @@ std::tuple XC_Functional::v_xc( } // endif } //enddo } - else if(PARAM.inp.nspin ==2) + else if(nspin ==2) { // spin-polarized case #ifdef _OPENMP @@ -97,7 +103,7 @@ std::tuple XC_Functional::v_xc( double vxc[2]; XC_Functional::xc_spin(arhox, zeta, exc, vxc[0], vxc[1]); - for (int is = 0;is < PARAM.inp.nspin;is++) + for (int is = 0;is < nspin;is++) { v(is, ir) = e2 * vxc[is]; } @@ -107,7 +113,7 @@ std::tuple XC_Functional::v_xc( } } } - else if(PARAM.inp.nspin == 4) + else if(nspin == 4) { #ifdef _OPENMP #pragma omp parallel for reduction(+:etxc) reduction(+:vtxc) @@ -171,7 +177,7 @@ std::tuple XC_Functional::v_xc( // the dummy variable dum contains gradient correction to stress // which is not used here std::vector dum; - gradcorr(etxc, vtxc, v, chr, chr->rhopw, ucell, dum); + gradcorr(etxc, vtxc, v, chr, chr->rhopw, ucell, dum, false, nspin, domag, domag_z); // parallel code : collect vtxc,etxc // mohan add 2008-06-01 diff --git a/source/source_pw/module_pwdft/forces_cc.cpp b/source/source_pw/module_pwdft/forces_cc.cpp index 45f7ea2fb1..41322e62e5 100644 --- a/source/source_pw/module_pwdft/forces_cc.cpp +++ b/source/source_pw/module_pwdft/forces_cc.cpp @@ -60,7 +60,8 @@ void Forces::cal_force_cc(ModuleBase::matrix& forcecc, { #ifdef USE_LIBXC const auto etxc_vtxc_v - = XC_Functional_Libxc::v_xc_meta(XC_Functional::get_func_id(), rho_basis->nrxx, ucell_in.omega, ucell_in.tpiba, chr); + = XC_Functional_Libxc::v_xc_meta(XC_Functional::get_func_id(), rho_basis->nrxx, ucell_in.omega, ucell_in.tpiba, chr, + PARAM.inp.nspin); // etxc = std::get<0>(etxc_vtxc_v); // vtxc = std::get<1>(etxc_vtxc_v); @@ -72,7 +73,10 @@ void Forces::cal_force_cc(ModuleBase::matrix& forcecc, else { elecstate::cal_ux(ucell_in); - const auto etxc_vtxc_v = XC_Functional::v_xc(rho_basis->nrxx, chr, &ucell_in); + const auto etxc_vtxc_v = XC_Functional::v_xc(rho_basis->nrxx, chr, &ucell_in, + PARAM.inp.nspin, + PARAM.globalv.domag, + PARAM.globalv.domag_z); // etxc = std::get<0>(etxc_vtxc_v); // vtxc = std::get<1>(etxc_vtxc_v); diff --git a/source/source_pw/module_pwdft/stress_cc.cpp b/source/source_pw/module_pwdft/stress_cc.cpp index bc986cdda7..3b0f291e88 100644 --- a/source/source_pw/module_pwdft/stress_cc.cpp +++ b/source/source_pw/module_pwdft/stress_cc.cpp @@ -55,7 +55,8 @@ void Stress_Func::stress_cc(ModuleBase::matrix& sigma, { #ifdef USE_LIBXC const auto etxc_vtxc_v - = XC_Functional_Libxc::v_xc_meta(XC_Functional::get_func_id(), rho_basis->nrxx, ucell.omega, ucell.tpiba, chr); + = XC_Functional_Libxc::v_xc_meta(XC_Functional::get_func_id(), rho_basis->nrxx, ucell.omega, ucell.tpiba, chr, + PARAM.inp.nspin); // etxc = std::get<0>(etxc_vtxc_v); // vtxc = std::get<1>(etxc_vtxc_v); @@ -67,7 +68,10 @@ void Stress_Func::stress_cc(ModuleBase::matrix& sigma, else { elecstate::cal_ux(ucell); - const auto etxc_vtxc_v = XC_Functional::v_xc(rho_basis->nrxx, chr, &ucell); + const auto etxc_vtxc_v = XC_Functional::v_xc(rho_basis->nrxx, chr, &ucell, + PARAM.inp.nspin, + PARAM.globalv.domag, + PARAM.globalv.domag_z); // etxc = std::get<0>(etxc_vtxc_v); // may delete? // vtxc = std::get<1>(etxc_vtxc_v); // may delete? vxc = std::get<2>(etxc_vtxc_v);