diff --git a/.github/workflows/pull_request.yaml b/.github/workflows/pull_request.yaml index 023be9e2..f08bc7f1 100644 --- a/.github/workflows/pull_request.yaml +++ b/.github/workflows/pull_request.yaml @@ -26,6 +26,6 @@ jobs: with: config_file: '.github/.licenserc.yaml' source_dir: 'include src tests' - compilers: '["gcc-11"]' + compilers: '["gcc-11", "clang-14"]' doc_target: 'integrals_cxx_api' secrets: inherit diff --git a/CMakeLists.txt b/CMakeLists.txt index 8632207e..c55816cf 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -13,39 +13,38 @@ # limitations under the License. cmake_minimum_required(VERSION 3.14) -set(VERSION 1.0.0) #TODO: get from git -project(integrals VERSION "${VERSION}" LANGUAGES CXX) -include(FetchContent) -FetchContent_Declare( - nwx_cmake - GIT_REPOSITORY https://github.com/NWChemEx/NWXCMake -) -FetchContent_MakeAvailable(nwx_cmake) -list(APPEND CMAKE_MODULE_PATH "${nwx_cmake_SOURCE_DIR}/cmake") +# Downloads common CMake modules used throughout NWChemEx +include(cmake/get_nwx_cmake.cmake) -set( - CMAKE_MODULE_PATH "${CMAKE_MODULE_PATH}" "${PROJECT_SOURCE_DIR}/cmake" - CACHE STRING "" FORCE -) -include(get_cmaize) +#Sets the version to whatever git thinks it is +include(get_version_from_git) +get_version_from_git(integrals_version "${CMAKE_CURRENT_LIST_DIR}") +project(integrals VERSION "${integrals_version}" LANGUAGES CXX) + include(nwx_versions) +include(get_cmaize) include(nwx_cxx_api_docs) -nwx_cxx_api_docs("${CMAKE_CURRENT_SOURCE_DIR}/integrals") -### Options ### -option(BUILD_TESTING "Should we build the tests?" OFF) -option(BUILD_PYBIND11_PYBINDINGS "Use pybind11 to build Python3 bindings?" OFF) -option(BUILD_CPPYY_PYBINDINGS "Use Cppyy to build Python3 bindings?" OFF) +### Paths ### +set(INTEGRALS_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/src") +set(INTEGRALS_INCLUDE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/include") +set(INTEGRALS_TESTS_DIR "${CMAKE_CURRENT_SOURCE_DIR}/tests") +nwx_cxx_api_docs("${INTEGRALS_SOURCE_DIR}" "${INTEGRALS_INCLUDE_DIR}") + +### Options ### +cmaize_option_list( + BUILD_TESTING OFF "Should we build the tests?" + BUILD_PYBIND11_PYBINDINGS ON "Build pybind11 python3 bindings?" +) # Can't build from github due to Libint setup. # Will find prebuilt. Probably for the best. cmaize_find_or_build_dependency( Libint2 URL github.com/evaleev/libint - VERSION ${NWX_LIBINT2_VERSION} BUILD_TARGET int2 FIND_TARGET Libint2::int2 ) @@ -53,65 +52,45 @@ cmaize_find_or_build_dependency( cmaize_find_or_build_dependency( simde URL github.com/NWChemEx/SimDE - PRIVATE TRUE - VERSION ${NWX_SIMDE_VERSION} BUILD_TARGET simde FIND_TARGET nwx::simde CMAKE_ARGS BUILD_TESTING=OFF + BUILD_PYBIND11_PYBINDINGS=${BUILD_PYBIND11_PYBINDINGS} ) -set(project_src_dir "${CMAKE_CURRENT_LIST_DIR}/src/${PROJECT_NAME}") -set(project_inc_dir "${CMAKE_CURRENT_LIST_DIR}/include/${PROJECT_NAME}") - cmaize_add_library( ${PROJECT_NAME} - SOURCE_DIR "${project_src_dir}" - INCLUDE_DIRS "${project_inc_dir}" + SOURCE_DIR "${INTEGRALS_SOURCE_DIR}/${PROJECT_NAME}" + INCLUDE_DIRS "${INTEGRALS_INCLUDE_DIR}/${PROJECT_NAME}" DEPENDS Libint2 simde ) include(nwx_pybind11) nwx_add_pybind11_module( ${PROJECT_NAME} - SOURCE_DIR "${CMAKE_CURRENT_LIST_DIR}/src/python" + SOURCE_DIR "${INTEGRALS_SOURCE_DIR}/python" DEPENDS "${PROJECT_NAME}" ) -include(nwx_python_mods) -cppyy_make_python_package(PACKAGE integrals NAMESPACES integrals DEPPACKAGES simde ) - if("${BUILD_TESTING}") - set(CXX_TEST_DIR ${CMAKE_CURRENT_LIST_DIR}/tests/cxx) - set(PYTHON_TEST_DIR ${CMAKE_CURRENT_LIST_DIR}/tests/python) + set(CXX_TEST_DIR ${INTEGRALS_TESTS_DIR}/cxx/) + set(PYTHON_TEST_DIR ${INTEGRALS_TESTS_DIR}/python) cmaize_find_or_build_dependency( Catch2 URL github.com/catchorg/Catch2 BUILD_TARGET Catch2 FIND_TARGET Catch2::Catch2 - VERSION ${NWX_CATCH2_VERSION} - ) - cmaize_find_or_build_dependency( - mokup - URL github.com/NWChemEx/Mokup - PRIVATE TRUE - VERSION ${NWX_MOKUP_VERSION} - BUILD_TARGET mokup - FIND_TARGET nwx::mokup - CMAKE_ARGS BUILD_TESTING=OFF + VERSION v3.6.0 ) + cmaize_add_tests( test_unit_integrals - SOURCE_DIR "${CXX_TEST_DIR}/unit" - INCLUDE_DIRS "${project_src_dir}" - DEPENDS Catch2 mokup ${PROJECT_NAME} - ) - cmaize_add_tests( - test_integration_integrals - SOURCE_DIR "${CXX_TEST_DIR}/integration" - INCLUDE_DIRS "${project_src_dir}" - DEPENDS Catch2 mokup ${PROJECT_NAME} + SOURCE_DIR "${CXX_TEST_DIR}/unit/${PROJECT_NAME}" + INCLUDE_DIRS "${INTEGRALS_SOURCE_DIR}/${PROJECT_NAME}" + DEPENDS Catch2 ${PROJECT_NAME} ) + nwx_pybind11_tests( py_integrals "${PYTHON_TEST_DIR}/unit_tests/test_integrals.py" SUBMODULES pluginplay chemist parallelzone simde diff --git a/cmake/Findlibint.cmake b/cmake/Findlibint.cmake deleted file mode 100644 index aab08352..00000000 --- a/cmake/Findlibint.cmake +++ /dev/null @@ -1,52 +0,0 @@ -# Copyright 2022 NWChemEx-Project -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -# - Try to find LibInt -# -# In order to aid find_package the user may set LIBINT_ROOT_DIR to the root of -# the installed libint. -# -# Once done this will define -# LIBINT_FOUND - System has Libint -# LIBINT_INCLUDE_DIR - The Libint include directories -# LIBINT_LIBRARY - The libraries needed to use Libint - -#Prefer LIBINT_ROOT_DIR if the user specified it -if(NOT DEFINED LIBINT_ROOT_DIR) - find_package(PkgConfig) - pkg_check_modules(PC_LIBINT QUIET libint2) -endif() - -find_path(LIBINT_INCLUDE_DIR libint2.hpp - HINTS ${PC_LIBINT_INCLUDEDIR} - ${PC_LIBINT_INCLUDE_DIRS} - PATHS ${LIBINT_ROOT_DIR} - PATH_SUFFIXES libint2) - -find_library(LIBINT_LIBRARY NAMES int2 - HINTS ${PC_LIBINT_LIBDIR} - ${PC_LIBINT_LIBRARY_DIRS} - PATHS ${LIBINT_ROOT_DIR} - ) - -include(FindPackageHandleStandardArgs) -find_package_handle_standard_args(libint DEFAULT_MSG - LIBINT_LIBRARY LIBINT_INCLUDE_DIR) - -#if (LibInt_FOUND) -# find_package(Eigen3 REQUIRED) -#endif() - -set(LIBINT_LIBRARIES ${LIBINT_LIBRARY}) -set(LIBINT_INCLUDE_DIRS ${LIBINT_INCLUDE_DIR})# ${EIGEN3_INCLUDE_DIRS}) diff --git a/tests/python/unit_tests/ao_integrals/__init__.py b/cmake/get_nwx_cmake.cmake similarity index 56% rename from tests/python/unit_tests/ao_integrals/__init__.py rename to cmake/get_nwx_cmake.cmake index 4851bf40..c99674d9 100644 --- a/tests/python/unit_tests/ao_integrals/__init__.py +++ b/cmake/get_nwx_cmake.cmake @@ -1,4 +1,4 @@ -# Copyright 2023 NWChemEx-Project +# Copyright 2024 NWChemEx-Project # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -12,3 +12,20 @@ # See the License for the specific language governing permissions and # limitations under the License. +include_guard() + +macro(get_nwx_cmake) + include(FetchContent) + FetchContent_Declare( + nwx_cmake + GIT_REPOSITORY https://github.com/NWChemEx/NWXCMake + ) + FetchContent_MakeAvailable(nwx_cmake) + set( + CMAKE_MODULE_PATH "${CMAKE_MODULE_PATH}" "${nwx_cmake_SOURCE_DIR}/cmake" + CACHE STRING "" + FORCE + ) +endmacro() + +get_nwx_cmake() diff --git a/docs/requirements.txt b/docs/requirements.txt index 82133027..528ccda4 100644 --- a/docs/requirements.txt +++ b/docs/requirements.txt @@ -1,2 +1,3 @@ -sphinx -sphinx_rtd_theme +GitPython +sphinx==v7.2.6 +sphinx_rtd_theme==1.3.0 diff --git a/docs/source/conf.py b/docs/source/conf.py index a5fbf4bd..6f9a6594 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -21,44 +21,55 @@ # http://www.sphinx-doc.org/en/master/config import os +import git # -- Project information ----------------------------------------------------- -project = u'LibChemist' +project = u'Integrals' copyright = u'2020, NWChemEx Team' author = u'NWChemEx Team' -# Get the version from version.txt -with open('../../version.txt', 'r') as file: - version = file.read().replace('\n', '') -# The full version, including alpha/beta/rc tags -release = version - ############################################################################## # Shouldn't need to change anything below this point # ############################################################################## +# -- Project Paths ----------------------------------------------------------- + +dir_path = os.path.dirname(os.path.realpath(__file__)) +doc_path = os.path.dirname(dir_path) +root_path = os.path.dirname(doc_path) + +# -- Package Version --------------------------------------------------------- + +# Read the git tags, from ../../.git and find the most recent one +repo = git.Repo(root_path) +tags = sorted(repo.tags, key=lambda t: t.commit.committed_datetime) + +if len(tags): + last_tag = tags[-1] +else: + last_tag = "1.0.0" + +# This is the strictly numeric version (e.g., no "beta" qualifier) +version = str(last_tag) + +# This is the full version (includes qualifiers like "beta" or +# "release candidate") +release = version + # -- General configuration --------------------------------------------------- # If your documentation needs a minimal Sphinx version, state it here. # -# needs_sphinx = '1.0' +needs_sphinx = '7.2.6' # Add any Sphinx extension module names here, as strings. They can be # extensions coming with Sphinx (named 'sphinx.ext.*') or your custom # ones. extensions = [ - 'sphinx.ext.autodoc', - 'sphinx.ext.doctest', - 'sphinx.ext.intersphinx', - 'sphinx.ext.todo', - 'sphinx.ext.coverage', - 'sphinx.ext.mathjax', - 'sphinx.ext.githubpages' + 'sphinx.ext.autodoc', 'sphinx.ext.mathjax', 'sphinx.ext.githubpages', + 'sphinx.ext.autosummary', 'sphinx_rtd_theme', 'sphinx.ext.intersphinx' ] -dir_path = os.path.dirname(os.path.realpath(__file__)) -doc_path = os.path.dirname(dir_path) -root_path = os.path.dirname(doc_path) # Add any paths that contain templates here, relative to this directory. #templates_path = ['_templates'] @@ -77,7 +88,7 @@ # # This is also used if you do content translation via gettext catalogs. # Usually you set "language" from the command line for these cases. -language = None +language = 'en' # List of patterns, relative to source directory, that match files and # directories to ignore when looking for source files. @@ -87,6 +98,8 @@ # The name of the Pygments (syntax highlighting) style to use. pygments_style = 'sphinx' +numfig = True +numfig_secnum_depth = 0 # -- Options for HTML output ------------------------------------------------- @@ -116,13 +129,11 @@ # # html_sidebars = {} - # -- Options for HTMLHelp output --------------------------------------------- # Output file base name for HTML help builder. htmlhelp_basename = project + 'doc' - # -- Options for LaTeX output ------------------------------------------------ latex_elements = { @@ -147,18 +158,16 @@ # (source start file, target name, title, # author, documentclass [howto, manual, or own class]). latex_documents = [ - (master_doc, project + '.tex',project + ' Documentation', author, 'manual'), + (master_doc, project + '.tex', project + ' Documentation', author, + 'manual'), ] - # -- Options for manual page output ------------------------------------------ # One entry per manual page. List of tuples # (source start file, name, description, authors, manual section). -man_pages = [ - (master_doc, project.lower(), project + ' Documentation', [author], 1) -] - +man_pages = [(master_doc, project.lower(), project + ' Documentation', + [author], 1)] # -- Options for Texinfo output ---------------------------------------------- @@ -166,19 +175,13 @@ # (source start file, target name, title, author, # dir menu entry, description, category) texinfo_documents = [ - (master_doc, project, project + ' Documentation', - author, project, 'One line description of project.', 'Miscellaneous'), + (master_doc, project, project + ' Documentation', author, project, + 'One line description of project.', 'Miscellaneous'), ] - # -- Extension configuration ------------------------------------------------- # -- Options for intersphinx extension --------------------------------------- # Example configuration for intersphinx: refer to the Python standard library. -intersphinx_mapping = {'https://docs.python.org/': None} - -# -- Options for todo extension ---------------------------------------------- - -# If true, `todo` and `todoList` produce output, else they produce nothing. -todo_include_todos = True +intersphinx_mapping = {'python': ('https://docs.python.org/3', None)} diff --git a/docs/source/transformed_design.rst b/docs/source/transformed_design.rst deleted file mode 100644 index b472408e..00000000 --- a/docs/source/transformed_design.rst +++ /dev/null @@ -1,23 +0,0 @@ -.. Copyright 2022 NWChemEx-Project -.. -.. Licensed under the Apache License, Version 2.0 (the "License"); -.. you may not use this file except in compliance with the License. -.. You may obtain a copy of the License at -.. -.. http://www.apache.org/licenses/LICENSE-2.0 -.. -.. Unless required by applicable law or agreed to in writing, software -.. distributed under the License is distributed on an "AS IS" BASIS, -.. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -.. See the License for the specific language governing permissions and -.. limitations under the License. - -**************************** -Design of Transformed Module -**************************** - -Some quick notes about the design of the ``Transformed`` module. - -- ``property_types::Transformed` is templated on the property type ``T`` - - - This allows modules to specify they need a transformed overlap matrix by``Transformed`` \ No newline at end of file diff --git a/include/integrals/integrals.hpp b/include/integrals/integrals.hpp index 1d46c6cf..ac432349 100644 --- a/include/integrals/integrals.hpp +++ b/include/integrals/integrals.hpp @@ -1,5 +1,5 @@ /* - * Copyright 2022 NWChemEx-Project + * Copyright 2024 NWChemEx-Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -23,3 +23,9 @@ */ #pragma once #include "integrals/integrals_mm.hpp" + +/** @namespace integrals + * + * @brief The primary namespace for the Integrals library + */ +namespace integrals {} // end namespace integrals diff --git a/include/integrals/integrals_mm.hpp b/include/integrals/integrals_mm.hpp index 34331be7..55e479d7 100644 --- a/include/integrals/integrals_mm.hpp +++ b/include/integrals/integrals_mm.hpp @@ -1,5 +1,5 @@ /* - * Copyright 2022 NWChemEx-Project + * Copyright 2024 NWChemEx-Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -19,6 +19,12 @@ namespace integrals { +/** @brief Load this plugin's modules into a Module Manager + * + * @param mm The Module Manager to load the modules into + * + * @throw none No throw guarantee + */ DECLARE_PLUGIN(integrals); } // end namespace integrals diff --git a/src/integrals/ao_integrals/ao_integrals.cpp b/src/integrals/ao_integrals/ao_integrals.cpp index 7a957568..07277c4c 100644 --- a/src/integrals/ao_integrals/ao_integrals.cpp +++ b/src/integrals/ao_integrals/ao_integrals.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2022 NWChemEx-Project + * Copyright 2024 NWChemEx-Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -15,230 +15,122 @@ */ #include "ao_integrals.hpp" -#include "cs_screened_integrals.hpp" -#include "detail_/aos2shells.hpp" -#include "detail_/bsets_shell_sizes.hpp" -#include "detail_/get_coeff.hpp" -#include "detail_/make_shape.hpp" -#include "detail_/select_allocator.hpp" +#include "detail_/get_basis_sets.hpp" +#include "detail_/libint_op.hpp" +#include "detail_/make_engine.hpp" +#include "detail_/make_libint_basis_set.hpp" #include "detail_/shells2ord.hpp" -#include "detail_/unpack_bases.hpp" -#include "shellnorms.hpp" -//#include -#include -#include +#include namespace integrals::ao_integrals { -/// Type of a module that produces integral factories -template -using factory_pt = simde::IntegralFactory; -using factory_t = simde::type::integral_factory; - -/// Type of a module that produces integral shapes -using integral_shape_pt = simde::IntegralShape; - -/// Grab the various detail_ functions -using namespace detail_; - -template -TEMPLATED_MODULE_CTOR(AOIntegral, N, OperatorType, direct) { - description("Computes integrals with Libint"); - using my_pt = simde::AOTensorRepresentation; - +template +TEMPLATED_MODULE_CTOR(AOIntegral, BraKetType) { + using my_pt = simde::EvaluateBraKet; satisfies_property_type(); + description("Computes integrals with Libint"); - add_submodule>("AO Integral Factory") - .set_description("Used to generate the AO factory"); - - add_submodule("Tensor Shape") - .set_description("Determines the shape of the resulting tensor"); + add_input("Threshold") + .set_default(1.0E-16) + .set_description( + "The target precision with which the integrals will be computed"); } -template -TEMPLATED_MODULE_RUN(AOIntegral, N, OperatorType, direct) { - // Typedefs - using my_pt = simde::AOTensorRepresentation; - using size_vector_t = std::vector; - using tensor_t = simde::type::tensor; - using field_t = typename tensor_t::field_type; - using shape_t = typename tensor_t::shape_type; - - auto bases = unpack_bases(inputs); - auto op_str = OperatorType().as_string(); - auto& fac_mod = submods.at("AO Integral Factory"); - const auto& op = inputs.at(op_str).template value(); - auto coeff = get_coefficient(op); - auto shell_sizes = bsets_shell_sizes(bases); - - // Cache result of factory module - fac_mod.run_as>(bases, op, 0ul); - - // Lambda to calculate values - auto l = [=](const auto& lo, const auto& up, auto* data) mutable { - // Convert index values from AOs to shells - size_vector_t lo_shells, up_shells; - for(auto i = 0; i < N; ++i) { - auto shells_in_tile = aos2shells(shell_sizes[i], lo[i], up[i]); - lo_shells.push_back(shells_in_tile.front()); - up_shells.push_back(shells_in_tile.back()); - } - - // Get integral factory - auto factory = fac_mod.run_as>(bases, op, 0ul); - - // Loop through shell combinations - size_vector_t curr_shells = lo_shells; - while(curr_shells[0] <= up_shells[0]) { - // Determine which values will be computed this time - auto ord_pos = - shells2ord(shell_sizes, curr_shells, lo_shells, up_shells); - - const auto& buf = factory.compute(curr_shells); - auto vals = buf[0]; - - if(vals) { - // Copy libint values into tile data; - for(auto i = 0; i < ord_pos.size(); ++i) { - data[ord_pos[i]] = vals[i] * coeff; - } - } else { - for(auto i = 0; i < ord_pos.size(); ++i) { - data[ord_pos[i]] = 0.0; - } +template +TEMPLATED_MODULE_RUN(AOIntegral, BraKetType) { + using my_pt = simde::EvaluateBraKet; + + const auto& [braket] = my_pt::unwrap_inputs(inputs); + auto thresh = inputs.at("Threshold").value(); + auto bra = braket.bra(); + auto ket = braket.ket(); + auto op = braket.op(); + + // Gather information from Bra, Ket, and Op + auto basis_sets = detail_::get_basis_sets(bra, ket); + constexpr int N = detail_::get_n(bra, ket); + + // Dimensional information + std::vector dims_shells(N); + Eigen::array dims_bfs; + for(auto i = 0; i < N; ++i) { + dims_shells[i] = basis_sets[i].size(); + dims_bfs[i] = basis_sets[i].nbf(); + } + + // Build tensor inputs + using tensor_t = simde::type::tensor; + using shape_t = tensorwrapper::shape::Smooth; + using layout_t = tensorwrapper::layout::Physical; + using buffer_t = tensorwrapper::buffer::Eigen; + using data_t = typename buffer_t::data_type; + + shape_t s{dims_bfs.begin(), dims_bfs.end()}; + layout_t l(s); + data_t d(dims_bfs); + buffer_t b{d, l}; + b.value().setZero(); + + // Make libint engine + auto engine = detail_::make_engine(basis_sets, op, thresh); + const auto& buf = engine.results(); + + // Fill in values + std::vector shells(N, 0); + while(shells[0] < dims_shells[0]) { + detail_::run_engine_(engine, basis_sets, shells, + std::make_index_sequence()); + + auto vals = buf[0]; + if(vals) { + auto ord = detail_::shells2ord(basis_sets, shells); + auto n_ord = ord.size(); + for(decltype(n_ord) i_ord = 0; i_ord < n_ord; ++i_ord) { + b.value().data()[ord[i_ord]] = vals[i_ord]; } + } - // Increment curr_shells - curr_shells[N - 1] += 1; - for(auto i = 1; i < N; ++i) { - if(curr_shells[N - i] > up_shells[N - i]) { - // Reset this dimension and increment the next one - // curr_shells[0] accumulates until we reach the end - curr_shells[N - i] = lo_shells[N - i]; - curr_shells[N - i - 1] += 1; - } + // Increment index + shells[N - 1] += 1; + for(auto i = 1; i < N; ++i) { + if(shells[N - i] >= dims_shells[N - i]) { + // Reset this dimension and increment the next one + // shells[0] accumulates until we reach the end + shells[N - i] = 0; + shells[N - i - 1] += 1; } } - }; + } - auto shape = submods.at("Tensor Shape").run_as(bases); - - tensor_t I(l, std::make_unique(shape), - select_allocator(bases, op)); - - // Finish + tensor_t t({s, b}); auto rv = results(); - return my_pt::wrap_results(rv, I); + return my_pt::wrap_results(rv, t); } -// ----------------------------------------------------------------------------- -// -- Template Declarations -// ----------------------------------------------------------------------------- - -#define TEMPLATE_AOI_AND_DIRECT(N, op) \ - template class AOIntegral; \ - template class AOIntegral - -TEMPLATE_AOI_AND_DIRECT(2, simde::type::el_el_coulomb); -TEMPLATE_AOI_AND_DIRECT(3, simde::type::el_el_coulomb); -TEMPLATE_AOI_AND_DIRECT(4, simde::type::el_el_coulomb); -TEMPLATE_AOI_AND_DIRECT(2, simde::type::el_kinetic); -TEMPLATE_AOI_AND_DIRECT(2, simde::type::el_nuc_coulomb); -TEMPLATE_AOI_AND_DIRECT(2, simde::type::el_identity); -TEMPLATE_AOI_AND_DIRECT(2, simde::type::el_el_stg); -TEMPLATE_AOI_AND_DIRECT(3, simde::type::el_el_stg); -TEMPLATE_AOI_AND_DIRECT(4, simde::type::el_el_stg); -TEMPLATE_AOI_AND_DIRECT(2, simde::type::el_el_yukawa); -TEMPLATE_AOI_AND_DIRECT(3, simde::type::el_el_yukawa); -TEMPLATE_AOI_AND_DIRECT(4, simde::type::el_el_yukawa); -TEMPLATE_AOI_AND_DIRECT(2, simde::type::el_el_f12_commutator); -TEMPLATE_AOI_AND_DIRECT(3, simde::type::el_el_f12_commutator); -TEMPLATE_AOI_AND_DIRECT(4, simde::type::el_el_f12_commutator); -TEMPLATE_AOI_AND_DIRECT(4, simde::type::el_el_delta); - -#undef TEMPLATE_AOI_AND_DIRECT - -// ----------------------------------------------------------------------------- -// -- Define Module Load Functions -// ----------------------------------------------------------------------------- - -#define ADD_AOI_WITH_DIRECT(N, op, key_base) \ - mm.add_module>(key_base); \ - mm.add_module>("Direct " key_base) - -#define ADD_CS_AOI_WITH_DIRECT(N, op, key_base) \ - mm.add_module>(key_base); \ - mm.add_module>("Direct " key_base) - -void load_ao_integrals(pluginplay::ModuleManager& mm) { - using namespace simde::type; - - mm.add_module("DOI"); - mm.add_module("Direct DOI"); - mm.add_module>("EDipole"); - mm.add_module>("EQuadrupole"); - mm.add_module>("EOctupole"); - mm.add_module>( - "STG 4 Center dfdr Squared"); - - ADD_AOI_WITH_DIRECT(2, el_el_coulomb, "ERI2"); - ADD_AOI_WITH_DIRECT(3, el_el_coulomb, "ERI3"); - ADD_AOI_WITH_DIRECT(4, el_el_coulomb, "ERI4"); - ADD_AOI_WITH_DIRECT(2, el_kinetic, "Kinetic"); - ADD_AOI_WITH_DIRECT(2, el_nuc_coulomb, "Nuclear"); - ADD_AOI_WITH_DIRECT(2, el_identity, "Overlap"); - ADD_AOI_WITH_DIRECT(2, el_el_stg, "STG2"); - ADD_AOI_WITH_DIRECT(3, el_el_stg, "STG3"); - ADD_AOI_WITH_DIRECT(4, el_el_stg, "STG4"); - ADD_AOI_WITH_DIRECT(2, el_el_yukawa, "Yukawa2"); - ADD_AOI_WITH_DIRECT(3, el_el_yukawa, "Yukawa3"); - ADD_AOI_WITH_DIRECT(4, el_el_yukawa, "Yukawa4"); - ADD_AOI_WITH_DIRECT(4, el_el_delta, "DOI4"); - ADD_CS_AOI_WITH_DIRECT(2, el_kinetic, "Kinetic CS"); - ADD_CS_AOI_WITH_DIRECT(2, el_nuc_coulomb, "Nuclear CS"); - ADD_CS_AOI_WITH_DIRECT(2, el_identity, "Overlap CS"); - ADD_CS_AOI_WITH_DIRECT(3, el_el_coulomb, "ERI3 CS"); - ADD_CS_AOI_WITH_DIRECT(4, el_el_coulomb, "ERI4 CS"); - ADD_CS_AOI_WITH_DIRECT(3, el_el_stg, "STG3 CS"); - ADD_CS_AOI_WITH_DIRECT(4, el_el_stg, "STG4 CS"); - ADD_CS_AOI_WITH_DIRECT(3, el_el_yukawa, "Yukawa3 CS"); - ADD_CS_AOI_WITH_DIRECT(4, el_el_yukawa, "Yukawa4 CS"); - - /// TODO: Uncomment after module optimization - // mm.add_module("Shell Norms Overlap"); - // mm.add_module("Shell Norms Coulomb"); - // mm.add_module("Shell Norms STG"); - // mm.add_module("Shell Norms Yukawa"); -} +#define AOI(bra, op, ket) AOIntegral> +#define EXTERN_AOI(bra, op, ket) template struct AOI(bra, op, ket) +#define LOAD_AOI(bra, op, ket, key) mm.add_module(key) -#undef ADD_AOI_WITH_DIRECT -#undef ADD_CS_AOI_WITH_DIRECT +EXTERN_AOI(aos, t_e_type, aos); +EXTERN_AOI(aos, v_en_type, aos); +EXTERN_AOI(aos, v_ee_type, aos); +EXTERN_AOI(aos, v_ee_type, aos_squared); +EXTERN_AOI(aos_squared, v_ee_type, aos_squared); void ao_integrals_set_defaults(pluginplay::ModuleManager& mm) { - // Set DOI submods - mm.change_submod("DOI", "DOI4", "DOI4"); - mm.change_submod("Direct DOI", "DOI4", "Direct DOI4"); - - // Set shell norm submods - // std::string sh_norm = "Shell Norms"; - // mm.change_submod("Kinetic CS", sh_norm, sh_norm + " Overlap"); - // mm.change_submod("Nuclear CS", sh_norm, sh_norm + " Overlap"); - // mm.change_submod("Overlap CS", sh_norm, sh_norm + " Overlap"); - // mm.change_submod("ERI3 CS", sh_norm, sh_norm + " Coulomb"); - // mm.change_submod("ERI4 CS", sh_norm, sh_norm + " Coulomb"); - // mm.change_submod("STG3 CS", sh_norm, sh_norm + " STG"); - // mm.change_submod("STG4 CS", sh_norm, sh_norm + " STG"); - // mm.change_submod("Yukawa3 CS", sh_norm, sh_norm + " Yukawa"); - // mm.change_submod("Yukawa4 CS", sh_norm, sh_norm + " Yukawa"); - // mm.change_submod("Direct Kinetic CS", sh_norm, sh_norm + " Overlap"); - // mm.change_submod("Direct Nuclear CS", sh_norm, sh_norm + " Overlap"); - // mm.change_submod("Direct Overlap CS", sh_norm, sh_norm + " Overlap"); - // mm.change_submod("Direct ERI3 CS", sh_norm, sh_norm + " Coulomb"); - // mm.change_submod("Direct ERI4 CS", sh_norm, sh_norm + " Coulomb"); - // mm.change_submod("Direct STG3 CS", sh_norm, sh_norm + " STG"); - // mm.change_submod("Direct STG4 CS", sh_norm, sh_norm + " STG"); - // mm.change_submod("Direct Yukawa3 CS", sh_norm, sh_norm + " Yukawa"); - // mm.change_submod("Direct Yukawa4 CS", sh_norm, sh_norm + " Yukawa"); + // Set any default associations } -} // namespace integrals::ao_integrals +void load_ao_integrals(pluginplay::ModuleManager& mm) { + LOAD_AOI(aos, t_e_type, aos, "Kinetic"); + LOAD_AOI(aos, v_en_type, aos, "Nuclear"); + LOAD_AOI(aos, v_ee_type, aos, "ERI2"); + LOAD_AOI(aos, v_ee_type, aos_squared, "ERI3"); + LOAD_AOI(aos_squared, v_ee_type, aos_squared, "ERI4"); + ao_integrals_set_defaults(mm); +} + +#undef AOI +#undef ADD_AOI + +} // namespace integrals::ao_integrals \ No newline at end of file diff --git a/src/integrals/ao_integrals/ao_integrals.hpp b/src/integrals/ao_integrals/ao_integrals.hpp index f57f0680..b040b1d3 100644 --- a/src/integrals/ao_integrals/ao_integrals.hpp +++ b/src/integrals/ao_integrals/ao_integrals.hpp @@ -1,5 +1,5 @@ /* - * Copyright 2022 NWChemEx-Project + * Copyright 2024 NWChemEx-Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -15,59 +15,56 @@ */ #pragma once -#include +#include #include +/** @namespace integrals::ao_integrals + * + * @brief The namespace for the modules that produce AO Integrals + */ namespace integrals::ao_integrals { -// ----------------------------------------------------------------------------- -// -- Declare Module Load Functions -// ----------------------------------------------------------------------------- +using simde::type::braket; -void load_ao_integrals(pluginplay::ModuleManager& mm); -void ao_integrals_set_defaults(pluginplay::ModuleManager& mm); +using simde::type::aos; +using simde::type::aos_squared; -// ----------------------------------------------------------------------------- -// -- Declare Integral Module Types -// ----------------------------------------------------------------------------- +using simde::type::t_e_type; +using simde::type::v_ee_type; +using simde::type::v_en_type; -template +/** @brief The Module for computing AO Integrals + * + * @tparam BraKetType The type of the BraKet input + */ +template DECLARE_MODULE(AOIntegral); -template -DECLARE_MODULE(AOIntegralMultipole); - -DECLARE_MODULE(AOIntegralDOI); - -// ----------------------------------------------------------------------------- -// -- Forward External Template Declarations -// ----------------------------------------------------------------------------- +/** @brief Load the AO integral modules into a Module Manager + * + * @param mm The Module Manager to load the modules into + * + * @throw none No throw guarantee + */ +void load_ao_integrals(pluginplay::ModuleManager& mm); -#define EXTERN_INT_AND_DIRECT(N, op) \ - extern template class AOIntegral; \ - extern template class AOIntegral +/** @brief Set default module relationships + * + * @param mm The Module Manager with modules whose defaults will be set + * + * @throw none No throw guarantee + */ +void ao_integrals_set_defaults(pluginplay::ModuleManager& mm); -EXTERN_INT_AND_DIRECT(2, simde::type::el_el_coulomb); -EXTERN_INT_AND_DIRECT(3, simde::type::el_el_coulomb); -EXTERN_INT_AND_DIRECT(4, simde::type::el_el_coulomb); -EXTERN_INT_AND_DIRECT(2, simde::type::el_kinetic); -EXTERN_INT_AND_DIRECT(2, simde::type::el_nuc_coulomb); -EXTERN_INT_AND_DIRECT(2, simde::type::el_identity); -EXTERN_INT_AND_DIRECT(2, simde::type::el_el_stg); -EXTERN_INT_AND_DIRECT(3, simde::type::el_el_stg); -EXTERN_INT_AND_DIRECT(4, simde::type::el_el_stg); -EXTERN_INT_AND_DIRECT(2, simde::type::el_el_yukawa); -EXTERN_INT_AND_DIRECT(3, simde::type::el_el_yukawa); -EXTERN_INT_AND_DIRECT(4, simde::type::el_el_yukawa); -EXTERN_INT_AND_DIRECT(2, simde::type::el_el_f12_commutator); -EXTERN_INT_AND_DIRECT(3, simde::type::el_el_f12_commutator); -EXTERN_INT_AND_DIRECT(4, simde::type::el_el_f12_commutator); -EXTERN_INT_AND_DIRECT(4, simde::type::el_el_delta); +// Forward External Template Declarations +#define EXTERN_AOI extern template struct AOIntegral -#undef EXTERN_INT_AND_DIRECT +EXTERN_AOI>; +EXTERN_AOI>; +EXTERN_AOI>; +EXTERN_AOI>; +EXTERN_AOI>; -extern template class AOIntegralMultipole<0, simde::type::el_dipole>; -extern template class AOIntegralMultipole<1, simde::type::el_quadrupole>; -extern template class AOIntegralMultipole<2, simde::type::el_octupole>; +#undef EXTERN_AOI } // namespace integrals::ao_integrals diff --git a/src/integrals/ao_integrals/cs_screened_integrals.cpp b/src/integrals/ao_integrals/cs_screened_integrals.cpp deleted file mode 100644 index afebdb91..00000000 --- a/src/integrals/ao_integrals/cs_screened_integrals.cpp +++ /dev/null @@ -1,220 +0,0 @@ -/* - * Copyright 2022 NWChemEx-Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "cs_screened_integrals.hpp" -#include "detail_/aos2shells.hpp" -#include "detail_/bsets_shell_centers.hpp" -#include "detail_/bsets_shell_sizes.hpp" -#include "detail_/get_coeff.hpp" -#include "detail_/make_shape.hpp" -#include "detail_/select_allocator.hpp" -#include "detail_/shells2ord.hpp" -#include "detail_/unpack_bases.hpp" -//#include -#include -#include -#include -#include - -namespace integrals::ao_integrals { - -/// Type of a module that produces integral factories -template -using factory_pt = simde::IntegralFactory; -using factory_t = simde::type::integral_factory; - -/// Type of a module that produces integral shapes -using integral_shape_pt = simde::IntegralShape; - -/// Grab the various detail_ functions -using namespace detail_; - -/// For 1-body screening -using identity_op_t = simde::type::el_identity; - -template -TEMPLATED_MODULE_CTOR(CSAOIntegral, N, OperatorType, direct) { - description("Computes an in-core integral with libint"); - using my_pt = simde::AOTensorRepresentation; - - satisfies_property_type(); - - add_submodule>("AO Integral Factory") - .set_description("Used to generate the AO factory"); - - add_submodule("Tensor Shape") - .set_description("Determines the shape of the resulting tensor"); - - add_input("Screening Threshold") - .set_default(0.0) - .set_description("Cauchy-Schwarz Screening Threshold"); - - if constexpr(N > 2) { /// Use operator based screening for 2-body integrals - add_submodule>("Shell Norms") - .set_description( - "Computes the Cauchy-Schwarz Matrix for a pair of basis sets"); - } - - if constexpr(N == 2) { /// Use overlap based screening for 1-body integrals - add_submodule>("Shell Norms") - .set_description( - "Computes the Cauchy-Schwarz Matrix for a pair of basis sets"); - } -} - -template -TEMPLATED_MODULE_RUN(CSAOIntegral, N, OperatorType, direct) { - // Typedefs - using my_pt = simde::AOTensorRepresentation; - using ao_space_t = simde::type::ao_space; - using tensor_t = simde::type::tensor; - using field_t = typename tensor_t::field_type; - using shape_t = typename tensor_t::shape_type; - using size_vector_t = std::vector; - using shell_norm_t = std::vector>; - - // Grab input information - auto bases = unpack_bases(inputs); - auto op_str = OperatorType().as_string(); - auto cs_thresh = inputs.at("Screening Threshold").value(); - auto& fac_mod = submods.at("AO Integral Factory"); - const auto& op = inputs.at(op_str).template value(); - auto coeff = get_coefficient(op); - auto shell_sizes = bsets_shell_sizes(bases); - auto shell_centers = bsets_shell_centers(bases); - - // Calculate Shell Norms for screening - shell_norm_t mat1, mat2; - auto& cs_screen = submods.at("Shell Norms"); - - if constexpr(N == 2) { - auto bra = inputs.at("bra").template value(); - auto ket = inputs.at("ket").template value(); - identity_op_t I; - mat1 = cs_screen.run_as>(bra, I, ket); - } - if constexpr(N > 2) { - auto ket1 = inputs.at("ket 1").template value(); - auto ket2 = inputs.at("ket 2").template value(); - mat1 = - cs_screen.run_as>(ket1, op, ket2); - } - if constexpr(N == 4) { - auto bra1 = inputs.at("bra 1").template value(); - auto bra2 = inputs.at("bra 2").template value(); - mat2 = - cs_screen.run_as>(bra1, op, bra2); - } - - // Cache result of factory module - fac_mod.run_as>(bases, op, 0ul); - - // Lambda to calculate values - auto l = [=](const auto& lo, const auto& up, auto* data) mutable { - // Convert index values from AOs to shells - size_vector_t lo_shells, up_shells; - for(auto i = 0; i < N; ++i) { - auto shells_in_tile = aos2shells(shell_sizes[i], lo[i], up[i]); - lo_shells.push_back(shells_in_tile.front()); - up_shells.push_back(shells_in_tile.back()); - } - - // Get integral factory - auto factory = fac_mod.run_as>(bases, op, 0ul); - - // Loop through shell combinations - size_vector_t curr_shells = lo_shells; - while(curr_shells[0] <= up_shells[0]) { - // Determine which values will be computed this time - auto ord_pos = - shells2ord(shell_sizes, curr_shells, lo_shells, up_shells); - - // Determine the screening value - auto screen_value = mat1[curr_shells[N - 2]][curr_shells[N - 1]]; - if constexpr(N == 4) { - screen_value *= mat2[curr_shells[N - 4]][curr_shells[N - 3]]; - } - - // Ensure that shells on the same center aren't screened out - // in 1-body integrals - if constexpr(N == 2) { - auto center_i = shell_centers[0][curr_shells[0]]; - auto center_j = shell_centers[1][curr_shells[1]]; - bool same_center = (center_i == center_j); - screen_value = (same_center) ? cs_thresh + 1 : screen_value; - } - - // If shell pair isn't screened out, calcuate the current values. - // Otherwise, set the current values to 0. - if(screen_value > cs_thresh) { - // Compute values - const auto& buf = factory.compute(curr_shells); - auto vals = buf[0]; - - // Copy libint values into tile data; - for(auto i = 0; i < ord_pos.size(); ++i) { - data[ord_pos[i]] = vals[i] * coeff; - } - } else { - for(auto i = 0; i < ord_pos.size(); ++i) { - data[ord_pos[i]] = 0.0; - } - } - - // Increment curr_shells - curr_shells[N - 1] += 1; - for(auto i = 1; i < N; ++i) { - if(curr_shells[N - i] > up_shells[N - i]) { - // Reset this dimension and increment the next one - // curr_shells[0] accumulates until we reach the end - curr_shells[N - i] = lo_shells[N - i]; - curr_shells[N - i - 1] += 1; - } - } - } - }; - - auto shape = submods.at("Tensor Shape").run_as(bases); - - tensor_t I(l, std::make_unique(shape), - select_allocator(bases, op, cs_thresh)); - - // Finish - auto rv = results(); - return my_pt::wrap_results(rv, I); -} - -// ----------------------------------------------------------------------------- -// -- Template Declarations -// ----------------------------------------------------------------------------- - -#define TEMPLATE_INT_AND_DIRECT(N, op) \ - template class CSAOIntegral; \ - template class CSAOIntegral - -TEMPLATE_INT_AND_DIRECT(2, simde::type::el_kinetic); -TEMPLATE_INT_AND_DIRECT(2, simde::type::el_nuc_coulomb); -TEMPLATE_INT_AND_DIRECT(2, simde::type::el_identity); -TEMPLATE_INT_AND_DIRECT(3, simde::type::el_el_coulomb); -TEMPLATE_INT_AND_DIRECT(4, simde::type::el_el_coulomb); -TEMPLATE_INT_AND_DIRECT(3, simde::type::el_el_stg); -TEMPLATE_INT_AND_DIRECT(4, simde::type::el_el_stg); -TEMPLATE_INT_AND_DIRECT(3, simde::type::el_el_yukawa); -TEMPLATE_INT_AND_DIRECT(4, simde::type::el_el_yukawa); - -#undef TEMPLATE_INT_AND_DIRECT - -} // namespace integrals::ao_integrals diff --git a/src/integrals/ao_integrals/cs_screened_integrals.hpp b/src/integrals/ao_integrals/cs_screened_integrals.hpp deleted file mode 100644 index 51b4480f..00000000 --- a/src/integrals/ao_integrals/cs_screened_integrals.hpp +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Copyright 2022 NWChemEx-Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#pragma once -#include -#include - -namespace integrals::ao_integrals { - -// ----------------------------------------------------------------------------- -// -- Declare Integral Module Types -// ----------------------------------------------------------------------------- - -template -DECLARE_MODULE(CSAOIntegral); - -// ----------------------------------------------------------------------------- -// -- Forward External Template Declarations -// ----------------------------------------------------------------------------- - -#define EXTERN_INT_AND_DIRECT(N, op) \ - extern template class CSAOIntegral; \ - extern template class CSAOIntegral - -EXTERN_INT_AND_DIRECT(2, simde::type::el_kinetic); -EXTERN_INT_AND_DIRECT(2, simde::type::el_nuc_coulomb); -EXTERN_INT_AND_DIRECT(2, simde::type::el_identity); -EXTERN_INT_AND_DIRECT(3, simde::type::el_el_coulomb); -EXTERN_INT_AND_DIRECT(4, simde::type::el_el_coulomb); -EXTERN_INT_AND_DIRECT(3, simde::type::el_el_stg); -EXTERN_INT_AND_DIRECT(4, simde::type::el_el_stg); -EXTERN_INT_AND_DIRECT(3, simde::type::el_el_yukawa); -EXTERN_INT_AND_DIRECT(4, simde::type::el_el_yukawa); - -#undef EXTERN_INT_AND_DIRECT - -} // namespace integrals::ao_integrals diff --git a/src/integrals/ao_integrals/detail_/aos2shells.hpp b/src/integrals/ao_integrals/detail_/aos2shells.hpp deleted file mode 100644 index a1ebb7e8..00000000 --- a/src/integrals/ao_integrals/detail_/aos2shells.hpp +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright 2022 NWChemEx-Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#pragma once -#include - -namespace integrals::ao_integrals::detail_ { - -/** @brief Find the shells that contain the specified AOs. - * - * Given an vector of shell sizes @p shell_sizes and a lower @p lower and - * upper @p AO index, returns a std::vector of shell indices that contain the - * AOs between @p lower and @p upper. - * - * @param[in] shell_sizes The size of the shells of the basis sets - * @param[in] lo The lower value of the AO range - * @param[in] up The upper value of the AO range - * @returns An std::vector of the shell indices - */ -inline auto aos2shells(const std::vector& shell_sizes, - std::size_t lo, std::size_t up) { - std::vector return_vec; - for(auto ishell = 0, offset = 0; ishell < shell_sizes.size(); ++ishell) { - if(offset >= up) break; - if(offset >= lo) return_vec.push_back(ishell); - offset += shell_sizes[ishell]; - } - return return_vec; -} - -} // namespace integrals::ao_integrals::detail_ diff --git a/src/integrals/ao_integrals/detail_/bsets_shell_centers.hpp b/src/integrals/ao_integrals/detail_/bsets_shell_centers.hpp deleted file mode 100644 index bf542443..00000000 --- a/src/integrals/ao_integrals/detail_/bsets_shell_centers.hpp +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright 2022 NWChemEx-Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#pragma once -#include - -namespace integrals::ao_integrals::detail_ { - -/** @brief Determine the centers of the shells of the basis sets. - * - * - * - * @param[in] bases A vector of basis sets. - * @returns The shell sizes for the basis sets as a vector of vectors. - */ -inline auto bsets_shell_centers( - const std::vector& bases) { - auto N = bases.size(); - std::vector> shell_centers(N); - for(auto i = 0; i < N; ++i) { - for(auto c = 0; c < bases[i].size(); ++c) { - for(auto s = 0; s < bases[i][c].size(); ++s) { - shell_centers[i].push_back(c); - } - } - } - return shell_centers; -} - -} // namespace integrals::ao_integrals::detail_ \ No newline at end of file diff --git a/src/integrals/ao_integrals/detail_/get_basis_sets.hpp b/src/integrals/ao_integrals/detail_/get_basis_sets.hpp new file mode 100644 index 00000000..8263eb85 --- /dev/null +++ b/src/integrals/ao_integrals/detail_/get_basis_sets.hpp @@ -0,0 +1,81 @@ +/* + * Copyright 2024 NWChemEx-Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#pragma once +#include "make_libint_basis_set.hpp" +#include + +namespace integrals::ao_integrals::detail_ { + +/** @brief Deterimine how many basis sets are in the Bra and Ket. + * + * @tparam BraType The type of the Bra + * @tparam KetType The type of the Ket + * @param[in] bra The Bra + * @param[in] ket The Ket + * @returns The number of basis sets in the Bra and Ket + */ +template +constexpr int get_n(const BraType& bra, const KetType& ket) { + using simde::type::aos; + using simde::type::aos_squared; + constexpr auto bra_is_aos = std::is_same_v; + constexpr auto bra_is_aos_squared = std::is_same_v; + constexpr auto ket_is_aos = std::is_same_v; + constexpr auto ket_is_aos_squared = std::is_same_v; + if constexpr(bra_is_aos && ket_is_aos) { + return 2; + } else if constexpr(bra_is_aos && ket_is_aos_squared) { + return 3; + } else if constexpr(bra_is_aos_squared && ket_is_aos_squared) { + return 4; + } +} + +/** @brief Unpack the basis sets from the Bra and Ket. + * + * @tparam BraType The type of the Bra + * @tparam KetType The type of the Ket + * @param[in] bra The Bra + * @param[in] ket The Ket + * @returns A vector of basis sets in libint form + */ +template +std::vector get_basis_sets(const BraType& bra, + const KetType& ket) { + using simde::type::aos; + using simde::type::aos_squared; + + std::vector basis_sets; + + if constexpr(std::is_same_v) { + basis_sets.push_back(make_libint_basis_set(bra.ao_basis_set())); + } else if constexpr(std::is_same_v) { + basis_sets.push_back(make_libint_basis_set(bra.lhs().ao_basis_set())); + basis_sets.push_back(make_libint_basis_set(bra.rhs().ao_basis_set())); + } + + if constexpr(std::is_same_v) { + basis_sets.push_back(make_libint_basis_set(ket.ao_basis_set())); + } else if constexpr(std::is_same_v) { + basis_sets.push_back(make_libint_basis_set(ket.lhs().ao_basis_set())); + basis_sets.push_back(make_libint_basis_set(ket.rhs().ao_basis_set())); + } + + return basis_sets; +} + +} // namespace integrals::ao_integrals::detail_ diff --git a/src/integrals/ao_integrals/detail_/get_coeff.hpp b/src/integrals/ao_integrals/detail_/get_coeff.hpp deleted file mode 100644 index b975d3ba..00000000 --- a/src/integrals/ao_integrals/detail_/get_coeff.hpp +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Copyright 2022 NWChemEx-Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#pragma once -#include -#include - -namespace integrals::ao_integrals::detail_ { - -/** @brief Get the scalar coefficient from STG-like operators. - * - * Accesses and returns the coefficient of STG-like operators, and returns 1.0 - * for all other operator types. - * - * @tparam OperatorType The type of the input operator - * @param[in] op The operator to access - * @returns The scaling coefficient for the operator - */ -template -auto get_coefficient(const OperatorType& op) { - /// Geminal exponent handling - constexpr auto is_stg = - std::is_same_v; - constexpr auto is_yukawa = - std::is_same_v; - - double coeff = 1.0; - if constexpr(is_stg || is_yukawa) { - coeff = op.template at<0>().coefficient; - } - return coeff; -} - -} // namespace integrals::ao_integrals::detail_ diff --git a/src/integrals/ao_integrals/detail_/hash_inputs.hpp b/src/integrals/ao_integrals/detail_/hash_inputs.hpp deleted file mode 100644 index 8256a1c5..00000000 --- a/src/integrals/ao_integrals/detail_/hash_inputs.hpp +++ /dev/null @@ -1,140 +0,0 @@ -/* - * Copyright 2022 NWChemEx-Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#pragma once -#include -#include -#include -#include - -namespace integrals::ao_integrals::detail_ { - -/** @brief Combines hashes in the same way as boost::hash_combine (apparently) - * - * @note based on https://stackoverflow.com/a/2595226 - * - * @param[in,out] seed The hash we are modifying - * @param[in] addition The hash we are adding to the seed - */ -inline void hash_together(std::size_t& seed, const std::size_t& addition) { - seed ^= addition + 0x9e3779b9 + (seed << 6) + (seed >> 2); -} - -/** @brief Default case for the corresponding variadic function - * - * @note based on https://stackoverflow.com/a/2595226 - * - * @param[in,out] seed The hash we are modifying - */ -inline void combine_hash(std::size_t& seed) {} - -/** @brief Hashes the input object and adds it to the seed hash - * - * @note based on https://stackoverflow.com/a/2595226 - * - * @tparam T The type of the first object to hash - * @tparam Rest The types of the rest of the objects to hash - * @param[in,out] seed The hash we are modifying - * @param[in] v The object to hash and add to the seed - * @param[in] rest The other objects to hash and add - */ -template -inline void combine_hash(std::size_t& seed, const T& v, Rest... rest) { - std::hash hasher; - hash_together(seed, hasher(v)); - combine_hash(seed, rest...); -} - -/** @brief Produces a hash of the input operator - * - * The libint_op and as_string should handle differentiating the operator - * types, but any additional information that can differentiate instances of - * an operator needs to be hashed as well. - * - * This should eventually be replaced with std::hash specializations for the - * different operator types. - * - * @tparam OpType The type of the operator we want to hash - * @param[in] op The operator that is being hashed - * @returns A hash of the operator - */ -template -inline std::size_t hash_operator(const OpType& op) { - /// NWX operator string - auto hash = std::hash{}(op.as_string()); - /// Additional information from op - if constexpr(std::is_same_v) { - const auto& nuclei = op.template at<1>(); - for(const auto& ai : nuclei) { - combine_hash(hash, ai.Z()); - combine_hash(hash, ai.name()); - combine_hash(hash, ai.mass()); - combine_hash(hash, ai.charge()); - for(auto c = 0; c < 3; ++c) combine_hash(hash, ai.coord(c)); - } - } else if constexpr(std::is_same_v || - std::is_same_v || - std::is_same_v) { - const auto& stg = op.template at<0>(); - combine_hash(hash, stg.coefficient); - combine_hash(hash, stg.exponent); - } - return hash; -} - -/** @brief Hashes the inputs to an integral module to produce a fxn_id - * - * @tparam OpType The type of the operator - * @param[in] bases The basis sets as a vector of libint basis sets - * @param[in] op The operator associated with the integral - * @param[in] cs_thresh The Cauchy-Schwarz screening threshold - * @returns A hash as a string - */ -template -std::string hash_inputs(const std::vector& bases, - const OpType& op, double cs_thresh = -1.0) { - std::size_t hash = hash_operator(op); - combine_hash(hash, bases, cs_thresh); - return std::to_string(hash); -} - -} // namespace integrals::ao_integrals::detail_ - -/** @brief std::hash specializaton for a vector of LibInt basis sets */ -template<> -struct std::hash> { - /** @brief Hashes the input vector - * - * @param[in] b A vector of libint basis sets - * @returns A hash of the vector - */ - std::size_t operator()( - const std::vector& b) const noexcept { - using integrals::ao_integrals::detail_::combine_hash; - /// Start with the number of basis sets - auto hash = std::hash{}(b.size()); - /// Set through the sets and hash the info - for(const auto& set : b) { - for(auto i = 0; i < set.n_primitives(); ++i) { - auto p = set.primitive(i); - combine_hash(hash, p.coefficient(), p.exponent(), - p.center().x(), p.center().y(), p.center().z()); - } - } - return hash; - } -}; diff --git a/src/integrals/ao_integrals/detail_/bsets_shell_sizes.hpp b/src/integrals/ao_integrals/detail_/libint_op.hpp similarity index 50% rename from src/integrals/ao_integrals/detail_/bsets_shell_sizes.hpp rename to src/integrals/ao_integrals/detail_/libint_op.hpp index 0fcae77c..bbbd1ae2 100644 --- a/src/integrals/ao_integrals/detail_/bsets_shell_sizes.hpp +++ b/src/integrals/ao_integrals/detail_/libint_op.hpp @@ -1,5 +1,5 @@ /* - * Copyright 2022 NWChemEx-Project + * Copyright 2024 NWChemEx-Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -15,27 +15,30 @@ */ #pragma once +#include #include namespace integrals::ao_integrals::detail_ { -/** @brief Collect the sizes of the shells of the basis sets. - * - * - * - * @param[in] bases A vector of basis sets. - * @returns The shell sizes for the basis sets as a vector of vectors. - */ -inline auto bsets_shell_sizes( - const std::vector& bases) { - auto N = bases.size(); - std::vector> shell_sizes(N); - for(auto i = 0; i < N; ++i) { - for(auto j = 0; j < bases[i].n_shells(); ++j) { - shell_sizes[i].push_back(bases[i].shell(j).size()); - } - } - return shell_sizes; -} - -} // namespace integrals::ao_integrals::detail_ \ No newline at end of file +template +struct LibintOp; + +template<> +struct LibintOp { + static constexpr auto value = libint2::Operator::coulomb; +}; + +template<> +struct LibintOp { + static constexpr auto value = libint2::Operator::kinetic; +}; + +template<> +struct LibintOp { + static constexpr auto value = libint2::Operator::nuclear; +}; + +template +static constexpr auto op_v = detail_::LibintOp::value; + +} // namespace integrals::ao_integrals::detail_ diff --git a/src/integrals/libint/detail_/make_engine.hpp b/src/integrals/ao_integrals/detail_/make_engine.hpp similarity index 62% rename from src/integrals/libint/detail_/make_engine.hpp rename to src/integrals/ao_integrals/detail_/make_engine.hpp index b7f7c98f..19b9f2fe 100644 --- a/src/integrals/libint/detail_/make_engine.hpp +++ b/src/integrals/ao_integrals/detail_/make_engine.hpp @@ -15,11 +15,11 @@ */ #pragma once -#include "../libint_op.hpp" +#include "libint_op.hpp" #include #include -namespace integrals::libint::detail_ { +namespace integrals::ao_integrals::detail_ { /** @brief Constructs a Libint engine. * @@ -27,26 +27,27 @@ namespace integrals::libint::detail_ { * @param[in] bases A vector of Libint basis sets * @param[in] op A NWX operator for the integral * @param[in] thresh The precision threshold of the integrals + * @param[in] deriv The level of derivative that should be computed * @returns An engine to compute the values of the associated integrals */ template auto make_engine(const std::vector& bases, const OpType& op, double thresh, std::size_t deriv = 0) { - /// Variables for engine construction - constexpr auto libint_op = integrals::libint::op_v; + // Variables for engine construction + constexpr auto libint_op = integrals::ao_integrals::detail_::op_v; auto max_nprims = libint2::max_nprim(bases[0]); auto max_l = libint2::max_l(bases[0]); - /// Find max_nprims and max_l in bases + // Find max_nprims and max_l in bases for(auto set : bases) { max_nprims = std::max(max_nprims, libint2::max_nprim(set)); max_l = std::max(max_l, libint2::max_l(set)); } - /// Construct engine and handl specialized settings + // Construct engine and handle specialized settings if(!libint2::initialized()) libint2::initialize(); libint2::Engine engine(libint_op, max_nprims, max_l, deriv, thresh); - /// Libint not acknowleding max_nprim in ctor? + // Libint not acknowleding max_nprim in ctor? engine.set_max_nprim(max_nprims); if(libint2::rank(libint_op) == 2) { @@ -54,30 +55,34 @@ auto make_engine(const std::vector& bases, const OpType& op, if(bases.size() == 3) engine.set(libint2::BraKet::xs_xx); } - if constexpr(std::is_same_v) { - const auto& nuclei = op.template at<1>(); + if constexpr(std::is_same_v) { + const auto& nuclei = op.rhs_particle(); std::vector>> qs; for(const auto& ai : nuclei) { std::array coords{ai.x(), ai.y(), ai.z()}; qs.emplace_back(static_cast(ai.Z()), coords); } engine.set_params(qs); - } else if constexpr(std::is_same_v || - std::is_same_v) { - const auto& stg = op.template at<0>(); - engine.set_params(stg.exponent); - } else if constexpr(std::is_same_v) { - const auto& stg = op.template at<0>(); - engine.set_params(2.0 * stg.exponent); - } else if constexpr(std::is_same_v || - std::is_same_v || - std::is_same_v) { - std::array origin{0, 0, 0}; - engine.set_params(origin); } return engine; } -} // namespace integrals::libint::detail_ +/** @brief Wrap the call of LibInt2 engine so it can take a variable number + * of shell inputs. + * + * @tparam Is A variadic parameter pack of integers from [0,NBases) to + * expand. + * @param engine The LibInt2 engine that computes integrals + * @param bases The bases sets that hold the shells + * @param shells The index of the requested shell block + */ +template +void run_engine_(libint2::Engine& engine, + const std::vector& bases, + const std::vector& shells, + std::index_sequence) { + engine.compute(bases[Is][shells[Is]]...); +} + +} // namespace integrals::ao_integrals::detail_ diff --git a/src/integrals/libint/detail_/make_libint_basis_set.hpp b/src/integrals/ao_integrals/detail_/make_libint_basis_set.hpp similarity index 94% rename from src/integrals/libint/detail_/make_libint_basis_set.hpp rename to src/integrals/ao_integrals/detail_/make_libint_basis_set.hpp index b22a9a1e..2baa6597 100644 --- a/src/integrals/libint/detail_/make_libint_basis_set.hpp +++ b/src/integrals/ao_integrals/detail_/make_libint_basis_set.hpp @@ -21,7 +21,7 @@ #include #include -namespace integrals::libint::detail_ { +namespace integrals::ao_integrals::detail_ { /** @brief Converts an NWX basis set object to a LibInt2 basis set object. * @@ -58,7 +58,8 @@ inline auto make_libint_basis_set(const simde::type::ao_basis_set& bs) { std::array origin = {0.0, 0.0, 0.0}; /// Convert centers and their shells to libint equivalents. - for(auto abs_i = 0; abs_i < bs.size(); ++abs_i) { + auto n_bs = bs.size(); + for(decltype(n_bs) abs_i = 0; abs_i < n_bs; ++abs_i) { /// Add current center to atoms list const auto& abs = bs[abs_i]; centers.push_back(atom_ctor(abs_i, abs.center().x(), abs.center().y(), @@ -86,4 +87,4 @@ inline auto make_libint_basis_set(const simde::type::ao_basis_set& bs) { return basis_t(centers, element_bases); } -} // namespace integrals::libint::detail_ +} // namespace integrals::ao_integrals::detail_ diff --git a/src/integrals/ao_integrals/detail_/make_shape.hpp b/src/integrals/ao_integrals/detail_/make_shape.hpp deleted file mode 100644 index fee07c79..00000000 --- a/src/integrals/ao_integrals/detail_/make_shape.hpp +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright 2022 NWChemEx-Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#pragma once -#include -#include - -namespace integrals::ao_integrals::detail_ { - -/** @brief Given a vector of basis sets, compute the shape of the corresponding - * integral. - * - * @param[in] bases A vector of basis sets - * @param[in] leading_extent An extent value added to the front of the shape - * @returns A unique_ptr for the resulting shape - */ -inline auto make_shape(const std::vector& bases, - std::size_t leading_extent = 0) { - using shape_t = typename simde::type::tensor::shape_type; - using extents_t = typename shape_t::extents_type; - - /// Count up the extents from the shells in the basis sets - extents_t extents{}; - if(leading_extent != 0) extents.push_back(leading_extent); - for(const auto& set : bases) { extents.push_back(set.n_aos()); } - - /// Make the unique pointer to the shape - return std::make_unique(extents); -} - -} // namespace integrals::ao_integrals::detail_ diff --git a/src/integrals/ao_integrals/detail_/select_allocator.hpp b/src/integrals/ao_integrals/detail_/select_allocator.hpp deleted file mode 100644 index 44a923ff..00000000 --- a/src/integrals/ao_integrals/detail_/select_allocator.hpp +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright 2022 NWChemEx-Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#pragma once -#include "hash_inputs.hpp" - -namespace integrals::ao_integrals::detail_ { - -/** @brief Choose type of and return an allocator - * - * @tparam direct Whether the integral if direct or not - * @tparam T The type the tensors field - * @tparam OpType The type of the operator - * @param[in] bases The basis sets as a vector - * @param[in] op The operator associated with the integral - * @param[in] cs_thresh The Cauchy-Schwarz screening threshold - * @returns An allocator - */ -template -auto select_allocator(const std::vector& bases, - const OpType& op, double cs_thresh = -1.0) { - if constexpr(direct) { - auto fxn_id = hash_inputs(bases, op, cs_thresh); - return tensorwrapper::tensor::allocator::direct_ta_allocator(fxn_id); - } else { - return tensorwrapper::tensor::default_allocator(); - } -} - -} // namespace integrals::ao_integrals::detail_ diff --git a/src/integrals/ao_integrals/detail_/shells2ord.hpp b/src/integrals/ao_integrals/detail_/shells2ord.hpp index 1fe932c1..b26f1c4b 100644 --- a/src/integrals/ao_integrals/detail_/shells2ord.hpp +++ b/src/integrals/ao_integrals/detail_/shells2ord.hpp @@ -15,73 +15,60 @@ */ #pragma once +#include #include namespace integrals::ao_integrals::detail_ { -/** @brief Find the ordinal indices spanned by the shell indices +/** @brief Find the ordinal indices spanned by the shell * - * @param[in] bases A vector of shell sizes. - * @param[in] shell A vector of indices for shells in the basis sets. - * @param[in] lo_shell The lower most shell index in the span. - * @param[in] up_shell The upper most shell index in the span. - * @returns An std::vector of the ordinal indices associated with the shells. + * @param[in] bases The basis sets. + * @param[in] shell The shell indices + * @returns A std::vector of the ordinal indices associated with the shell. */ -inline auto shells2ord(const std::vector>& shell_sizes, - std::vector& shells, - std::vector& lo_shells, - std::vector& up_shells) { +inline auto shells2ord(const std::vector& bases, + std::vector& shells) { using size_vector_t = std::vector; - auto N = shell_sizes.size(); - size_vector_t extents; - size_vector_t lo_ao; - size_vector_t up_ao; - for(auto i = 0; i < N; ++i) { - std::size_t set_extent = 0; - for(auto j = lo_shells[i]; j <= up_shells[i]; ++j) { - if(j == shells[i]) { - lo_ao.push_back(set_extent); - up_ao.push_back(set_extent + shell_sizes[i][j] - 1); - } - set_extent += shell_sizes[i][j]; - } - extents.push_back(set_extent); + // Calculate the ordinal step of each basis dimension other than the Nth. + auto N = bases.size(); + size_vector_t step_sizes(N - 1); + for(decltype(N) i = 1; i <= N - 1; ++i) { + step_sizes[N - 1 - i] = bases[N - i].nbf(); + if(i > 1) step_sizes[N - 1 - i] *= step_sizes[N - i]; } - /// Calculate the ordinal step of each basis dimension other than the Nth. - size_vector_t step_size; - for(auto i = 0; i < N - 1; ++i) { - auto step = extents[N - 1]; - for(auto j = i + 1; j < N - 1; ++j) step *= extents[j]; - step_size.push_back(step); + // Set starting and ending AO indices + size_vector_t curr_ao(N); + size_vector_t up_ao(N); + for(decltype(N) i = 0; i < N; ++i) { + curr_ao[i] = bases[i].shell2bf()[shells[i]]; + up_ao[i] = curr_ao[i] + bases[i][shells[i]].size(); } - /// Increment through the AO indices of the shell and determine the ordinal - /// index for each. - size_vector_t curr_ao = lo_ao; - size_vector_t ord_pos; - while(curr_ao[0] <= up_ao[0]) { - /// ordinal calculation - auto curr_ord_pos = curr_ao[N - 1]; - for(auto i = 0; i < N - 1; ++i) { - curr_ord_pos += curr_ao[i] * step_size[i]; + // Increment through the AO indices of the shell and determine the ordinal + // index for each. + size_vector_t ords; + while(curr_ao[0] < up_ao[0]) { + // ordinal calculation + auto curr_ord = curr_ao.back(); + for(std::size_t i = 0; i < step_sizes.size(); ++i) { + curr_ord += curr_ao[i] * step_sizes[i]; } - ord_pos.push_back(curr_ord_pos); + ords.push_back(curr_ord); - /// Increment to the next AO index. - curr_ao[N - 1] += 1; - for(auto i = 1; i < N; ++i) { - if(curr_ao[N - i] > up_ao[N - i]) { - /// curr_ao[0] accumalates until it passes up_aos[0] - /// and the loop terminates. - curr_ao[N - i] = lo_ao[N - i]; + // Increment to the next AO index. + curr_ao.back() += 1; + for(decltype(N) i = 1; i < N; ++i) { + if(curr_ao[N - i] >= up_ao[N - i]) { + // curr_ao[0] accumalates until it passes up_aos[0] + // and the loop terminates. + curr_ao[N - i] = bases[N - i].shell2bf()[shells[N - i]]; curr_ao[N - i - 1] += 1; } } } - - return ord_pos; + return ords; } } // namespace integrals::ao_integrals::detail_ diff --git a/src/integrals/ao_integrals/detail_/unpack_bases.hpp b/src/integrals/ao_integrals/detail_/unpack_bases.hpp deleted file mode 100644 index c5a0f306..00000000 --- a/src/integrals/ao_integrals/detail_/unpack_bases.hpp +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright 2022 NWChemEx-Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#pragma once -#include -#include /// For ShellType -#include -#include -#include - -namespace integrals::ao_integrals::detail_ { - -/** @brief Unpacks the basis sets from the inputs - * - * @param[in] inputs The module inputs containing the basis sets. - * @returns A vector of the basis sets. - */ -template -auto unpack_bases(const ModuleInputs& inputs) { - using ao_space_t = simde::type::ao_space; - using ao_basis_t = simde::type::ao_basis_set; - std::vector aos(N); - if constexpr(N == 2) { - aos[0] = inputs.at("bra").template value().basis_set(); - aos[1] = inputs.at("ket").template value().basis_set(); - } else if constexpr(N == 3) { - aos[0] = inputs.at("bra").template value().basis_set(); - aos[1] = inputs.at("ket 1").template value().basis_set(); - aos[2] = inputs.at("ket 2").template value().basis_set(); - } else if constexpr(N == 4) { - aos[0] = inputs.at("bra 1").template value().basis_set(); - aos[1] = inputs.at("bra 2").template value().basis_set(); - aos[2] = inputs.at("ket 1").template value().basis_set(); - aos[3] = inputs.at("ket 2").template value().basis_set(); - } - return aos; -} - -} // namespace integrals::ao_integrals::detail_ diff --git a/src/integrals/ao_integrals/differential_overlap_integral.cpp b/src/integrals/ao_integrals/differential_overlap_integral.cpp deleted file mode 100644 index 5cd4980d..00000000 --- a/src/integrals/ao_integrals/differential_overlap_integral.cpp +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Copyright 2022 NWChemEx-Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "ao_integrals.hpp" -#include "detail_/aos2shells.hpp" -#include "detail_/get_coeff.hpp" -#include "detail_/make_shape.hpp" -#include "detail_/select_allocator.hpp" -#include "detail_/shells2ord.hpp" -#include "detail_/unpack_bases.hpp" -#include -#include - -namespace integrals::ao_integrals { - -/// Grab the various detail_ functions -using namespace detail_; - -MODULE_CTOR(AOIntegralDOI) { - description("Computes DOI integrals"); - using op_t = simde::type::el_el_delta; - using my_pt = simde::AOTensorRepresentation<2, op_t>; - using doi4_pt = simde::AOTensorRepresentation<4, op_t>; - - satisfies_property_type(); - - add_submodule("DOI4").set_description("Computes DOI4 integrals"); -} - -MODULE_RUN(AOIntegralDOI) { - using op_t = simde::type::el_el_delta; - using my_pt = simde::AOTensorRepresentation<2, op_t>; - using doi4_pt = simde::AOTensorRepresentation<4, op_t>; - - /// Get inputs - const auto& [bra, op, ket] = my_pt::unwrap_inputs(inputs); - auto& doi4_mod = submods.at("DOI4"); - - /// Run DOI4 - auto I = doi4_mod.run_as(bra, bra, op, ket, ket); - - /// Finish - auto rv = results(); - return my_pt::wrap_results(rv, I); -} - -} // namespace integrals::ao_integrals diff --git a/src/integrals/ao_integrals/emultipole.cpp b/src/integrals/ao_integrals/emultipole.cpp deleted file mode 100644 index 2b4ce7ed..00000000 --- a/src/integrals/ao_integrals/emultipole.cpp +++ /dev/null @@ -1,181 +0,0 @@ -/* - * Copyright 2022 NWChemEx-Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "ao_integrals.hpp" -#include "detail_/aos2shells.hpp" -#include "detail_/bsets_shell_sizes.hpp" -#include "detail_/make_shape.hpp" -#include "detail_/select_allocator.hpp" -#include "detail_/shells2ord.hpp" -#include "detail_/unpack_bases.hpp" -#include -#include - -namespace integrals::ao_integrals { - -using identity_op = simde::type::el_identity; -using dipole_op = simde::type::el_dipole; -using quadrupole_op = simde::type::el_quadrupole; -using octupole_op = simde::type::el_octupole; - -using overlap_pt = simde::AOTensorRepresentation<2, identity_op>; -using dipole_pt = simde::AOTensorRepresentation<2, dipole_op>; -using quadrupole_pt = simde::AOTensorRepresentation<2, quadrupole_op>; -using octupole_pt = simde::AOTensorRepresentation<2, octupole_op>; - -/// Type of a module that produces integral factories -template -using factory_pt = simde::IntegralFactory; -using factory_t = simde::type::integral_factory; - -/// Grab the various detail_ functions -using namespace detail_; - -template -TEMPLATED_MODULE_CTOR(AOIntegralMultipole, L, OperatorType) { - description("Computes an in-core multipole integral"); - - /// This should satisfy overlap, but we can't reduce the dimensionality - /// of the tensor at the moment. - // satisfies_property_type(); - // identity_op I; - // change_input(I.as_string()).change(std::move(I)); - - satisfies_property_type(); - dipole_op r; - change_input(r.as_string()).change(std::move(r)); - - if constexpr(L > 0) { - satisfies_property_type(); - quadrupole_op r2; - change_input(r2.as_string()).change(std::move(r2)); - } - - if constexpr(L > 1) { - satisfies_property_type(); - octupole_op r3; - change_input(r3.as_string()).change(std::move(r3)); - } - - add_submodule>("AO Integral Factory") - .set_description("Used to generate the AO factory"); -} - -template -TEMPLATED_MODULE_RUN(AOIntegralMultipole, L, OperatorType) { - // Typedefs - using size_vector_t = std::vector; - using tensor_t = simde::type::tensor; - using field_t = typename tensor_t::field_type; - - // Grab input information - auto bases = unpack_bases<2>(inputs); - auto op_str = OperatorType().as_string(); - auto op = inputs.at(op_str).template value(); - auto& fac_mod = submods.at("AO Integral Factory"); - auto shell_sizes = bsets_shell_sizes(bases); - - // Cache result of factory module - fac_mod.run_as>(bases, op, 0ul); - - // Lambda to calculate values - auto l = [=](const auto& lo, const auto& up, auto* data) mutable { - // Convert index values from AOs to shells - // Leading index is for multipole components - constexpr std::size_t N = 2; - size_vector_t lo_shells, up_shells; - for(auto i = 0; i < N; ++i) { - auto shells_in_tile = - aos2shells(shell_sizes[i], lo[i + 1], up[i + 1]); - lo_shells.push_back(shells_in_tile.front()); - up_shells.push_back(shells_in_tile.back()); - } - - // Calculate the number of values per leading index - auto leading_step = 0; - for(auto i = lo_shells[0]; i <= up_shells[0]; ++i) { - for(auto j = lo_shells[1]; j <= up_shells[1]; ++j) { - leading_step += shell_sizes[0][i] * shell_sizes[1][j]; - } - } - - // Get integral factory - auto factory = fac_mod.run_as>(bases, op, 0ul); - - // Loop through shell combinations - size_vector_t curr_shells = lo_shells; - while(curr_shells[0] <= up_shells[0]) { - // Determine which values will be computed this time - auto ord_pos = - shells2ord(shell_sizes, curr_shells, lo_shells, up_shells); - - // Compute values - const auto& buf = factory.compute(curr_shells); - - // Copy libint values into tile data; - for(auto i = lo[0]; i < up[0]; ++i) { - auto depth = i * leading_step; - for(auto j = 0; j < ord_pos.size(); ++j) { - data[ord_pos[j] + depth] = buf[i][j]; - } - } - - // Increment curr_shells - curr_shells[N - 1] += 1; - for(auto i = 1; i < N; ++i) { - if(curr_shells[N - i] > up_shells[N - i]) { - // Reset this dimension and increment the next one - // curr_shells[0] accumulates until we reach the end - curr_shells[N - i] = lo_shells[N - i]; - curr_shells[N - i - 1] += 1; - } - } - } - }; - - // Count up necessary components for multipole - std::size_t leading_extent = 4; - if constexpr(L == 1) { leading_extent = 10; } - if constexpr(L == 2) { leading_extent = 20; } - - // Make complete tensor and slice out return values - /// TODO: Switch out make_shape with an IntegralShape module - tensor_t I(l, make_shape(bases, leading_extent), - tensorwrapper::tensor::default_allocator()); - - auto rv = results(); - auto D = I.slice({1, 0, 0}, {4, 7, 7}); - rv = dipole_pt::wrap_results(rv, D); - if constexpr(L > 0) { - auto Q = I.slice({4, 0, 0}, {10, 7, 7}); - rv = quadrupole_pt::wrap_results(rv, Q); - } - if constexpr(L > 1) { - auto O = I.slice({10, 0, 0}, {20, 7, 7}); - rv = octupole_pt::wrap_results(rv, O); - } - return rv; -} - -// ----------------------------------------------------------------------------- -// -- Template Declarations -// ----------------------------------------------------------------------------- - -template class AOIntegralMultipole<0, simde::type::el_dipole>; -template class AOIntegralMultipole<1, simde::type::el_quadrupole>; -template class AOIntegralMultipole<2, simde::type::el_octupole>; - -} // namespace integrals::ao_integrals diff --git a/src/integrals/ao_integrals/shellnorms.cpp b/src/integrals/ao_integrals/shellnorms.cpp deleted file mode 100644 index 97e9ef94..00000000 --- a/src/integrals/ao_integrals/shellnorms.cpp +++ /dev/null @@ -1,154 +0,0 @@ -/* - * Copyright 2022 NWChemEx-Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/// TODO: Optimize for IntegralFactory usage - -#include "detail_/bsets_shell_sizes.hpp" -#include "detail_/unpack_bases.hpp" -#include "shellnorms.hpp" -#include -#include -#include - -namespace integrals::ao_integrals { - -/// Type of a module that produces integral factories -template -using factory_pt = simde::IntegralFactory; -using factory_t = simde::type::integral_factory; - -/// Grab the various detail_ functions -using namespace detail_; - -template -TEMPLATED_MODULE_CTOR(ShellNorms, NBodies, OperatorType) { - description("Calculates the Cauchy-Schwarz screening matrix for a pair of " - "basis sets"); - - using my_pt = simde::ShellNorms; - satisfies_property_type(); - - add_submodule>("AO Integral Factory") - .set_description("Used to generate the AO factory"); -} - -template -TEMPLATED_MODULE_RUN(ShellNorms, NBodies, OperatorType) { - using my_pt = simde::ShellNorms; - using elem_vec = typename std::vector; - using return_vec = typename std::vector; - - // Get inputs - auto bases = unpack_bases<2>(inputs); - auto op_str = OperatorType().as_string(); - auto& fac_mod = submods.at("AO Integral Factory"); - const auto& op = inputs.at(op_str).template value(); - - // Double up on the basis sets if 2-body - if constexpr(NBodies == 2) { - bases.push_back(bases[0]); - bases.push_back(bases[1]); - } - - // Check if the basis sets are the same - bool same_bs = (bases[0] == bases[1]); - - // Get shell sizes - auto shell_sizes = bsets_shell_sizes(bases); - - // Our return value - return_vec mat(bases[0].n_shells(), elem_vec(bases[1].n_shells(), 0.0)); - - // Cache result of factory module - fac_mod.run_as>(bases, op, 0ul); - - // Lambda to fill in the values - std::function into_mat; - if constexpr(NBodies == 1) { - into_mat = [&](std::size_t i, std::size_t j) mutable { - auto factory = - fac_mod.run_as>(bases, op, 0ul); - const auto& buf = factory.compute({i, j}); - auto vals = buf[0]; - - // Determine the number of compute values - std::size_t nvals = (shell_sizes[0][i] * shell_sizes[1][j]); - - // Find the norm and take the square root - double frobenius_norm_squared = 0.0; - if(vals != nullptr) { - for(int a = 0; a < nvals; ++a) { - frobenius_norm_squared += vals[a] * vals[a]; - } - } - mat[i][j] = std::sqrt(frobenius_norm_squared); - if(same_bs && (i != j)) { - mat[j][i] = mat[i][j]; - } // cut down on work - }; - } else if constexpr(NBodies == 2) { - into_mat = [&](std::size_t i, std::size_t j) mutable { - auto factory = - fac_mod.run_as>(bases, op, 0ul); - const auto& buf = factory.compute({i, j, i, j}); - auto vals = buf[0]; - - // Determine the number of compute values - std::size_t nvals = (shell_sizes[0][i] * shell_sizes[0][i]); - nvals *= (shell_sizes[1][j] * shell_sizes[1][j]); - - // Find the norm and take the square root - double inf_norm_squared = 0.0; - if(vals != nullptr) { - for(int a = 0; a < nvals; ++a) { - inf_norm_squared = - std::max(inf_norm_squared, std::abs(vals[a])); - } - } - mat[i][j] = std::sqrt(inf_norm_squared); - if(same_bs && (i != j)) { - mat[j][i] = mat[i][j]; - } // cut down on work - }; - } - - // Calculate values - auto& my_runtime = get_runtime(); - auto comm = get_runtime().mpi_comm(); - auto& world = *madness::World::find_instance(SafeMPI::Intracomm(comm)); - for(std::size_t i = 0; i < bases[0].n_shells(); ++i) { - // only do lower triangle if basis sets are the same - auto len = (same_bs) ? i : bases[1].n_shells() - 1; - for(std::size_t j = 0; j <= len; ++j) { - world.taskq.add(into_mat, i, j); - } - } - world.gop.fence(); - - auto rv = results(); - return my_pt::wrap_results(rv, mat); -} - -// ----------------------------------------------------------------------------- -// -- Template Declarations -// ----------------------------------------------------------------------------- - -template class ShellNorms<1, simde::type::el_identity>; -template class ShellNorms<2, simde::type::el_el_coulomb>; -template class ShellNorms<2, simde::type::el_el_stg>; -template class ShellNorms<2, simde::type::el_el_yukawa>; - -} // namespace integrals::ao_integrals diff --git a/src/integrals/ao_integrals/shellnorms.hpp b/src/integrals/ao_integrals/shellnorms.hpp deleted file mode 100644 index 7ef5fbe5..00000000 --- a/src/integrals/ao_integrals/shellnorms.hpp +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright 2022 NWChemEx-Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#pragma once -#include - -namespace integrals::ao_integrals { - -// ----------------------------------------------------------------------------- -// -- Declare Integral Module Types -// ----------------------------------------------------------------------------- - -template -DECLARE_MODULE(ShellNorms); - -using ShellNormOverlap = ShellNorms<1, simde::type::el_identity>; -using ShellNormCoulomb = ShellNorms<2, simde::type::el_el_coulomb>; -using ShellNormSTG = ShellNorms<2, simde::type::el_el_stg>; -using ShellNormYukawa = ShellNorms<2, simde::type::el_el_yukawa>; - -// ----------------------------------------------------------------------------- -// -- Forward External Template Declarations -// ----------------------------------------------------------------------------- - -extern template class ShellNorms<1, simde::type::el_identity>; -extern template class ShellNorms<2, simde::type::el_el_coulomb>; -extern template class ShellNorms<2, simde::type::el_el_stg>; -extern template class ShellNorms<2, simde::type::el_el_yukawa>; - -} // namespace integrals::ao_integrals diff --git a/src/integrals/integrals_mm.cpp b/src/integrals/integrals_mm.cpp index d4fb66f2..691d7c78 100644 --- a/src/integrals/integrals_mm.cpp +++ b/src/integrals/integrals_mm.cpp @@ -15,86 +15,22 @@ */ #include "ao_integrals/ao_integrals.hpp" -#include "libint/libint.hpp" -#include "shapes/shapes.hpp" -#include "transforms/transforms.hpp" #include -using namespace simde::type; - namespace integrals { +/** @brief Set default module relationships + * + * @param mm The Module Manager with modules whose defaults will be set + * + * @throw none No throw guarantee + */ void set_defaults(pluginplay::ModuleManager& mm) { - /// Submodule name - auto fac_sub = "AO Integral Factory"; - - /// Set Factory and Shape for non-screened integrals - std::vector module_names{ - "ERI2", "ERI3", "ERI4", "Kinetic", "Nuclear", "Overlap", "STG2", - "STG3", "STG4", "Yukawa2", "Yukawa3", "Yukawa4", "DOI4"}; - for(const auto& name : module_names) { - mm.change_submod(name, "Tensor Shape", "OneTileShape"); - mm.change_submod("Direct " + name, "Tensor Shape", "OneTileShape"); - mm.change_submod(name, fac_sub, name + " Factory"); - mm.change_submod("Direct " + name, fac_sub, name + " Factory"); - } - mm.change_submod("STG 4 Center dfdr Squared", "Tensor Shape", - "OneTileShape"); - mm.change_submod("STG 4 Center dfdr Squared", fac_sub, "F12 4C Factory"); - - /// Set Factory and Shape for screened integrals - module_names = {"ERI3", "ERI4", "Kinetic", "Nuclear", "Overlap", - "STG3", "STG4", "Yukawa3", "Yukawa4"}; - for(const auto& name : module_names) { - auto name_cs = name + " CS"; - mm.change_submod(name_cs, "Tensor Shape", "OneTileShape"); - mm.change_submod("Direct " + name_cs, "Tensor Shape", "OneTileShape"); - mm.change_submod(name_cs, fac_sub, name + " Factory"); - mm.change_submod("Direct " + name_cs, fac_sub, name + " Factory"); - } - - /// Set Factory and Shape for multipoles - module_names = {"EDipole", "EQuadrupole", "EOctupole"}; - for(const auto& name : module_names) { - mm.change_submod(name, fac_sub, name + " Factory"); - } - - /// Set Factory for shell norms - /// TODO: Uncomment after module optimization - // mm.change_submod("Shell Norms Overlap", fac_sub, "Overlap Factory"); - // mm.change_submod("Shell Norms Coulomb", fac_sub, "ERI4 Factory"); - // mm.change_submod("Shell Norms STG", fac_sub, "STG4 Factory"); - // mm.change_submod("Shell Norms Yukawa", fac_sub, "Yukawa4 Factory"); - - /// TODO: Need to be removed. See module declarations. - std::string sh_norm = "Shell Norms"; - mm.change_submod("Kinetic CS", sh_norm, sh_norm + " Overlap"); - mm.change_submod("Nuclear CS", sh_norm, sh_norm + " Overlap"); - mm.change_submod("Overlap CS", sh_norm, sh_norm + " Overlap"); - mm.change_submod("ERI3 CS", sh_norm, sh_norm + " Coulomb"); - mm.change_submod("ERI4 CS", sh_norm, sh_norm + " Coulomb"); - mm.change_submod("STG3 CS", sh_norm, sh_norm + " STG"); - mm.change_submod("STG4 CS", sh_norm, sh_norm + " STG"); - mm.change_submod("Yukawa3 CS", sh_norm, sh_norm + " Yukawa"); - mm.change_submod("Yukawa4 CS", sh_norm, sh_norm + " Yukawa"); - mm.change_submod("Direct Kinetic CS", sh_norm, sh_norm + " Overlap"); - mm.change_submod("Direct Nuclear CS", sh_norm, sh_norm + " Overlap"); - mm.change_submod("Direct Overlap CS", sh_norm, sh_norm + " Overlap"); - mm.change_submod("Direct ERI3 CS", sh_norm, sh_norm + " Coulomb"); - mm.change_submod("Direct ERI4 CS", sh_norm, sh_norm + " Coulomb"); - mm.change_submod("Direct STG3 CS", sh_norm, sh_norm + " STG"); - mm.change_submod("Direct STG4 CS", sh_norm, sh_norm + " STG"); - mm.change_submod("Direct Yukawa3 CS", sh_norm, sh_norm + " Yukawa"); - mm.change_submod("Direct Yukawa4 CS", sh_norm, sh_norm + " Yukawa"); + // Defaults go here } void load_modules(pluginplay::ModuleManager& mm) { ao_integrals::load_ao_integrals(mm); - libint::load_libint_modules(mm); - transforms::load_transformed_integrals(mm); - shapes::load_modules(mm); - - ao_integrals::ao_integrals_set_defaults(mm); set_defaults(mm); } diff --git a/src/integrals/libint/libint.cpp b/src/integrals/libint/libint.cpp deleted file mode 100644 index 988a6901..00000000 --- a/src/integrals/libint/libint.cpp +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Copyright 2023 NWChemEx-Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -#include "libint.hpp" -#include "make_libint_factory.hpp" -#include "shellnorms.hpp" - -namespace integrals::libint { - -// ----------------------------------------------------------------------------- -// -- Define Module Load Functions -// ----------------------------------------------------------------------------- - -#define ADD_FACTORY(N, op, key) \ - mm.add_module>(key " Factory") - -void load_libint_modules(pluginplay::ModuleManager& mm) { - using namespace simde::type; - - ADD_FACTORY(2, el_el_coulomb, "ERI2"); - ADD_FACTORY(3, el_el_coulomb, "ERI3"); - ADD_FACTORY(4, el_el_coulomb, "ERI4"); - ADD_FACTORY(2, el_kinetic, "Kinetic"); - ADD_FACTORY(2, el_nuc_coulomb, "Nuclear"); - ADD_FACTORY(2, el_identity, "Overlap"); - ADD_FACTORY(2, el_el_stg, "STG2"); - ADD_FACTORY(3, el_el_stg, "STG3"); - ADD_FACTORY(4, el_el_stg, "STG4"); - ADD_FACTORY(2, el_el_yukawa, "Yukawa2"); - ADD_FACTORY(3, el_el_yukawa, "Yukawa3"); - ADD_FACTORY(4, el_el_yukawa, "Yukawa4"); - ADD_FACTORY(2, el_el_f12_commutator, "F12 2C"); - ADD_FACTORY(3, el_el_f12_commutator, "F12 3C"); - ADD_FACTORY(4, el_el_f12_commutator, "F12 4C"); - ADD_FACTORY(2, el_dipole, "EDipole"); - ADD_FACTORY(2, el_quadrupole, "EQuadrupole"); - ADD_FACTORY(2, el_octupole, "EOctupole"); - ADD_FACTORY(4, el_el_delta, "DOI4"); - - /// TODO: Need to be removed. See module declarations. - mm.add_module("Shell Norms Overlap"); - mm.add_module("Shell Norms Coulomb"); - mm.add_module("Shell Norms STG"); - mm.add_module("Shell Norms Yukawa"); -} - -#undef ADD_FACTORY - -} // namespace integrals::libint diff --git a/src/integrals/libint/libint.hpp b/src/integrals/libint/libint.hpp deleted file mode 100644 index 6c41e3bb..00000000 --- a/src/integrals/libint/libint.hpp +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Copyright 2023 NWChemEx-Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#pragma once -#include - -namespace integrals::libint { - -// ----------------------------------------------------------------------------- -// -- Declare Module Load Functions -// ----------------------------------------------------------------------------- - -void load_libint_modules(pluginplay::ModuleManager& mm); - -} // namespace integrals::libint diff --git a/src/integrals/libint/libint_factory.hpp b/src/integrals/libint/libint_factory.hpp deleted file mode 100644 index f61e36bd..00000000 --- a/src/integrals/libint/libint_factory.hpp +++ /dev/null @@ -1,126 +0,0 @@ -/* - * Copyright 2022 NWChemEx-Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "detail_/make_engine.hpp" -#include -#include - -namespace integrals::libint { - -template -class LibintFactory : public chemist::IntegralFactoryPIMPL { -public: - /// Base type and this type - using base_type = chemist::IntegralFactoryPIMPL; - using my_type = LibintFactory; - - /// Types from the base type - using pimpl_ptr_type = typename base_type::pimpl_ptr_t; - using indices_type = typename base_type::indices_t; - using buffer_type = typename base_type::buffer_t; - - /// Types unique to this class - using libint_basis_type = libint2::BasisSet; - using libint_basis_vector = std::vector; - using const_lbv_reference = const libint_basis_vector&; - using operator_type = OpType; - using threshold_type = double; - using derivative_order_type = int; - using const_buffer_reference = const buffer_type&; - using const_indices_reference = const indices_type&; - - LibintFactory(libint_basis_vector bases, operator_type op, - threshold_type thesh, derivative_order_type deriv); - -private: - const_buffer_reference compute_(const_indices_reference idx) override; - pimpl_ptr_type clone_() const override; - bool are_equal_(const base_type& rhs) const override; - - /** @brief Wrap the call of LibInt2 engine so it can take a variable - * number of shell inputs. - * - * Libint requires the engine for an `n`-center integral to be called - * with `n` positional arguments. The API of `IntegralFactory` relies on - * `std::vector` to avoid needing to know the number of centers at - * compile time. This function wraps the process of unpacking the - * `std::vector` of indices. - * - * @tparam Is A variadic parameter pack of integers from [0,NCenters) to - * expand. - * - * @param[in] shells The indices of the requested shell block. - * @param[in] An `index_sequence` used to get the compile time - * indices for expanding @p shells. - */ - template - void run_engine_(const_indices_reference shells, - std::index_sequence); - - libint_basis_vector m_bases_; - operator_type m_op_; - threshold_type m_thresh_; - derivative_order_type m_deriv_; - libint2::Engine m_engine_; - buffer_type m_buffer_; -}; - -#define LIBINT_FACTORY LibintFactory - -template -LIBINT_FACTORY::LibintFactory(libint_basis_vector bases, OpType op, - threshold_type thresh, - derivative_order_type deriv) : - m_bases_(std::move(bases)), - m_op_(op), - m_thresh_(thresh), - m_deriv_(deriv), - m_engine_(detail_::make_engine(m_bases_, m_op_, m_thresh_, m_deriv_)) {} - -template -typename LIBINT_FACTORY::const_buffer_reference LIBINT_FACTORY::compute_( - const_indices_reference idx) { - auto idx_seq = std::make_index_sequence(); - run_engine_(idx, idx_seq); - const auto& results = m_engine_.results(); - m_buffer_ = buffer_type(results.begin(), results.end()); - return m_buffer_; -} - -template -typename LIBINT_FACTORY::pimpl_ptr_type LIBINT_FACTORY::clone_() const { - return std::make_unique(m_bases_, m_op_, m_thresh_, m_deriv_); -} - -template -bool LIBINT_FACTORY::are_equal_(const base_type& rhs) const { - auto ptr = dynamic_cast(&rhs); - if(ptr == nullptr) return false; - return (m_bases_ == ptr->m_bases_) && (m_op_ == ptr->m_op_) && - (m_thresh_ == ptr->m_thresh_) && (m_deriv_ == ptr->m_deriv_) && - (m_buffer_ == ptr->m_buffer_); -} - -template -template -void LIBINT_FACTORY::run_engine_(const_indices_reference shells, - std::index_sequence) { - m_engine_.compute(m_bases_[Is][shells[Is]]...); -} - -#undef LIBINT_FACTORY - -} // namespace integrals::libint diff --git a/src/integrals/libint/libint_op.hpp b/src/integrals/libint/libint_op.hpp deleted file mode 100644 index c96dfe69..00000000 --- a/src/integrals/libint/libint_op.hpp +++ /dev/null @@ -1,87 +0,0 @@ -/* - * Copyright 2022 NWChemEx-Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#pragma once -#include -#include - -namespace integrals::libint { -namespace detail_ { - -template -struct LibintOp; - -template<> -struct LibintOp { - static constexpr auto value = libint2::Operator::delta; -}; - -template<> -struct LibintOp { - static constexpr auto value = libint2::Operator::coulomb; -}; - -template<> -struct LibintOp { - static constexpr auto value = libint2::Operator::kinetic; -}; - -template<> -struct LibintOp { - static constexpr auto value = libint2::Operator::overlap; -}; - -template<> -struct LibintOp { - static constexpr auto value = libint2::Operator::nuclear; -}; - -template<> -struct LibintOp { - static constexpr auto value = libint2::Operator::stg; -}; - -template<> -struct LibintOp { - static constexpr auto value = libint2::Operator::stg; -}; - -template<> -struct LibintOp { - static constexpr auto value = libint2::Operator::yukawa; -}; - -template<> -struct LibintOp { - static constexpr auto value = libint2::Operator::emultipole1; -}; - -template<> -struct LibintOp { - static constexpr auto value = libint2::Operator::emultipole2; -}; - -template<> -struct LibintOp { - static constexpr auto value = libint2::Operator::emultipole3; -}; - -} // namespace detail_ - -template -static constexpr auto op_v = detail_::LibintOp::value; - -} // namespace integrals::libint diff --git a/src/integrals/libint/make_libint_factory.cpp b/src/integrals/libint/make_libint_factory.cpp deleted file mode 100644 index 8371ab76..00000000 --- a/src/integrals/libint/make_libint_factory.cpp +++ /dev/null @@ -1,89 +0,0 @@ -/* - * Copyright 2022 NWChemEx-Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "detail_/make_libint_basis_set.hpp" -#include "libint_factory.hpp" -#include "libint_op.hpp" -#include "make_libint_factory.hpp" -#include - -namespace integrals::libint { - -template -TEMPLATED_MODULE_CTOR(MakeLibintFactory, N, OperatorType) { - using my_pt = simde::IntegralFactory; - - satisfies_property_type(); - - add_input("Threshold") - .set_default(1.0E-16) - .set_description( - "The target precision with which the integrals will be computed"); -} - -template -TEMPLATED_MODULE_RUN(MakeLibintFactory, N, OperatorType) { - using my_pt = simde::IntegralFactory; - using integral_factory = simde::type::integral_factory; - using libint_factory = LibintFactory; - using libint_basis_vector = typename libint_factory::libint_basis_vector; - - /// Inputs - const auto& [bases, op, deriv] = my_pt::unwrap_inputs(inputs); - auto thresh = inputs.at("Threshold").value(); - - // Convert from NWX bases to libint - libint_basis_vector libint_bases; - for(const auto& basis_i : bases) - libint_bases.push_back(detail_::make_libint_basis_set(basis_i)); - - /// Make factory - auto pfactory = std::make_unique(std::move(libint_bases), - op, thresh, deriv); - integral_factory fac(std::move(pfactory)); - auto rv = results(); - return my_pt::wrap_results(rv, fac); -} - -// ----------------------------------------------------------------------------- -// -- Template Declarations -// ----------------------------------------------------------------------------- - -#define TEMPLATE_DECLARE(N, op) template class MakeLibintFactory - -TEMPLATE_DECLARE(2, simde::type::el_el_coulomb); -TEMPLATE_DECLARE(3, simde::type::el_el_coulomb); -TEMPLATE_DECLARE(4, simde::type::el_el_coulomb); -TEMPLATE_DECLARE(2, simde::type::el_kinetic); -TEMPLATE_DECLARE(2, simde::type::el_nuc_coulomb); -TEMPLATE_DECLARE(2, simde::type::el_identity); -TEMPLATE_DECLARE(2, simde::type::el_el_stg); -TEMPLATE_DECLARE(3, simde::type::el_el_stg); -TEMPLATE_DECLARE(4, simde::type::el_el_stg); -TEMPLATE_DECLARE(2, simde::type::el_el_yukawa); -TEMPLATE_DECLARE(3, simde::type::el_el_yukawa); -TEMPLATE_DECLARE(4, simde::type::el_el_yukawa); -TEMPLATE_DECLARE(2, simde::type::el_el_f12_commutator); -TEMPLATE_DECLARE(3, simde::type::el_el_f12_commutator); -TEMPLATE_DECLARE(4, simde::type::el_el_f12_commutator); -TEMPLATE_DECLARE(2, simde::type::el_dipole); -TEMPLATE_DECLARE(2, simde::type::el_quadrupole); -TEMPLATE_DECLARE(2, simde::type::el_octupole); -TEMPLATE_DECLARE(4, simde::type::el_el_delta); - -#undef TEMPLATE_DECLARE - -} // namespace integrals::libint diff --git a/src/integrals/libint/make_libint_factory.hpp b/src/integrals/libint/make_libint_factory.hpp deleted file mode 100644 index 0a1bdeb3..00000000 --- a/src/integrals/libint/make_libint_factory.hpp +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Copyright 2022 NWChemEx-Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#pragma once -#include -#include - -namespace integrals::libint { - -// ----------------------------------------------------------------------------- -// -- Declare MakeLibintFactory Module Type -// ----------------------------------------------------------------------------- - -template -DECLARE_MODULE(MakeLibintFactory); - -// ----------------------------------------------------------------------------- -// -- Forward External Template Declarations -// ----------------------------------------------------------------------------- - -#define EXTERN_DECLARE(N, op) extern template class MakeLibintFactory - -EXTERN_DECLARE(2, simde::type::el_el_coulomb); -EXTERN_DECLARE(3, simde::type::el_el_coulomb); -EXTERN_DECLARE(4, simde::type::el_el_coulomb); -EXTERN_DECLARE(2, simde::type::el_kinetic); -EXTERN_DECLARE(2, simde::type::el_nuc_coulomb); -EXTERN_DECLARE(2, simde::type::el_identity); -EXTERN_DECLARE(2, simde::type::el_el_stg); -EXTERN_DECLARE(3, simde::type::el_el_stg); -EXTERN_DECLARE(4, simde::type::el_el_stg); -EXTERN_DECLARE(2, simde::type::el_el_yukawa); -EXTERN_DECLARE(3, simde::type::el_el_yukawa); -EXTERN_DECLARE(4, simde::type::el_el_yukawa); -EXTERN_DECLARE(2, simde::type::el_el_f12_commutator); -EXTERN_DECLARE(3, simde::type::el_el_f12_commutator); -EXTERN_DECLARE(4, simde::type::el_el_f12_commutator); -EXTERN_DECLARE(2, simde::type::el_dipole); -EXTERN_DECLARE(2, simde::type::el_quadrupole); -EXTERN_DECLARE(2, simde::type::el_octupole); -EXTERN_DECLARE(4, simde::type::el_el_delta); - -#undef EXTERN_DECLARE - -} // namespace integrals::libint \ No newline at end of file diff --git a/src/integrals/libint/shellnorms.cpp b/src/integrals/libint/shellnorms.cpp deleted file mode 100644 index 67f19c8b..00000000 --- a/src/integrals/libint/shellnorms.cpp +++ /dev/null @@ -1,144 +0,0 @@ -/* - * Copyright 2022 NWChemEx-Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/// TODO: These modules need to be removed once the IntegralFactory versions -/// are better optimized. - -#include "detail_/make_engine.hpp" -#include "detail_/make_libint_basis_set.hpp" -#include "shellnorms.hpp" -#include -#include - -namespace integrals::libint { - -/// Grab the various detail_ functions -using namespace detail_; - -template -TEMPLATED_MODULE_CTOR(ShellNorms, NBodies, OperatorType) { - description("Calculates the Cauchy-Schwarz screening matrix for a pair of " - "basis sets"); - - using my_pt = simde::ShellNorms; - satisfies_property_type(); - - add_input("Threshold") - .set_description("Convergence threshold of integrals") - .set_default(1.0E-16); -} - -template -TEMPLATED_MODULE_RUN(ShellNorms, NBodies, OperatorType) { - using my_pt = simde::ShellNorms; - using elem_vec = typename std::vector; - using return_vec = typename std::vector; - - // Get inputs - const auto& [bra, op, ket] = my_pt::unwrap_inputs(inputs); - auto thresh = inputs.at("Threshold").value(); - - // Libint basis sets - auto set_bra = make_libint_basis_set(bra.basis_set()); - auto set_ket = make_libint_basis_set(ket.basis_set()); - - // Check if the basis sets are the same - bool same_bs = (set_bra == set_ket); - - // Our return value - return_vec mat(set_bra.size(), elem_vec(set_ket.size(), 0.0)); - - // Lambda to fill in the values - std::function into_mat; - std::vector bases{set_bra, set_ket}; - auto engine = detail_::make_engine(bases, op, thresh); - if constexpr(NBodies == 1) { - engine.set(libint2::BraKet::xs_xs); - into_mat = [&mat, &same_bs, &bases, engine](std::size_t i, - std::size_t j) mutable { - const auto& buf = engine.results(); - engine.compute(bases[0][i], bases[1][j]); - auto vals = buf[0]; - - // Determine the number of compute values - std::size_t nvals = (bases[0][i].size() * bases[1][j].size()); - - // Find the norm and take the square root - double frobenius_norm_squared = 0.0; - if(vals != nullptr) { - for(int a = 0; a < nvals; ++a) { - frobenius_norm_squared += vals[a] * vals[a]; - } - } - mat[i][j] = std::sqrt(frobenius_norm_squared); - if(same_bs && (i != j)) { - mat[j][i] = mat[i][j]; - } // cut down on work - }; - } else if constexpr(NBodies == 2) { - engine.set(libint2::BraKet::xx_xx); - into_mat = [&mat, &same_bs, &bases, engine](std::size_t i, - std::size_t j) mutable { - const auto& buf = engine.results(); - engine.compute(bases[0][i], bases[1][j], bases[0][i], bases[1][j]); - auto vals = buf[0]; - - // Determine the number of compute values - std::size_t nvals = (bases[0][i].size() * bases[0][i].size()); - nvals *= (bases[1][j].size() * bases[1][j].size()); - - // Find the norm and take the square root - double inf_norm_squared = 0.0; - if(vals != nullptr) { - for(int a = 0; a < nvals; ++a) { - inf_norm_squared = - std::max(inf_norm_squared, std::abs(vals[a])); - } - } - mat[i][j] = std::sqrt(inf_norm_squared); - if(same_bs && (i != j)) { - mat[j][i] = mat[i][j]; - } // cut down on work - }; - } - - // Calculate values - auto& my_runtime = get_runtime(); - auto comm = get_runtime().mpi_comm(); - auto& world = *madness::World::find_instance(SafeMPI::Intracomm(comm)); - for(std::size_t i = 0; i < bases[0].size(); ++i) { - // only do lower triangle if basis sets are the same - auto len = (same_bs) ? i : bases[1].size() - 1; - for(std::size_t j = 0; j <= len; ++j) { - world.taskq.add(into_mat, i, j); - } - } - world.gop.fence(); - - auto rv = results(); - return my_pt::wrap_results(rv, mat); -} - -// ----------------------------------------------------------------------------- -// -- Template Declarations -// ----------------------------------------------------------------------------- - -template class ShellNorms<1, simde::type::el_identity>; -template class ShellNorms<2, simde::type::el_el_coulomb>; -template class ShellNorms<2, simde::type::el_el_stg>; -template class ShellNorms<2, simde::type::el_el_yukawa>; - -} // namespace integrals::libint diff --git a/src/integrals/libint/shellnorms.hpp b/src/integrals/libint/shellnorms.hpp deleted file mode 100644 index 754b64d8..00000000 --- a/src/integrals/libint/shellnorms.hpp +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright 2022 NWChemEx-Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/// TODO: These modules need to be removed once the IntegralFactory versions -/// are better optimized. - -#pragma once -#include - -namespace integrals::libint { - -// ----------------------------------------------------------------------------- -// -- Declare Integral Module Types -// ----------------------------------------------------------------------------- - -template -DECLARE_MODULE(ShellNorms); - -using ShellNormOverlap = ShellNorms<1, simde::type::el_identity>; -using ShellNormCoulomb = ShellNorms<2, simde::type::el_el_coulomb>; -using ShellNormSTG = ShellNorms<2, simde::type::el_el_stg>; -using ShellNormYukawa = ShellNorms<2, simde::type::el_el_yukawa>; - -// ----------------------------------------------------------------------------- -// -- Forward External Template Declarations -// ----------------------------------------------------------------------------- - -extern template class ShellNorms<1, simde::type::el_identity>; -extern template class ShellNorms<2, simde::type::el_el_coulomb>; -extern template class ShellNorms<2, simde::type::el_el_stg>; -extern template class ShellNorms<2, simde::type::el_el_yukawa>; - -} // namespace integrals::libint diff --git a/src/integrals/shapes/center_tiled_shape.cpp b/src/integrals/shapes/center_tiled_shape.cpp deleted file mode 100644 index 4c7bf759..00000000 --- a/src/integrals/shapes/center_tiled_shape.cpp +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Copyright 2022 NWChemEx-Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "shapes.hpp" -#include - -namespace integrals::shapes { - -using integral_shape_t = simde::IntegralShape; -using shape_t = typename simde::type::tensor::shape_type; -using tiling_t = typename shape_t::tiling_type; - -MODULE_CTOR(CenterTiledShape) { - satisfies_property_type(); - description("Construct a tensor shape that is tiled on basis set centers"); -} - -MODULE_RUN(CenterTiledShape) { - auto [bases] = integral_shape_t::unwrap_inputs(inputs); - - tiling_t tiling; - for(const auto& set : bases) { - tiling.push_back({0}); - auto& current_tiling = tiling.back(); - for(const auto& center : set) { - current_tiling.push_back(current_tiling.back() + center.n_aos()); - } - } - shape_t shape{tiling}; - - auto rv = results(); - return integral_shape_t::wrap_results(rv, shape); -} - -} // namespace integrals::shapes diff --git a/src/integrals/shapes/one_tile_shape.cpp b/src/integrals/shapes/one_tile_shape.cpp deleted file mode 100644 index 393dfa3e..00000000 --- a/src/integrals/shapes/one_tile_shape.cpp +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright 2022 NWChemEx-Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "shapes.hpp" -#include - -namespace integrals::shapes { - -using integral_shape_t = simde::IntegralShape; -using shape_t = typename simde::type::tensor::shape_type; -using extents_t = typename shape_t::extents_type; - -MODULE_CTOR(OneTileShape) { - satisfies_property_type(); - description("Construct a tensor shape that has one big tile"); -} - -MODULE_RUN(OneTileShape) { - auto [bases] = integral_shape_t::unwrap_inputs(inputs); - - extents_t extents; - for(auto& set : bases) { extents.push_back(set.n_aos()); } - shape_t shape{extents}; - - auto rv = results(); - return integral_shape_t::wrap_results(rv, shape); -} - -} // namespace integrals::shapes diff --git a/src/integrals/transforms/detail_/run_fundamental.hpp b/src/integrals/transforms/detail_/run_fundamental.hpp deleted file mode 100644 index 7151e8ea..00000000 --- a/src/integrals/transforms/detail_/run_fundamental.hpp +++ /dev/null @@ -1,70 +0,0 @@ -/* - * Copyright 2022 NWChemEx-Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#pragma once -#include - -namespace integrals::detail_ { - -/** @brief Code factorization for building a tensor with AO basis sets. - * - * The starting point for all transforms is the tensor in the AO basis set. - * To get the AO-based tensor we need to unpack the map of AO basis sets that - * the calling module has. This function wraps that process to avoid code - * duplication. - * - * @tparam N The number of centers in the integral. - * @tparam OpType The type of the operator for the integral - * - * @param[in] submod The module to use to compute the AO-based tensor. - * @param[in] all_aos The map from 0-based mode offset to the AO space to use - * for it. - * @param[in] op The operator in the integral. - * - * @return The requested tensor. - * - * @throw std::runtime_error if all_aos.size() != N. Strong throw guarantee. - */ -template -auto run_fundamental(pluginplay::Module& submod, - const simde::space_map_t& all_aos, - const OpType& op) { - using sub_pt = simde::AOTensorRepresentation>; - - if(all_aos.size() != N) - throw std::runtime_error("One or modes doesn't have a basis set."); - - simde::type::tensor x; - - // There's at least two AO bases - const auto& aos0 = all_aos.at(0).get(); - const auto& aos1 = all_aos.at(1).get(); - if constexpr(N == 2) { - x = submod.run_as(aos0, op, aos1); - } else if constexpr(N == 3) { - const auto& aos2 = all_aos.at(2).get(); - x = submod.run_as(aos0, op, aos1, aos2); - } else if constexpr(N == 4) { - const auto& aos2 = all_aos.at(2).get(); - const auto& aos3 = all_aos.at(3).get(); - x = submod.run_as(aos0, aos1, op, aos2, aos3); - } else { - static_assert(N == 2, "Unsupported number of centers"); - } - return x; -} - -} // namespace integrals::detail_ diff --git a/src/integrals/transforms/standard.cpp b/src/integrals/transforms/standard.cpp deleted file mode 100644 index e456db2d..00000000 --- a/src/integrals/transforms/standard.cpp +++ /dev/null @@ -1,94 +0,0 @@ -/* - * Copyright 2022 NWChemEx-Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "detail_/run_fundamental.hpp" -#include "standard.hpp" -#include -#include - -namespace integrals { - -template -TEMPLATED_MODULE_CTOR(StandardTransform, N, OpType) { - using pt = simde::TransformedTensorRepresentation; - using sub_pt = simde::AOTensorRepresentation; - - satisfies_property_type(); - - add_submodule("integral kernel"); -} - -template -TEMPLATED_MODULE_RUN(StandardTransform, N, OpType) { - using pt = simde::TransformedTensorRepresentation; - - const auto& [ao_spaces, derived_spaces, op] = pt::unwrap_inputs(inputs); - - if(ao_spaces.size() + derived_spaces.size() != N) - throw std::runtime_error("Did not get enough (or got too many) bases."); - - // Grab the AO basis sets for each mode - std::decay_t all_aos; - for(const auto& [mode, aos] : ao_spaces) all_aos.emplace(mode, aos); - for(const auto& [mode, mos] : derived_spaces) - all_aos.emplace(mode, std::cref(mos.get().from_space())); - - // Get the integral in the AO basis - auto& submod = submods.at("integral kernel"); - auto t = detail_::run_fundamental(submod.value(), all_aos, op); - - // Sort transforms - std::multimap size2mode; - for(const auto& [mode, mos] : derived_spaces) { - size2mode.emplace(mos.get().size(), mode); - } - - // Do the transforms - simde::type::tensor temp; - const auto out_idx = t.make_annotation(); /// (e.g. "i0,i1,i2,i3") - for(const auto& [size, mode] : size2mode) { - /// Get the current coefficients - const auto& C = derived_spaces.at(mode).get().C(); - /// Identify the mode to contract (e.g. "i2") - std::string mode2trans = "i" + std::to_string(mode); - /// Label the targeted mode from out_idx as "mu" (e.g. "i0,i1,mu,i3") - auto in_idx = utilities::strings::replace(mode2trans, "mu", out_idx); - /// Contract the targeted mode with the current coefficients - /// (e.g. temp("i0,i1,i2,i3") = C("mu,i2") * t("i0,i1,mu,i3")) - temp(out_idx) = C("mu," + mode2trans) * t(in_idx); - /// Overwrite t - t = temp; - } - - auto rv = results(); - return pt::wrap_results(rv, t); -} - -// ----------------------------------------------------------------------------- -// -- Template Declarations -// ----------------------------------------------------------------------------- - -template class StandardTransform<2, simde::type::el_scf_k>; -template class StandardTransform<2, simde::type::fock>; -template class StandardTransform<2, simde::type::el_kinetic>; -template class StandardTransform<2, simde::type::el_nuc_coulomb>; -template class StandardTransform<3, simde::type::el_el_coulomb>; -template class StandardTransform<4, simde::type::el_el_coulomb>; -template class StandardTransform<4, simde::type::el_el_f12_commutator>; -template class StandardTransform<4, simde::type::el_el_stg>; -template class StandardTransform<4, simde::type::el_el_yukawa>; - -} // namespace integrals diff --git a/src/integrals/transforms/standard.hpp b/src/integrals/transforms/standard.hpp deleted file mode 100644 index 08692d30..00000000 --- a/src/integrals/transforms/standard.hpp +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright 2022 NWChemEx-Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#pragma once -#include - -namespace integrals { - -// ----------------------------------------------------------------------------- -// -- Declare Module Types -// ----------------------------------------------------------------------------- - -template -DECLARE_MODULE(StandardTransform); - -// ----------------------------------------------------------------------------- -// -- Forward External Template Declarations -// ----------------------------------------------------------------------------- - -extern template class StandardTransform<2, simde::type::el_scf_k>; -extern template class StandardTransform<2, simde::type::fock>; -extern template class StandardTransform<2, simde::type::el_kinetic>; -extern template class StandardTransform<2, simde::type::el_nuc_coulomb>; -extern template class StandardTransform<2, simde::type::fock>; -extern template class StandardTransform<3, simde::type::el_el_coulomb>; -extern template class StandardTransform<4, simde::type::el_el_coulomb>; -extern template class StandardTransform<4, simde::type::el_el_f12_commutator>; -extern template class StandardTransform<4, simde::type::el_el_stg>; -extern template class StandardTransform<4, simde::type::el_el_yukawa>; -} // namespace integrals diff --git a/src/integrals/transforms/transforms.cpp b/src/integrals/transforms/transforms.cpp deleted file mode 100644 index 45fb35a3..00000000 --- a/src/integrals/transforms/transforms.cpp +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Copyright 2023 NWChemEx-Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "transforms.hpp" - -namespace integrals::transforms { - -// ----------------------------------------------------------------------------- -// -- Define Module Load Functions -// ----------------------------------------------------------------------------- - -template -void register_transformed_integral(pluginplay::ModuleManager& mm, - std::string key) { - using module_t = StandardTransform; - auto new_key = "Transformed " + key; - mm.add_module(new_key); - mm.change_submod(new_key, "integral kernel", key); -} - -void load_transformed_integrals(pluginplay::ModuleManager& mm) { - using namespace simde::type; - - // register_transformed_integral>(mm, "EDipole"); - // register_transformed_integral>(mm, "EQuadrupole"); - // register_transformed_integral>(mm, "EOctopole"); - // register_transformed_integral>(mm, "ERI2"); - register_transformed_integral<3, el_el_coulomb>(mm, "ERI3"); - register_transformed_integral<4, el_el_coulomb>(mm, "ERI4"); - // register_transformed_integral>(mm, "Kinetic"); - // register_transformed_integral>(mm, "Nuclear"); - // register_transformed_integral>(mm, "Overlap"); - register_transformed_integral<2, el_kinetic>(mm, "Kinetic"); - register_transformed_integral<2, el_nuc_coulomb>(mm, "Nuclear"); - register_transformed_integral<4, el_el_stg>(mm, "STG4"); - register_transformed_integral<4, el_el_yukawa>(mm, "Yukawa4"); - register_transformed_integral<4, el_el_f12_commutator>( - mm, "STG 4 Center dfdr Squared"); - - mm.add_module>("Transformed K"); - mm.add_module>("Transformed Fock"); -} - -} // namespace integrals::transforms diff --git a/src/integrals/transforms/transforms.hpp b/src/integrals/transforms/transforms.hpp deleted file mode 100644 index 6445b430..00000000 --- a/src/integrals/transforms/transforms.hpp +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Copyright 2022 NWChemEx-Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#pragma once -#include "standard.hpp" -#include - -namespace integrals::transforms { - -// ----------------------------------------------------------------------------- -// -- Declare Module Load Functions -// ----------------------------------------------------------------------------- - -void load_transformed_integrals(pluginplay::ModuleManager& mm); - -} // namespace integrals::transforms diff --git a/tests/cxx/integration/blank_test.cpp b/tests/cxx/integration/blank_test.cpp deleted file mode 100644 index f0e48aac..00000000 --- a/tests/cxx/integration/blank_test.cpp +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright 2023 NWChemEx-Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#define CATCH_CONFIG_MAIN -#include -#include - -int print_and_return(int ii) { - std::cout << "This is only a blank model for an integration test." - << std::endl; - return 0; -} - -TEST_CASE("Blank test", "[classic]") { REQUIRE(print_and_return(0) == 0); } diff --git a/tests/cxx/unit/integrals/ao_integrals/detail_/aos2shell.cpp b/tests/cxx/unit/integrals/ao_integrals/detail_/aos2shell.cpp deleted file mode 100644 index e467308b..00000000 --- a/tests/cxx/unit/integrals/ao_integrals/detail_/aos2shell.cpp +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copyright 2022 NWChemEx-Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "integrals/ao_integrals/detail_/aos2shells.hpp" -#include - -using integrals::ao_integrals::detail_::aos2shells; - -TEST_CASE("aos2shells") { - std::vector shell_sizes{1, 1, 3, 1, 1}; - - // Run with different inputs - auto all = aos2shells(shell_sizes, 0, 7); - auto only_o = aos2shells(shell_sizes, 0, 5); - auto only_h1 = aos2shells(shell_sizes, 5, 6); - auto only_h2 = aos2shells(shell_sizes, 6, 7); - auto both_hs = aos2shells(shell_sizes, 5, 7); - - /// Check outputs - REQUIRE(all == std::vector{0, 1, 2, 3, 4}); - REQUIRE(only_o == std::vector{0, 1, 2}); - REQUIRE(only_h1 == std::vector{3}); - REQUIRE(only_h2 == std::vector{4}); - REQUIRE(both_hs == std::vector{3, 4}); -} \ No newline at end of file diff --git a/tests/cxx/unit/integrals/ao_integrals/detail_/bsets_shell_centers.cpp b/tests/cxx/unit/integrals/ao_integrals/detail_/bsets_shell_centers.cpp deleted file mode 100644 index 393959c6..00000000 --- a/tests/cxx/unit/integrals/ao_integrals/detail_/bsets_shell_centers.cpp +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright 2022 NWChemEx-Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "integrals/ao_integrals/detail_/bsets_shell_centers.hpp" -#include -#include - -using namespace mokup; - -using integrals::ao_integrals::detail_::bsets_shell_centers; - -TEST_CASE("bsets_shell_centers") { - const auto name = molecule::h2o; - const auto bs = basis_set::sto3g; - auto aos = get_bases(name, bs); - const auto& bset = aos.basis_set(); - std::vector input{bset}; - - std::vector> corr{{0, 0, 0, 1, 2}}; - - auto result = bsets_shell_centers(input); - REQUIRE(result == corr); -} \ No newline at end of file diff --git a/tests/cxx/unit/integrals/ao_integrals/detail_/bsets_shell_sizes.cpp b/tests/cxx/unit/integrals/ao_integrals/detail_/bsets_shell_sizes.cpp deleted file mode 100644 index e562ce66..00000000 --- a/tests/cxx/unit/integrals/ao_integrals/detail_/bsets_shell_sizes.cpp +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright 2022 NWChemEx-Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "integrals/ao_integrals/detail_/bsets_shell_sizes.hpp" -#include -#include - -using namespace mokup; - -using integrals::ao_integrals::detail_::bsets_shell_sizes; - -TEST_CASE("bsets_shell_sizes") { - const auto name = molecule::h2o; - const auto bs = basis_set::sto3g; - auto aos = get_bases(name, bs); - const auto& bset = aos.basis_set(); - std::vector input{bset}; - - std::vector> corr{{1, 1, 3, 1, 1}}; - - auto result = bsets_shell_sizes(input); - REQUIRE(result == corr); -} \ No newline at end of file diff --git a/tests/cxx/unit/integrals/ao_integrals/detail_/get_coeff.cpp b/tests/cxx/unit/integrals/ao_integrals/detail_/get_coeff.cpp deleted file mode 100644 index 56811460..00000000 --- a/tests/cxx/unit/integrals/ao_integrals/detail_/get_coeff.cpp +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Copyright 2022 NWChemEx-Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "integrals/ao_integrals/detail_/get_coeff.hpp" -#include -#include -#include - -using namespace mokup; - -using integrals::ao_integrals::detail_::get_coefficient; - -TEST_CASE("get_coeff") { - auto default_value = -1.0 / 1.2; - chemist::Electron e; - chemist::operators::STG stg; - - SECTION("Yukawa") { - simde::type::el_el_stg op(stg); - auto result = get_coefficient(op); - REQUIRE(result == default_value); - } - - SECTION("STG") { - chemist::Electron e; - simde::type::el_el_yukawa op(stg, e, e); - auto result = get_coefficient(op); - REQUIRE(result == default_value); - } - - SECTION("Neither") { - simde::type::el_identity op; - auto result = get_coefficient(op); - REQUIRE(result == 1.0); - } -} \ No newline at end of file diff --git a/tests/cxx/unit/integrals/ao_integrals/detail_/hash_inputs.cpp b/tests/cxx/unit/integrals/ao_integrals/detail_/hash_inputs.cpp deleted file mode 100644 index d0018b17..00000000 --- a/tests/cxx/unit/integrals/ao_integrals/detail_/hash_inputs.cpp +++ /dev/null @@ -1,161 +0,0 @@ -/* - * Copyright 2022 NWChemEx-Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "integrals/ao_integrals/detail_/hash_inputs.hpp" -#include -#include - -using namespace mokup; -using namespace integrals::ao_integrals::detail_; - -using bases_vector_t = std::vector; - -TEST_CASE("Combining hashes") { - /// Values for input and comparison - const double v = 1.23456; - std::size_t v_hash = std::hash{}(v); - std::size_t corr1 = 0 ^ (v_hash + 0x9e3779b9 + (0 << 6) + (0 >> 2)); - std::size_t corr2 = - corr1 ^ (v_hash + 0x9e3779b9 + (corr1 << 6) + (corr1 >> 2)); - - SECTION("hash_together") { - std::size_t seed = 0; - hash_together(seed, v_hash); - REQUIRE(seed == corr1); - hash_together(seed, v_hash); - REQUIRE(seed == corr2); - } - - SECTION("combine_hash") { - std::size_t seed = 0; - combine_hash(seed, v); - REQUIRE(seed == corr1); - combine_hash(seed, v); - REQUIRE(seed == corr2); - - /// Reset seed and check if it works as one call - seed = 0; - combine_hash(seed, v, v); - REQUIRE(seed == corr2); - } -} - -TEST_CASE("Hashing Operators") { - SECTION("el_el_coulomb") { - simde::type::el_el_coulomb op; - simde::type::el_el_delta other_op; - auto op_hash = hash_operator(op); - auto corr = std::hash{}("(r₁₂)⁻¹"); - - /// Check correctness of hash - REQUIRE(op_hash == corr); - /// Check differentiation of hashes - REQUIRE(op_hash != hash_operator(other_op)); - } - - SECTION("el_nuc_coulomb") { - using e_t = chemist::Electron; - using atom_t = chemist::Atom; - using nuc_t = chemist::Nuclei; - using op_t = simde::type::el_nuc_coulomb; - - atom_t a1{"X", std::size_t{1}, 0.0, 0.0, 0.0, 0.0}; - atom_t a2{"X", std::size_t{2}, 0.0, 1.0, 0.0, 0.0}; - op_t op(e_t{}, nuc_t{a1.nucleus()}); - op_t other_op1(e_t{}, nuc_t{a2.nucleus()}); - op_t other_op2(e_t{}, nuc_t{a1.nucleus(), a2.nucleus()}); - auto op_hash = hash_operator(op); - - auto corr = std::hash{}("(r₁₂)⁻¹"); - combine_hash(corr, std::size_t{1}, std::string("X"), 0.0, 1.0, 0.0, 0.0, - 0.0); - - /// Check correctness of hash - REQUIRE(op_hash == corr); - /// Check differentiation of hashes - REQUIRE(op_hash != hash_operator(other_op1)); - REQUIRE(op_hash != hash_operator(other_op2)); - } - - SECTION("el_el_stg") { - using stg_t = chemist::operators::STG; - using op_t = simde::type::el_el_stg; - - op_t op(stg_t{1.0, 1.0}); - op_t other_op1(stg_t{2.0, 1.0}); - op_t other_op2(stg_t{1.0, 2.0}); - auto op_hash = hash_operator(op); - - auto corr = std::hash{}("f₁₂"); - combine_hash(corr, 1.0, 1.0); - - /// Check correctness of hash - REQUIRE(op_hash == corr); - /// Check differentiation of hashes - REQUIRE(op_hash != hash_operator(other_op1)); - REQUIRE(op_hash != hash_operator(other_op2)); - } -} - -TEST_CASE("Hashing Bases") { - const auto name = molecule::h2o; - auto sto3g_nwx = get_bases(name, basis_set::sto3g); - auto ccpvdz_nwx = get_bases(name, basis_set::ccpvdz); - - auto sto3g = sto3g_nwx.basis_set(); - auto ccpvdz = ccpvdz_nwx.basis_set(); - - bases_vector_t set1{sto3g}; - bases_vector_t set2{ccpvdz}; - bases_vector_t set3{sto3g, sto3g}; - bases_vector_t set4{sto3g, ccpvdz}; - bases_vector_t set5{ccpvdz, sto3g}; - - std::hash hasher; - auto hash1 = hasher(set1); - auto hash2 = hasher(set2); - auto hash3 = hasher(set3); - auto hash4 = hasher(set4); - auto hash5 = hasher(set5); - - /// Checking the absolute correctness of the hash is overly involved, - /// so I'm just checking for differentiation between instances. - REQUIRE(hash1 != hash2); // Same number, different contents - REQUIRE(hash1 != hash3); // Different number of the same set - REQUIRE(hash4 != hash5); // Check asymetry of hashing -} - -/// Everything else is tested by this point, so just make sure that this -/// is consistent with expectation. -TEST_CASE("hash_inputs") { - /// Inputs - simde::type::el_el_coulomb op; - const auto name = molecule::h2o; - auto sto3g_nwx = get_bases(name, basis_set::sto3g); - auto sto3g = sto3g_nwx.basis_set(); - bases_vector_t bases{sto3g}; - double t = 1.23456; - - /// Hash inputs - auto hash = hash_inputs(bases, op, t); - - /// Correct value - auto corr = hash_operator(op); - combine_hash(corr, bases, t); - - /// Check correctness of hash - REQUIRE(hash == std::to_string(corr)); -} diff --git a/tests/cxx/unit/integrals/libint/detail_/libint_basis_set_water.hpp b/tests/cxx/unit/integrals/ao_integrals/detail_/libint_basis_set_water.hpp similarity index 98% rename from tests/cxx/unit/integrals/libint/detail_/libint_basis_set_water.hpp rename to tests/cxx/unit/integrals/ao_integrals/detail_/libint_basis_set_water.hpp index 6e710618..e51cab1c 100644 --- a/tests/cxx/unit/integrals/libint/detail_/libint_basis_set_water.hpp +++ b/tests/cxx/unit/integrals/ao_integrals/detail_/libint_basis_set_water.hpp @@ -17,7 +17,7 @@ #pragma once #include -namespace testing { +namespace test { /// Constructor for Atom inline libint2::Atom make_atom(int Z, double x, double y, double z) { @@ -68,4 +68,4 @@ inline libint2::BasisSet water_basis_set() { return basis_t(atoms, shells); } -} // namespace testing \ No newline at end of file +} // namespace test \ No newline at end of file diff --git a/tests/cxx/unit/integrals/ao_integrals/detail_/make_shape.cpp b/tests/cxx/unit/integrals/ao_integrals/detail_/make_shape.cpp deleted file mode 100644 index c106d603..00000000 --- a/tests/cxx/unit/integrals/ao_integrals/detail_/make_shape.cpp +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright 2022 NWChemEx-Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "integrals/ao_integrals/detail_/make_shape.hpp" -#include -#include - -using namespace mokup; - -using extents_t = typename simde::type::tensor::shape_type::extents_type; -using integrals::ao_integrals::detail_::make_shape; - -TEST_CASE("make_shape") { - /// Basis set inputs - const auto name = molecule::h2o; - const auto bs = basis_set::sto3g; - auto aos = get_bases(name, bs); - const auto& bset = aos.basis_set(); - std::vector bsets{bset, bset}; - - /// Check output - SECTION("standard usage") { - auto shape_ptr = make_shape(bsets); - REQUIRE(shape_ptr->extents() == extents_t{7, 7}); - } - - /// Check leading extent option - SECTION("with leading extent") { - std::size_t extra = 3; - auto shape_ptr = make_shape(bsets, extra); - REQUIRE(shape_ptr->extents() == extents_t{3, 7, 7}); - } -} \ No newline at end of file diff --git a/tests/cxx/unit/integrals/ao_integrals/detail_/shells2ord.cpp b/tests/cxx/unit/integrals/ao_integrals/detail_/shells2ord.cpp deleted file mode 100644 index 557e9edf..00000000 --- a/tests/cxx/unit/integrals/ao_integrals/detail_/shells2ord.cpp +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Copyright 2022 NWChemEx-Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "integrals/ao_integrals/detail_/shells2ord.hpp" -#include - -using integrals::ao_integrals::detail_::shells2ord; -using size_vector_t = std::vector; - -TEST_CASE("shell2ord") { - // Shell sizes - size_vector_t shell_sizes{1, 1, 3, 1, 1}; - - // Check different dimensionalities - SECTION("2D") { - std::vector sizes{shell_sizes, shell_sizes}; - size_vector_t curr{2, 0}, lo{0, 0}, up{4, 4}; - auto ord_pos = shells2ord(sizes, curr, lo, up); - REQUIRE(ord_pos == size_vector_t{14, 21, 28}); - } - - SECTION("3D") { - std::vector sizes{shell_sizes, shell_sizes, shell_sizes}; - size_vector_t curr{2, 0, 0}, lo{0, 0, 0}, up{4, 4, 4}; - auto ord_pos = shells2ord(sizes, curr, lo, up); - REQUIRE(ord_pos == size_vector_t{98, 147, 196}); - } - - SECTION("4D") { - std::vector sizes{shell_sizes, shell_sizes, shell_sizes, shell_sizes}; - size_vector_t curr{2, 0, 0, 0}, lo{0, 0, 0, 0}, up{4, 4, 4, 4}; - auto ord_pos = shells2ord(sizes, curr, lo, up); - REQUIRE(ord_pos == size_vector_t{686, 1029, 1372}); - } - - SECTION("specific tile") { - std::vector sizes{shell_sizes, shell_sizes}; - size_vector_t lo{2, 0}, up{3, 0}; - SECTION("lower") { - auto ord_pos = shells2ord(sizes, lo, lo, up); - REQUIRE(ord_pos == size_vector_t{0, 1, 2}); - } - SECTION("upper") { - auto ord_pos = shells2ord(sizes, up, lo, up); - REQUIRE(ord_pos == size_vector_t{3}); - } - } -} \ No newline at end of file diff --git a/tests/cxx/unit/integrals/libint/detail_/make_libint_basis_set.cpp b/tests/cxx/unit/integrals/ao_integrals/detail_/test_make_libint_basis_set.cpp similarity index 56% rename from tests/cxx/unit/integrals/libint/detail_/make_libint_basis_set.cpp rename to tests/cxx/unit/integrals/ao_integrals/detail_/test_make_libint_basis_set.cpp index 9242cb10..016c11d1 100644 --- a/tests/cxx/unit/integrals/libint/detail_/make_libint_basis_set.cpp +++ b/tests/cxx/unit/integrals/ao_integrals/detail_/test_make_libint_basis_set.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2022 NWChemEx-Project + * Copyright 2024 NWChemEx-Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,24 +14,15 @@ * limitations under the License. */ -#include "integrals/libint/detail_/make_libint_basis_set.hpp" +#include "../../water_sto3g.hpp" +#include "integrals/ao_integrals/detail_/make_libint_basis_set.hpp" #include "libint_basis_set_water.hpp" -#include -#include - -using namespace mokup; - -using integrals::libint::detail_::make_libint_basis_set; +#include TEST_CASE("make_libint_basis_set") { - const auto name = molecule::h2o; - const auto bs = basis_set::sto3g; - auto aos = get_bases(name, bs); - - /// Expected Libint result - auto libint_corr = testing::water_basis_set(); - - /// Check output - auto libint_bs = make_libint_basis_set(aos.basis_set()); + using integrals::ao_integrals::detail_::make_libint_basis_set; + auto aobs = test::water_sto3g_basis_set(); + auto libint_bs = make_libint_basis_set(aobs); + auto libint_corr = test::water_basis_set(); REQUIRE(libint_bs == libint_corr); -} \ No newline at end of file +} diff --git a/src/integrals/shapes/shapes.hpp b/tests/cxx/unit/integrals/ao_integrals/detail_/test_shells2ord.cpp similarity index 50% rename from src/integrals/shapes/shapes.hpp rename to tests/cxx/unit/integrals/ao_integrals/detail_/test_shells2ord.cpp index efbcefb9..911b9147 100644 --- a/src/integrals/shapes/shapes.hpp +++ b/tests/cxx/unit/integrals/ao_integrals/detail_/test_shells2ord.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2022 NWChemEx-Project + * Copyright 2024 NWChemEx-Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,17 +14,16 @@ * limitations under the License. */ -#pragma once -#include +#include "integrals/ao_integrals/detail_/shells2ord.hpp" +#include "libint_basis_set_water.hpp" +#include -namespace integrals::shapes { - -DECLARE_MODULE(OneTileShape); -DECLARE_MODULE(CenterTiledShape); - -inline void load_modules(pluginplay::ModuleManager& mm) { - mm.add_module("OneTileShape"); - mm.add_module("CenterTiledShape"); +TEST_CASE("shells2ord") { + using integrals::ao_integrals::detail_::shells2ord; + auto aobs = test::water_basis_set(); + std::vector basis_sets{aobs, aobs}; + std::vector shells{2, 2}; + auto out = shells2ord(basis_sets, shells); + std::vector corr = {16, 17, 18, 23, 24, 25, 30, 31, 32}; + REQUIRE(out == corr); } - -} // namespace integrals::shapes \ No newline at end of file diff --git a/tests/cxx/unit/integrals/ao_integrals/dfdr_squared.cpp b/tests/cxx/unit/integrals/ao_integrals/dfdr_squared.cpp deleted file mode 100644 index d2ce86ac..00000000 --- a/tests/cxx/unit/integrals/ao_integrals/dfdr_squared.cpp +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright 2022 NWChemEx-Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "integrals/integrals.hpp" -#include -#include -#include -#include -#include - -using namespace mokup; - -TEST_CASE("STG 4 Center dfdr Squared") { - using op_type = simde::type::el_el_f12_commutator; - using integral_type = simde::AOTensorRepresentation<4, op_type>; - const auto key = "STG 4 Center dfdr Squared"; - - pluginplay::ModuleManager mm; - integrals::load_modules(mm); - - const auto name = molecule::h2; - const auto bs = basis_set::sto3g; - const auto prop = property::stg_dfdr_squared; - op_type fTf; - - std::vector bs_key(4, bs); - auto aos = get_bases(name, bs); - auto X_corr = get_ao_data(name, bs_key, prop); - auto X = mm.at(key).run_as(aos, aos, fTf, aos, aos); - REQUIRE(tensorwrapper::tensor::allclose(X, X_corr)); -} diff --git a/tests/cxx/unit/integrals/ao_integrals/direct_allclose.hpp b/tests/cxx/unit/integrals/ao_integrals/direct_allclose.hpp deleted file mode 100644 index 209791e7..00000000 --- a/tests/cxx/unit/integrals/ao_integrals/direct_allclose.hpp +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Copyright 2022 NWChemEx-Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#pragma once -#include -#include - -/// Roundabout comparison because of lazy eval and allclose -/// TODO: remove when allclose can handle direct tensors -inline bool direct_allclose(simde::type::tensor direct_tensor, - simde::type::tensor ref) { - simde::type::tensor data_tensor, diff; - auto idx = ref.make_annotation(); - - diff(idx) = direct_tensor(idx) - ref(idx); - data_tensor(idx) = ref(idx) + diff(idx); - - return tensorwrapper::tensor::allclose(data_tensor, ref); -} \ No newline at end of file diff --git a/tests/cxx/unit/integrals/ao_integrals/stg_correlation_factor.cpp b/tests/cxx/unit/integrals/ao_integrals/stg_correlation_factor.cpp deleted file mode 100644 index 649cce93..00000000 --- a/tests/cxx/unit/integrals/ao_integrals/stg_correlation_factor.cpp +++ /dev/null @@ -1,66 +0,0 @@ -/* - * Copyright 2022 NWChemEx-Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "integrals/integrals.hpp" -#include -#include -#include -#include - -using namespace mokup; - -TEST_CASE("STG 2 Center Correlation Factor") { - using op_type = simde::type::el_el_stg; - using integral_type = simde::AOTensorRepresentation<2, op_type>; - const auto key = "STG2"; - - pluginplay::ModuleManager mm; - integrals::load_modules(mm); - - const auto name = molecule::h2; - const auto bs = basis_set::sto3g; - const auto prop = property::stg_correlation_factor; - - chemist::Electron e; - op_type stg; - - std::vector bs_key(2, bs); - auto aos = get_bases(name, bs); - auto X_corr = get_ao_data(name, bs_key, prop); - auto X = mm.at(key).run_as(aos, stg, aos); - REQUIRE(tensorwrapper::tensor::allclose(X, X_corr)); -} - -TEST_CASE("STG 4 Center Correlation Factor") { - using op_type = simde::type::el_el_stg; - using integral_type = simde::AOTensorRepresentation<4, op_type>; - const auto key = "STG4"; - - pluginplay::ModuleManager mm; - integrals::load_modules(mm); - - const auto name = molecule::h2; - const auto bs = basis_set::sto3g; - const auto prop = property::stg_correlation_factor; - chemist::Electron e; - op_type stg; - - std::vector bs_key(4, bs); - auto aos = get_bases(name, bs); - auto X_corr = get_ao_data(name, bs_key, prop); - auto X = mm.at(key).run_as(aos, aos, stg, aos, aos); - REQUIRE(tensorwrapper::tensor::allclose(X, X_corr)); -} diff --git a/tests/cxx/unit/integrals/ao_integrals/stg_correlation_factor_squared.cpp b/tests/cxx/unit/integrals/ao_integrals/stg_correlation_factor_squared.cpp deleted file mode 100644 index 4e9d9a8d..00000000 --- a/tests/cxx/unit/integrals/ao_integrals/stg_correlation_factor_squared.cpp +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright 2022 NWChemEx-Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "integrals/integrals.hpp" -#include -#include -#include -#include - -using namespace mokup; - -TEST_CASE("STG 4 Center Correlation Factor Squared") { - using op_type = simde::type::el_el_stg; - using integral_type = simde::AOTensorRepresentation<4, op_type>; - const auto key = "STG4"; - - pluginplay::ModuleManager mm; - integrals::load_modules(mm); - - const auto name = molecule::h2; - const auto bs = basis_set::sto3g; - const auto prop = property::stg_correlation_factor_squared; - - chemist::Electron e; - chemist::operators::STG stg; - op_type f12(stg * stg); - - std::vector bs_key(4, bs); - auto aos = get_bases(name, bs); - auto X_corr = get_ao_data(name, bs_key, prop); - auto X = mm.at(key).run_as(aos, aos, f12, aos, aos); - REQUIRE(tensorwrapper::tensor::allclose(X, X_corr)); -} diff --git a/tests/cxx/unit/integrals/ao_integrals/stg_gr.cpp b/tests/cxx/unit/integrals/ao_integrals/stg_gr.cpp deleted file mode 100644 index a5dc2cbf..00000000 --- a/tests/cxx/unit/integrals/ao_integrals/stg_gr.cpp +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright 2022 NWChemEx-Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "integrals/integrals.hpp" -#include -#include -#include -#include - -using namespace mokup; - -TEST_CASE("STG 4 Center GR") { - using op_type = simde::type::el_el_yukawa; - using integral_type = simde::AOTensorRepresentation<4, op_type>; - const auto key = "Yukawa4"; - - pluginplay::ModuleManager mm; - integrals::load_modules(mm); - - const auto name = mokup::molecule::h2; - const auto bs = basis_set::sto3g; - const auto prop = property::stg_gr; - - chemist::Electron e; - op_type gr(chemist::operators::STG(), e, e); - - std::vector bs_key(4, bs); - auto aos = get_bases(name, bs); - auto X_corr = get_ao_data(name, bs_key, prop); - auto X = mm.at(key).run_as(aos, aos, gr, aos, aos); - REQUIRE(tensorwrapper::tensor::allclose(X, X_corr)); -} diff --git a/tests/cxx/unit/integrals/ao_integrals/test_ao_integrals.hpp b/tests/cxx/unit/integrals/ao_integrals/test_ao_integrals.hpp new file mode 100644 index 00000000..d11b1a15 --- /dev/null +++ b/tests/cxx/unit/integrals/ao_integrals/test_ao_integrals.hpp @@ -0,0 +1,42 @@ +/* + * Copyright 2024 NWChemEx-Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "../water_sto3g.hpp" +#include +#include +#include + +namespace test { + +template +auto eigen_buffer(const tensorwrapper::buffer::BufferBase& buffer) { + return static_cast&>(buffer); +} + +template +auto trace(const TensorType& t) { + Eigen::Tensor trace = t.value().trace(); + return trace.coeff(); +} + +template +auto norm(const TensorType& t) { + Eigen::Tensor norm = + t.value().square().sum().sqrt(); + return norm.coeff(); +} + +} // namespace test \ No newline at end of file diff --git a/tests/cxx/unit/integrals/ao_integrals/test_doi.cpp b/tests/cxx/unit/integrals/ao_integrals/test_doi.cpp deleted file mode 100644 index b9785659..00000000 --- a/tests/cxx/unit/integrals/ao_integrals/test_doi.cpp +++ /dev/null @@ -1,64 +0,0 @@ -/* - * Copyright 2022 NWChemEx-Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "direct_allclose.hpp" -#include "integrals/integrals.hpp" -#include -#include -#include -#include - -using namespace mokup; - -TEST_CASE("DOI") { - using op_type = simde::type::el_el_delta; - using doi_type = simde::EDOI; - using doi4_type = simde::AOTensorRepresentation<4, op_type>; - - pluginplay::ModuleManager mm; - integrals::load_modules(mm); - - const auto name = molecule::h2o; - const auto bs = basis_set::sto3g; - auto aos = get_bases(name, bs); - std::vector bases{bs, bs}; - auto corr = get_ao_data(name, bases, property::dois); - - op_type d; - - SECTION("Explicit") { - SECTION("Four-Index") { - auto X = mm.at("DOI4").run_as(aos, aos, d, aos, aos); - REQUIRE(tensorwrapper::tensor::allclose(X, corr)); - } - SECTION("Wrapper") { - auto X = mm.at("DOI").run_as(aos, d, aos); - REQUIRE(tensorwrapper::tensor::allclose(X, corr)); - } - } - - SECTION("Direct") { - SECTION("Four-Index") { - auto X = - mm.at("Direct DOI4").run_as(aos, aos, d, aos, aos); - REQUIRE(direct_allclose(X, corr)); - } - SECTION("Wrapper") { - auto X = mm.at("Direct DOI").run_as(aos, d, aos); - REQUIRE(direct_allclose(X, corr)); - } - } -} diff --git a/tests/cxx/unit/integrals/ao_integrals/test_edipole.cpp b/tests/cxx/unit/integrals/ao_integrals/test_edipole.cpp deleted file mode 100644 index 86e39f30..00000000 --- a/tests/cxx/unit/integrals/ao_integrals/test_edipole.cpp +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright 2022 NWChemEx-Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "integrals/integrals.hpp" -#include -#include -#include -#include - -using namespace integrals; -using namespace mokup; - -TEST_CASE("Dipole") { - using i_op = simde::type::el_identity; - using d_op = simde::type::el_dipole; - using s_type = simde::AOTensorRepresentation<2, i_op>; - using d_type = simde::AOTensorRepresentation<2, d_op>; - - pluginplay::ModuleManager mm; - integrals::load_modules(mm); - - const auto name = molecule::h2o; - const auto bs = basis_set::sto3g; - auto aos = get_bases(name, bs); - std::vector bases{bs, bs}; - auto corr = get_ao_data(name, bases, property::dipole); - d_op r; - - // SECTION("overlap matrix") { - // mm.change_input("EDipole", "Origin", origin); - // auto [S] = mm.at("EDipole").run_as(aos, aos); - // REQUIRE(tensorwrapper::ta_helpers::allclose(S, X)); - // } - - SECTION("dipole matrix") { - auto D = mm.at("EDipole").run_as(aos, r, aos); - REQUIRE(tensorwrapper::tensor::allclose(D, corr)); - } -} diff --git a/tests/cxx/unit/integrals/ao_integrals/test_eoctopole.cpp b/tests/cxx/unit/integrals/ao_integrals/test_eoctopole.cpp deleted file mode 100644 index 601499c7..00000000 --- a/tests/cxx/unit/integrals/ao_integrals/test_eoctopole.cpp +++ /dev/null @@ -1,71 +0,0 @@ -/* - * Copyright 2022 NWChemEx-Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "integrals/integrals.hpp" -#include -#include -#include -#include - -using namespace integrals; -using namespace mokup; - -TEST_CASE("Octupole") { - using i_op = simde::type::el_identity; - using d_op = simde::type::el_dipole; - using q_op = simde::type::el_quadrupole; - using o_op = simde::type::el_octupole; - using s_type = simde::AOTensorRepresentation<2, i_op>; - using d_type = simde::AOTensorRepresentation<2, d_op>; - using q_type = simde::AOTensorRepresentation<2, q_op>; - using o_type = simde::AOTensorRepresentation<2, o_op>; - - pluginplay::ModuleManager mm; - integrals::load_modules(mm); - - const auto name = molecule::h2o; - const auto bs = basis_set::sto3g; - auto aos = get_bases(name, bs); - std::vector bases{bs, bs}; - d_op r; - q_op r2; - o_op r3; - - /// TODO: this needs to actually test something. - // SECTION("overlap matrix") { - // mm.change_input("EDipole", "Origin", origin); - // auto [S] = mm.at("EDipole").run_as(aos, aos); - // REQUIRE(tensorwrapper::ta_helpers::allclose(S, X)); - // } - - SECTION("dipole matrix") { - auto D = mm.at("EOctupole").run_as(aos, r, aos); - auto corr = get_ao_data(name, bases, property::dipole); - REQUIRE(tensorwrapper::tensor::allclose(D, corr)); - } - - SECTION("Quadrupole") { - auto Q = mm.at("EOctupole").run_as(aos, r2, aos); - auto corr = get_ao_data(name, bases, property::quadrupole); - REQUIRE(tensorwrapper::tensor::allclose(Q, corr)); - } - - SECTION("Octupole") { - auto O = mm.at("EOctupole").run_as(aos, r3, aos); - auto corr = get_ao_data(name, bases, property::octopole); - REQUIRE(tensorwrapper::tensor::allclose(O, corr)); - } -} diff --git a/tests/cxx/unit/integrals/ao_integrals/test_equadrupole.cpp b/tests/cxx/unit/integrals/ao_integrals/test_equadrupole.cpp deleted file mode 100644 index 68e40a0c..00000000 --- a/tests/cxx/unit/integrals/ao_integrals/test_equadrupole.cpp +++ /dev/null @@ -1,62 +0,0 @@ -/* - * Copyright 2022 NWChemEx-Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "integrals/integrals.hpp" -#include -#include -#include -#include - -using namespace integrals; -using namespace mokup; - -TEST_CASE("Quadrupole") { - using i_op = simde::type::el_identity; - using d_op = simde::type::el_dipole; - using q_op = simde::type::el_quadrupole; - using s_type = simde::AOTensorRepresentation<2, i_op>; - using d_type = simde::AOTensorRepresentation<2, d_op>; - using q_type = simde::AOTensorRepresentation<2, q_op>; - - pluginplay::ModuleManager mm; - integrals::load_modules(mm); - - const auto name = molecule::h2o; - const auto bs = basis_set::sto3g; - auto aos = get_bases(name, bs); - std::vector bases{bs, bs}; - d_op r; - q_op r2; - - /// TODO: this needs to actually test something. - // SECTION("overlap matrix") { - // mm.change_input("EDipole", "Origin", origin); - // auto [S] = mm.at("EDipole").run_as(aos, aos); - // REQUIRE(tensorwrapper::ta_helpers::allclose(S, X)); - // } - - SECTION("dipole matrix") { - auto D = mm.at("EQuadrupole").run_as(aos, r, aos); - auto corr = get_ao_data(name, bases, property::dipole); - REQUIRE(tensorwrapper::tensor::allclose(D, corr)); - } - - SECTION("Quadrupole") { - auto Q = mm.at("EQuadrupole").run_as(aos, r2, aos); - auto corr = get_ao_data(name, bases, property::quadrupole); - REQUIRE(tensorwrapper::tensor::allclose(Q, corr)); - } -} diff --git a/tests/cxx/unit/integrals/ao_integrals/test_eri2.cpp b/tests/cxx/unit/integrals/ao_integrals/test_eri2.cpp index 418d736e..4204f716 100644 --- a/tests/cxx/unit/integrals/ao_integrals/test_eri2.cpp +++ b/tests/cxx/unit/integrals/ao_integrals/test_eri2.cpp @@ -14,37 +14,35 @@ * limitations under the License. */ -#include "direct_allclose.hpp" -#include "integrals/integrals.hpp" -#include -#include -#include -#include +#include "test_ao_integrals.hpp" -using namespace mokup; - -TEST_CASE("ERI2C") { - using op_type = simde::type::el_el_coulomb; - using integral_type = simde::AOTensorRepresentation<2, op_type>; +TEST_CASE("ERI2") { + using test_pt = simde::ERI2; pluginplay::ModuleManager mm; integrals::load_modules(mm); + REQUIRE(mm.count("ERI2")); + + // Get basis set + auto mol = test::water_molecule(); + auto aobs = test::water_sto3g_basis_set(); + + // Make AOS object + simde::type::aos aos(aobs); - const auto name = molecule::h2o; - const auto bs = basis_set::sto3g; - auto aos = get_bases(name, bs); - std::vector bases{bs, bs}; - auto corr = get_ao_data(name, bases, property::eris); + // Make Operator + simde::type::v_ee_type op{}; - op_type r12; + // Make BraKet Input + chemist::braket::BraKet braket(aos, op, aos); - SECTION("Explicit") { - auto X = mm.at("ERI2").run_as(aos, r12, aos); - REQUIRE(tensorwrapper::tensor::allclose(X, corr)); - } + // Call module + auto T = mm.at("ERI2").run_as(braket); - SECTION("Direct") { - auto X = mm.at("Direct ERI2").run_as(aos, r12, aos); - REQUIRE(direct_allclose(X, corr)); - } + // Check output + auto t = test::eigen_buffer<2>(T.buffer()); + REQUIRE(test::trace(t) == + Catch::Approx(124.7011973877891364).margin(1.0e-16)); + REQUIRE(test::norm(t) == + Catch::Approx(90.2562579028763707).margin(1.0e-16)); } diff --git a/tests/cxx/unit/integrals/ao_integrals/test_eri3.cpp b/tests/cxx/unit/integrals/ao_integrals/test_eri3.cpp index e31b234a..cc386cd2 100644 --- a/tests/cxx/unit/integrals/ao_integrals/test_eri3.cpp +++ b/tests/cxx/unit/integrals/ao_integrals/test_eri3.cpp @@ -14,37 +14,36 @@ * limitations under the License. */ -#include "direct_allclose.hpp" -#include "integrals/integrals.hpp" -#include -#include -#include -#include +#include "test_ao_integrals.hpp" -using namespace mokup; - -TEST_CASE("ERI3C") { - using op_type = simde::type::el_el_coulomb; - using integral_type = simde::AOTensorRepresentation<3, op_type>; +TEST_CASE("ERI3") { + using test_pt = simde::ERI3; pluginplay::ModuleManager mm; integrals::load_modules(mm); + REQUIRE(mm.count("ERI3")); + + // Get basis set + auto mol = test::water_molecule(); + auto aobs = test::water_sto3g_basis_set(); + + // Make AOS object + simde::type::aos aos(aobs); + simde::type::aos_squared aos_squared(aos, aos); - const auto name = molecule::h2o; - const auto bs = basis_set::sto3g; - auto aos = get_bases(name, bs); - std::vector bases{bs, bs, bs}; - auto corr = get_ao_data(name, bases, property::eris); + // Make Operator + simde::type::v_ee_type op{}; - op_type r12; + // Make BraKet Input + chemist::braket::BraKet braket(aos, op, aos_squared); - SECTION("Explicit") { - auto X = mm.at("ERI3").run_as(aos, r12, aos, aos); - REQUIRE(tensorwrapper::tensor::allclose(X, corr)); - } + // Call module + auto T = mm.at("ERI3").run_as(braket); - SECTION("Direct") { - auto X = mm.at("Direct ERI3").run_as(aos, r12, aos, aos); - REQUIRE(direct_allclose(X, corr)); - } + // Check output + auto t = test::eigen_buffer<3>(T.buffer()); + REQUIRE(test::trace(t) == + Catch::Approx(16.8245948391706577).margin(1.0e-16)); + REQUIRE(test::norm(t) == + Catch::Approx(20.6560572032543597).margin(1.0e-16)); } diff --git a/tests/cxx/unit/integrals/ao_integrals/test_eri4.cpp b/tests/cxx/unit/integrals/ao_integrals/test_eri4.cpp index 4f37d4a0..4fd4f436 100644 --- a/tests/cxx/unit/integrals/ao_integrals/test_eri4.cpp +++ b/tests/cxx/unit/integrals/ao_integrals/test_eri4.cpp @@ -14,38 +14,35 @@ * limitations under the License. */ -#include "direct_allclose.hpp" -#include "integrals/integrals.hpp" -#include -#include -#include -#include +#include "test_ao_integrals.hpp" -using namespace mokup; - -TEST_CASE("ERI4C") { - using op_type = simde::type::el_el_coulomb; - using integral_type = simde::AOTensorRepresentation<4, op_type>; +TEST_CASE("ERI4") { + using test_pt = simde::ERI4; pluginplay::ModuleManager mm; integrals::load_modules(mm); + REQUIRE(mm.count("ERI4")); + + // Get basis set + auto mol = test::water_molecule(); + auto aobs = test::water_sto3g_basis_set(); + + // Make AOS object + simde::type::aos aos(aobs); + simde::type::aos_squared aos_squared(aos, aos); - const auto name = molecule::h2o; - const auto bs = basis_set::sto3g; - auto aos = get_bases(name, bs); - std::vector bases{bs, bs, bs, bs}; - auto corr = get_ao_data(name, bases, property::eris); + // Make Operator + simde::type::v_ee_type op{}; - op_type r12; + // Make BraKet Input + chemist::braket::BraKet braket(aos_squared, op, aos_squared); - SECTION("Explicit") { - auto X = mm.at("ERI4").run_as(aos, aos, r12, aos, aos); - REQUIRE(tensorwrapper::tensor::allclose(X, corr)); - } + // Call module + auto T = mm.at("ERI4").run_as(braket); - SECTION("Direct") { - auto X = - mm.at("Direct ERI4").run_as(aos, aos, r12, aos, aos); - REQUIRE(direct_allclose(X, corr)); - } + // Check output + auto t = test::eigen_buffer<4>(T.buffer()); + REQUIRE(test::trace(t) == + Catch::Approx(9.7919608941952063).margin(1.0e-16)); + REQUIRE(test::norm(t) == Catch::Approx(7.7796143419802553).margin(1.0e-16)); } diff --git a/tests/cxx/unit/integrals/ao_integrals/test_kinetic.cpp b/tests/cxx/unit/integrals/ao_integrals/test_kinetic.cpp index 92e330a1..3bfba42b 100644 --- a/tests/cxx/unit/integrals/ao_integrals/test_kinetic.cpp +++ b/tests/cxx/unit/integrals/ao_integrals/test_kinetic.cpp @@ -14,37 +14,35 @@ * limitations under the License. */ -#include "direct_allclose.hpp" -#include "integrals/integrals.hpp" -#include -#include -#include -#include - -using namespace mokup; +#include "test_ao_integrals.hpp" TEST_CASE("Kinetic") { - using op_type = simde::type::el_kinetic; - using integral_type = simde::AOTensorRepresentation<2, op_type>; + using test_pt = simde::aos_t_e_aos; pluginplay::ModuleManager mm; integrals::load_modules(mm); + REQUIRE(mm.count("Kinetic")); + + // Get basis set + auto mol = test::water_molecule(); + auto aobs = test::water_sto3g_basis_set(); + + // Make AOS object + simde::type::aos aos(aobs); - const auto name = molecule::h2o; - const auto bs = basis_set::sto3g; - auto aos = get_bases(name, bs); - std::vector bases{bs, bs}; - auto corr = get_ao_data(name, bases, property::kinetic); + // Make Operator + simde::type::t_e_type op{}; - op_type t; + // Make BraKet Input + chemist::braket::BraKet braket(aos, op, aos); - SECTION("Explicit") { - auto T = mm.at("Kinetic").run_as(aos, t, aos); - REQUIRE(tensorwrapper::tensor::allclose(T, corr)); - } + // Call module + auto T = mm.at("Kinetic").run_as(braket); - SECTION("Direct") { - auto T = mm.at("Direct Kinetic").run_as(aos, t, aos); - REQUIRE(direct_allclose(T, corr)); - } + // Check output + auto t = test::eigen_buffer<2>(T.buffer()); + REQUIRE(test::trace(t) == + Catch::Approx(38.9175852621874441).margin(1.0e-16)); + REQUIRE(test::norm(t) == + Catch::Approx(29.3665362218072552).margin(1.0e-16)); } diff --git a/tests/cxx/unit/integrals/ao_integrals/test_nuclear.cpp b/tests/cxx/unit/integrals/ao_integrals/test_nuclear.cpp index d13b60d0..5abb3cca 100644 --- a/tests/cxx/unit/integrals/ao_integrals/test_nuclear.cpp +++ b/tests/cxx/unit/integrals/ao_integrals/test_nuclear.cpp @@ -14,38 +14,35 @@ * limitations under the License. */ -#include "direct_allclose.hpp" -#include "integrals/integrals.hpp" -#include -#include -#include -#include - -using namespace mokup; +#include "test_ao_integrals.hpp" TEST_CASE("Nuclear") { - using op_type = simde::type::el_nuc_coulomb; - using integral_type = simde::AOTensorRepresentation<2, op_type>; + using test_pt = simde::aos_v_en_aos; pluginplay::ModuleManager mm; integrals::load_modules(mm); + REQUIRE(mm.count("Nuclear")); + + // Get basis set + auto mol = test::water_molecule(); + auto aobs = test::water_sto3g_basis_set(); + + // Make AOS object + simde::type::aos aos(aobs); - const auto name = molecule::h2o; - const auto bs = basis_set::sto3g; - auto mol = get_molecule(name); - auto aos = get_bases(name, bs); - std::vector bases{bs, bs}; - auto corr = get_ao_data(name, bases, property::nuclear); + // Make Operator + simde::type::v_en_type op{chemist::Electron{}, mol.nuclei().as_nuclei()}; - op_type riA(chemist::Electron{}, mol.nuclei()); + // Make BraKet Input + chemist::braket::BraKet braket(aos, op, aos); - SECTION("Explicit") { - auto V = mm.at("Nuclear").run_as(aos, riA, aos); - REQUIRE(tensorwrapper::tensor::allclose(V, corr)); - } + // Call module + auto T = mm.at("Nuclear").run_as(braket); - SECTION("Direct") { - auto V = mm.at("Direct Nuclear").run_as(aos, riA, aos); - REQUIRE(direct_allclose(V, corr)); - } + // Check output + auto t = test::eigen_buffer<2>(T.buffer()); + REQUIRE(test::trace(t) == + Catch::Approx(-111.9975421879705664).margin(1.0e-16)); + REQUIRE(test::norm(t) == + Catch::Approx(66.4857539908047528).margin(1.0e-16)); } diff --git a/tests/cxx/unit/integrals/ao_integrals/test_overlap.cpp b/tests/cxx/unit/integrals/ao_integrals/test_overlap.cpp deleted file mode 100644 index ff1a99e4..00000000 --- a/tests/cxx/unit/integrals/ao_integrals/test_overlap.cpp +++ /dev/null @@ -1,69 +0,0 @@ -/* - * Copyright 2022 NWChemEx-Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "direct_allclose.hpp" -#include "integrals/integrals.hpp" -#include -#include -#include -#include - -using namespace mokup; - -TEST_CASE("Overlap") { - using op_type = simde::type::el_identity; - using integral_type = simde::AOTensorRepresentation<2, op_type>; - using shape_t = typename simde::type::tensor::shape_type; - using field_t = typename simde::type::tensor::field_type; - - // TODO: Better names which describe what's being tested - pluginplay::ModuleManager mm; - integrals::load_modules(mm); - - const auto name = molecule::h2o; - const auto bs = basis_set::sto3g; - auto aos = get_bases(name, bs); - std::vector bases{bs, bs}; - auto corr_S = get_ao_data(name, bases, property::overlap); - - op_type I; - - SECTION("Explicit") { - auto S = mm.at("Overlap").run_as(aos, I, aos); - REQUIRE(tensorwrapper::tensor::allclose(S, corr_S)); - } - - SECTION("Direct") { - auto S = mm.at("Direct Overlap").run_as(aos, I, aos); - REQUIRE(direct_allclose(S, corr_S)); - } - - SECTION("Center-based Tiling") { - /// TODO: Different tiling needs to be simpler to accomplish - auto S_vector = tensorwrapper::tensor::to_vector(corr_S); - auto shape = shape_t({{0, 5, 6, 7}, {0, 5, 6, 7}}); - auto l = [S_vector](const auto& idx) { - auto ord = idx[0] * 7 + idx[1]; - return S_vector[ord]; - }; - tensor_t corr(l, std::make_unique(shape), - tensorwrapper::tensor::default_allocator()); - - mm.change_submod("Overlap", "Tensor Shape", "CenterTiledShape"); - auto S = mm.at("Overlap").run_as(aos, I, aos); - REQUIRE(tensorwrapper::tensor::allclose(S, corr)); - } -} diff --git a/tests/cxx/unit/integrals/ao_integrals/test_screened.cpp b/tests/cxx/unit/integrals/ao_integrals/test_screened.cpp deleted file mode 100644 index 9e7bc0d9..00000000 --- a/tests/cxx/unit/integrals/ao_integrals/test_screened.cpp +++ /dev/null @@ -1,98 +0,0 @@ -/* - * Copyright 2022 NWChemEx-Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "direct_allclose.hpp" -#include "integrals/integrals.hpp" -#include -#include -#include -#include - -using namespace mokup; - -TEST_CASE("Overlap CS") { - using integral_type = simde::EOverlap; - using shape_t = typename simde::type::tensor::shape_type; - using field_t = typename simde::type::tensor::field_type; - - pluginplay::ModuleManager mm; - integrals::load_modules(mm); - mm.change_input("Overlap CS", "Screening Threshold", 0.5); - mm.change_input("Direct Overlap CS", "Screening Threshold", 0.5); - - const auto name = molecule::h2o; - const auto bs = basis_set::sto3g; - auto aos = get_bases(name, bs); - std::vector bases{bs, bs}; - auto corr_S = get_ao_data(name, bases, property::screened_overlap); - - simde::type::el_identity I; - - SECTION("Explicit") { - auto S = mm.at("Overlap CS").run_as(aos, I, aos); - REQUIRE(tensorwrapper::tensor::allclose(S, corr_S)); - } - - SECTION("Direct") { - auto S = mm.at("Direct Overlap CS").run_as(aos, I, aos); - REQUIRE(direct_allclose(S, corr_S)); - } - - SECTION("Center-based Tiling") { - /// TODO: Different tiling needs to be simpler to accomplish - auto S_vector = tensorwrapper::tensor::to_vector(corr_S); - auto shape = shape_t({{0, 5, 6, 7}, {0, 5, 6, 7}}); - auto l = [S_vector](const auto& idx) { - auto ord = idx[0] * 7 + idx[1]; - return S_vector[ord]; - }; - tensor_t corr(l, std::make_unique(shape), - tensorwrapper::tensor::default_allocator()); - - mm.change_submod("Overlap CS", "Tensor Shape", "CenterTiledShape"); - auto S = mm.at("Overlap CS").run_as(aos, I, aos); - REQUIRE(tensorwrapper::tensor::allclose(S, corr)); - } -} - -TEST_CASE("ERI4C CS") { - using integral_type = simde::ERI4; - - pluginplay::ModuleManager mm; - integrals::load_modules(mm); - mm.change_input("ERI4 CS", "Screening Threshold", 0.005); - mm.change_input("Direct ERI4 CS", "Screening Threshold", 0.005); - - const auto name = molecule::h2o; - const auto bs = basis_set::sto3g; - auto aos = get_bases(name, bs); - std::vector bases{bs, bs, bs, bs}; - auto corr_X = get_ao_data(name, bases, property::screened_eris); - - simde::type::el_el_coulomb r12; - - SECTION("Explicit") { - auto X = - mm.at("ERI4 CS").run_as(aos, aos, r12, aos, aos); - REQUIRE(tensorwrapper::tensor::allclose(X, corr_X)); - } - - SECTION("Direct") { - auto X = mm.at("Direct ERI4 CS") - .run_as(aos, aos, r12, aos, aos); - REQUIRE(direct_allclose(X, corr_X)); - } -} diff --git a/tests/cxx/unit/integrals/ao_integrals/test_shellnorms.cpp b/tests/cxx/unit/integrals/ao_integrals/test_shellnorms.cpp deleted file mode 100644 index 9b63e832..00000000 --- a/tests/cxx/unit/integrals/ao_integrals/test_shellnorms.cpp +++ /dev/null @@ -1,140 +0,0 @@ -/* - * Copyright 2022 NWChemEx-Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "integrals/integrals.hpp" -#include -#include -#include - -using namespace mokup; - -std::vector> ovlp_check{ - {1.0000000000000004, 0.2367039365108476, 0.0000000000000000, - 0.0384055905375414, 0.0384055905375414}, - {0.2367039365108476, 1.0000000000000002, 0.0000000000000000, - 0.3861387808638141, 0.3861387808638141}, - {0.0000000000000000, 0.0000000000000000, 1.7320508075688781, - 0.3406529836379423, 0.3406529836379423}, - {0.0384055905375414, 0.3861387808638141, 0.3406529836379423, - 1.0000000000000000, 0.1817608634919521}, - {0.0384055905375414, 0.3861387808638141, 0.3406529836379423, - 0.1817608634919521, 1.0000000000000000}, -}; - -std::vector> eri_check{ - {2.1874792352627042, 0.3699640325144978, 0.1564525878919850, - 0.0606886000006391, 0.0606886000006391}, - {0.3699640325144978, 0.9039946468459082, 0.4248745604347619, - 0.3222057218175323, 0.3222057218175323}, - {0.1564525878919850, 0.4248745604347619, 0.9381679451862797, - 0.2740491521872362, 0.2740491521872362}, - {0.0606886000006391, 0.3222057218175323, 0.2740491521872362, - 0.8801170058122373, 0.1336470421634229}, - {0.0606886000006391, 0.3222057218175323, 0.2740491521872362, - 0.1336470421634229, 0.8801170058122373}, -}; - -std::vector> stg_check{ - {0.8712382481019230, 0.1833574527284384, 0.0499799084050583, - 0.0298548303674855, 0.0298548303674855}, - {0.1833574527284384, 0.5049372580585069, 0.2429078076543889, - 0.1760787877695699, 0.1760787877695699}, - {0.0499799084050583, 0.2429078076543889, 0.5178471413265817, - 0.1563617001398491, 0.1563617001398491}, - {0.0298548303674855, 0.1760787877695699, 0.1563617001398491, - 0.4834953496227799, 0.0689823476694450}, - {0.0298548303674855, 0.1760787877695699, 0.1563617001398491, - 0.0689823476694450, 0.4834953496227799}, -}; - -std::vector> yuk_check{ - {1.9779965679341631, 0.3052904918032274, 0.1515386376453260, - 0.0502970255598737, 0.0502970255598737}, - {0.3052904918032274, 0.5375014882330088, 0.3623472474047580, - 0.1781992287690466, 0.1781992287690466}, - {0.1515386376453260, 0.3623472474047580, 0.5862346971968084, - 0.1769470889613180, 0.1769470889613180}, - {0.0502970255598737, 0.1781992287690466, 0.1769470889613180, - 0.5201331598096510, 0.0647323127080033}, - {0.0502970255598737, 0.1781992287690466, 0.1769470889613180, - 0.0647323127080033, 0.5201331598096510}, -}; - -const double eps = 100000000 * std::numeric_limits::epsilon(); -const double marg = 1000000 * std::numeric_limits::epsilon(); - -TEST_CASE("Cauchy-Schwarz") { - pluginplay::ModuleManager mm; - integrals::load_modules(mm); - - auto name = molecule::h2o; - auto bs = basis_set::sto3g; - auto mol = get_molecule(name); - auto aos = get_bases(name, bs); - - SECTION("Overlap") { - using op_t = simde::type::el_identity; - using cs_pt = simde::ShellNorms; - op_t op; - auto rv = mm.at("Shell Norms Overlap").run_as(aos, op, aos); - for(int i = 0; i < 5; ++i) { - for(int j = 0; j < 5; ++j) { - REQUIRE(rv[i][j] == - Approx(ovlp_check[i][j]).epsilon(eps).margin(marg)); - } - } - } - - SECTION("Coulomb") { - using op_t = simde::type::el_el_coulomb; - using cs_pt = simde::ShellNorms; - op_t op; - auto rv = mm.at("Shell Norms Coulomb").run_as(aos, op, aos); - for(int i = 0; i < 5; ++i) { - for(int j = 0; j < 5; ++j) { - REQUIRE(rv[i][j] == - Approx(eri_check[i][j]).epsilon(eps).margin(marg)); - } - } - } - - SECTION("STG") { - using op_t = simde::type::el_el_stg; - using cs_pt = simde::ShellNorms; - op_t op(chemist::operators::STG(1.0, 1.0)); - auto rv = mm.at("Shell Norms STG").run_as(aos, op, aos); - for(int i = 0; i < 5; ++i) { - for(int j = 0; j < 5; ++j) { - REQUIRE(rv[i][j] == - Approx(stg_check[i][j]).epsilon(eps).margin(marg)); - } - } - } - - SECTION("Yukawa") { - using op_t = simde::type::el_el_yukawa; - using cs_pt = simde::ShellNorms; - chemist::Electron e; - op_t op(chemist::operators::STG(1.0, 1.0), e, e); - auto rv = mm.at("Shell Norms Yukawa").run_as(aos, op, aos); - for(int i = 0; i < 5; ++i) { - for(int j = 0; j < 5; ++j) { - REQUIRE(rv[i][j] == - Approx(yuk_check[i][j]).epsilon(eps).margin(marg)); - } - } - } -} diff --git a/tests/cxx/unit/integrals/ao_integrals/test_stg2.cpp b/tests/cxx/unit/integrals/ao_integrals/test_stg2.cpp deleted file mode 100644 index bb24dffa..00000000 --- a/tests/cxx/unit/integrals/ao_integrals/test_stg2.cpp +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright 2022 NWChemEx-Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "direct_allclose.hpp" -#include "integrals/integrals.hpp" -#include -#include -#include -#include - -using namespace mokup; - -TEST_CASE("STG2C") { - using op_type = simde::type::el_el_stg; - using integral_type = simde::AOTensorRepresentation<2, op_type>; - - pluginplay::ModuleManager mm; - integrals::load_modules(mm); - - auto name = molecule::h2o; - auto bs = basis_set::sto3g; - auto aos = get_bases(name, bs); - std::vector bases{bs, bs}; - auto corr = get_ao_data(name, bases, property::stg); - - chemist::Electron e; - op_type stg(chemist::operators::STG(1.0, 1.0)); - - SECTION("Explicit") { - auto X = mm.at("STG2").run_as(aos, stg, aos); - REQUIRE(tensorwrapper::tensor::allclose(X, corr)); - } - - SECTION("Direct") { - auto X = mm.at("Direct STG2").run_as(aos, stg, aos); - REQUIRE(direct_allclose(X, corr)); - } -} diff --git a/tests/cxx/unit/integrals/ao_integrals/test_stg3.cpp b/tests/cxx/unit/integrals/ao_integrals/test_stg3.cpp deleted file mode 100644 index 74c685da..00000000 --- a/tests/cxx/unit/integrals/ao_integrals/test_stg3.cpp +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright 2022 NWChemEx-Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "direct_allclose.hpp" -#include "integrals/integrals.hpp" -#include -#include -#include -#include - -using namespace mokup; - -TEST_CASE("STG3C") { - using op_type = simde::type::el_el_stg; - using integral_type = simde::AOTensorRepresentation<3, op_type>; - - pluginplay::ModuleManager mm; - integrals::load_modules(mm); - - auto name = molecule::h2o; - auto bs = basis_set::sto3g; - auto aos = get_bases(name, bs); - std::vector bases{bs, bs, bs}; - auto corr = get_ao_data(name, bases, property::stg); - - chemist::Electron e; - op_type stg(chemist::operators::STG(1.0, 1.0)); - - SECTION("Explicit") { - auto X = mm.at("STG3").run_as(aos, stg, aos, aos); - REQUIRE(tensorwrapper::tensor::allclose(X, corr)); - } - - SECTION("Direct") { - auto X = mm.at("Direct STG3").run_as(aos, stg, aos, aos); - REQUIRE(direct_allclose(X, corr)); - } -} diff --git a/tests/cxx/unit/integrals/ao_integrals/test_stg4.cpp b/tests/cxx/unit/integrals/ao_integrals/test_stg4.cpp deleted file mode 100644 index e387ffa0..00000000 --- a/tests/cxx/unit/integrals/ao_integrals/test_stg4.cpp +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright 2022 NWChemEx-Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "direct_allclose.hpp" -#include "integrals/integrals.hpp" -#include -#include -#include -#include - -using namespace mokup; - -TEST_CASE("STG4C") { - using op_type = simde::type::el_el_stg; - using integral_type = simde::AOTensorRepresentation<4, op_type>; - - pluginplay::ModuleManager mm; - integrals::load_modules(mm); - - auto name = molecule::h2o; - auto bs = basis_set::sto3g; - auto aos = get_bases(name, bs); - std::vector bases{bs, bs, bs, bs}; - auto corr = get_ao_data(name, bases, property::stg); - - chemist::Electron e; - op_type stg(chemist::operators::STG(1.0, 1.0)); - - SECTION("Explicit") { - auto X = mm.at("STG4").run_as(aos, aos, stg, aos, aos); - REQUIRE(tensorwrapper::tensor::allclose(X, corr)); - } - - SECTION("Direct") { - auto X = - mm.at("Direct STG4").run_as(aos, aos, stg, aos, aos); - REQUIRE(direct_allclose(X, corr)); - } -} diff --git a/tests/cxx/unit/integrals/ao_integrals/test_yukawa2.cpp b/tests/cxx/unit/integrals/ao_integrals/test_yukawa2.cpp deleted file mode 100644 index 8e4ca9f1..00000000 --- a/tests/cxx/unit/integrals/ao_integrals/test_yukawa2.cpp +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright 2022 NWChemEx-Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "direct_allclose.hpp" -#include "integrals/integrals.hpp" -#include -#include -#include -#include - -using namespace mokup; - -TEST_CASE("Yukawa2C") { - using op_type = simde::type::el_el_yukawa; - using integral_type = simde::AOTensorRepresentation<2, op_type>; - - pluginplay::ModuleManager mm; - integrals::load_modules(mm); - - auto name = molecule::h2o; - auto bs = basis_set::sto3g; - auto aos = get_bases(name, bs); - std::vector bases{bs, bs}; - auto corr = get_ao_data(name, bases, property::yukawa); - - chemist::Electron e; - op_type gr(chemist::operators::STG(1.0, 1.0), e, e); - - SECTION("Explicit") { - auto X = mm.at("Yukawa2").run_as(aos, gr, aos); - REQUIRE(tensorwrapper::tensor::allclose(X, corr)); - } - - SECTION("Direct") { - auto X = mm.at("Direct Yukawa2").run_as(aos, gr, aos); - REQUIRE(direct_allclose(X, corr)); - } -} diff --git a/tests/cxx/unit/integrals/ao_integrals/test_yukawa3.cpp b/tests/cxx/unit/integrals/ao_integrals/test_yukawa3.cpp deleted file mode 100644 index 45fe99d3..00000000 --- a/tests/cxx/unit/integrals/ao_integrals/test_yukawa3.cpp +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright 2022 NWChemEx-Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "direct_allclose.hpp" -#include "integrals/integrals.hpp" -#include -#include -#include -#include - -using namespace mokup; - -TEST_CASE("Yukawa3C") { - using op_type = simde::type::el_el_yukawa; - using integral_type = simde::AOTensorRepresentation<3, op_type>; - - pluginplay::ModuleManager mm; - integrals::load_modules(mm); - - auto name = molecule::h2o; - auto bs = basis_set::sto3g; - auto aos = get_bases(name, bs); - std::vector bases{bs, bs, bs}; - auto corr = get_ao_data(name, bases, property::yukawa); - - chemist::Electron e; - op_type gr(chemist::operators::STG(1.0, 1.0), e, e); - - SECTION("Explicit") { - auto X = mm.at("Yukawa3").run_as(aos, gr, aos, aos); - REQUIRE(tensorwrapper::tensor::allclose(X, corr)); - } - - SECTION("Direct") { - auto X = - mm.at("Direct Yukawa3").run_as(aos, gr, aos, aos); - REQUIRE(direct_allclose(X, corr)); - } -} diff --git a/tests/cxx/unit/integrals/ao_integrals/test_yukawa4.cpp b/tests/cxx/unit/integrals/ao_integrals/test_yukawa4.cpp deleted file mode 100644 index b94c1253..00000000 --- a/tests/cxx/unit/integrals/ao_integrals/test_yukawa4.cpp +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright 2022 NWChemEx-Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "direct_allclose.hpp" -#include "integrals/integrals.hpp" -#include -#include -#include -#include - -using namespace mokup; - -TEST_CASE("Yukawa4C") { - using op_type = simde::type::el_el_yukawa; - using integral_type = simde::AOTensorRepresentation<4, op_type>; - - pluginplay::ModuleManager mm; - integrals::load_modules(mm); - - auto name = molecule::h2o; - auto bs = basis_set::sto3g; - auto aos = get_bases(name, bs); - std::vector bases{bs, bs, bs, bs}; - auto corr = get_ao_data(name, bases, property::yukawa); - - chemist::Electron e; - op_type gr(chemist::operators::STG(1.0, 1.0), e, e); - - SECTION("Explicit") { - auto X = mm.at("Yukawa4").run_as(aos, aos, gr, aos, aos); - REQUIRE(tensorwrapper::tensor::allclose(X, corr)); - } - - SECTION("Direct") { - auto X = - mm.at("Direct Yukawa4").run_as(aos, aos, gr, aos, aos); - REQUIRE(direct_allclose(X, corr)); - } -} diff --git a/tests/cxx/unit/integrals/libint/detail_/make_engine.cpp b/tests/cxx/unit/integrals/libint/detail_/make_engine.cpp deleted file mode 100644 index ea228d0a..00000000 --- a/tests/cxx/unit/integrals/libint/detail_/make_engine.cpp +++ /dev/null @@ -1,154 +0,0 @@ -/* - * Copyright 2022 NWChemEx-Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "libint_basis_set_water.hpp" -#include "make_engine.hpp" - -const double eps = 100000000 * std::numeric_limits::epsilon(); -const double marg = 1000000 * std::numeric_limits::epsilon(); - -using integrals::libint::detail_::make_engine; - -TEST_CASE("make_engine") { - /// Libint Basis Set - auto bset = testing::water_basis_set(); - - /// Basis set inputs - std::vector two_sets{bset, bset}; - std::vector three_sets{bset, bset, bset}; - std::vector four_sets{bset, bset, bset, bset}; - - /// Threshold input - double t = 1.0E-16; - - /// Components for operators - chemist::Electron e{}; - chemist::operators::STG stg{1.0, 1.0}; - chemist::Atom o1{"O", 8ul, 0.0, 0.0, -0.143222342980786, 0.0}; - chemist::Atom h1{"H", 1ul, 0.0, 1.638033502034240, 1.136556880358410, 0.0}; - chemist::Atom h2{"H", 1ul, 0.0, -1.638033502034240, 1.136556880358410, 0.0}; - chemist::Nuclei water{o1.nucleus(), h1.nucleus(), h2.nucleus()}; - - SECTION("el_el_coulomb") { - using op_t = simde::type::el_el_coulomb; - op_t op; - - SECTION("Two basis sets") { - auto engine = make_engine(two_sets, op, t); - testing::test_engine_standard(engine); - REQUIRE(engine.braket() == libint2::BraKet::xs_xs); - } - - SECTION("Three basis sets") { - auto engine = make_engine(three_sets, op, t); - testing::test_engine_standard(engine); - REQUIRE(engine.braket() == libint2::BraKet::xs_xx); - } - - SECTION("Four basis sets") { - auto engine = make_engine(four_sets, op, t); - testing::test_engine_standard(engine); - REQUIRE(engine.braket() == libint2::BraKet::xx_xx); - } - } - - /// For the rest of these, the correctness of the parameter setting - /// is tested indirectly by checking some computed values from the - /// engine against the expected result. - SECTION("el_nuc_coulomb") { - using op_t = simde::type::el_nuc_coulomb; - op_t op(e, water); - auto engine = make_engine(two_sets, op, t); - testing::test_engine_standard(engine); - const auto& buf = engine.compute(two_sets[0][0], two_sets[1][0]); - REQUIRE(buf[0][0] == - Approx(-61.5805952694322).epsilon(eps).margin(marg)); - } - - SECTION("el_el_stg") { - using op_t = simde::type::el_el_stg; - op_t op(stg); - auto engine = make_engine(two_sets, op, t); - testing::test_engine_standard(engine); - const auto& buf = engine.compute(two_sets[0][0], two_sets[1][0]); - REQUIRE(buf[0][0] == - Approx(0.2537942162587338).epsilon(eps).margin(marg)); - } - - SECTION("el_el_yukawa") { - using op_t = simde::type::el_el_yukawa; - op_t op(stg, e, e); - auto engine = make_engine(two_sets, op, t); - testing::test_engine_standard(engine); - const auto& buf = engine.compute(two_sets[0][0], two_sets[1][0]); - REQUIRE(buf[0][0] == - Approx(0.7174258302062281).epsilon(eps).margin(marg)); - } - - SECTION("el_el_f12_commutator") { - using op_t = simde::type::el_el_f12_commutator; - op_t op(stg, e, e); - auto engine = make_engine(two_sets, op, t); - testing::test_engine_standard(engine); - const auto& buf = engine.compute(two_sets[0][0], two_sets[1][0]); - REQUIRE(buf[0][0] == Approx(0.1612010046).epsilon(eps).margin(marg)); - } - - SECTION("el_dipole") { - using op_t = simde::type::el_dipole; - op_t op; - auto engine = make_engine(two_sets, op, t); - testing::test_engine_standard(engine); - const auto& buf = engine.results(); - engine.compute(two_sets[0][0], two_sets[1][0]); - REQUIRE(buf[0][0] == - Approx(1.0000000000000004).epsilon(eps).margin(marg)); - REQUIRE(buf[2][0] == - Approx(-0.1432223429807861).epsilon(eps).margin(marg)); - } - - SECTION("el_quadrupole") { - using op_t = simde::type::el_quadrupole; - op_t op; - auto engine = make_engine(two_sets, op, t); - testing::test_engine_standard(engine); - const auto& buf = engine.results(); - engine.compute(two_sets[0][0], two_sets[1][0]); - REQUIRE(buf[0][0] == - Approx(1.0000000000000004).epsilon(eps).margin(marg)); - REQUIRE(buf[2][0] == - Approx(-0.1432223429807861).epsilon(eps).margin(marg)); - REQUIRE(buf[4][0] == - Approx(0.0170208494985677).epsilon(eps).margin(marg)); - } - - SECTION("el_octupole") { - using op_t = simde::type::el_octupole; - op_t op; - auto engine = make_engine(two_sets, op, t); - testing::test_engine_standard(engine); - const auto& buf = engine.results(); - engine.compute(two_sets[0][0], two_sets[1][0]); - REQUIRE(buf[0][0] == - Approx(1.0000000000000004).epsilon(eps).margin(marg)); - REQUIRE(buf[2][0] == - Approx(-0.1432223429807861).epsilon(eps).margin(marg)); - REQUIRE(buf[4][0] == - Approx(0.0170208494985677).epsilon(eps).margin(marg)); - REQUIRE(buf[11][0] == - Approx(-0.0024377659447082).epsilon(eps).margin(marg)); - } -} diff --git a/tests/cxx/unit/integrals/libint/detail_/make_engine.hpp b/tests/cxx/unit/integrals/libint/detail_/make_engine.hpp deleted file mode 100644 index 3a9b63d9..00000000 --- a/tests/cxx/unit/integrals/libint/detail_/make_engine.hpp +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Copyright 2022 NWChemEx-Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#pragma once -#include "integrals/libint/detail_/make_engine.hpp" -#include -#include - -namespace testing { - -/// Checks the common parts of the test engines -template -void test_engine_standard(libint2::Engine& engine) { - REQUIRE(engine.oper() == integrals::libint::op_v); - REQUIRE(engine.max_nprim() == 3); - REQUIRE(engine.max_l() == 1); - REQUIRE(engine.precision() == 1.0E-16); -} - -} // namespace testing \ No newline at end of file diff --git a/tests/cxx/unit/integrals/libint/libint_factory.cpp b/tests/cxx/unit/integrals/libint/libint_factory.cpp deleted file mode 100644 index 5df74fce..00000000 --- a/tests/cxx/unit/integrals/libint/libint_factory.cpp +++ /dev/null @@ -1,86 +0,0 @@ -/* - * Copyright 2022 NWChemEx-Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "detail_/libint_basis_set_water.hpp" -#include "integrals/libint/libint_factory.hpp" -#include -#include -#include - -using namespace mokup; - -const double eps = 100000000 * std::numeric_limits::epsilon(); -const double marg = 1000000 * std::numeric_limits::epsilon(); - -using op1_type = simde::type::el_identity; -using op2_type = simde::type::el_el_stg; -using test1_t = integrals::libint::LibintFactory<2, op1_type>; -using test2_t = integrals::libint::LibintFactory<2, op2_type>; - -TEST_CASE("LibintFactory") { - auto basis = testing::water_basis_set(); - - /// Inputs - std::vector sets1{basis, basis}; - std::vector sets2{basis, basis, basis}; - op1_type I; - op2_type stg1(chemist::operators::STG(1.0, 1.0)); - op2_type stg2(chemist::operators::STG(2.0, 2.0)); - double thresh = 1.0E-16; - int deriv = 0; - - /// Construct - test1_t fac1(sets1, I, thresh, deriv); - test2_t fac2(sets1, stg1, thresh, deriv); - test2_t fac3(sets1, stg2, thresh, deriv); - - SECTION("compute") { - const auto& results = fac1.compute({2, 2}); - for(auto i = 0; i < 3; ++i) { - for(auto j = 0; j < 3; ++j) { - auto val = results[0][i * 3 + j]; - if(i == j) { - REQUIRE(val == Approx(1.0).epsilon(eps).margin(marg)); - } else { - REQUIRE(val == Approx(0.0).epsilon(eps).margin(marg)); - } - } - } - } - - SECTION("clone") { - auto clone = fac1.clone(); - REQUIRE(clone->are_equal(fac1)); - } - - SECTION("are_equal") { - SECTION("Same") { - REQUIRE(fac1.are_equal(test1_t(sets1, I, thresh, deriv))); - } - SECTION("Different OpType") { REQUIRE_FALSE(fac1.are_equal(fac2)); } - SECTION("Differnt Basis sets") { - REQUIRE_FALSE(fac1.are_equal(test1_t(sets2, I, thresh, deriv))); - } - SECTION("Differnt Operator") { REQUIRE_FALSE(fac2.are_equal(fac3)); } - SECTION("Differnt Threshold") { - REQUIRE_FALSE(fac1.are_equal(test1_t(sets1, I, 1.0E-12, deriv))); - } - /// Libint installation doesn't have derivatives, so this segfaults ATM. - // SECTION("Differnt Derivatives") { - // REQUIRE_FALSE(fac1.are_equal(test1_t(sets1, I, thresh, 1))); - // } - } -} \ No newline at end of file diff --git a/tests/cxx/unit/integrals/libint/make_libint_factory.cpp b/tests/cxx/unit/integrals/libint/make_libint_factory.cpp deleted file mode 100644 index 042ba52b..00000000 --- a/tests/cxx/unit/integrals/libint/make_libint_factory.cpp +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Copyright 2022 NWChemEx-Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "detail_/libint_basis_set_water.hpp" -#include "integrals/integrals.hpp" -#include "integrals/libint/libint_factory.hpp" -#include -#include -#include -#include - -using namespace mokup; - -TEST_CASE("Make Overlap LibintFactory") { - using op_t = simde::type::el_identity; - using factory_t = simde::type::integral_factory; - using libint_fac_t = integrals::libint::LibintFactory<2, op_t>; - using test_pt = simde::IntegralFactory; - - /// Load up modules - pluginplay::ModuleManager mm; - integrals::load_modules(mm); - - /// Inputs - const auto name = molecule::h2o; - const auto bs = basis_set::sto3g; - auto aos = get_bases(name, bs); - auto basis = aos.basis_set(); - std::vector sets{basis, basis}; - op_t op; - - /// Correct result - auto libint_basis = testing::water_basis_set(); - std::vector libint_sets{libint_basis, libint_basis}; - auto p = - std::make_unique(std::move(libint_sets), op, 1.0E-16, 0); - factory_t corr(std::move(p)); - - /// Check module output - auto fac = mm.at("Overlap Factory").run_as(sets, op, 0ul); - REQUIRE(fac == corr); -} diff --git a/tests/cxx/unit/integrals/shapes/center_tiled_shape.cpp b/tests/cxx/unit/integrals/shapes/center_tiled_shape.cpp deleted file mode 100644 index a3f12245..00000000 --- a/tests/cxx/unit/integrals/shapes/center_tiled_shape.cpp +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright 2022 NWChemEx-Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "integrals/integrals.hpp" -#include -#include -#include - -using pt = simde::IntegralShape; -using shape_t = typename simde::type::tensor::shape_type; -using input_t = std::vector; - -using namespace mokup; - -TEST_CASE("CenterTiledShape") { - pluginplay::ModuleManager mm; - integrals::load_modules(mm); - - auto name = molecule::h2o; - auto sto3g_space = get_bases(name, basis_set::sto3g); - auto ccpvdz_space = get_bases(name, basis_set::ccpvdz); - - input_t inputs(2); - inputs[0] = sto3g_space.basis_set(); - inputs[1] = ccpvdz_space.basis_set(); - - auto shape = mm.at("CenterTiledShape").run_as(inputs); - shape_t corr{{{0, 5, 6, 7}, {0, 14, 19, 24}}}; - REQUIRE(shape == corr); -} diff --git a/tests/cxx/unit/integrals/shapes/one_tile_shape.cpp b/tests/cxx/unit/integrals/shapes/one_tile_shape.cpp deleted file mode 100644 index 4b321a8d..00000000 --- a/tests/cxx/unit/integrals/shapes/one_tile_shape.cpp +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright 2022 NWChemEx-Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "integrals/integrals.hpp" -#include -#include -#include - -using pt = simde::IntegralShape; -using shape_t = typename simde::type::tensor::shape_type; -using input_t = std::vector; - -using namespace mokup; - -TEST_CASE("OneTileShape") { - pluginplay::ModuleManager mm; - integrals::load_modules(mm); - - auto name = molecule::h2o; - auto sto3g_space = get_bases(name, basis_set::sto3g); - auto ccpvdz_space = get_bases(name, basis_set::ccpvdz); - - input_t inputs(2); - inputs[0] = sto3g_space.basis_set(); - inputs[1] = ccpvdz_space.basis_set(); - - auto shape = mm.at("OneTileShape").run_as(inputs); - shape_t corr{{7, 24}}; - REQUIRE(shape == corr); -} diff --git a/tests/cxx/unit/integrals/test_main.cpp b/tests/cxx/unit/integrals/test_main.cpp index 97660692..d35a4c37 100644 --- a/tests/cxx/unit/integrals/test_main.cpp +++ b/tests/cxx/unit/integrals/test_main.cpp @@ -15,18 +15,11 @@ */ #define CATCH_CONFIG_RUNNER -#include -#include +#include +#include int main(int argc, char* argv[]) { - // Initialize Everything and set world pointer - auto& world = TA::initialize(argc, argv); - - // Run tests + auto rt = parallelzone::runtime::RuntimeView(argc, argv); int res = Catch::Session().run(argc, argv); - - // Finalize Everything - TA::finalize(); - return res; } diff --git a/tests/cxx/unit/integrals/transforms/run_fundamental.cpp b/tests/cxx/unit/integrals/transforms/run_fundamental.cpp deleted file mode 100644 index e12fc006..00000000 --- a/tests/cxx/unit/integrals/transforms/run_fundamental.cpp +++ /dev/null @@ -1,84 +0,0 @@ -/* - * Copyright 2022 NWChemEx-Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "integrals/transforms/detail_/run_fundamental.hpp" -#include -#include - -using namespace integrals::detail_; - -using map_type = simde::space_map_t; - -TEST_CASE("run_fundamental") { - simde::type::el_el_coulomb r12; - simde::type::ao_space aos; - - map_type mode2ao; - mode2ao.emplace(0, aos); - mode2ao.emplace(1, aos); - - simde::type::tensor t; - - auto mod2 = - pluginplay::make_lambda([&](auto&& b, auto&& op, auto&& k) { - REQUIRE(b == aos); - REQUIRE(op == r12); - REQUIRE(k == aos); - return t; - }); - - SECTION("Two bases") { - auto rv = run_fundamental<2>(mod2, mode2ao, r12); - REQUIRE(t == rv); - } - - SECTION("Three bases") { - auto mod3 = pluginplay::make_lambda( - [&](auto&& b, auto&& op, auto&& k0, auto&& k1) { - REQUIRE(b == aos); - REQUIRE(op == r12); - REQUIRE(k0 == aos); - REQUIRE(k1 == aos); - return t; - }); - mode2ao.emplace(2, aos); - auto rv = run_fundamental<3>(mod3, mode2ao, r12); - } - - SECTION("Four bases") { - auto mod4 = pluginplay::make_lambda( - [&](auto&& b0, auto&& b1, auto&& op, auto&& k0, auto&& k1) { - REQUIRE(b0 == aos); - REQUIRE(b1 == aos); - REQUIRE(op == r12); - REQUIRE(k0 == aos); - REQUIRE(k1 == aos); - return t; - }); - mode2ao.emplace(2, aos); - mode2ao.emplace(3, aos); - auto rv = run_fundamental<4>(mod4, mode2ao, r12); - } - - SECTION("Raises an error if N != mode2ao.size()") { - REQUIRE_THROWS_AS(run_fundamental<3>(mod2, mode2ao, r12), - std::runtime_error); - } - - // These shouldn't compile (uncomment to check) - // run_fundamental<1>(mod2, mode2ao, r12); - // run_fundamental<5>(mod2, mode2ao, r12); -} diff --git a/tests/cxx/unit/integrals/transforms/standard.cpp b/tests/cxx/unit/integrals/transforms/standard.cpp deleted file mode 100644 index e6a2381a..00000000 --- a/tests/cxx/unit/integrals/transforms/standard.cpp +++ /dev/null @@ -1,269 +0,0 @@ -/* - * Copyright 2022 NWChemEx-Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "integrals/integrals.hpp" -#include -#include -#include -#include - -using namespace mokup; - -TEST_CASE("Transformed") { - using op_type = simde::type::el_el_coulomb; - using submod_t = simde::AOTensorRepresentation<4, op_type>; - using pt = simde::TransformedTensorRepresentation<4, op_type>; - - using ao_map = simde::space_map_t; - using mo_map = simde::space_map_t; - - pluginplay::ModuleManager mm; - integrals::load_modules(mm); - - auto name = molecule::h2; - auto bs = basis_set::sto3g; - auto aos = get_bases(name, bs); - auto mos = get_space(property::occupied, name, bs); - std::vector bases{bs, bs, bs, bs}; - auto G = get_ao_data(name, bases, property::eris); - - auto& mod = mm.at("Transformed ERI4"); - const auto& C = mos.C(); - op_type r12; - - auto submod = pluginplay::make_lambda( - [&](auto&& b1, auto&& b2, auto&& op, auto&& k1, auto&& k2) { - REQUIRE(b1 == aos); - REQUIRE(b2 == aos); - REQUIRE(op == r12); - REQUIRE(k1 == aos); - REQUIRE(k2 == aos); - return G; - }); - mod.change_submod("Integral Kernel", submod); - - SECTION("Transform mode 0") { - ao_map ao_spaces; - mo_map mo_spaces; - mo_spaces.emplace(0, mos); - ao_spaces.emplace(1, aos); - ao_spaces.emplace(2, aos); - ao_spaces.emplace(3, aos); - auto rv = mod.run_as(ao_spaces, mo_spaces, r12); - simde::type::tensor corr; - corr("i,b,c,d") = C("a,i") * G("a,b,c,d"); - REQUIRE(tensorwrapper::tensor::allclose(rv, corr)); - } - - SECTION("Transform mode 1") { - ao_map ao_spaces; - mo_map mo_spaces; - mo_spaces.emplace(1, mos); - ao_spaces.emplace(0, aos); - ao_spaces.emplace(2, aos); - ao_spaces.emplace(3, aos); - auto rv = mod.run_as(ao_spaces, mo_spaces, r12); - simde::type::tensor corr; - corr("a,i,c,d") = C("b,i") * G("a,b,c,d"); - REQUIRE(tensorwrapper::tensor::allclose(rv, corr)); - } - - SECTION("Transform mode 2") { - ao_map ao_spaces; - mo_map mo_spaces; - mo_spaces.emplace(2, mos); - ao_spaces.emplace(0, aos); - ao_spaces.emplace(1, aos); - ao_spaces.emplace(3, aos); - auto rv = mod.run_as(ao_spaces, mo_spaces, r12); - simde::type::tensor corr; - corr("a,b,i,d") = C("c,i") * G("a,b,c,d"); - REQUIRE(tensorwrapper::tensor::allclose(rv, corr)); - } - - SECTION("Transform mode 3") { - ao_map ao_spaces; - mo_map mo_spaces; - mo_spaces.emplace(3, mos); - ao_spaces.emplace(0, aos); - ao_spaces.emplace(1, aos); - ao_spaces.emplace(2, aos); - auto rv = mod.run_as(ao_spaces, mo_spaces, r12); - simde::type::tensor corr; - corr("a,b,c,i") = C("d,i") * G("a,b,c,d"); - REQUIRE(tensorwrapper::tensor::allclose(rv, corr)); - } - - SECTION("Transform modes 0 and 1") { - ao_map ao_spaces; - mo_map mo_spaces; - mo_spaces.emplace(0, mos); - mo_spaces.emplace(1, mos); - ao_spaces.emplace(2, aos); - ao_spaces.emplace(3, aos); - auto rv = mod.run_as(ao_spaces, mo_spaces, r12); - simde::type::tensor temp, corr; - temp("i,b,c,d") = C("a,i") * G("a,b,c,d"); - corr("i,j,c,d") = C("b,j") * temp("i,b,c,d"); - REQUIRE(tensorwrapper::tensor::allclose(rv, corr)); - } - - SECTION("Transform modes 0 and 2") { - ao_map ao_spaces; - mo_map mo_spaces; - mo_spaces.emplace(0, mos); - mo_spaces.emplace(2, mos); - ao_spaces.emplace(1, aos); - ao_spaces.emplace(3, aos); - auto rv = mod.run_as(ao_spaces, mo_spaces, r12); - simde::type::tensor temp, corr; - temp("i,b,c,d") = C("a,i") * G("a,b,c,d"); - corr("i,b,j,d") = C("c,j") * temp("i,b,c,d"); - REQUIRE(tensorwrapper::tensor::allclose(rv, corr)); - } - - SECTION("Transform modes 0 and 3") { - ao_map ao_spaces; - mo_map mo_spaces; - mo_spaces.emplace(0, mos); - mo_spaces.emplace(3, mos); - ao_spaces.emplace(1, aos); - ao_spaces.emplace(2, aos); - auto rv = mod.run_as(ao_spaces, mo_spaces, r12); - simde::type::tensor temp, corr; - temp("i,b,c,d") = C("a,i") * G("a,b,c,d"); - corr("i,b,c,j") = C("d,j") * temp("i,b,c,d"); - REQUIRE(tensorwrapper::tensor::allclose(rv, corr)); - } - - SECTION("Transform modes 1 and 2") { - ao_map ao_spaces; - mo_map mo_spaces; - mo_spaces.emplace(1, mos); - mo_spaces.emplace(2, mos); - ao_spaces.emplace(0, aos); - ao_spaces.emplace(3, aos); - auto rv = mod.run_as(ao_spaces, mo_spaces, r12); - simde::type::tensor temp, corr; - temp("a,i,c,d") = C("b,i") * G("a,b,c,d"); - corr("a,i,j,d") = C("c,j") * temp("a,i,c,d"); - REQUIRE(tensorwrapper::tensor::allclose(rv, corr)); - } - - SECTION("Transform modes 1 and 3") { - ao_map ao_spaces; - mo_map mo_spaces; - mo_spaces.emplace(1, mos); - mo_spaces.emplace(3, mos); - ao_spaces.emplace(0, aos); - ao_spaces.emplace(2, aos); - auto rv = mod.run_as(ao_spaces, mo_spaces, r12); - simde::type::tensor temp, corr; - temp("a,i,c,d") = C("b,i") * G("a,b,c,d"); - corr("a,i,c,j") = C("d,j") * temp("a,i,c,d"); - REQUIRE(tensorwrapper::tensor::allclose(rv, corr)); - } - - SECTION("Transform modes 2 and 3") { - ao_map ao_spaces; - mo_map mo_spaces; - mo_spaces.emplace(2, mos); - mo_spaces.emplace(3, mos); - ao_spaces.emplace(0, aos); - ao_spaces.emplace(1, aos); - auto rv = mod.run_as(ao_spaces, mo_spaces, r12); - simde::type::tensor temp, corr; - temp("a,b,i,d") = C("c,i") * G("a,b,c,d"); - corr("a,b,i,j") = C("d,j") * temp("a,b,i,d"); - REQUIRE(tensorwrapper::tensor::allclose(rv, corr)); - } - - SECTION("Transform modes 0, 1, and 2") { - ao_map ao_spaces; - mo_map mo_spaces; - mo_spaces.emplace(0, mos); - mo_spaces.emplace(1, mos); - mo_spaces.emplace(2, mos); - ao_spaces.emplace(3, aos); - auto rv = mod.run_as(ao_spaces, mo_spaces, r12); - simde::type::tensor temp, corr; - corr("i,b,c,d") = C("a,i") * G("a,b,c,d"); - temp("i,j,c,d") = C("b,j") * corr("i,b,c,d"); - corr("i,j,k,d") = C("c,k") * temp("i,j,c,d"); - REQUIRE(tensorwrapper::tensor::allclose(rv, corr)); - } - - SECTION("Transform modes 0, 1, and 3") { - ao_map ao_spaces; - mo_map mo_spaces; - mo_spaces.emplace(0, mos); - mo_spaces.emplace(1, mos); - mo_spaces.emplace(3, mos); - ao_spaces.emplace(2, aos); - auto rv = mod.run_as(ao_spaces, mo_spaces, r12); - simde::type::tensor temp, corr; - corr("i,b,c,d") = C("a,i") * G("a,b,c,d"); - temp("i,j,c,d") = C("b,j") * corr("i,b,c,d"); - corr("i,j,c,k") = C("d,k") * temp("i,j,c,d"); - REQUIRE(tensorwrapper::tensor::allclose(rv, corr)); - } - - SECTION("Transform modes 0, 2, and 3") { - ao_map ao_spaces; - mo_map mo_spaces; - mo_spaces.emplace(0, mos); - mo_spaces.emplace(2, mos); - mo_spaces.emplace(3, mos); - ao_spaces.emplace(1, aos); - auto rv = mod.run_as(ao_spaces, mo_spaces, r12); - simde::type::tensor temp, corr; - corr("i,b,c,d") = C("a,i") * G("a,b,c,d"); - temp("i,b,j,d") = C("c,j") * corr("i,b,c,d"); - corr("i,b,j,k") = C("d,k") * temp("i,b,j,d"); - REQUIRE(tensorwrapper::tensor::allclose(rv, corr)); - } - - SECTION("Transform modes 1, 2, and 3") { - ao_map ao_spaces; - mo_map mo_spaces; - mo_spaces.emplace(1, mos); - mo_spaces.emplace(2, mos); - mo_spaces.emplace(3, mos); - ao_spaces.emplace(0, aos); - auto rv = mod.run_as(ao_spaces, mo_spaces, r12); - simde::type::tensor temp, corr; - corr("a,i,c,d") = C("b,i") * G("a,b,c,d"); - temp("a,i,j,d") = C("c,j") * corr("a,i,c,d"); - corr("a,i,j,k") = C("d,k") * temp("a,i,j,d"); - REQUIRE(tensorwrapper::tensor::allclose(rv, corr)); - } - - SECTION("Transform all modes") { - ao_map ao_spaces; - mo_map mo_spaces; - mo_spaces.emplace(0, mos); - mo_spaces.emplace(1, mos); - mo_spaces.emplace(2, mos); - mo_spaces.emplace(3, mos); - auto rv = mod.run_as(ao_spaces, mo_spaces, r12); - simde::type::tensor corr, temp; - corr("i,b,c,d") = C("a,i") * G("a,b,c,d"); - temp("i,j,c,d") = C("b,j") * corr("i,b,c,d"); - corr("i,j,k,d") = C("c,k") * temp("i,j,c,d"); - temp("i,j,k,l") = C("d,l") * corr("i,j,k,d"); - REQUIRE(tensorwrapper::tensor::allclose(rv, temp)); - } -} diff --git a/tests/cxx/unit/integrals/water_sto3g.hpp b/tests/cxx/unit/integrals/water_sto3g.hpp new file mode 100644 index 00000000..797a87e2 --- /dev/null +++ b/tests/cxx/unit/integrals/water_sto3g.hpp @@ -0,0 +1,73 @@ +/* + * Copyright 2024 NWChemEx-Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#pragma once +#include + +namespace test { + +inline simde::type::molecule water_molecule() { + using atom_t = simde::type::atom; + using molecule_t = simde::type::molecule; + atom_t O{"O", 8ul, 0.0, 0.0, -0.143222342980786, 0.0}; + atom_t H1{"H", 1ul, 0.0, 1.638033502034240, 1.136556880358410, 0.0}; + atom_t H2{"H", 1ul, 0.0, -1.638033502034240, 1.136556880358410, 0.0}; + return molecule_t{O, H1, H2}; +} + +inline simde::type::ao_basis_set water_sto3g_basis_set() { + using ao_basis_t = simde::type::ao_basis_set; + using atomic_basis_t = simde::type::atomic_basis_set; + using cg_t = simde::type::contracted_gaussian; + using point_t = simde::type::point; + using doubles_t = std::vector; + + auto mol = water_molecule(); + point_t r0 = mol[0].as_nucleus(); + point_t r1 = mol[1].as_nucleus(); + point_t r2 = mol[2].as_nucleus(); + + doubles_t cs0{0.15432897, 0.53532814, 0.44463454}; + doubles_t es0{130.7093200, 23.8088610, 6.4436083}; + doubles_t cs1{-0.09996723, 0.39951283, 0.70011547}; + doubles_t es1{5.0331513, 1.1695961, 0.3803890}; + doubles_t cs2{0.15591627, 0.60768372, 0.39195739}; + doubles_t es2{5.0331513, 1.1695961, 0.3803890}; + cg_t cg0(cs0.begin(), cs0.end(), es0.begin(), es0.end(), r0); + cg_t cg1(cs1.begin(), cs1.end(), es1.begin(), es1.end(), r0); + cg_t cg2(cs2.begin(), cs2.end(), es2.begin(), es2.end(), r0); + atomic_basis_t o("sto-3g", 8, r0); + o.add_shell(chemist::ShellType::pure, 0, cg0); + o.add_shell(chemist::ShellType::pure, 0, cg1); + o.add_shell(chemist::ShellType::pure, 1, cg2); + + doubles_t cs3{0.1543289673, 0.5353281423, 0.4446345422}; + doubles_t es3{3.425250914, 0.6239137298, 0.1688554040}; + cg_t cg3(cs3.begin(), cs3.end(), es3.begin(), es3.end(), r1); + cg_t cg4(cs3.begin(), cs3.end(), es3.begin(), es3.end(), r2); + atomic_basis_t h0("sto-3g", 1, r1); + atomic_basis_t h1("sto-3g", 1, r2); + h0.add_shell(chemist::ShellType::pure, 0, cg3); + h1.add_shell(chemist::ShellType::pure, 0, cg4); + + ao_basis_t bs; + bs.add_center(o); + bs.add_center(h0); + bs.add_center(h1); + return bs; +} + +} // namespace test diff --git a/tests/python/unit_tests/ao_integrals/test_kinetic.py b/tests/python/unit_tests/ao_integrals/test_kinetic.py deleted file mode 100644 index 9929bb21..00000000 --- a/tests/python/unit_tests/ao_integrals/test_kinetic.py +++ /dev/null @@ -1,34 +0,0 @@ -# -# Copyright 2023 NWChemEx-Project -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - -import pluginplay -import simde -import integrals -import unittest - - -class TestKinetic(unittest.TestCase): - - def test_integral(self): - - mm = pluginplay.ModuleManager() - integrals.load_modules(mm) - mod = mm.at('Kinetic') - - # Uncomment when pt and tensor class is exposed - # pt = simde.AOTensorRepresentation2T() - # ints = mod.run_as(pt, aos, t, aos) - # self.AssertEqual(ints, corr) diff --git a/tests/python/unit_tests/test_integrals.py b/tests/python/unit_tests/test_integrals.py index 71662c93..59c4987d 100644 --- a/tests/python/unit_tests/test_integrals.py +++ b/tests/python/unit_tests/test_integrals.py @@ -19,7 +19,6 @@ import sys import unittest - if __name__ == '__main__': rv = pz.runtime.RuntimeView() @@ -27,7 +26,7 @@ my_dir = os.path.dirname(os.path.realpath(__file__)) loader = unittest.TestLoader() - tests = loader.discover(my_dir) + tests = loader.discover(my_dir) testrunner = unittest.runner.TextTestRunner() ret = not testrunner.run(tests).wasSuccessful() sys.exit(ret)