diff --git a/src/integrals/ao_integrals/ao_integrals.hpp b/src/integrals/ao_integrals/ao_integrals.hpp new file mode 100644 index 00000000..f7b1a8a5 --- /dev/null +++ b/src/integrals/ao_integrals/ao_integrals.hpp @@ -0,0 +1,39 @@ +/* + * 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 integrals::ao_integrals { + +DECLARE_MODULE(AOIntegralsDriver); +DECLARE_MODULE(JFourCenter); +DECLARE_MODULE(KFourCenter); + +inline void set_defaults(pluginplay::ModuleManager& mm) { + const auto ao_driver = "AO integral driver"; + mm.change_submod(ao_driver, "Coulomb matrix", "Four center J builder"); + mm.change_submod(ao_driver, "Exchange matrix", "Four center K builder"); +} + +inline void load_modules(pluginplay::ModuleManager& mm) { + mm.add_module("AO integral driver"); + mm.add_module("Four center J builder"); + mm.add_module("Four center K builder"); + set_defaults(mm); +} + +} // namespace integrals::ao_integrals \ No newline at end of file diff --git a/src/integrals/ao_integrals/ao_integrals_driver.cpp b/src/integrals/ao_integrals/ao_integrals_driver.cpp new file mode 100644 index 00000000..16879a65 --- /dev/null +++ b/src/integrals/ao_integrals/ao_integrals_driver.cpp @@ -0,0 +1,106 @@ +/* + * 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 "ao_integrals.hpp" + +namespace integrals::ao_integrals { + +namespace { + +const auto desc = R"( +AO Integrals Driver +------------------- +)"; + +} + +using pluginplay::type::submodule_map; +using simde::type::aos; +using simde::type::tensor; + +using pt = simde::aos_op_base_aos; +using t_e_pt = simde::aos_t_e_aos; +using v_en_pt = simde::aos_v_en_aos; +using j_e_pt = simde::aos_j_e_aos; +using k_e_pt = simde::aos_k_e_aos; + +class AODispatcher : public chemist::qm_operator::OperatorVisitor { +public: + using t_e_type = simde::type::t_e_type; + using v_en_type = simde::type::v_en_type; + using j_e_type = simde::type::j_e_type; + using k_e_type = simde::type::k_e_type; + + using submods_type = pluginplay::type::submodule_map; + + AODispatcher(const aos& bra, const aos& ket, submodule_map& submods, + tensor& t) : + m_pbra_(&bra), m_pket_(&ket), m_psubmods_(&submods), m_ptensor_(&t) {} + + void run(const t_e_type& t_e) { + chemist::braket::BraKet input(*m_pbra_, t_e, *m_pket_); + *m_ptensor_ = m_psubmods_->at("Kinetic").run_as(input); + } + + void run(const v_en_type& v_en) { + chemist::braket::BraKet input(*m_pbra_, v_en, *m_pket_); + const auto key = "Electron-Nuclear attraction"; + *m_ptensor_ = m_psubmods_->at(key).run_as(input); + } + + void run(const j_e_type& j_e) { + chemist::braket::BraKet input(*m_pbra_, j_e, *m_pket_); + const auto key = "Coulomb matrix"; + *m_ptensor_ = m_psubmods_->at(key).run_as(input); + } + + void run(const k_e_type& k_e) { + chemist::braket::BraKet input(*m_pbra_, k_e, *m_pket_); + const auto key = "Exchange matrix"; + *m_ptensor_ = m_psubmods_->at(key).run_as(input); + } + +private: + const aos* m_pbra_; + const aos* m_pket_; + submodule_map* m_psubmods_; + tensor* m_ptensor_; +}; + +MODULE_CTOR(AOIntegralsDriver) { + description(desc); + satisfies_property_type(); + add_submodule("Kinetic"); + add_submodule("Electron-Nuclear attraction"); + add_submodule("Coulomb matrix"); + add_submodule("Exchange matrix"); +} + +MODULE_RUN(AOIntegralsDriver) { + const auto&& [braket] = pt::unwrap_inputs(inputs); + const auto& bra = braket.bra(); + const auto& op = braket.op(); + const auto& ket = braket.ket(); + + tensor t; + AODispatcher visitor(bra, ket, submods, t); + op.visit(visitor); + + auto rv = results(); + return pt::wrap_results(rv, std::move(t)); +} + +} // namespace integrals::ao_integrals \ No newline at end of file diff --git a/src/integrals/ao_integrals/j_four_center.cpp b/src/integrals/ao_integrals/j_four_center.cpp new file mode 100644 index 00000000..f262f44a --- /dev/null +++ b/src/integrals/ao_integrals/j_four_center.cpp @@ -0,0 +1,61 @@ +/* + * 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 "ao_integrals.hpp" + +namespace integrals::ao_integrals { + +using pt = simde::aos_j_e_aos; +using pt_4c = simde::ERI4; + +namespace { + +auto desc = R"( +Four-Center J Builder +--------------------- +)"; + +} +MODULE_CTOR(JFourCenter) { + description(desc); + satisfies_property_type(); + add_submodule("Four-center ERI"); +} + +MODULE_RUN(JFourCenter) { + const auto&& [braket] = pt::unwrap_inputs(inputs); + auto bra = braket.bra(); + auto ket = braket.ket(); + const auto& j_hat = braket.op(); + const auto& rho = j_hat.rhs_particle(); + const auto& p = rho.value(); + auto rho_aos = rho.basis_set(); + auto& eri_mod = submods.at("Four-center ERI"); + + simde::type::v_ee_type v_ee; + simde::type::aos_squared ij_pair(bra, ket); + simde::type::aos_squared kl_pair(rho_aos, rho_aos); + chemist::braket::BraKet ij_v_kl(ij_pair, v_ee, kl_pair); + const auto& I = eri_mod.run_as(std::move(ij_v_kl)); + + simde::type::tensor j; + j("i,j") = p("k,l") * I("i,j,k,l"); + + auto rv = results(); + return pt::wrap_results(rv, std::move(j)); +} + +} // namespace integrals::ao_integrals \ No newline at end of file diff --git a/src/integrals/ao_integrals/k_four_center.cpp b/src/integrals/ao_integrals/k_four_center.cpp new file mode 100644 index 00000000..96fcea05 --- /dev/null +++ b/src/integrals/ao_integrals/k_four_center.cpp @@ -0,0 +1,62 @@ +/* + * 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 "ao_integrals.hpp" + +namespace integrals::ao_integrals { + +using pt = simde::aos_k_e_aos; +using pt_4c = simde::ERI4; + +namespace { + +auto desc = R"( +Four-Center K Builder +--------------------- +)"; + +} + +MODULE_CTOR(KFourCenter) { + description(desc); + satisfies_property_type(); + add_submodule("Four-center ERI"); +} + +MODULE_RUN(KFourCenter) { + const auto&& [braket] = pt::unwrap_inputs(inputs); + auto bra = braket.bra(); + auto ket = braket.ket(); + const auto& j_hat = braket.op(); + const auto& rho = j_hat.rhs_particle(); + const auto& p = rho.value(); + auto rho_aos = rho.basis_set(); + auto& eri_mod = submods.at("Four-center ERI"); + + simde::type::v_ee_type v_ee; + simde::type::aos_squared ik_pair(bra, rho_aos); + simde::type::aos_squared lj_pair(rho_aos, ket); + chemist::braket::BraKet ik_v_lj(ik_pair, v_ee, ik_pair); + const auto& I = eri_mod.run_as(std::move(ik_v_lj)); + + simde::type::tensor k; + k("i,j") = p("k,l") * I("i,k,l,j"); + + auto rv = results(); + return pt::wrap_results(rv, std::move(k)); +} + +} // namespace integrals::ao_integrals \ No newline at end of file diff --git a/src/integrals/integrals_mm.cpp b/src/integrals/integrals_mm.cpp index 936e8c16..4b3a1ab6 100644 --- a/src/integrals/integrals_mm.cpp +++ b/src/integrals/integrals_mm.cpp @@ -14,6 +14,7 @@ * limitations under the License. */ +#include "ao_integrals/ao_integrals.hpp" #include "libint/libint.hpp" #include @@ -26,11 +27,16 @@ namespace integrals { * @throw none No throw guarantee */ void set_defaults(pluginplay::ModuleManager& mm) { - // Defaults go here + const auto ao_driver = "AO integral driver"; + mm.change_submod(ao_driver, "Kinetic", "Kinetic"); + mm.change_submod(ao_driver, "Electron-Nuclear attraction", "Nuclear"); + mm.change_submod("Four center J builder", "Four-center ERI", "ERI4"); + mm.change_submod("Four center K builder", "Four-center ERI", "ERI4"); } void load_modules(pluginplay::ModuleManager& mm) { - libint::load_libint(mm); + ao_integrals::load_modules(mm); + libint::load_modules(mm); set_defaults(mm); } diff --git a/src/integrals/libint/libint.cpp b/src/integrals/libint/libint.cpp index cad962dd..2f3639c4 100644 --- a/src/integrals/libint/libint.cpp +++ b/src/integrals/libint/libint.cpp @@ -157,13 +157,13 @@ EXTERN_LIBINT(aos_squared, v_ee_type, aos_squared); #undef EXTERN_LIBINT -void libint_set_defaults(pluginplay::ModuleManager& mm) { +void set_defaults(pluginplay::ModuleManager& mm) { // Set any default associations } #define LOAD_LIBINT(bra, op, ket, key) mm.add_module(key) -void load_libint(pluginplay::ModuleManager& mm) { +void load_modules(pluginplay::ModuleManager& mm) { LOAD_LIBINT(aos, op_base_type, aos, "Evaluate 2-Index BraKet"); LOAD_LIBINT(aos, op_base_type, aos_squared, "Evaluate 3-Index BraKet"); LOAD_LIBINT(aos_squared, op_base_type, aos_squared, @@ -174,7 +174,7 @@ void load_libint(pluginplay::ModuleManager& mm) { LOAD_LIBINT(aos, v_ee_type, aos, "ERI2"); LOAD_LIBINT(aos, v_ee_type, aos_squared, "ERI3"); LOAD_LIBINT(aos_squared, v_ee_type, aos_squared, "ERI4"); - libint_set_defaults(mm); + set_defaults(mm); } #undef LOAD_LIBINT diff --git a/src/integrals/libint/libint.hpp b/src/integrals/libint/libint.hpp index b3f172ce..d05968fb 100644 --- a/src/integrals/libint/libint.hpp +++ b/src/integrals/libint/libint.hpp @@ -48,7 +48,7 @@ DECLARE_MODULE(Libint); * * @throw none No throw guarantee */ -void load_libint(pluginplay::ModuleManager& mm); +void load_modules(pluginplay::ModuleManager& mm); /** @brief Set default module relationships * @@ -56,7 +56,7 @@ void load_libint(pluginplay::ModuleManager& mm); * * @throw none No throw guarantee */ -void libint_set_defaults(pluginplay::ModuleManager& mm); +void set_defaults(pluginplay::ModuleManager& mm); // Forward External Template Declarations #define EXTERN_LIBINT extern template struct Libint diff --git a/tests/cxx/unit/integrals/ao_integrals/ao_integrals_driver.cpp b/tests/cxx/unit/integrals/ao_integrals/ao_integrals_driver.cpp new file mode 100644 index 00000000..6d6a1247 --- /dev/null +++ b/tests/cxx/unit/integrals/ao_integrals/ao_integrals_driver.cpp @@ -0,0 +1,100 @@ +/* + * 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 "../testing.hpp" + +using simde::type::tensor; + +namespace { + +void compare_matrices(const tensor& A, const tensor& A_corr) { + using alloc_type = tensorwrapper::allocator::Eigen; + const auto& A_buffer = alloc_type::rebind(A.buffer()); + const auto& A_corr_buffer = alloc_type::rebind(A_corr.buffer()); + const auto& A_eigen = A_buffer.value(); + const auto& A_corr_eigen = A_corr_buffer.value(); + + const auto tol = 1E-6; + REQUIRE(A_eigen(0, 0) == Catch::Approx(A_corr_eigen(0, 0)).margin(tol)); + REQUIRE(A_eigen(0, 1) == Catch::Approx(A_corr_eigen(0, 1)).margin(tol)); + REQUIRE(A_eigen(1, 0) == Catch::Approx(A_corr_eigen(1, 0)).margin(tol)); + REQUIRE(A_eigen(1, 1) == Catch::Approx(A_corr_eigen(1, 1)).margin(tol)); +} + +} // namespace + +TEST_CASE("AOIntegralsDriver") { + using pt = simde::aos_op_base_aos; + using erased_type = + chemist::braket::BraKet; + + pluginplay::ModuleManager mm; + integrals::load_modules(mm); + REQUIRE(mm.count("AO integral driver")); + auto& mod = mm.at("AO integral driver"); + + // Get basis set + auto mol = test::h2_molecule(); + auto aobs = test::h2_sto3g_basis_set(); + + // Make AOS object + simde::type::aos aos(aobs); + + // Operator Inputs + simde::type::electron e; + auto rho = test::h2_density(); + + SECTION("Calling Kinetic") { + auto& tmod = mm.at("Kinetic"); + simde::type::t_e_type t_e(e); + chemist::braket::BraKet braket(aos, t_e, aos); + erased_type copy_braket(braket); + const auto& T = mod.run_as(copy_braket); + const auto& T_corr = tmod.run_as(braket); + compare_matrices(T, T_corr); + } + + SECTION("Calling Electron-Nuclear Attraction") { + auto& tmod = mm.at("Nuclear"); + simde::type::v_en_type v_en(e, mol.nuclei().as_nuclei()); + chemist::braket::BraKet braket(aos, v_en, aos); + erased_type copy_braket(braket); + const auto& V = mod.run_as(copy_braket); + const auto& V_corr = tmod.run_as(braket); + compare_matrices(V, V_corr); + } + + SECTION("Calling J Matrix") { + auto& jmod = mm.at("Four center J builder"); + simde::type::j_e_type j_e(e, rho); + chemist::braket::BraKet braket(aos, j_e, aos); + erased_type copy_braket(braket); + const auto& J = mod.run_as(copy_braket); + const auto& J_corr = jmod.run_as(braket); + compare_matrices(J, J_corr); + } + + SECTION("Calling K Matrix") { + auto& kmod = mm.at("Four center K builder"); + simde::type::k_e_type k_e(e, rho); + chemist::braket::BraKet braket(aos, k_e, aos); + erased_type copy_braket(braket); + const auto& K = mod.run_as(copy_braket); + const auto& K_corr = kmod.run_as(braket); + compare_matrices(K, K_corr); + } +} \ No newline at end of file diff --git a/tests/cxx/unit/integrals/ao_integrals/j_four_center.cpp b/tests/cxx/unit/integrals/ao_integrals/j_four_center.cpp new file mode 100644 index 00000000..da0d66b2 --- /dev/null +++ b/tests/cxx/unit/integrals/ao_integrals/j_four_center.cpp @@ -0,0 +1,47 @@ +/* + * 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 "../testing.hpp" + +TEST_CASE("Four center J builder") { + using pt = simde::aos_j_e_aos; + + pluginplay::ModuleManager mm; + integrals::load_modules(mm); + REQUIRE(mm.count("Four center J builder")); + + // Get basis set + auto mol = test::h2_molecule(); + auto aobs = test::h2_sto3g_basis_set(); + + // Make AOS object + simde::type::aos aos(aobs); + + // Make Operator + simde::type::j_e_type op(simde::type::electron{}, test::h2_density()); + + // Make BraKet Input + chemist::braket::BraKet braket(aos, op, aos); + + // Call module + const auto& T = mm.at("Four center J builder").run_as(braket); + + auto t = test::eigen_buffer<2>(T.buffer()); + REQUIRE(t.value()(0, 0) == Catch::Approx(0.56044143).margin(1E-6)); + REQUIRE(t.value()(0, 1) == Catch::Approx(0.24704427).margin(1E-6)); + REQUIRE(t.value()(1, 0) == Catch::Approx(0.24704427).margin(1E-6)); + REQUIRE(t.value()(1, 1) == Catch::Approx(0.56044143).margin(1E-6)); +} \ No newline at end of file diff --git a/tests/cxx/unit/integrals/ao_integrals/k_four_center.cpp b/tests/cxx/unit/integrals/ao_integrals/k_four_center.cpp new file mode 100644 index 00000000..f001ea16 --- /dev/null +++ b/tests/cxx/unit/integrals/ao_integrals/k_four_center.cpp @@ -0,0 +1,47 @@ +/* + * 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 "../testing.hpp" + +TEST_CASE("Four center K builder") { + using pt = simde::aos_k_e_aos; + + pluginplay::ModuleManager mm; + integrals::load_modules(mm); + REQUIRE(mm.count("Four center K builder")); + + // Get basis set + auto mol = test::h2_molecule(); + auto aobs = test::h2_sto3g_basis_set(); + + // Make AOS object + simde::type::aos aos(aobs); + + // Make Operator + simde::type::k_e_type op(simde::type::electron{}, test::h2_density()); + + // Make BraKet Input + chemist::braket::BraKet braket(aos, op, aos); + + // Call module + const auto& T = mm.at("Four center K builder").run_as(braket); + + auto t = test::eigen_buffer<2>(T.buffer()); + REQUIRE(t.value()(0, 0) == Catch::Approx(0.45617623).margin(1E-6)); + REQUIRE(t.value()(0, 1) == Catch::Approx(0.35130947).margin(1E-6)); + REQUIRE(t.value()(1, 0) == Catch::Approx(0.35130947).margin(1E-6)); + REQUIRE(t.value()(1, 1) == Catch::Approx(0.45617623).margin(1E-6)); +} \ No newline at end of file diff --git a/tests/cxx/unit/integrals/libint/detail_/test_make_libint_basis_set.cpp b/tests/cxx/unit/integrals/libint/detail_/test_make_libint_basis_set.cpp index a1a85110..cee03ffd 100644 --- a/tests/cxx/unit/integrals/libint/detail_/test_make_libint_basis_set.cpp +++ b/tests/cxx/unit/integrals/libint/detail_/test_make_libint_basis_set.cpp @@ -14,10 +14,9 @@ * limitations under the License. */ -#include "../../water_sto3g.hpp" +#include "../../testing.hpp" #include "integrals/libint/detail_/make_libint_basis_set.hpp" #include "libint_basis_set_water.hpp" -#include TEST_CASE("make_libint_basis_set") { using integrals::libint::detail_::make_libint_basis_set; diff --git a/tests/cxx/unit/integrals/libint/test_arbitrary_operator.cpp b/tests/cxx/unit/integrals/libint/test_arbitrary_operator.cpp index 1f78c0aa..1bf408eb 100644 --- a/tests/cxx/unit/integrals/libint/test_arbitrary_operator.cpp +++ b/tests/cxx/unit/integrals/libint/test_arbitrary_operator.cpp @@ -14,8 +14,8 @@ * limitations under the License. */ +#include "../testing.hpp" #include "integrals/uncertain_types.hpp" -#include "test_libint.hpp" using udouble = integrals::type::uncertain_double; constexpr bool has_sigma = integrals::type::has_sigma(); diff --git a/tests/cxx/unit/integrals/libint/test_eri2.cpp b/tests/cxx/unit/integrals/libint/test_eri2.cpp index d1a61bbb..4b1e8c09 100644 --- a/tests/cxx/unit/integrals/libint/test_eri2.cpp +++ b/tests/cxx/unit/integrals/libint/test_eri2.cpp @@ -14,7 +14,7 @@ * limitations under the License. */ -#include "test_libint.hpp" +#include "../testing.hpp" TEST_CASE("ERI2") { using test_pt = simde::ERI2; diff --git a/tests/cxx/unit/integrals/libint/test_eri3.cpp b/tests/cxx/unit/integrals/libint/test_eri3.cpp index ae16ebea..ebca158e 100644 --- a/tests/cxx/unit/integrals/libint/test_eri3.cpp +++ b/tests/cxx/unit/integrals/libint/test_eri3.cpp @@ -14,7 +14,7 @@ * limitations under the License. */ -#include "test_libint.hpp" +#include "../testing.hpp" TEST_CASE("ERI3") { using test_pt = simde::ERI3; diff --git a/tests/cxx/unit/integrals/libint/test_eri4.cpp b/tests/cxx/unit/integrals/libint/test_eri4.cpp index c82a0628..58268edd 100644 --- a/tests/cxx/unit/integrals/libint/test_eri4.cpp +++ b/tests/cxx/unit/integrals/libint/test_eri4.cpp @@ -14,7 +14,7 @@ * limitations under the License. */ -#include "test_libint.hpp" +#include "../testing.hpp" TEST_CASE("ERI4") { using test_pt = simde::ERI4; diff --git a/tests/cxx/unit/integrals/libint/test_kinetic.cpp b/tests/cxx/unit/integrals/libint/test_kinetic.cpp index 15bed72f..9d9d93f2 100644 --- a/tests/cxx/unit/integrals/libint/test_kinetic.cpp +++ b/tests/cxx/unit/integrals/libint/test_kinetic.cpp @@ -14,7 +14,7 @@ * limitations under the License. */ -#include "test_libint.hpp" +#include "../testing.hpp" TEST_CASE("Kinetic") { using test_pt = simde::aos_t_e_aos; diff --git a/tests/cxx/unit/integrals/libint/test_libint.hpp b/tests/cxx/unit/integrals/libint/test_libint.hpp deleted file mode 100644 index 7a51fccc..00000000 --- a/tests/cxx/unit/integrals/libint/test_libint.hpp +++ /dev/null @@ -1,42 +0,0 @@ -/* - * 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 tensorwrapper::buffer::Eigen& t) { - Eigen::Tensor trace = t.value().trace(); - return trace.coeff(); -} - -template -auto norm(const tensorwrapper::buffer::Eigen& 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/libint/test_nuclear.cpp b/tests/cxx/unit/integrals/libint/test_nuclear.cpp index 9cb163da..26c34a93 100644 --- a/tests/cxx/unit/integrals/libint/test_nuclear.cpp +++ b/tests/cxx/unit/integrals/libint/test_nuclear.cpp @@ -14,7 +14,7 @@ * limitations under the License. */ -#include "test_libint.hpp" +#include "../testing.hpp" TEST_CASE("Nuclear") { using test_pt = simde::aos_v_en_aos; diff --git a/tests/cxx/unit/integrals/libint/test_overlap.cpp b/tests/cxx/unit/integrals/libint/test_overlap.cpp index 190b7f2c..535c9afc 100644 --- a/tests/cxx/unit/integrals/libint/test_overlap.cpp +++ b/tests/cxx/unit/integrals/libint/test_overlap.cpp @@ -14,7 +14,7 @@ * limitations under the License. */ -#include "test_libint.hpp" +#include "../testing.hpp" TEST_CASE("Overlap") { using test_pt = simde::aos_s_e_aos; diff --git a/tests/cxx/unit/integrals/water_sto3g.hpp b/tests/cxx/unit/integrals/testing.hpp similarity index 51% rename from tests/cxx/unit/integrals/water_sto3g.hpp rename to tests/cxx/unit/integrals/testing.hpp index 797a87e2..402dbc50 100644 --- a/tests/cxx/unit/integrals/water_sto3g.hpp +++ b/tests/cxx/unit/integrals/testing.hpp @@ -15,10 +15,38 @@ */ #pragma once +#include + +// For common inputs #include +// Common Catch2 includes +#include +#include + namespace test { +// Checking eigen outputs +template +auto eigen_buffer(const tensorwrapper::buffer::BufferBase& buffer) { + return static_cast&>( + buffer); +} + +template +auto trace(const tensorwrapper::buffer::Eigen& t) { + Eigen::Tensor trace = t.value().trace(); + return trace.coeff(); +} + +template +auto norm(const tensorwrapper::buffer::Eigen& t) { + Eigen::Tensor norm = + t.value().square().sum().sqrt(); + return norm.coeff(); +} + +// Inputs for Water tests inline simde::type::molecule water_molecule() { using atom_t = simde::type::atom; using molecule_t = simde::type::molecule; @@ -70,4 +98,53 @@ inline simde::type::ao_basis_set water_sto3g_basis_set() { return bs; } +// Inputs for H2 tests +inline simde::type::molecule h2_molecule() { + using atom_t = simde::type::atom; + using molecule_t = simde::type::molecule; + atom_t H0("H", 1ul, 1836.15, 0.0, 0.0, 0.0); + atom_t H1("H", 1ul, 1836.15, 0.0, 0.0, 1.3984); + return molecule_t{H0, H1}; +} + +inline simde::type::ao_basis_set h2_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(); + + doubles_t cs{0.1543289673, 0.5353281423, 0.4446345422}; + doubles_t es{3.425250914, 0.6239137298, 0.1688554040}; + cg_t cg0(cs.begin(), cs.end(), es.begin(), es.end(), r0); + cg_t cg1(cs.begin(), cs.end(), es.begin(), es.end(), r1); + atomic_basis_t h0("sto-3g", 1, r0); + atomic_basis_t h1("sto-3g", 1, r1); + h0.add_shell(chemist::ShellType::cartesian, 0, cg0); + h1.add_shell(chemist::ShellType::cartesian, 0, cg1); + + ao_basis_t bs; + bs.add_center(h0); + bs.add_center(h1); + return bs; +} + +inline auto h2_mos() { + using mos_type = simde::type::mos; + using tensor_type = typename mos_type::transform_type; + tensor_type c({{-0.565516, -1.07019}, {-0.565516, 1.07019}}); + return mos_type(simde::type::aos(h2_sto3g_basis_set()), std::move(c)); +} + +inline auto h2_density() { + using density_type = simde::type::decomposable_e_density; + typename density_type::value_type rho( + {{0.31980835, 0.31980835}, {0.31980835, 0.31980835}}); + return density_type(rho, h2_mos()); +} + } // namespace test