Skip to content
Merged
Show file tree
Hide file tree
Changes from 6 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
54 changes: 54 additions & 0 deletions src/integrals/ao_integrals/ao_integrals.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
/*
* 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);
DECLARE_MODULE(JDensityFitted);
DECLARE_MODULE(KDensityFitted);
DECLARE_MODULE(DFIntegral);
DECLARE_MODULE(CoulombMetric);

inline void set_defaults(pluginplay::ModuleManager& mm) {
mm.change_submod("AO integral driver", "Coulomb matrix",
"Four center J builder");
mm.change_submod("AO integral driver", "Exchange matrix",
"Four center K builder");
mm.change_submod("Density Fitted J builder", "DF ERI",
"Density Fitting Integral");
mm.change_submod("Density Fitted K builder", "DF ERI",
"Density Fitting Integral");
mm.change_submod("Density Fitting Integral", "Coulomb Metric",
"Coulomb Metric");
}

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");
mm.add_module<JDensityFitted>("Density Fitted J builder");
mm.add_module<KDensityFitted>("Density Fitted K builder");
mm.add_module<DFIntegral>("Density Fitting Integral");
mm.add_module<CoulombMetric>("Coulomb Metric");
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
51 changes: 51 additions & 0 deletions src/integrals/ao_integrals/coulomb_metric.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
/*
* Copyright 2025 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::ERI2;

namespace {

auto desc = R"(
Inverse Coulomb Metric
---------------------
)";

}

MODULE_CTOR(CoulombMetric) {
description(desc);
satisfies_property_type<pt>();
add_submodule<pt>("Two-center ERI");
}

MODULE_RUN(CoulombMetric) {
const auto& [braket] = pt::unwrap_inputs(inputs);
auto& eri2_mod = submods.at("Two-center ERI");

const auto& M = eri2_mod.run_as<pt>(braket);

// Cholesky Decomp


auto rv = results();
return pt::wrap_results(rv, M);
}

} // namespace integrals::ao_integrals
60 changes: 60 additions & 0 deletions src/integrals/ao_integrals/df_integral.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
/*
* Copyright 2025 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::ERI3;
using pt_2c = simde::ERI2;

namespace {

auto desc = R"(
Three-index ERI with Coulomb metric transformation
---------------------
)";

}

MODULE_CTOR(DFIntegral) {
description(desc);
satisfies_property_type<pt>();
add_submodule<pt>("Three-center ERI");
add_submodule<pt_2c>("Coulomb Metric");
}

MODULE_RUN(DFIntegral) {
const auto& [braket] = pt::unwrap_inputs(inputs);
auto bra = braket.bra();
auto ket = braket.ket();
auto& op = braket.op();
auto& eri2_mod = submods.at("Coulomb Metric");
auto& eri3_mod = submods.at("Three-center ERI");

chemist::braket::BraKet aux_v_aux(bra, op, bra);
const auto& M = eri2_mod.run_as<pt_2c>(aux_v_aux);
const auto& I = eri3_mod.run_as<pt>(braket);

// Failing at the moment
simde::type::tensor L;
// L.multiplication_assignment("i,k,l", M("i,j"), I("j,k,l"));

auto rv = results();
return pt::wrap_results(rv, std::move(L));
}

} // namespace integrals::ao_integrals
69 changes: 69 additions & 0 deletions src/integrals/ao_integrals/j_density_fitted.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
/*
* 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_3c = simde::ERI3;
using aos_t = simde::type::aos;

namespace {

auto desc = R"(
Density Fitted J Builder
---------------------
)";

}
MODULE_CTOR(JDensityFitted) {
description(desc);
satisfies_property_type<pt>();
add_submodule<pt_3c>("DF ERI");
add_input<aos_t>("Auxiliary Basis Set");
}

MODULE_RUN(JDensityFitted) {
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 aux = inputs.at("Auxiliary Basis Set").value<aos_t>();
auto& eri_mod = submods.at("DF 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 aux_v_ij(aux, v_ee, ij_pair);
chemist::braket::BraKet aux_v_kl(aux, v_ee, kl_pair);
const auto& I_akl = eri_mod.run_as<pt_3c>(std::move(aux_v_kl));
const auto& I_aij = eri_mod.run_as<pt_3c>(std::move(aux_v_ij));

simde::type::tensor temp, j;
// Failing at the moment
// temp.multiplication_assignment("a", p("k,l"), I_akl("a,k,l"));
// j.multiplication_assignment("i,j", temp("a"), I_aij("a,i,j"));

auto rv = results();
return pt::wrap_results(rv, std::move(j));
}

} // namespace integrals::ao_integrals
Loading