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
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ else()
# if pinning to specific SHA change the FETCHCONTENT_LIBXC_GIT_SHALLOW default to OFF, https://cmake.org/cmake/help/latest/module/ExternalProject.html#git
GIT_TAG 7.0.0
GIT_SHALLOW ${FETCHCONTENT_LIBXC_GIT_SHALLOW}
PATCH_COMMAND sed -i -e "s/p->info->family != XC_KINETIC/p->info->kind != XC_KINETIC/g" src/work_mgga_inc.c
PATCH_COMMAND "${CMAKE_COMMAND}" -P "${CMAKE_CURRENT_LIST_DIR}/cmake/patch_libxc_work_mgga.cmake"
)
set( Libxc_VERSION 7.0.0 )

Expand Down
13 changes: 13 additions & 0 deletions cmake/patch_libxc_work_mgga.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# patch_libxc_work_mgga.cmake
# Portable replacement for:
# sed -i -e "s/p->info->family != XC_KINETIC/p->info->kind != XC_KINETIC/g" src/work_mgga_inc.c
# Run from the libxc source directory via PATCH_COMMAND.

set(_file "src/work_mgga_inc.c")
if(NOT EXISTS "${_file}")
message(FATAL_ERROR "patch_libxc_work_mgga.cmake: ${_file} not found (cwd=${CMAKE_CURRENT_SOURCE_DIR})")
endif()

file(READ "${_file}" _content)
string(REPLACE "p->info->family != XC_KINETIC" "p->info->kind != XC_KINETIC" _content "${_content}")
file(WRITE "${_file}" "${_content}")
Comment on lines +11 to +13
4 changes: 2 additions & 2 deletions include/exchcxx/exceptions/exchcxx_exception.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ class exchcxx_exception : public std::exception {

auto msg = ss.str();

return strdup( msg.c_str() );
return _strdup( msg.c_str() );
}

public:
Expand All @@ -77,7 +77,7 @@ class exchcxx_exception : public std::exception {
};

