diff --git a/.gitignore b/.gitignore index 514a186..dda5e57 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ build .vscode *.*.swp +build*/ \ No newline at end of file diff --git a/CMakeLists.txt b/CMakeLists.txt index 92eca2a..65873ea 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -3,6 +3,18 @@ include(FetchContent) # Set up project definition + version information project( ExchCXX VERSION 1.0.0 LANGUAGES C CXX ) +set(CMAKE_CXX_STANDARD 17) +set(CMAKE_CXX_STANDARD_REQUIRED ON) + +if(MSVC) + # /EHsc: standard C++ exception-handling model (required by STL and noexcept). + # /permissive-: conformance mode — recognises C++ alternative tokens (not, and, or, …). + # Scoped to CXX only so libxc's C sources are not affected. + add_compile_options( + $<$:/EHsc> + $<$:/permissive-> + ) +endif() # ExchCXX Options option( EXCHCXX_ENABLE_BENCHMARK "Enable Performance Benchmark" OFF ) @@ -81,7 +93,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 ) @@ -90,12 +102,16 @@ else() FetchContent_MakeAvailable( libxc ) add_library( Libxc::xc ALIAS xc ) - target_include_directories( xc - PUBLIC + target_include_directories( xc + PUBLIC $ $ $ ) + if(MSVC) + # Suppress CRT deprecation warnings (strcpy, sscanf, etc.) in libxc C sources + target_compile_definitions( xc PRIVATE _CRT_SECURE_NO_WARNINGS ) + endif() message( STATUS "Libxc Source: ${libxc_SOURCE_DIR}" ) # disable unity builds for libxc diff --git a/cmake/patch_libxc_work_mgga.cmake b/cmake/patch_libxc_work_mgga.cmake new file mode 100644 index 0000000..eaf2d7a --- /dev/null +++ b/cmake/patch_libxc_work_mgga.cmake @@ -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}") diff --git a/include/exchcxx/exceptions/exchcxx_exception.hpp b/include/exchcxx/exceptions/exchcxx_exception.hpp index 6d6563f..73837f2 100644 --- a/include/exchcxx/exceptions/exchcxx_exception.hpp +++ b/include/exchcxx/exceptions/exchcxx_exception.hpp @@ -47,7 +47,6 @@ #include #include -#include #include namespace ExchCXX { @@ -57,27 +56,27 @@ class exchcxx_exception : public std::exception { std::string file_; int line_; std::string msg_prefix_; + std::string what_msg_; const char* what() const noexcept override { - std::stringstream ss; - ss << "EXCHCXX Exception (" << msg_prefix_ << ")" << std::endl - << " File " << file_ << std::endl - << " Line " << line_ << std::endl; - - auto msg = ss.str(); - - return strdup( msg.c_str() ); + return what_msg_.c_str(); } public: exchcxx_exception( std::string file, int line, std::string msg) : - file_(file), line_(line), msg_prefix_(msg) { } + file_(std::move(file)), line_(line), msg_prefix_(std::move(msg)) { + std::stringstream ss; + ss << "EXCHCXX Exception (" << msg_prefix_ << ")" << std::endl + << " File " << file_ << std::endl + << " Line " << line_ << std::endl; + what_msg_ = ss.str(); + } }; #define EXCHCXX_BOOL_CHECK( MSG, V ) \ - if( not (V) ) \ + if( !(V) ) \ throw exchcxx_exception( __FILE__, __LINE__, MSG ); } diff --git a/include/exchcxx/impl/builtin/kernels/deorbitalized.hpp b/include/exchcxx/impl/builtin/kernels/deorbitalized.hpp index e00bc23..e34c74d 100644 --- a/include/exchcxx/impl/builtin/kernels/deorbitalized.hpp +++ b/include/exchcxx/impl/builtin/kernels/deorbitalized.hpp @@ -70,10 +70,9 @@ struct kernel_traits> { 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 ) { + eval_exc_unpolar( double rho, double sigma, double lapl, [[maybe_unused]] double tau, double& eps ) { double TAU; ke_traits::eval_exc_unpolar(rho, sigma, lapl, 0.0, TAU); @@ -84,7 +83,7 @@ struct kernel_traits> { } BUILTIN_KERNEL_EVAL_RETURN - eval_exc_vxc_unpolar( double rho, double sigma, double lapl, double tau, double& eps, double& vrho, double& vsigma, double& vlapl, double& vtau ) { + eval_exc_vxc_unpolar( double rho, double sigma, double lapl, [[maybe_unused]] double tau, double& eps, double& vrho, double& vsigma, double& vlapl, double& vtau ) { double TAU, vrho_k, vsigma_k, vlapl_k, dummy; ke_traits::eval_exc_vxc_unpolar(rho, sigma, lapl, 0.0, TAU, vrho_k, vsigma_k, vlapl_k, dummy); @@ -101,7 +100,7 @@ struct kernel_traits> { } BUILTIN_KERNEL_EVAL_RETURN - eval_exc_polar( double rho_a, double rho_b, double sigma_aa, double sigma_ab, double sigma_bb, double lapl_a, double lapl_b, double tau_a, double tau_b, double& eps ) { + eval_exc_polar( double rho_a, double rho_b, double sigma_aa, double sigma_ab, double sigma_bb, double lapl_a, double lapl_b, [[maybe_unused]] double tau_a, [[maybe_unused]] double tau_b, double& eps ) { double TAU_A, TAU_B; ke_traits::eval_exc_polar(rho_a, 0.0, sigma_aa, 0.0, 0.0, lapl_a, 0.0, 0.0, 0.0, TAU_A); @@ -114,9 +113,9 @@ struct kernel_traits> { } BUILTIN_KERNEL_EVAL_RETURN - eval_exc_vxc_polar( double rho_a, double rho_b, double sigma_aa, double sigma_ab, double sigma_bb, double lapl_a, double lapl_b, double tau_a, double tau_b, double& eps, double& vrho_a, double& vrho_b, double& vsigma_aa, double& vsigma_ab, double& vsigma_bb, double& vlapl_a, double& vlapl_b, double& vtau_a, double& vtau_b ) { + eval_exc_vxc_polar( double rho_a, double rho_b, double sigma_aa, double sigma_ab, double sigma_bb, double lapl_a, double lapl_b, [[maybe_unused]] double tau_a, [[maybe_unused]] double tau_b, double& eps, double& vrho_a, double& vrho_b, double& vsigma_aa, double& vsigma_ab, double& vsigma_bb, double& vlapl_a, double& vlapl_b, double& vtau_a, double& vtau_b ) { - double TAU_A, TAU_B, vrho_a_k, vrho_b_k, vsigma_aa_k, vsigma_bb_k, vlapl_a_k, vlapl_b_k, vtau_k, dummy; + double TAU_A, TAU_B, vrho_a_k, vrho_b_k, vsigma_aa_k, vsigma_bb_k, vlapl_a_k, vlapl_b_k, dummy; ke_traits::eval_exc_vxc_polar(rho_a, 0.0, sigma_aa, 0.0, 0.0, lapl_a, 0.0, 0.0, 0.0, TAU_A, vrho_a_k, dummy, vsigma_aa_k, dummy, dummy, vlapl_a_k, dummy, dummy, dummy); ke_traits::eval_exc_vxc_polar(rho_b, 0.0, sigma_bb, 0.0, 0.0, lapl_b, 0.0, 0.0, 0.0, TAU_B, vrho_b_k, dummy, vsigma_bb_k, dummy, dummy, vlapl_b_k, dummy, dummy, dummy); diff --git a/include/exchcxx/impl/builtin/kernels/screening_interface.hpp b/include/exchcxx/impl/builtin/kernels/screening_interface.hpp index e34b775..a34c2f6 100644 --- a/include/exchcxx/impl/builtin/kernels/screening_interface.hpp +++ b/include/exchcxx/impl/builtin/kernels/screening_interface.hpp @@ -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); } @@ -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); } @@ -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, @@ -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); } @@ -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, @@ -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); } @@ -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); } @@ -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); } diff --git a/include/exchcxx/xc_functional.hpp b/include/exchcxx/xc_functional.hpp index 838e6e6..62d952e 100644 --- a/include/exchcxx/xc_functional.hpp +++ b/include/exchcxx/xc_functional.hpp @@ -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(); @@ -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; @@ -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 { diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index ec0adad..6faed6c 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -16,6 +16,33 @@ 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 PRIVATE + -Wno-sign-conversion # mirrors /wd4365: signed/unsigned in STL-heavy code + -Wno-switch-enum # mirrors /wd4061: intentional default: covers all kernels + ) + else() # cl + target_compile_options( exchcxx PUBLIC + /Zc:preprocessor # PUBLIC: public headers use NOTYPE empty macro; consumers need conforming preprocessor + ) + # silence noisy level-4 warnings that appear because STL raises the level to 4 during template instantiations + target_compile_options( exchcxx PRIVATE + /wd4061 # enumerator not in switch case: intentional default: handler covers all kernels + /wd4266 # no override for virtual function: by-design partial override in APPROX specialisations + /wd4365 # signed/unsigned in STL code: safe, values always non-negative + /wd4514 # unreferenced inline removed: informational, linker dead-strips correctly + /wd4626 # assignment operator deleted: by-design non-copyable classes with reference members + /wd4702 # unreachable code: macro-expanded dispatch tables, not real dead code + /wd4710 # function not inlined: informational, optimizer decision + /wd4711 # function auto-inlined: informational, optimizer decision + /wd4800 # implicit double-to-bool: fires in auto-generated kernel headers, intentional + /wd4820 # struct padding: ABI layout decision, informational + /wd5045 # Spectre mitigation remark: informational, /Qspectre not in use + ) + endif() +endif() if( EXCHCXX_ENABLE_LIBXC ) target_link_libraries( exchcxx PUBLIC Libxc::xc ) endif() @@ -28,7 +55,6 @@ configure_file( target_compile_definitions( exchcxx PUBLIC "EXCHCXX_HAS_CONFIG_H=1" ) - # Device specific if( EXCHCXX_ENABLE_CUDA ) include( cuda/exchcxx_cuda.cmake ) @@ -43,7 +69,6 @@ if( EXCHCXX_ENABLE_SYCL ) endif() - target_include_directories( exchcxx PUBLIC $ @@ -53,7 +78,9 @@ target_include_directories( exchcxx ) include( CheckCXXCompilerFlag ) -check_cxx_compiler_flag( -Wall EXCHCXX_CXX_HAS_WALL ) +if(NOT MSVC) # under clang-cl, -Wall maps to /Wall (= -Weverything) + check_cxx_compiler_flag( -Wall EXCHCXX_CXX_HAS_WALL ) +endif() check_cxx_compiler_flag( -Wextra EXCHCXX_CXX_HAS_WEXTRA ) check_cxx_compiler_flag( -Wpedantic EXCHCXX_CXX_HAS_WPEDANTIC ) check_cxx_compiler_flag( -Wnon-virtual-dtor EXCHCXX_CXX_HAS_WNON_VIRTUAL_DTOR ) @@ -79,10 +106,10 @@ if( EXCHCXX_CXX_HAS_WSHADOW ) target_compile_options( exchcxx PRIVATE $<$: -Wshadow -Werror=shadow> ) endif() + # INSTALL rules add_library( ExchCXX::ExchCXX ALIAS exchcxx ) - include( GNUInstallDirs ) set( INSTALL_CONFIGDIR ${CMAKE_INSTALL_LIBDIR}/cmake/ExchCXX ) @@ -93,7 +120,6 @@ install(TARGETS exchcxx ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} ) - set_target_properties( exchcxx PROPERTIES EXPORT_NAME ExchCXX ) # Install Headers diff --git a/src/builtin_interface.cxx b/src/builtin_interface.cxx index 3ad7ce2..03a757b 100644 --- a/src/builtin_interface.cxx +++ b/src/builtin_interface.cxx @@ -67,7 +67,7 @@ std::unique_ptr // 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( polar ); diff --git a/src/libxc.cxx b/src/libxc.cxx index fb859bd..79efd6b 100644 --- a/src/libxc.cxx +++ b/src/libxc.cxx @@ -256,7 +256,7 @@ 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 ; } @@ -264,13 +264,13 @@ bool LibxcKernelImpl::is_lda_() const noexcept { 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 { @@ -291,12 +291,11 @@ bool LibxcKernelImpl::is_polarized_() const noexcept { } 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; + int xcNumber = xc_info()->number; + return 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; + return false; #endif } diff --git a/src/xc_functional.cxx b/src/xc_functional.cxx index 24f99b4..6acfe02 100644 --- a/src/xc_functional.cxx +++ b/src/xc_functional.cxx @@ -711,7 +711,7 @@ LDA_EXC_GENERATOR( XCFunctional::eval_exc ) const { const size_t len_exc_buffer = exc_buffer_len(N); std::vector 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. ); @@ -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 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 ); } @@ -869,7 +869,7 @@ GGA_EXC_GENERATOR( XCFunctional::eval_exc ) const { const size_t len_exc_buffer = exc_buffer_len(N); std::vector 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. ); @@ -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 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 ); @@ -988,7 +988,7 @@ GGA_FXC_GENERATOR( XCFunctional::eval_fxc ) const { const size_t len_v2sigma2_buffer = v2sigma2_buffer_len(N); std::vector 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 ); @@ -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 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 ); @@ -1130,7 +1130,7 @@ MGGA_EXC_GENERATOR( XCFunctional::eval_exc ) const { const size_t len_exc_buffer = exc_buffer_len(N); std::vector 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. ); @@ -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 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 ); @@ -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() ) @@ -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() ) @@ -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); } @@ -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); } diff --git a/test/reference_values.cxx b/test/reference_values.cxx index dac4d7c..5590175 100644 --- a/test/reference_values.cxx +++ b/test/reference_values.cxx @@ -292,7 +292,7 @@ lda_reference load_lda_reference_values(ExchCXX::Kernel k, ExchCXX::Spin p) { if( p == Spin::Unpolarized ) { copy_iterable( rho, std::back_inserter(ref_vals.rho) ); - ref_vals.npts = rho.size(); + ref_vals.npts = static_cast(rho.size()); switch(k) { case Kernel::SlaterExchange: @@ -306,7 +306,7 @@ lda_reference load_lda_reference_values(ExchCXX::Kernel k, ExchCXX::Spin p) { } else { copy_iterable( rho_polarized, std::back_inserter(ref_vals.rho) ); - ref_vals.npts = rho_polarized.size() / 2; + ref_vals.npts = static_cast(rho_polarized.size() / 2); switch(k) { case Kernel::SlaterExchange: @@ -333,7 +333,7 @@ gga_reference load_gga_reference_values(ExchCXX::Kernel k, ExchCXX::Spin p) { if( p == Spin::Unpolarized ) { - ref_vals.npts = rho.size(); + ref_vals.npts = static_cast(rho.size()); copy_iterable( rho, std::back_inserter(ref_vals.rho) ); copy_iterable( sigma, std::back_inserter(ref_vals.sigma) ); @@ -349,7 +349,7 @@ gga_reference load_gga_reference_values(ExchCXX::Kernel k, ExchCXX::Spin p) { } else { - ref_vals.npts = rho_polarized.size() / 2; + ref_vals.npts = static_cast(rho_polarized.size() / 2); copy_iterable( rho_polarized, std::back_inserter(ref_vals.rho) ); copy_iterable( sigma_polarized, std::back_inserter(ref_vals.sigma) ); @@ -380,7 +380,7 @@ mgga_reference load_mgga_reference_values(ExchCXX::Kernel k, ExchCXX::Spin p, bo copy_iterable( sigma, std::back_inserter(ref_vals.sigma) ); copy_iterable( tau, std::back_inserter(ref_vals.tau) ); if(need_lap) copy_iterable( lapl, std::back_inserter(ref_vals.lapl) ); - ref_vals.npts = rho.size(); + ref_vals.npts = static_cast(rho.size()); switch(k) { case Kernel::SCAN_X: @@ -406,7 +406,7 @@ mgga_reference load_mgga_reference_values(ExchCXX::Kernel k, ExchCXX::Spin p, bo copy_iterable( sigma_polarized, std::back_inserter(ref_vals.sigma) ); copy_iterable( tau_polarized, std::back_inserter(ref_vals.tau) ); if(need_lap) copy_iterable( lapl_polarized, std::back_inserter(ref_vals.lapl) ); - ref_vals.npts = rho_polarized.size() / 2; + ref_vals.npts = static_cast(rho_polarized.size() / 2); switch(k) { case Kernel::SCAN_X: @@ -544,10 +544,10 @@ std::pair> load_reference_density(ExchCXX::Spin s) { int npts; if( s == ExchCXX::Spin::Polarized ) { - npts = rho_polarized.size() / 2; + npts = static_cast(rho_polarized.size() / 2); copy_iterable( rho_polarized, std::back_inserter(ref_rho) ); } else { - npts = rho.size(); + npts = static_cast(rho.size()); copy_iterable( rho, std::back_inserter(ref_rho) ); } return std::make_pair(npts, ref_rho); @@ -561,10 +561,10 @@ std::pair> load_reference_sigma(ExchCXX::Spin s) { int npts; if( s == ExchCXX::Spin::Polarized ) { - npts = sigma_polarized.size() / 3; + npts = static_cast(sigma_polarized.size() / 3); copy_iterable( sigma_polarized, std::back_inserter(ref_sigma) ); } else { - npts = sigma.size(); + npts = static_cast(sigma.size()); copy_iterable( sigma, std::back_inserter(ref_sigma) ); } return std::make_pair(npts, ref_sigma); @@ -577,10 +577,10 @@ std::pair> load_reference_lapl(ExchCXX::Spin s) { int npts; if( s == ExchCXX::Spin::Polarized ) { - npts = lapl_polarized.size() / 2; + npts = static_cast(lapl_polarized.size() / 2); copy_iterable( lapl_polarized, std::back_inserter(ref_lapl) ); } else { - npts = lapl.size(); + npts = static_cast(lapl.size()); copy_iterable( lapl, std::back_inserter(ref_lapl) ); } return std::make_pair(npts, ref_lapl); @@ -593,10 +593,10 @@ std::pair> load_reference_tau(ExchCXX::Spin s) { int npts; if( s == ExchCXX::Spin::Polarized ) { - npts = tau_polarized.size() / 2; + npts = static_cast(tau_polarized.size() / 2); copy_iterable( tau_polarized, std::back_inserter(ref_tau) ); } else { - npts = tau.size(); + npts = static_cast(tau.size()); copy_iterable( tau, std::back_inserter(ref_tau) ); } return std::make_pair(npts, ref_tau); diff --git a/test/xc_functional_test.cxx b/test/xc_functional_test.cxx index 58b0e9f..72a58da 100644 --- a/test/xc_functional_test.cxx +++ b/test/xc_functional_test.cxx @@ -345,26 +345,26 @@ void check_correctness( TestInterface interface, Backend backend, Spin polar, if( interface == TestInterface::EXC ) { if( kern.is_lda() ) - kern.eval_exc( npts, rho.data(), eps_refs.back().data() ); + kern.eval_exc( static_cast(npts), rho.data(), eps_refs.back().data() ); else if( kern.is_gga() ) - kern.eval_exc( npts, rho.data(), sigma.data(), + kern.eval_exc( static_cast(npts), rho.data(), sigma.data(), eps_refs.back().data() ); else if( kern.is_mgga() ) - kern.eval_exc( npts, rho.data(), sigma.data(), lapl.data(), tau.data(), + kern.eval_exc( static_cast(npts), rho.data(), sigma.data(), lapl.data(), tau.data(), eps_refs.back().data() ); } else if( interface == TestInterface::EXC_VXC ) { if( kern.is_lda() ) - kern.eval_exc_vxc( npts, rho.data(), eps_refs.back().data(), + kern.eval_exc_vxc( static_cast(npts), rho.data(), eps_refs.back().data(), vrho_refs.back().data() ); else if( kern.is_gga() ) - kern.eval_exc_vxc( npts, rho.data(), sigma.data(), + kern.eval_exc_vxc( static_cast(npts), rho.data(), sigma.data(), eps_refs.back().data(), vrho_refs.back().data(), vsigma_refs.back().data() ); else if( kern.is_mgga() ) - kern.eval_exc_vxc( npts, rho.data(), sigma.data(), - lapl.data(), tau.data(), eps_refs.back().data(), + kern.eval_exc_vxc( static_cast(npts), rho.data(), sigma.data(), + lapl.data(), tau.data(), eps_refs.back().data(), vrho_refs.back().data(), vsigma_refs.back().data(), vlapl_refs.back().data(), vtau_refs.back().data() ); @@ -382,13 +382,13 @@ void check_correctness( TestInterface interface, Backend backend, Spin polar, vtau( func.vtau_buffer_len( npts ) ); if( func.is_lda() ) - func.eval_exc_vxc( npts, rho.data(), eps.data(), vrho.data() ); + func.eval_exc_vxc( static_cast(npts), rho.data(), eps.data(), vrho.data() ); else if( func.is_gga() ) - func.eval_exc_vxc( npts, rho.data(), sigma.data(), + func.eval_exc_vxc( static_cast(npts), rho.data(), sigma.data(), eps.data(), vrho.data(), vsigma.data() ); else if( func.is_mgga() ) - func.eval_exc_vxc( npts, rho.data(), sigma.data(), - lapl.data(), tau.data(), eps.data(), vrho.data(), + func.eval_exc_vxc( static_cast(npts), rho.data(), sigma.data(), + lapl.data(), tau.data(), eps.data(), vrho.data(), vsigma.data(), vlapl.data(), vtau.data() ); diff --git a/test/xc_kernel_test.cxx b/test/xc_kernel_test.cxx index 71a099c..a08cd76 100644 --- a/test/xc_kernel_test.cxx +++ b/test/xc_kernel_test.cxx @@ -56,7 +56,7 @@ using namespace ExchCXX; TEST_CASE( "XCKernel Metadata Validity", "[xc-kernel]" ) { - const int npts = 1024; + const size_t npts = 1024; auto lda_kernel_test = Kernel::SlaterExchange; auto gga_kernel_test = Kernel::LYP; @@ -65,7 +65,7 @@ TEST_CASE( "XCKernel Metadata Validity", "[xc-kernel]" ) { auto mgga_lapl_kernel_test = Kernel::R2SCANL_C; auto epc_lda_kernel_test = Kernel::EPC17_2; - Backend backend; + Backend backend = Backend::builtin; SECTION( "Pure LDA Unpolarized" ) { @@ -392,7 +392,7 @@ TEST_CASE( "XCKernel Metadata Validity", "[xc-kernel]" ) { TEST_CASE( "XCKernel Metadata Correctness", "[xc-kernel]" ) { - Backend backend; + Backend backend = Backend::builtin; SECTION( "LDA Kernels" ) { SECTION( "Libxc Backend" ) { backend = Backend::libxc; } @@ -488,7 +488,7 @@ void kernel_test( TestInterface interface, Backend backend, Kernel kern, load_lda_reference_values( kern, polar ) : gen_lda_reference_values( backend,kern, polar ); - size_t npts = ref_vals.npts; + int npts = ref_vals.npts; const auto& rho = ref_vals.rho; const auto& exc_ref = ref_vals.exc; const auto& vrho_ref = ref_vals.vrho; @@ -577,7 +577,7 @@ void kernel_test( TestInterface interface, Backend backend, Kernel kern, load_gga_reference_values( kern, polar ) : gen_gga_reference_values( backend,kern, polar ); - size_t npts = ref_vals.npts; + int npts = ref_vals.npts; const auto& sigma = ref_vals.sigma; const auto& rho = ref_vals.rho; const auto& exc_ref = ref_vals.exc; @@ -695,7 +695,7 @@ void kernel_test( TestInterface interface, Backend backend, Kernel kern, //auto ref_vals = // gen_mgga_reference_values( backend,kern, polar ); - size_t npts = ref_vals.npts; + int npts = ref_vals.npts; const auto& rho = ref_vals.rho; const auto& sigma = ref_vals.sigma; const auto& lapl = ref_vals.lapl; @@ -974,27 +974,27 @@ void compare_libxc_builtin( TestInterface interface, EvalType evaltype, REQUIRE( npts_lda == npts_mgga ); REQUIRE( npts_lda == npts_lapl ); - const int npts = npts_lda; + const int npts = static_cast(npts_lda); XCKernel func_libxc ( Backend::libxc, kern, polar ); XCKernel func_builtin( Backend::builtin, kern, polar ); - const int len_rho = func_libxc.rho_buffer_len( npts ); - const int len_sigma = func_libxc.sigma_buffer_len( npts ); - const int len_lapl = func_libxc.lapl_buffer_len( npts ); - const int len_tau = func_libxc.tau_buffer_len( npts ); - - const int len_v2rho2 = func_libxc.v2rho2_buffer_len( npts ); - const int len_v2rhosigma = func_libxc.v2rhosigma_buffer_len( npts ); - const int len_v2rholapl = func_libxc.v2rholapl_buffer_len( npts ); - const int len_v2rhotau = func_libxc.v2rhotau_buffer_len( npts ); - const int len_v2sigma2 = func_libxc.v2sigma2_buffer_len( npts ); - const int len_v2sigmalapl = func_libxc.v2sigmalapl_buffer_len( npts ); - const int len_v2sigmatau = func_libxc.v2sigmatau_buffer_len( npts ); - const int len_v2lapl2 = func_libxc.v2lapl2_buffer_len( npts ); - const int len_v2lapltau = func_libxc.v2lapltau_buffer_len( npts ); - const int len_v2tau2 = func_libxc.v2tau2_buffer_len( npts ); + const size_t len_rho = func_libxc.rho_buffer_len( npts ); + const size_t len_sigma = func_libxc.sigma_buffer_len( npts ); + const size_t len_lapl = func_libxc.lapl_buffer_len( npts ); + const size_t len_tau = func_libxc.tau_buffer_len( npts ); + + const size_t len_v2rho2 = func_libxc.v2rho2_buffer_len( npts ); + const size_t len_v2rhosigma = func_libxc.v2rhosigma_buffer_len( npts ); + const size_t len_v2rholapl = func_libxc.v2rholapl_buffer_len( npts ); + const size_t len_v2rhotau = func_libxc.v2rhotau_buffer_len( npts ); + const size_t len_v2sigma2 = func_libxc.v2sigma2_buffer_len( npts ); + const size_t len_v2sigmalapl = func_libxc.v2sigmalapl_buffer_len( npts ); + const size_t len_v2sigmatau = func_libxc.v2sigmatau_buffer_len( npts ); + const size_t len_v2lapl2 = func_libxc.v2lapl2_buffer_len( npts ); + const size_t len_v2lapltau = func_libxc.v2lapltau_buffer_len( npts ); + const size_t len_v2tau2 = func_libxc.v2tau2_buffer_len( npts ); std::vector rho_small(len_rho, 1e-13); std::vector sigma_small(len_sigma, 1e-14);