Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ TEST_CASE("AOIntegralsDriver") {

// Operator Inputs
simde::type::electron e;
auto rho = h2_density();
auto rho = h2_density<double>();

SECTION("Calling Kinetic") {
auto& tmod = mm.at("Kinetic");
Expand Down
2 changes: 1 addition & 1 deletion tests/cxx/unit/integrals/ao_integrals/j_density_fitted.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<double>());

// Make BraKet Input
chemist::braket::BraKet braket(aos, op, aos);
Expand Down
61 changes: 50 additions & 11 deletions tests/cxx/unit/integrals/ao_integrals/j_four_center.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<double>());

// 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<pt>(braket);
// Call module
const auto& T = mm.at("Four center J builder").run_as<pt>(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<udouble>());

// Make BraKet Input
chemist::braket::BraKet braket(aos, op, aos);

// Call module
const auto& T = mm.at("Four center J builder").run_as<pt>(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<udouble> 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
}
2 changes: 1 addition & 1 deletion tests/cxx/unit/integrals/ao_integrals/k_density_fitted.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<double>());

// Make BraKet Input
chemist::braket::BraKet braket(aos, op, aos);
Expand Down
61 changes: 50 additions & 11 deletions tests/cxx/unit/integrals/ao_integrals/k_four_center.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<double>());

// 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<pt>(braket);
// Call module
const auto& T = mm.at("Four center K builder").run_as<pt>(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<udouble>());

// Make BraKet Input
chemist::braket::BraKet braket(aos, op, aos);

// Call module
const auto& T = mm.at("Four center K builder").run_as<pt>(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<udouble> 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
}
50 changes: 28 additions & 22 deletions tests/cxx/unit/integrals/ao_integrals/test_uq_driver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand All @@ -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
Expand All @@ -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<test_pt>(braket);
auto T_corr = mm.at("UQ w/analytic Error").run_as<test_pt>(braket);
auto T = mm.at("UQ Driver").run_as<test_pt>(braket);

// std::cout << T << std::endl;
// std::cout << T_corr << std::endl;

// auto T_corr = corr_answer<float_type>(T);
// using tensorwrapper::operations::approximately_equal;
// REQUIRE(approximately_equal(T_corr, T, 1E-6));
auto T_corr = corr_answer<float_type>(T);
using tensorwrapper::operations::approximately_equal;
REQUIRE(approximately_equal(T_corr, T, 1E-6));
}
}
8 changes: 6 additions & 2 deletions tests/cxx/unit/integrals/testing/testing.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,10 +88,14 @@ inline auto h2_mos() {
return mos_type(simde::type::aos(h2_sto3g_basis_set()), std::move(c));
}

template<typename FloatType>
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<FloatType> 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());
}

Expand Down