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
39 changes: 39 additions & 0 deletions src/integrals/ao_integrals/ao_integrals.hpp
Original file line number Diff line number Diff line change
@@ -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 <simde/simde.hpp>

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<AOIntegralsDriver>("AO integral driver");
mm.add_module<JFourCenter>("Four center J builder");
mm.add_module<KFourCenter>("Four center K builder");
set_defaults(mm);
}

} // namespace integrals::ao_integrals
106 changes: 106 additions & 0 deletions src/integrals/ao_integrals/ao_integrals_driver.cpp
Original file line number Diff line number Diff line change
@@ -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<t_e_pt>(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<v_en_pt>(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<j_e_pt>(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<k_e_pt>(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<pt>();
add_submodule<t_e_pt>("Kinetic");
add_submodule<v_en_pt>("Electron-Nuclear attraction");
add_submodule<j_e_pt>("Coulomb matrix");
add_submodule<k_e_pt>("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
61 changes: 61 additions & 0 deletions src/integrals/ao_integrals/j_four_center.cpp
Original file line number Diff line number Diff line change
@@ -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<pt>();
add_submodule<pt_4c>("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<pt_4c>(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
62 changes: 62 additions & 0 deletions src/integrals/ao_integrals/k_four_center.cpp
Original file line number Diff line number Diff line change
@@ -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<pt>();
add_submodule<pt_4c>("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<pt_4c>(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
10 changes: 8 additions & 2 deletions src/integrals/integrals_mm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
* limitations under the License.
*/

#include "ao_integrals/ao_integrals.hpp"
#include "libint/libint.hpp"
#include <integrals/integrals_mm.hpp>

Expand All @@ -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);
}

Expand Down
6 changes: 3 additions & 3 deletions src/integrals/libint/libint.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<LIBINT(bra, op, ket)>(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,
Expand All @@ -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
Expand Down
4 changes: 2 additions & 2 deletions src/integrals/libint/libint.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,15 +48,15 @@ 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
*
* @param mm The Module Manager with modules whose defaults will be set
*
* @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
Expand Down
Loading