diff --git a/tests/cxx/unit/integrals/ao_integrals/ao_integrals_driver.cpp b/tests/cxx/unit/integrals/ao_integrals/ao_integrals_driver.cpp index 2003d808..ab26cecc 100644 --- a/tests/cxx/unit/integrals/ao_integrals/ao_integrals_driver.cpp +++ b/tests/cxx/unit/integrals/ao_integrals/ao_integrals_driver.cpp @@ -65,7 +65,7 @@ TEST_CASE("AOIntegralsDriver") { // Operator Inputs simde::type::electron e; - auto rho = h2_density(); + auto rho = h2_density(); SECTION("Calling Kinetic") { auto& tmod = mm.at("Kinetic"); diff --git a/tests/cxx/unit/integrals/ao_integrals/j_density_fitted.cpp b/tests/cxx/unit/integrals/ao_integrals/j_density_fitted.cpp index ae01db8c..2db5556b 100644 --- a/tests/cxx/unit/integrals/ao_integrals/j_density_fitted.cpp +++ b/tests/cxx/unit/integrals/ao_integrals/j_density_fitted.cpp @@ -32,7 +32,7 @@ TEST_CASE("Density Fitted J builder") { simde::type::aos aos(aobs); // Make Operator - simde::type::j_e_type op(simde::type::electron{}, h2_density()); + simde::type::j_e_type op(simde::type::electron{}, h2_density()); // Make BraKet Input chemist::braket::BraKet braket(aos, op, aos); diff --git a/tests/cxx/unit/integrals/ao_integrals/j_four_center.cpp b/tests/cxx/unit/integrals/ao_integrals/j_four_center.cpp index ff13bac6..590bf0b9 100644 --- a/tests/cxx/unit/integrals/ao_integrals/j_four_center.cpp +++ b/tests/cxx/unit/integrals/ao_integrals/j_four_center.cpp @@ -31,18 +31,57 @@ TEST_CASE("Four center J builder") { // Make AOS object simde::type::aos aos(aobs); - // Make Operator - simde::type::j_e_type op(simde::type::electron{}, h2_density()); + SECTION("No QCUP") { + // Make Operator + simde::type::j_e_type op(simde::type::electron{}, h2_density()); - // Make BraKet Input - chemist::braket::BraKet braket(aos, op, aos); + // Make BraKet Input + chemist::braket::BraKet braket(aos, op, aos); - // Call module - const auto& T = mm.at("Four center J builder").run_as(braket); + // Call module + const auto& T = mm.at("Four center J builder").run_as(braket); - auto t = eigen_tensor<2>(T.buffer()); - REQUIRE(t(0, 0) == Catch::Approx(0.56044143).margin(1E-6)); - REQUIRE(t(0, 1) == Catch::Approx(0.24704427).margin(1E-6)); - REQUIRE(t(1, 0) == Catch::Approx(0.24704427).margin(1E-6)); - REQUIRE(t(1, 1) == Catch::Approx(0.56044143).margin(1E-6)); + auto t = eigen_tensor<2>(T.buffer()); + REQUIRE(t(0, 0) == Catch::Approx(0.56044143).margin(1E-6)); + REQUIRE(t(0, 1) == Catch::Approx(0.24704427).margin(1E-6)); + REQUIRE(t(1, 0) == Catch::Approx(0.24704427).margin(1E-6)); + REQUIRE(t(1, 1) == Catch::Approx(0.56044143).margin(1E-6)); + } + +#ifdef ENABLE_SIGMA + SECTION("QCUP") { + mm.change_submod("Four center J builder", "Four-center ERI", + "UQ Driver"); + mm.change_input("ERI4", "Threshold", 1e-6); + + using tensorwrapper::types::udouble; + + // Make Operator + simde::type::j_e_type op(simde::type::electron{}, + 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 = eigen_tensor<2, sigma::UDouble>(T.buffer()); + + // Disclaimer: these values are just what was output by the first run + // they may not actually be correct. FWIW, the means are right + std::vector corr{ + udouble{0.56044, 4.52277e-07}, udouble{0.247036, 7.702e-06}, + udouble{0.247036, 7.702e-06}, udouble{0.56044, 4.52277e-07}}; + + REQUIRE(t(0, 0).mean() == Catch::Approx(corr[0].mean()).margin(1E-6)); + REQUIRE(t(0, 0).sd() == Catch::Approx(corr[0].sd()).margin(1E-6)); + REQUIRE(t(0, 1).mean() == Catch::Approx(corr[1].mean()).margin(1E-6)); + REQUIRE(t(0, 1).sd() == Catch::Approx(corr[1].sd()).margin(1E-6)); + REQUIRE(t(1, 0).mean() == Catch::Approx(corr[2].mean()).margin(1E-6)); + REQUIRE(t(1, 0).sd() == Catch::Approx(corr[2].sd()).margin(1E-6)); + REQUIRE(t(1, 1).mean() == Catch::Approx(corr[3].mean()).margin(1E-6)); + REQUIRE(t(1, 1).sd() == Catch::Approx(corr[3].sd()).margin(1E-6)); + } +#endif } diff --git a/tests/cxx/unit/integrals/ao_integrals/k_density_fitted.cpp b/tests/cxx/unit/integrals/ao_integrals/k_density_fitted.cpp index fe7a8e1a..13163f6b 100644 --- a/tests/cxx/unit/integrals/ao_integrals/k_density_fitted.cpp +++ b/tests/cxx/unit/integrals/ao_integrals/k_density_fitted.cpp @@ -32,7 +32,7 @@ TEST_CASE("Density Fitted K builder") { simde::type::aos aos(aobs); // Make Operator - simde::type::k_e_type op(simde::type::electron{}, h2_density()); + simde::type::k_e_type op(simde::type::electron{}, h2_density()); // Make BraKet Input chemist::braket::BraKet braket(aos, op, aos); diff --git a/tests/cxx/unit/integrals/ao_integrals/k_four_center.cpp b/tests/cxx/unit/integrals/ao_integrals/k_four_center.cpp index 85f06dbc..a053c828 100644 --- a/tests/cxx/unit/integrals/ao_integrals/k_four_center.cpp +++ b/tests/cxx/unit/integrals/ao_integrals/k_four_center.cpp @@ -31,18 +31,57 @@ TEST_CASE("Four center K builder") { // Make AOS object simde::type::aos aos(aobs); - // Make Operator - simde::type::k_e_type op(simde::type::electron{}, h2_density()); + SECTION("No QCUP") { + // Make Operator + simde::type::k_e_type op(simde::type::electron{}, h2_density()); - // Make BraKet Input - chemist::braket::BraKet braket(aos, op, aos); + // Make BraKet Input + chemist::braket::BraKet braket(aos, op, aos); - // Call module - const auto& T = mm.at("Four center K builder").run_as(braket); + // Call module + const auto& T = mm.at("Four center K builder").run_as(braket); - auto t = eigen_tensor<2>(T.buffer()); - REQUIRE(t(0, 0) == Catch::Approx(0.45617623).margin(1E-6)); - REQUIRE(t(0, 1) == Catch::Approx(0.35130947).margin(1E-6)); - REQUIRE(t(1, 0) == Catch::Approx(0.35130947).margin(1E-6)); - REQUIRE(t(1, 1) == Catch::Approx(0.45617623).margin(1E-6)); + auto t = eigen_tensor<2>(T.buffer()); + REQUIRE(t(0, 0) == Catch::Approx(0.45617623).margin(1E-6)); + REQUIRE(t(0, 1) == Catch::Approx(0.35130947).margin(1E-6)); + REQUIRE(t(1, 0) == Catch::Approx(0.35130947).margin(1E-6)); + REQUIRE(t(1, 1) == Catch::Approx(0.45617623).margin(1E-6)); + } + +#ifdef ENABLE_SIGMA + SECTION("QCUP") { + mm.change_submod("Four center K builder", "Four-center ERI", + "UQ Driver"); + mm.change_input("ERI4", "Threshold", 1e-6); + + using tensorwrapper::types::udouble; + + // Make Operator + simde::type::k_e_type op(simde::type::electron{}, + 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 = eigen_tensor<2, sigma::UDouble>(T.buffer()); + + // Disclaimer: these values are just what was output by the first run + // they may not actually be correct. FWIW the means are right. + std::vector corr{ + udouble{0.456171, 5.45552e-06}, udouble{0.351305, 5.45552e-06}, + udouble{0.351305, 5.45552e-06}, udouble{0.456171, 5.45552e-06}}; + + REQUIRE(t(0, 0).mean() == Catch::Approx(corr[0].mean()).margin(1E-6)); + REQUIRE(t(0, 0).sd() == Catch::Approx(corr[0].sd()).margin(1E-6)); + REQUIRE(t(0, 1).mean() == Catch::Approx(corr[1].mean()).margin(1E-6)); + REQUIRE(t(0, 1).sd() == Catch::Approx(corr[1].sd()).margin(1E-6)); + REQUIRE(t(1, 0).mean() == Catch::Approx(corr[2].mean()).margin(1E-6)); + REQUIRE(t(1, 0).sd() == Catch::Approx(corr[2].sd()).margin(1E-6)); + REQUIRE(t(1, 1).mean() == Catch::Approx(corr[3].mean()).margin(1E-6)); + REQUIRE(t(1, 1).sd() == Catch::Approx(corr[3].sd()).margin(1E-6)); + } +#endif } diff --git a/tests/cxx/unit/integrals/ao_integrals/test_uq_driver.cpp b/tests/cxx/unit/integrals/ao_integrals/test_uq_driver.cpp index e85ab324..22ec0ff9 100644 --- a/tests/cxx/unit/integrals/ao_integrals/test_uq_driver.cpp +++ b/tests/cxx/unit/integrals/ao_integrals/test_uq_driver.cpp @@ -28,20 +28,32 @@ auto corr_answer(const simde::type::tensor& T) { simde::type::tensor T_corr(T); auto& corr_buffer = buffer::make_contiguous(T_corr.buffer()); corr_buffer.set_elem({0, 0, 0, 0}, FloatType{0.774606, 0}); - corr_buffer.set_elem({0, 0, 0, 1}, FloatType{0.265558, 2.49687e-06}); - corr_buffer.set_elem({0, 0, 1, 0}, FloatType{0.265558, 2.49687e-06}); + corr_buffer.set_elem({0, 0, 0, 1}, + FloatType{0.265558, 0.0000010000000000}); + corr_buffer.set_elem({0, 0, 1, 0}, + FloatType{0.265558, 0.0000010000000000}); corr_buffer.set_elem({0, 0, 1, 1}, FloatType{0.446701, 0}); - corr_buffer.set_elem({0, 1, 0, 0}, FloatType{0.265558, 2.49687e-06}); - corr_buffer.set_elem({0, 1, 0, 1}, FloatType{0.120666, 1.10748e-05}); - corr_buffer.set_elem({0, 1, 1, 0}, FloatType{0.120666, 1.10748e-05}); - corr_buffer.set_elem({0, 1, 1, 1}, FloatType{0.265558, 2.49687e-06}); - corr_buffer.set_elem({1, 0, 0, 0}, FloatType{0.265558, 2.49687e-06}); - corr_buffer.set_elem({1, 0, 0, 1}, FloatType{0.120666, 1.10748e-05}); - corr_buffer.set_elem({1, 0, 1, 0}, FloatType{0.120666, 1.10748e-05}); - corr_buffer.set_elem({1, 0, 1, 1}, FloatType{0.265558, 2.49687e-06}); + corr_buffer.set_elem({0, 1, 0, 0}, + FloatType{0.265558, 0.0000010000000000}); + corr_buffer.set_elem({0, 1, 0, 1}, + FloatType{0.120666, 0.0000170000000000}); + corr_buffer.set_elem({0, 1, 1, 0}, + FloatType{0.120666, 0.0000170000000000}); + corr_buffer.set_elem({0, 1, 1, 1}, + FloatType{0.265558, 0.0000010000000000}); + corr_buffer.set_elem({1, 0, 0, 0}, + FloatType{0.265558, 0.0000010000000000}); + corr_buffer.set_elem({1, 0, 0, 1}, + FloatType{0.120666, 0.0000170000000000}); + corr_buffer.set_elem({1, 0, 1, 0}, + FloatType{0.120666, 0.0000170000000000}); + corr_buffer.set_elem({1, 0, 1, 1}, + FloatType{0.265558, 0.0000010000000000}); corr_buffer.set_elem({1, 1, 0, 0}, FloatType{0.446701, 0}); - corr_buffer.set_elem({1, 1, 0, 1}, FloatType{0.265558, 2.49687e-06}); - corr_buffer.set_elem({1, 1, 1, 0}, FloatType{0.265558, 2.49687e-06}); + corr_buffer.set_elem({1, 1, 0, 1}, + FloatType{0.265558, 0.0000010000000000}); + corr_buffer.set_elem({1, 1, 1, 0}, + FloatType{0.265558, 0.0000010000000000}); corr_buffer.set_elem({1, 1, 1, 1}, FloatType{0.774606, 0}); return T_corr; } @@ -57,8 +69,6 @@ TEST_CASE("UQ Driver") { integrals::load_modules(mm); integrals::set_defaults(mm); REQUIRE(mm.count("UQ Driver")); - mm.copy_module("UQ Driver", "UQ w/analytic Error"); - mm.change_submod("UQ w/analytic Error", "ERI Error", "Analytic Error"); mm.change_input("ERI4", "Threshold", 1.0e-6); // Get basis set @@ -76,14 +86,10 @@ TEST_CASE("UQ Driver") { chemist::braket::BraKet braket(aos_squared, op, aos_squared); // Call modules - auto T = mm.at("UQ Driver").run_as(braket); - auto T_corr = mm.at("UQ w/analytic Error").run_as(braket); + auto T = mm.at("UQ Driver").run_as(braket); - // std::cout << T << std::endl; - // std::cout << T_corr << std::endl; - - // auto T_corr = corr_answer(T); - // using tensorwrapper::operations::approximately_equal; - // REQUIRE(approximately_equal(T_corr, T, 1E-6)); + auto T_corr = corr_answer(T); + using tensorwrapper::operations::approximately_equal; + REQUIRE(approximately_equal(T_corr, T, 1E-6)); } } diff --git a/tests/cxx/unit/integrals/testing/testing.hpp b/tests/cxx/unit/integrals/testing/testing.hpp index 035b30b1..3a208f13 100644 --- a/tests/cxx/unit/integrals/testing/testing.hpp +++ b/tests/cxx/unit/integrals/testing/testing.hpp @@ -88,10 +88,14 @@ inline auto h2_mos() { return mos_type(simde::type::aos(h2_sto3g_basis_set()), std::move(c)); } +template 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}}); + std::vector data{FloatType{0.31980835}, FloatType{0.31980835}, + FloatType{0.31980835}, FloatType{0.31980835}}; + tensorwrapper::shape::Smooth shape({2, 2}); + tensorwrapper::buffer::Contiguous buffer(std::move(data), shape); + typename density_type::value_type rho(std::move(buffer), shape); return density_type(rho, h2_mos()); }