-
Notifications
You must be signed in to change notification settings - Fork 1
Adds a UQ model for primitive screening #155
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
7a5d9eb
backup
ryanmrichard b31e89a
backukp
ryanmrichard e7841d6
backup
ryanmrichard 2b2732a
refactor estimator
ryanmrichard b445944
Merge branch 'master' into uq_model
ryanmrichard ff1ee5b
uses normalized coeffs, refactor testing infrastructure
ryanmrichard 2decb23
cs screening seems to work
ryanmrichard 374130f
backup
ryanmrichard 8814ac1
module for screening pairs
ryanmrichard e6cebb0
finally r2g
ryanmrichard 032709f
run precommit/add missing header
ryanmrichard 10bf4a7
ifdef protect sigma code
ryanmrichard 4fe81d9
blank lines for precommit
ryanmrichard a5609d2
address comments
ryanmrichard 9f1f55d
call utils::set_defaults
ryanmrichard File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,90 @@ | ||
| /* | ||
| * Copyright 2026 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 <simde/simde.hpp> | ||
|
|
||
| /* This example showcases how to: | ||
| * | ||
| * 1. Compute the analytic error in an ERI4 integral tensor owing to primitive | ||
| * pair screening. | ||
| */ | ||
|
|
||
| namespace { | ||
|
|
||
| // This makes a basis set for H2 (bond distance 1.40 a.u.) using STO-3G. | ||
| 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<double>; | ||
|
|
||
| point_t r0{0.0, 0.0, 0.0}; | ||
| point_t r1{0.0, 0.0, 1.40}; | ||
|
|
||
| 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; | ||
| } | ||
|
|
||
| } // namespace | ||
|
|
||
| // Property types for the ERI4 and the error in the ERI4 | ||
| using eri4_pt = simde::ERI4; | ||
| using eri4_error_pt = integrals::property_types::Uncertainty<eri4_pt>; | ||
|
|
||
| int main(int argc, char* argv[]) { | ||
| // Makes sure the environment doesn't go out of scope before the end. | ||
| auto rt = std::make_unique<parallelzone::runtime::RuntimeView>(); | ||
|
|
||
| // Initializes a ModuleManager object with the integrals plugin | ||
| pluginplay::ModuleManager mm(std::move(rt), nullptr); | ||
| integrals::load_modules(mm); | ||
| integrals::set_defaults(mm); | ||
|
|
||
| // Modules for computing analytic error and estimating error | ||
| auto& analytic_error_mod = mm.at("Analytic Error"); | ||
| auto& error_model = mm.at("Primitive Error Model"); | ||
|
|
||
| // Makes: basis set, direct product of the basis set, and 1/r12 operator | ||
| simde::type::aos aos(h2_sto3g_basis_set()); | ||
| simde::type::aos_squared aos2(aos, aos); | ||
| simde::type::v_ee_type op{}; | ||
|
|
||
| // Make BraKet | ||
| chemist::braket::BraKet mnls(aos2, op, aos2); | ||
|
|
||
| // Compute the error by screening with tolerance "tol" | ||
| double tol = 1E-10; | ||
| auto error = analytic_error_mod.run_as<eri4_error_pt>(mnls, tol); | ||
| auto approx_error = error_model.run_as<eri4_error_pt>(mnls, tol); | ||
|
|
||
| std::cout << "Analytic error: " << error << std::endl; | ||
| std::cout << "Estimated error: " << approx_error << std::endl; | ||
|
|
||
| return 0; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,56 @@ | ||
| /* | ||
| * Copyright 2026 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 <integrals/integrals.hpp> | ||
|
|
||
| namespace integrals::libint { | ||
| namespace { | ||
|
|
||
| const auto desc = "Uses the error in the ERI4 as the uncertainty."; | ||
| } | ||
|
|
||
| using eri4_pt = simde::ERI4; | ||
| using pt = integrals::property_types::Uncertainty<eri4_pt>; | ||
|
|
||
| MODULE_CTOR(AnalyticError) { | ||
| satisfies_property_type<pt>(); | ||
| description(desc); | ||
|
|
||
| add_submodule<eri4_pt>("ERI4s"); | ||
| } | ||
|
|
||
| MODULE_RUN(AnalyticError) { | ||
| const auto& [braket, tol] = pt::unwrap_inputs(inputs); | ||
|
|
||
| auto& eri_mod = submods.at("ERI4s"); | ||
|
|
||
| auto normal_mod = eri_mod.value().unlocked_copy(); | ||
| normal_mod.change_input("Threshold", tol); | ||
|
|
||
| // N.b., t_0 is the benchmark value | ||
| const auto& t_0 = eri_mod.run_as<eri4_pt>(braket); | ||
| const auto& t = normal_mod.run_as<eri4_pt>(braket); | ||
|
|
||
| simde::type::tensor error; | ||
| error("m,n,l,s") = t("m,n,l,s") - t_0("m,n,l,s"); | ||
|
|
||
| // Wrap and return the results | ||
| auto rv = results(); | ||
| return pt::wrap_results(rv, error); | ||
| } | ||
|
|
||
| } // namespace integrals::libint |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.