|
| 1 | +/* |
| 2 | + * Copyright 2026 NWChemEx-Project |
| 3 | + * |
| 4 | + * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | + * you may not use this file except in compliance with the License. |
| 6 | + * You may obtain a copy of the License at |
| 7 | + * |
| 8 | + * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | + * |
| 10 | + * Unless required by applicable law or agreed to in writing, software |
| 11 | + * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | + * See the License for the specific language governing permissions and |
| 14 | + * limitations under the License. |
| 15 | + */ |
| 16 | + |
| 17 | +#include <integrals/integrals.hpp> |
| 18 | +#include <simde/simde.hpp> |
| 19 | + |
| 20 | +/* This example showcases how to: |
| 21 | + * |
| 22 | + * 1. Compute the analytic error in an ERI4 integral tensor owing to primitive |
| 23 | + * pair screening. |
| 24 | + */ |
| 25 | + |
| 26 | +namespace { |
| 27 | + |
| 28 | +// This makes a basis set for H2 (bond distance 1.40 a.u.) using STO-3G. |
| 29 | +inline simde::type::ao_basis_set h2_sto3g_basis_set() { |
| 30 | + using ao_basis_t = simde::type::ao_basis_set; |
| 31 | + using atomic_basis_t = simde::type::atomic_basis_set; |
| 32 | + using cg_t = simde::type::contracted_gaussian; |
| 33 | + using point_t = simde::type::point; |
| 34 | + using doubles_t = std::vector<double>; |
| 35 | + |
| 36 | + point_t r0{0.0, 0.0, 0.0}; |
| 37 | + point_t r1{0.0, 0.0, 1.40}; |
| 38 | + |
| 39 | + doubles_t cs{0.1543289673, 0.5353281423, 0.4446345422}; |
| 40 | + doubles_t es{3.425250914, 0.6239137298, 0.1688554040}; |
| 41 | + cg_t cg0(cs.begin(), cs.end(), es.begin(), es.end(), r0); |
| 42 | + cg_t cg1(cs.begin(), cs.end(), es.begin(), es.end(), r1); |
| 43 | + atomic_basis_t h0("sto-3g", 1, r0); |
| 44 | + atomic_basis_t h1("sto-3g", 1, r1); |
| 45 | + h0.add_shell(chemist::ShellType::cartesian, 0, cg0); |
| 46 | + h1.add_shell(chemist::ShellType::cartesian, 0, cg1); |
| 47 | + |
| 48 | + ao_basis_t bs; |
| 49 | + bs.add_center(h0); |
| 50 | + bs.add_center(h1); |
| 51 | + return bs; |
| 52 | +} |
| 53 | + |
| 54 | +} // namespace |
| 55 | + |
| 56 | +// Property types for the ERI4 and the error in the ERI4 |
| 57 | +using eri4_pt = simde::ERI4; |
| 58 | +using eri4_error_pt = integrals::property_types::Uncertainty<eri4_pt>; |
| 59 | + |
| 60 | +int main(int argc, char* argv[]) { |
| 61 | + // Makes sure the environment doesn't go out of scope before the end. |
| 62 | + auto rt = std::make_unique<parallelzone::runtime::RuntimeView>(); |
| 63 | + |
| 64 | + // Initializes a ModuleManager object with the integrals plugin |
| 65 | + pluginplay::ModuleManager mm(std::move(rt), nullptr); |
| 66 | + integrals::load_modules(mm); |
| 67 | + integrals::set_defaults(mm); |
| 68 | + |
| 69 | + // Modules for computing analytic error and estimating error |
| 70 | + auto& analytic_error_mod = mm.at("Analytic Error"); |
| 71 | + auto& error_model = mm.at("Primitive Error Model"); |
| 72 | + |
| 73 | + // Makes: basis set, direct product of the basis set, and 1/r12 operator |
| 74 | + simde::type::aos aos(h2_sto3g_basis_set()); |
| 75 | + simde::type::aos_squared aos2(aos, aos); |
| 76 | + simde::type::v_ee_type op{}; |
| 77 | + |
| 78 | + // Make BraKet |
| 79 | + chemist::braket::BraKet mnls(aos2, op, aos2); |
| 80 | + |
| 81 | + // Compute the error by screening with tolerance "tol" |
| 82 | + double tol = 1E-10; |
| 83 | + auto error = analytic_error_mod.run_as<eri4_error_pt>(mnls, tol); |
| 84 | + auto approx_error = error_model.run_as<eri4_error_pt>(mnls, tol); |
| 85 | + |
| 86 | + std::cout << "Analytic error: " << error << std::endl; |
| 87 | + std::cout << "Estimated error: " << approx_error << std::endl; |
| 88 | + |
| 89 | + return 0; |
| 90 | +} |
0 commit comments