Skip to content

Commit 6441a65

Browse files
committed
add XC-functional BLYP_LIBXC and BLYP_LR to test
1 parent 8c5ea60 commit 6441a65

File tree

3 files changed

+52
-28
lines changed

3 files changed

+52
-28
lines changed

source/module_hamilt_general/module_xc/xc_functional.cpp

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -235,6 +235,31 @@ void XC_Functional::set_xc_type(const std::string xc_func_in)
235235
func_type = 4;
236236
use_libxc = true;
237237
}
238+
// just for test BLYP in libxc, added by jghan, 2024-10-22
239+
else if( xc_func == "BLYP_LIBXC")
240+
{
241+
func_id.push_back(XC_GGA_X_B88); // complete B88_X, id=106
242+
func_id.push_back(XC_GGA_C_LYP); // complete LYP_C, id=131
243+
func_type = 2;
244+
use_libxc = true;
245+
}
246+
else if( xc_func == "BLYP_LR")
247+
{
248+
// BLYP_XC_lr = -BLYP_XC_sr + BLYP_XC, the realization of it is in v_xc_libxc() function, xc_functional_libxc_vxc.cpp
249+
func_id.push_back(XC_GGA_X_ITYH); // short-range of B88_X, id=529
250+
func_id.push_back(XC_GGA_C_LYPR); // short-range of LYP_C, id=624
251+
func_id.push_back(XC_GGA_X_B88); // complete B88_X, id=106
252+
func_id.push_back(XC_GGA_C_LYP); // complete LYP_C, id=131
253+
254+
// the scaling factor of BLYP_LR-functionals
255+
scaling_factor_xc[XC_GGA_X_ITYH] = -1.0;
256+
scaling_factor_xc[XC_GGA_C_LYPR] = -1.0;
257+
scaling_factor_xc[XC_GGA_X_B88] = 1.0;
258+
scaling_factor_xc[XC_GGA_X_B88] = 1.0;
259+
260+
func_type = 2;
261+
use_libxc = true;
262+
}
238263
#endif
239264
else
240265
{

source/module_hamilt_general/module_xc/xc_functional_libxc.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,14 +89,14 @@ std::vector<xc_func_type> XC_Functional_Libxc::init_func(const std::vector<int>
8989
else if( id == XC_GGA_X_ITYH ) // short-range of B88_X
9090
{
9191
add_func( XC_GGA_X_ITYH );
92-
double parameter_omega[1] = {GlobalC::exx_info.info_global.hse_omega};
92+
double parameter_omega[1] = {PARAM.inp.exx_hse_omega}; // GlobalC::exx_info.info_global.hse_omega
9393
xc_func_set_ext_params(&funcs.back(), parameter_omega);
9494
}
9595
else if( id == XC_GGA_C_LYPR ) // short-range of LYP_C
9696
{
9797
add_func( XC_GGA_C_LYPR );
9898
// the first six parameters come from libxc, and may need to be modified in some cases
99-
double parameter_lypr[7] = {0.04918, 0.132, 0.2533, 0.349, 0.35/2.29, 2.0/2.29, GlobalC::exx_info.info_global.hse_omega};
99+
double parameter_lypr[7] = {0.04918, 0.132, 0.2533, 0.349, 0.35/2.29, 2.0/2.29, PARAM.inp.exx_hse_omega};
100100
xc_func_set_ext_params(&funcs.back(), parameter_lypr);
101101
}
102102
#endif

source/module_rdmft/rdmft.cpp

Lines changed: 25 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -583,32 +583,31 @@ void RDMFT<TK, TR>::cal_V_XC()
583583

584584
get_DM_XC(DM_XC);
585585

586-
// //test
587-
588-
DM_XC_pass = DM_XC;
589-
590-
elecstate::DensityMatrix<TK, double> DM_test(ParaV, nspin, kv->kvec_d, nk_total);
591-
elecstate::cal_dm_psi(ParaV, wg, wfc, DM_test);
592-
DM_test.init_DMR(&GlobalC::GridD, &GlobalC::ucell);
593-
DM_test.cal_DMR();
594-
595-
// compare DM_XC and DM get in update_charge(or ABACUS)
596-
std::cout << "\n\ntest DM_XC - DM in ABACUS: \n" << std::endl;
597-
double DM_XC_minus_DMtest = 0.0;
598-
for(int ik=0; ik<nk_total; ++ik)
599-
{
600-
TK* dmk_pointer = DM_test.get_DMK_pointer(ik);
601-
for(int iloc=0; iloc<ParaV->nloc; ++iloc)
602-
{
603-
double test = std::abs(DM_XC[ik][iloc] - dmk_pointer[iloc]);
604-
DM_XC_minus_DMtest += test;
605-
if( test > 1e-16 )
606-
{
607-
std::cout << "\nik, iloc, minus[ik][iloc]: " << ik << " " << iloc << " " << test << std::endl;
608-
}
609-
}
610-
}
611-
std::cout << "\nsum of DM_XC - DM in ABACUS: " << DM_XC_minus_DMtest << std::endl;
586+
// // //test
587+
// DM_XC_pass = DM_XC;
588+
589+
// elecstate::DensityMatrix<TK, double> DM_test(ParaV, nspin, kv->kvec_d, nk_total);
590+
// elecstate::cal_dm_psi(ParaV, wg, wfc, DM_test);
591+
// DM_test.init_DMR(&GlobalC::GridD, &GlobalC::ucell);
592+
// DM_test.cal_DMR();
593+
594+
// // compare DM_XC and DM get in update_charge(or ABACUS)
595+
// std::cout << "\n\ntest DM_XC - DM in ABACUS: \n" << std::endl;
596+
// double DM_XC_minus_DMtest = 0.0;
597+
// for(int ik=0; ik<nk_total; ++ik)
598+
// {
599+
// TK* dmk_pointer = DM_test.get_DMK_pointer(ik);
600+
// for(int iloc=0; iloc<ParaV->nloc; ++iloc)
601+
// {
602+
// double test = std::abs(DM_XC[ik][iloc] - dmk_pointer[iloc]);
603+
// DM_XC_minus_DMtest += test;
604+
// if( test > 1e-16 )
605+
// {
606+
// std::cout << "\nik, iloc, minus[ik][iloc]: " << ik << " " << iloc << " " << test << std::endl;
607+
// }
608+
// }
609+
// }
610+
// std::cout << "\nsum of DM_XC - DM in ABACUS: " << DM_XC_minus_DMtest << std::endl;
612611

613612
if( !only_exx_type )
614613
{

0 commit comments

Comments
 (0)