Skip to content
Open
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
1 change: 1 addition & 0 deletions source/module_esolver/esolver_ks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,7 @@ void ESolver_KS<T, Device>::before_all_runners(UnitCell& ucell, const Input_para
{
XC_Functional::set_xc_type(ucell.atoms[0].ncpp.xc_func);
}
GlobalV::ofs_running<<XC_Functional::output_info()<<std::endl;
ModuleBase::GlobalFunc::DONE(GlobalV::ofs_running, "SETUP UNITCELL");

//! 4) setup the charge mixing parameters
Expand Down
9 changes: 6 additions & 3 deletions source/module_hamilt_general/module_xc/test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,21 @@ AddTest(
TARGET XCTest_PBE
LIBS parameter MPI::MPI_CXX Libxc::xc # required by global.h; for details, `remove_definitions(-D__MPI)`.
SOURCES test_xc.cpp ../xc_functional.cpp ../xc_functional_wrapper_xc.cpp ../xc_functional_wrapper_gcxc.cpp ../xc_funct_corr_gga.cpp ../xc_funct_corr_lda.cpp ../xc_funct_exch_gga.cpp ../xc_funct_exch_lda.cpp ../xc_funct_hcth.cpp
../xc_functional_libxc_wrapper_gcxc.cpp ../xc_functional_libxc.cpp
../xc_functional_libxc_wrapper_gcxc.cpp ../xc_functional_libxc.cpp ../../../module_base/tool_title.cpp
)

AddTest(
TARGET XCTest_HSE
LIBS parameter MPI::MPI_CXX Libxc::xc # required by global.h; for details, `remove_definitions(-D__MPI)`.
SOURCES test_xc1.cpp ../xc_functional.cpp ../xc_functional_libxc.cpp
SOURCES test_xc1.cpp ../xc_functional.cpp ../xc_functional_libxc.cpp ../../../module_base/tool_title.cpp
)


AddTest(
TARGET XCTest_PZ_SPN
LIBS parameter MPI::MPI_CXX Libxc::xc # required by global.h; for details, `remove_definitions(-D__MPI)`.
SOURCES test_xc2.cpp ../xc_functional.cpp ../xc_functional_wrapper_xc.cpp ../xc_functional_wrapper_gcxc.cpp ../xc_funct_corr_gga.cpp ../xc_funct_corr_lda.cpp ../xc_funct_exch_gga.cpp ../xc_funct_exch_lda.cpp ../xc_funct_hcth.cpp
../xc_functional_libxc_wrapper_gcxc.cpp ../xc_functional_libxc_wrapper_xc.cpp ../xc_functional_libxc.cpp
../xc_functional_libxc_wrapper_gcxc.cpp ../xc_functional_libxc_wrapper_xc.cpp ../xc_functional_libxc.cpp ../../../module_base/tool_title.cpp
)

if (USE_CUDA)
Expand All @@ -43,6 +43,7 @@ AddTest(
../../../module_base/libm/branred.cpp
../../../module_base/libm/sincos.cpp
../../../module_base/blas_connector.cpp
../../../module_base/tool_title.cpp
../../../module_basis/module_pw/module_fft/fft_bundle.cpp
../../../module_basis/module_pw/module_fft/fft_cpu.cpp
${FFT_SRC}
Expand All @@ -59,6 +60,7 @@ AddTest(
../xc_functional_libxc_wrapper_tauxc.cpp
../xc_funct_corr_gga.cpp ../xc_funct_corr_lda.cpp
../xc_funct_exch_gga.cpp ../xc_funct_exch_lda.cpp ../xc_funct_hcth.cpp
../../../module_base/tool_title.cpp
)

AddTest(
Expand All @@ -81,6 +83,7 @@ AddTest(
../../../module_base/timer.cpp
../../../module_base/libm/branred.cpp
../../../module_base/libm/sincos.cpp
../../../module_base/tool_title.cpp
../../../module_basis/module_pw/module_fft/fft_bundle.cpp
../../../module_basis/module_pw/module_fft/fft_cpu.cpp
${FFT_SRC}
Expand Down
70 changes: 63 additions & 7 deletions source/module_hamilt_general/module_xc/xc_functional.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
#include "module_hamilt_pw/hamilt_pwdft/global.h"
#include "module_parameter/parameter.h"
#include "module_base/global_function.h"
#include "module_base/tool_title.h"

#ifdef USE_PAW
#include "module_cell/module_paw/paw_cell.h"
#endif
Expand Down Expand Up @@ -34,30 +36,44 @@ int XC_Functional::get_func_type()
{
return func_type;
}

void XC_Functional::set_xc_first_loop(const UnitCell& ucell)
{
ModuleBase::TITLE("XC_Functional", "set_xc_first_loop");
/** In the special "two-level" calculation case,
the first scf iteration only calculate the functional without exact
exchange. but in "nscf" calculation, there is no need of "two-level"
method. */
if (ucell.atoms[0].ncpp.xc_func == "HF" || ucell.atoms[0].ncpp.xc_func == "HSE"
|| ucell.atoms[0].ncpp.xc_func == "PBE0"|| ucell.atoms[0].ncpp.xc_func == "LC_PBE"
|| ucell.atoms[0].ncpp.xc_func == "LC_WPBE" || ucell.atoms[0].ncpp.xc_func == "LRC_WPBEH"
|| ucell.atoms[0].ncpp.xc_func == "CAM_PBEH") {
if (ucell.atoms[0].ncpp.xc_func == "HF" || ucell.atoms[0].ncpp.xc_func == "PBE0" || ucell.atoms[0].ncpp.xc_func == "HSE")
{
XC_Functional::set_xc_type("pbe");
}
else if (ucell.atoms[0].ncpp.xc_func == "SCAN0") {
XC_Functional::set_xc_type("scan");
else if ( ucell.atoms[0].ncpp.xc_func == "LC_PBE" || ucell.atoms[0].ncpp.xc_func == "LC_WPBE"
|| ucell.atoms[0].ncpp.xc_func == "LRC_WPBEH" || ucell.atoms[0].ncpp.xc_func == "CAM_PBEH" )
{
XC_Functional::set_xc_type("pbe");
}
else if (ucell.atoms[0].ncpp.xc_func == "B3LYP") {
// added by jghan, 2024-07-07
else if ( ucell.atoms[0].ncpp.xc_func == "MULLER" || ucell.atoms[0].ncpp.xc_func == "POWER"
|| ucell.atoms[0].ncpp.xc_func == "WP22" || ucell.atoms[0].ncpp.xc_func == "CWP22" )
{
XC_Functional::set_xc_type("pbe");
}
else if (ucell.atoms[0].ncpp.xc_func == "B3LYP")
{
XC_Functional::set_xc_type("blyp");
}
else if (ucell.atoms[0].ncpp.xc_func == "SCAN0")
{
XC_Functional::set_xc_type("scan");
}
}

// 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)
{
ModuleBase::TITLE("XC_Functional", "set_xc_type");
//Note : due to the separation of gcx_spin and gcc_spin,
//when you are adding new GGA functionals,
//please put exchange first, followed by correlation,
Expand Down Expand Up @@ -346,4 +362,44 @@ void XC_Functional::set_xc_type(const std::string xc_func_in)
use_libxc = false;
#endif

}


std::string XC_Functional::output_info()
{
#ifdef USE_LIBXC
if(use_libxc)
{
std::stringstream ss;
ss<<" Libxc v"<<xc_version_string()<<std::endl;
ss<<"\t"<<xc_reference()<<std::endl;

std::vector<xc_func_type> funcs = XC_Functional_Libxc::init_func(func_id, XC_UNPOLARIZED);
for(const auto &func : funcs)
{
const xc_func_info_type *info = xc_func_get_info(&func);
ss<<" XC: "<<xc_func_info_get_name(info)<<std::endl;
for(int i=0; i<XC_MAX_REFERENCES; ++i)
{
const func_reference_type *ref = xc_func_info_get_references(func.info, i);
if(ref)
ss<<"\t"<<xc_func_reference_get_ref(ref)<<std::endl;
}
}
XC_Functional_Libxc::finish_func(funcs);
return ss.str();
}
else
{
std::string s = " XC:\t";
for(const auto &id: func_id)
s += std::string(xc_functional_get_name(id))+"\t";
return s;
}
#else
std::string s = " XC:\t";
for(const auto &id: func_id)
s += std::to_string(id)+"\t";
return s;
#endif
}
1 change: 1 addition & 0 deletions source/module_hamilt_general/module_xc/xc_functional.h
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ class XC_Functional

public:
static std::vector<int> get_func_id() { return func_id; }
static std::string output_info();

//-------------------
// xc_functional_wrapper_xc.cpp
Expand Down
15 changes: 1 addition & 14 deletions source/module_ri/Exx_LRI_interface.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -147,20 +147,7 @@ void Exx_LRI_Interface<T, Tdata>::exx_beforescf(const int istep,
}
else
{
if (ucell.atoms[0].ncpp.xc_func == "HF" || ucell.atoms[0].ncpp.xc_func == "PBE0" || ucell.atoms[0].ncpp.xc_func == "HSE")
{
XC_Functional::set_xc_type("pbe");
}
else if (ucell.atoms[0].ncpp.xc_func == "SCAN0")
{
XC_Functional::set_xc_type("scan");
}
// added by jghan, 2024-07-07
else if ( ucell.atoms[0].ncpp.xc_func == "MULLER" || ucell.atoms[0].ncpp.xc_func == "POWER"
|| ucell.atoms[0].ncpp.xc_func == "WP22" || ucell.atoms[0].ncpp.xc_func == "CWP22" )
{
XC_Functional::set_xc_type("pbe");
}
XC_Functional::set_xc_first_loop(ucell);
}

this->cal_exx_ions(ucell,PARAM.inp.out_ri_cv);
Expand Down
Loading