#define EXCHCXX_BOOL_CHECK( MSG, V ) \
if( not (V) ) \
if( !(V) ) \
throw exchcxx_exception( __FILE__, __LINE__, MSG );

}
1 change: 0 additions & 1 deletion include/exchcxx/impl/builtin/kernels/deorbitalized.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@ struct kernel_traits<Deorbitalized<XCEF,KEDF>> {
static constexpr bool needs_laplacian = true;
static constexpr bool is_kedf = false;
static constexpr bool is_epc = false;
static constexpr double exx_coeff = xc_traits::exx_coeff + ke_traits::exx_coeff;

BUILTIN_KERNEL_EVAL_RETURN
eval_exc_unpolar( double rho, double sigma, double lapl, double tau, double& eps ) {
Expand Down
16 changes: 8 additions & 8 deletions include/exchcxx/impl/builtin/kernels/screening_interface.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -394,7 +394,7 @@ struct mgga_screening_interface {
constexpr auto sigma_tol_sq = traits::sigma_tol * traits::sigma_tol;
sigma = safe_max(sigma, sigma_tol_sq);
tau = safe_max(tau, traits::tau_tol);
if constexpr (not traits::is_kedf) {
if constexpr (!traits::is_kedf) {
sigma = enforce_fermi_hole_curvature(sigma, rho, tau);
}

Expand All @@ -421,7 +421,7 @@ struct mgga_screening_interface {
sigma_bb = safe_max(sigma_bb, sigma_tol_sq);
tau_a = safe_max(tau_a, traits::tau_tol);
tau_b = safe_max(tau_b, traits::tau_tol);
if constexpr (not traits::is_kedf) {
if constexpr (!traits::is_kedf) {
sigma_aa = enforce_fermi_hole_curvature(sigma_aa, rho_a, tau_a);
sigma_bb = enforce_fermi_hole_curvature(sigma_bb, rho_b, tau_b);
}
Expand Down Expand Up @@ -450,7 +450,7 @@ struct mgga_screening_interface {
constexpr auto sigma_tol_sq = traits::sigma_tol * traits::sigma_tol;
sigma = safe_max(sigma, sigma_tol_sq);
tau = safe_max(tau, traits::tau_tol);
if constexpr (not traits::is_kedf) {
if constexpr (!traits::is_kedf) {
sigma = enforce_fermi_hole_curvature(sigma, rho, tau);
}
traits::eval_exc_vxc_unpolar_impl(rho, sigma, lapl, tau,
Expand Down Expand Up @@ -489,7 +489,7 @@ struct mgga_screening_interface {
sigma_bb = safe_max(sigma_bb, sigma_tol_sq);
tau_a = safe_max(tau_a, traits::tau_tol);
tau_b = safe_max(tau_b, traits::tau_tol);
if constexpr (not traits::is_kedf) {
if constexpr (!traits::is_kedf) {
sigma_aa = enforce_fermi_hole_curvature(sigma_aa, rho_a, tau_a);
sigma_bb = enforce_fermi_hole_curvature(sigma_bb, rho_b, tau_b);
}
Expand Down Expand Up @@ -519,7 +519,7 @@ BUILTIN_KERNEL_EVAL_RETURN
constexpr auto sigma_tol_sq = traits::sigma_tol * traits::sigma_tol;
sigma = safe_max(sigma, sigma_tol_sq);
tau = safe_max(tau, traits::tau_tol);
if constexpr (not traits::is_kedf) {
if constexpr (!traits::is_kedf) {
sigma = enforce_fermi_hole_curvature(sigma, rho, tau);
}
traits::eval_fxc_unpolar_impl(rho, sigma, lapl, tau,
Expand Down Expand Up @@ -575,7 +575,7 @@ BUILTIN_KERNEL_EVAL_RETURN
sigma_bb = safe_max(sigma_bb, sigma_tol_sq);
tau_a = safe_max(tau_a, traits::tau_tol);
tau_b = safe_max(tau_b, traits::tau_tol);
if constexpr (not traits::is_kedf) {
if constexpr (!traits::is_kedf) {
sigma_aa = enforce_fermi_hole_curvature(sigma_aa, rho_a, tau_a);
sigma_bb = enforce_fermi_hole_curvature(sigma_bb, rho_b, tau_b);
}
Expand Down Expand Up @@ -621,7 +621,7 @@ BUILTIN_KERNEL_EVAL_RETURN
sigma = safe_max(sigma, sigma_tol_sq);
tau = safe_max(tau, traits::tau_tol);

if constexpr (not traits::is_kedf) {
if constexpr (!traits::is_kedf) {
sigma = enforce_fermi_hole_curvature(sigma, rho, tau);
}

Expand Down Expand Up @@ -686,7 +686,7 @@ BUILTIN_KERNEL_EVAL_RETURN
tau_a = safe_max(tau_a, traits::tau_tol);
tau_b = safe_max(tau_b, traits::tau_tol);

if constexpr (not traits::is_kedf) {
if constexpr (!traits::is_kedf) {
sigma_aa = enforce_fermi_hole_curvature(sigma_aa, rho_a, tau_a);
sigma_bb = enforce_fermi_hole_curvature(sigma_bb, rho_b, tau_b);
}
Expand Down
6 changes: 3 additions & 3 deletions include/exchcxx/xc_functional.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ class XCFunctional {
inline bool sanity_check() const {

// Must have one kernel
if( not kernels_.size() ) return false;
if( !kernels_.size() ) return false;

// Polarization is all or nothing
int polar_one = kernels_.at(0).second.is_polarized();
Expand All @@ -103,7 +103,7 @@ class XCFunctional {
}
);

if( not polar_all ) return false;
if( !polar_all ) return false;

// If we made it, kernel is sane
return true;
Expand Down Expand Up @@ -164,7 +164,7 @@ class XCFunctional {
return std::any_of(
kernels_.begin(), kernels_.end(),
[](const auto& x) { return x.second.is_gga(); }
) and not is_mgga();
) && !is_mgga();
}

inline bool is_mgga() const {
Expand Down
49 changes: 49 additions & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,55 @@ add_library( exchcxx ${EXCHCXX_SOURCES} )
# TARGET properties

target_compile_features( exchcxx PUBLIC cxx_std_17 )
if(MSVC)
target_compile_definitions( exchcxx PUBLIC _USE_MATH_DEFINES )
if(CMAKE_CXX_COMPILER_ID MATCHES "Clang") # clang-cl
target_compile_options( exchcxx PUBLIC
-Wno-c++98-compat
-Wno-c++98-compat-local-type-template-args
-Wno-c++98-compat-pedantic
-Wno-deprecated-declarations
-Wno-exit-time-destructors
-Wno-extra-semi
-Wno-extra-semi-stmt
-Wno-float-conversion
-Wno-float-equal
-Wno-global-constructors
-Wno-inconsistent-missing-destructor-override
-Wno-missing-prototypes
-Wno-missing-variable-declarations
-Wno-old-style-cast
-Wno-pre-c++14-compat
-Wno-pre-c++17-compat
-Wno-reserved-macro-identifier
-Wno-sign-conversion
-Wno-suggest-destructor-override
-Wno-switch-enum
-Wno-undefined-func-template
-Wno-unsafe-buffer-usage
-Wno-unsafe-buffer-usage-in-libc-call
-Wno-unused-macros
-Wno-unused-parameter
-Wno-unused-variable
)
Comment on lines +19 to +49
else() # cl
target_compile_options( exchcxx PUBLIC
/wd4003 # not enough actual parameters for macro 'identifier'
/wd4061 # enumerator 'enumerator' in switch of enum 'enumeration' is not explicitly handled by a case label
/wd4244 # conversion from 'type1' to 'type2', possible loss of data
/wd4266 # no override available for virtual member function from base 'class'; function is hidden
/wd4267 # conversion from 'size_t' to 'type', possible loss of data
/wd4365 # conversion from 'type1' to 'type2', signed/unsigned mismatch
/wd4514 # unreferenced inline function has been removed
/wd4267 # conversion from 'size_t' to 'type', possible loss of data
/wd4710 # function 'function' not inlined
/wd4711 # function 'function' selected for automatic inline expansion
/wd4800 # forcing value to bool 'true' or 'false' (performance warning)
/wd4820 # 'bytes' bytes padding added after construct 'member_name'
/wd5246 # C-style struct initialization may not be portable
)
endif()
endif()
if( EXCHCXX_ENABLE_LIBXC )
target_link_libraries( exchcxx PUBLIC Libxc::xc )
endif()
Expand Down
2 changes: 1 addition & 1 deletion src/builtin_interface.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ std::unique_ptr<BuiltinKernel>

// Bail if polarized eval is requested and not supported
EXCHCXX_BOOL_CHECK(kernel_map.key(kern) + " Needs to be Spin-Polarized!",
supports_unpolarized(kern) or polar == Spin::Polarized);
supports_unpolarized(kern) || polar == Spin::Polarized);

if( kern == Kernel::SlaterExchange )
return std::make_unique<BuiltinSlaterExchange>( polar );
Expand Down
8 changes: 4 additions & 4 deletions src/libxc.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -256,21 +256,21 @@ std::unique_ptr< XCKernelImpl > LibxcKernelImpl::clone_() const {
bool LibxcKernelImpl::is_lda_() const noexcept {
return (kernel_.info->family == XC_FAMILY_LDA)
#if XC_MAJOR_VERSION > 6
or (kernel_.info->family == XC_FAMILY_HYB_LDA)
|| (kernel_.info->family == XC_FAMILY_HYB_LDA)
#endif
;
}

bool LibxcKernelImpl::is_gga_() const noexcept {
return
(kernel_.info->family == XC_FAMILY_GGA )
or (kernel_.info->family == XC_FAMILY_HYB_GGA);
|| (kernel_.info->family == XC_FAMILY_HYB_GGA);
}

bool LibxcKernelImpl::is_mgga_() const noexcept {
return
(kernel_.info->family == XC_FAMILY_MGGA )
or (kernel_.info->family == XC_FAMILY_HYB_MGGA);
|| (kernel_.info->family == XC_FAMILY_HYB_MGGA);
}

bool LibxcKernelImpl::needs_laplacian_() const noexcept {
Expand All @@ -294,7 +294,7 @@ bool LibxcKernelImpl::is_epc_() const noexcept {
int xcNumber = xc_info()->number;
return
#if XC_MAJOR_VERSION > 7
xcNumber == XC_LDA_C_EPC17 or xcNumber == XC_LDA_C_EPC17_2 or xcNumber == XC_LDA_C_EPC18_1 or xcNumber == XC_LDA_C_EPC18_2;
xcNumber == XC_LDA_C_EPC17 || xcNumber == XC_LDA_C_EPC17_2 || xcNumber == XC_LDA_C_EPC18_1 || xcNumber == XC_LDA_C_EPC18_2;
#else
false;
#endif
Expand Down
24 changes: 12 additions & 12 deletions src/xc_functional.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -711,7 +711,7 @@ LDA_EXC_GENERATOR( XCFunctional::eval_exc ) const {
const size_t len_exc_buffer = exc_buffer_len(N);

std::vector<double> eps_scr;
if( kernels_.size() > 1 and not supports_inc_interface() )
if( kernels_.size() > 1 && !supports_inc_interface() )
eps_scr.resize( len_exc_buffer );

std::fill_n( eps, len_exc_buffer, 0. );
Expand Down Expand Up @@ -749,7 +749,7 @@ LDA_EXC_VXC_GENERATOR( XCFunctional::eval_exc_vxc ) const {
const size_t len_vxc_buffer = vrho_buffer_len(N);

std::vector<double> eps_scr, vxc_scr;
if( kernels_.size() > 1 and not supports_inc_interface() ) {
if( kernels_.size() > 1 && !supports_inc_interface() ) {
eps_scr.resize( len_exc_buffer );
vxc_scr.resize( len_vxc_buffer );
}
Expand Down Expand Up @@ -869,7 +869,7 @@ GGA_EXC_GENERATOR( XCFunctional::eval_exc ) const {
const size_t len_exc_buffer = exc_buffer_len(N);

std::vector<double> eps_scr;
if( kernels_.size() > 1 and not supports_inc_interface() )
if( kernels_.size() > 1 && !supports_inc_interface() )
eps_scr.resize( len_exc_buffer );

std::fill_n( eps, len_exc_buffer, 0. );
Expand Down Expand Up @@ -919,7 +919,7 @@ GGA_EXC_VXC_GENERATOR( XCFunctional::eval_exc_vxc ) const {
const size_t len_vsigma_buffer = vsigma_buffer_len(N);

std::vector<double> eps_scr, vrho_scr, vsigma_scr;
if( kernels_.size() > 1 and not supports_inc_interface() ) {
if( kernels_.size() > 1 && !supports_inc_interface() ) {
eps_scr.resize( len_exc_buffer );
vrho_scr.resize( len_vrho_buffer );
vsigma_scr.resize( len_vsigma_buffer );
Expand Down Expand Up @@ -988,7 +988,7 @@ GGA_FXC_GENERATOR( XCFunctional::eval_fxc ) const {
const size_t len_v2sigma2_buffer = v2sigma2_buffer_len(N);

std::vector<double> v2sigma2_scr, v2rhosigma_scr, v2rho2_scr;
if( kernels_.size() > 1 and not supports_inc_interface() ) {
if( kernels_.size() > 1 && !supports_inc_interface() ) {
v2rho2_scr.resize( len_v2rho2_buffer );
v2rhosigma_scr.resize( len_v2rhosigma_buffer );
v2sigma2_scr.resize( len_v2sigma2_buffer );
Expand Down Expand Up @@ -1053,7 +1053,7 @@ GGA_VXC_FXC_GENERATOR( XCFunctional::eval_vxc_fxc ) const {
const size_t len_v2sigma2_buffer = v2sigma2_buffer_len(N);

std::vector<double> vrho_scr, vsigma_scr, v2rho2_scr, v2rhosigma_scr, v2sigma2_scr;
if( kernels_.size() > 1 and not supports_inc_interface() ) {
if( kernels_.size() > 1 && !supports_inc_interface() ) {
vrho_scr.resize( len_vrho_buffer );
vsigma_scr.resize( len_vsigma_buffer );
v2rho2_scr.resize( len_v2rho2_buffer );
Expand Down Expand Up @@ -1130,7 +1130,7 @@ MGGA_EXC_GENERATOR( XCFunctional::eval_exc ) const {
const size_t len_exc_buffer = exc_buffer_len(N);

std::vector<double> eps_scr;
if( kernels_.size() > 1 and not supports_inc_interface() )
if( kernels_.size() > 1 && !supports_inc_interface() )
eps_scr.resize( len_exc_buffer );

std::fill_n( eps, len_exc_buffer, 0. );
Expand Down Expand Up @@ -1188,7 +1188,7 @@ MGGA_EXC_VXC_GENERATOR( XCFunctional::eval_exc_vxc ) const {
const size_t len_vtau_buffer = vtau_buffer_len(N);

std::vector<double> eps_scr, vrho_scr, vsigma_scr, vlapl_scr, vtau_scr;
if( kernels_.size() > 1 and not supports_inc_interface() ) {
if( kernels_.size() > 1 && !supports_inc_interface() ) {
eps_scr.resize( len_exc_buffer );
vrho_scr.resize( len_vrho_buffer );
vsigma_scr.resize( len_vsigma_buffer );
Expand Down Expand Up @@ -1244,7 +1244,7 @@ MGGA_EXC_VXC_GENERATOR( XCFunctional::eval_exc_vxc ) const {
_addscal( len_exc_buffer, kernels_[i].first, eps, eps_eval );
_addscal( len_vrho_buffer, kernels_[i].first, vrho, vrho_eval );

if( kernels_[i].second.is_gga() or kernels_[i].second.is_mgga() )
if( kernels_[i].second.is_gga() || kernels_[i].second.is_mgga() )
_addscal( len_vsigma_buffer, kernels_[i].first, vsigma, vsigma_eval );

if( kernels_[i].second.needs_laplacian() )
Expand All @@ -1258,7 +1258,7 @@ MGGA_EXC_VXC_GENERATOR( XCFunctional::eval_exc_vxc ) const {
_scal( len_exc_buffer, kernels_[i].first, eps );
_scal( len_vrho_buffer, kernels_[i].first, vrho );

if( kernels_[i].second.is_gga() or kernels_[i].second.is_mgga() )
if( kernels_[i].second.is_gga() || kernels_[i].second.is_mgga() )
_scal( len_vsigma_buffer, kernels_[i].first, vsigma );

if( kernels_[i].second.needs_laplacian() )
Expand Down Expand Up @@ -1361,7 +1361,7 @@ MGGA_FXC_GENERATOR( XCFunctional::eval_fxc ) const {
if (i) {
_addscal(len_v2rho2_buffer, kernels_[i].first, v2rho2, v2rho2_eval);

if( kernels_[i].second.is_gga() or kernels_[i].second.is_mgga() ){
if( kernels_[i].second.is_gga() || kernels_[i].second.is_mgga() ){
_addscal(len_v2rhosigma_buffer, kernels_[i].first, v2rhosigma, v2rhosigma_eval);
_addscal(len_v2sigma2_buffer, kernels_[i].first, v2sigma2, v2sigma2_eval);
}
Expand All @@ -1384,7 +1384,7 @@ MGGA_FXC_GENERATOR( XCFunctional::eval_fxc ) const {

_scal(len_v2rho2_buffer, kernels_[i].first, v2rho2);

if (kernels_[i].second.is_gga() or kernels_[i].second.is_mgga()) {
if (kernels_[i].second.is_gga() || kernels_[i].second.is_mgga()) {
_scal(len_v2rhosigma_buffer, kernels_[i].first, v2rhosigma);
_scal(len_v2sigma2_buffer, kernels_[i].first, v2sigma2);
}
Expand Down
Loading