From 4bb7465fd68eb07d8be2b2006b2de5d36a719950 Mon Sep 17 00:00:00 2001 From: Shuhang Li Date: Tue, 5 Mar 2024 09:53:01 -0500 Subject: [PATCH 01/55] First commit. --- forte/mrdsrg-spin-adapted/eom_dsrg.cc | 45 +++++++++++++++++++++++++++ forte/mrdsrg-spin-adapted/sa_mrdsrg.h | 4 ++- forte/mrdsrg-spin-adapted/sadsrg.h | 5 ++- 3 files changed, 52 insertions(+), 2 deletions(-) create mode 100644 forte/mrdsrg-spin-adapted/eom_dsrg.cc diff --git a/forte/mrdsrg-spin-adapted/eom_dsrg.cc b/forte/mrdsrg-spin-adapted/eom_dsrg.cc new file mode 100644 index 000000000..3bb6545e1 --- /dev/null +++ b/forte/mrdsrg-spin-adapted/eom_dsrg.cc @@ -0,0 +1,45 @@ +/* + * @BEGIN LICENSE + * + * Forte: an open-source plugin to Psi4 (https://github.com/psi4/psi4) + * that implements a variety of quantum chemistry methods for strongly + * correlated electrons. + * + * Copyright (c) 2012-2023 by its authors (see COPYING, COPYING.LESSER, + * AUTHORS). + * + * The copyrights for code used from other parties are included in + * the corresponding files. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see http://www.gnu.org/licenses/. + * + * @END LICENSE + */ + +#include "helpers/timer.h" +#include "sa_mrdsrg.h" +using namespace psi; +namespace forte { +ambit::BlockedTensor SA_MRDSRG::compute_eom_hbar() { + // IP singles. Should add foptions. + EOM_Hbar_ = BTF_->build(tensor_type_, "EOM-Hbar", {"hh"}, true); + + EOM_Hbar["mn"] = -Hbar1_["mn"]; + E0M_Hbar["mv"] = -Hbar1_["mu"] * L1_["uv"] + Hbar2_["mwuv"] * L2_["uvwx"]; + EOM_Hbar["wx"] = -Hbar1_["vu"] * L1_["ux"] * L1_["wv"] + Hbar1_["vu"] * L2_["uwvx"] + + 0.5 * Hbar2_["wxuv"] * L1_["yw"] * L2_["uvxz"] - + 0.5 * Hbar2_["wxuv"] * L1_["uz"] * L2_["uywx"] + + 0.25 * Hbar2_["wxuv"] * L3_["uvywxz"]; +} +} // namespace forte \ No newline at end of file diff --git a/forte/mrdsrg-spin-adapted/sa_mrdsrg.h b/forte/mrdsrg-spin-adapted/sa_mrdsrg.h index 3b4869e83..e1204ee88 100644 --- a/forte/mrdsrg-spin-adapted/sa_mrdsrg.h +++ b/forte/mrdsrg-spin-adapted/sa_mrdsrg.h @@ -160,6 +160,8 @@ class SA_MRDSRG : public SADSRG { void compute_hbar_sequential(); /// Compute DSRG-transformed Hamiltonian truncated to 2-nested commutator void compute_hbar_qc(); + /// Compute EOM-LDSRG2 hbar <\Psi|a_i^{\dagger} Hbar a_j|\Psi> + std::make_shared compute_eom_hbar(); /// Add H2's Hermitian conjugate to itself, H2 need to contain gGgG block void add_hermitian_conjugate(BlockedTensor& H2); @@ -188,7 +190,7 @@ class SA_MRDSRG : public SADSRG { /// Clean up for pointers used for DIIS void diis_manager_cleanup(); - /// Compute MR-LDSRG(2) + /// Compute MR-LDSRG(2)s double compute_energy_ldsrg2(); /// Compute DSRG-transformed multipoles diff --git a/forte/mrdsrg-spin-adapted/sadsrg.h b/forte/mrdsrg-spin-adapted/sadsrg.h index 6bb07bf55..8b53086cb 100644 --- a/forte/mrdsrg-spin-adapted/sadsrg.h +++ b/forte/mrdsrg-spin-adapted/sadsrg.h @@ -321,6 +321,9 @@ class SADSRG : public DynamicCorrelationSolver { /// DSRG transformed 3-body Hamiltonian (active only in DSRG-PT, but full in MRDSRG) ambit::BlockedTensor Hbar3_; + /// EOM-LDSRG2 Hamiltonian: + std::make_shared EOM_Hbar_; + /// Scalar of the DSRG transformed multipoles std::vector Mbar0_; /// DSRG transformed 1-body multipoles @@ -469,7 +472,7 @@ class SADSRG : public DynamicCorrelationSolver { /// Print the contents with padding: void print_contents(const std::string& str, size_t size = 45); /// Print done and timing - void print_done(double t, const std::string& done="Done"); + void print_done(double t, const std::string& done = "Done"); // ==> common amplitudes analysis and printing <== From 4f3f31fafe6f9d0946bca11f9bb81235a8d094dd Mon Sep 17 00:00:00 2001 From: Shuhang Li Date: Tue, 5 Mar 2024 11:25:56 -0500 Subject: [PATCH 02/55] Waiting for spin-adaptation. --- forte/mrdsrg-spin-adapted/eom_dsrg.cc | 38 +++++++++++++++++++++------ forte/mrdsrg-spin-adapted/sa_mrdsrg.h | 2 +- forte/mrdsrg-spin-adapted/sadsrg.h | 2 +- 3 files changed, 32 insertions(+), 10 deletions(-) diff --git a/forte/mrdsrg-spin-adapted/eom_dsrg.cc b/forte/mrdsrg-spin-adapted/eom_dsrg.cc index 3bb6545e1..59d73317e 100644 --- a/forte/mrdsrg-spin-adapted/eom_dsrg.cc +++ b/forte/mrdsrg-spin-adapted/eom_dsrg.cc @@ -31,15 +31,37 @@ #include "sa_mrdsrg.h" using namespace psi; namespace forte { -ambit::BlockedTensor SA_MRDSRG::compute_eom_hbar() { +std::shared_ptr SA_MRDSRG::compute_eom_hbar() { // IP singles. Should add foptions. - EOM_Hbar_ = BTF_->build(tensor_type_, "EOM-Hbar", {"hh"}, true); - - EOM_Hbar["mn"] = -Hbar1_["mn"]; - E0M_Hbar["mv"] = -Hbar1_["mu"] * L1_["uv"] + Hbar2_["mwuv"] * L2_["uvwx"]; + size_t nhole = mo_space_info_->dimension("GENERALIZED HOLE").sum(); + size_t nocc = mo_space_info_->dimension("RESTRICTED_DOCC").sum(); + size_t nact = mo_space_info_->dimension("ACTIVE").sum(); + ambit::BlockedTensor EOM_Hbar = BTF_->build(tensor_type_, "EOM-Hbar", {"hh"}, true); + EOM_Hbar_mat_ = std::make_shared("EOM-Hbar-Matrx", nhole, nhole); + /// Should do spin adaptation. + EOM_Hbar["nm"] = -Hbar1_["nm"]; + E0M_Hbar["mv"] = -Hbar1_["mu"] * L1_["uv"] + Hbar2_["mwux"] * L2_["uxwv"]; EOM_Hbar["wx"] = -Hbar1_["vu"] * L1_["ux"] * L1_["wv"] + Hbar1_["vu"] * L2_["uwvx"] + - 0.5 * Hbar2_["wxuv"] * L1_["yw"] * L2_["uvxz"] - - 0.5 * Hbar2_["wxuv"] * L1_["uz"] * L2_["uywx"] + - 0.25 * Hbar2_["wxuv"] * L3_["uvywxz"]; + 0.5 * Hbar2_["yzuv"] * L1_["wy"] * L2_["uvzx"] - + 0.5 * Hbar2_["yzuv"] * L1_["vx"] * L2_["uwyz"] + + 0.25 * Hbar2_["yzuv"] * L3_["uvwyzx"]; + + EOM_Hbar.iterate([&](const std::vector& i, double& value) { + EOM_Hbar_mat_->set(i[0], i[1], value); + }); + + /// Overlap matrix + std::shared_ptr S = std::make_shared("EOM-S-sub", nhole, nhole); + std::shared_ptr Sevec = std::make_shared("S-evec", nhole, nhole); + std::shared_ptr Seval = std::make_shared("S-eval", nhole); + S->identity(); + L1_.iterate([&](const std::vector& i, double& value) { + S->set(i[0] + nocc, i[1] + nocc, value); + }); + S->diagonalize(Sevec, Seval); + + EOM_Hbar_mat_ = Sevec->transpose() * EOM_Hbar_mat_ * Sevec; + + return EOM_Hbar_mat_; } } // namespace forte \ No newline at end of file diff --git a/forte/mrdsrg-spin-adapted/sa_mrdsrg.h b/forte/mrdsrg-spin-adapted/sa_mrdsrg.h index e1204ee88..daa9698a1 100644 --- a/forte/mrdsrg-spin-adapted/sa_mrdsrg.h +++ b/forte/mrdsrg-spin-adapted/sa_mrdsrg.h @@ -161,7 +161,7 @@ class SA_MRDSRG : public SADSRG { /// Compute DSRG-transformed Hamiltonian truncated to 2-nested commutator void compute_hbar_qc(); /// Compute EOM-LDSRG2 hbar <\Psi|a_i^{\dagger} Hbar a_j|\Psi> - std::make_shared compute_eom_hbar(); + std::shared_ptr compute_eom_hbar(); /// Add H2's Hermitian conjugate to itself, H2 need to contain gGgG block void add_hermitian_conjugate(BlockedTensor& H2); diff --git a/forte/mrdsrg-spin-adapted/sadsrg.h b/forte/mrdsrg-spin-adapted/sadsrg.h index 8b53086cb..986211330 100644 --- a/forte/mrdsrg-spin-adapted/sadsrg.h +++ b/forte/mrdsrg-spin-adapted/sadsrg.h @@ -322,7 +322,7 @@ class SADSRG : public DynamicCorrelationSolver { ambit::BlockedTensor Hbar3_; /// EOM-LDSRG2 Hamiltonian: - std::make_shared EOM_Hbar_; + std::shared_ptr EOM_Hbar_mat_; /// Scalar of the DSRG transformed multipoles std::vector Mbar0_; From 5967d57a66c0cb7016bdc7a19c4006028052698a Mon Sep 17 00:00:00 2001 From: Shuhang Li Date: Tue, 5 Mar 2024 13:51:10 -0500 Subject: [PATCH 03/55] Waiting for Spin-adaptation. --- forte/CMakeLists.txt | 1 + forte/mrdsrg-spin-adapted/eom_dsrg.cc | 32 +++++++++++++++----------- forte/mrdsrg-spin-adapted/sa_ldsrg2.cc | 7 ++++++ forte/mrdsrg-spin-adapted/sa_mrdsrg.h | 4 ++-- forte/register_forte_options.py | 2 ++ 5 files changed, 30 insertions(+), 16 deletions(-) diff --git a/forte/CMakeLists.txt b/forte/CMakeLists.txt index 80740d8b0..0a440ed05 100644 --- a/forte/CMakeLists.txt +++ b/forte/CMakeLists.txt @@ -168,6 +168,7 @@ mrdsrg-spin-adapted/sa_mrdsrg_diis.cc mrdsrg-spin-adapted/sa_mrpt2.cc mrdsrg-spin-adapted/sa_mrpt2_oeprop.cc mrdsrg-spin-adapted/sa_mrpt3.cc +mrdsrg-spin-adapted/eom_dsrg.cc mrdsrg-spin-integrated/dsrg_mrpt2.cc mrdsrg-spin-integrated/dsrg_mrpt2_grad/dsrg_mrpt2_gradient.cc mrdsrg-spin-integrated/dsrg_mrpt2_grad/dsrg_mrpt2_deriv_write_rdms.cc diff --git a/forte/mrdsrg-spin-adapted/eom_dsrg.cc b/forte/mrdsrg-spin-adapted/eom_dsrg.cc index 59d73317e..96bb7f06e 100644 --- a/forte/mrdsrg-spin-adapted/eom_dsrg.cc +++ b/forte/mrdsrg-spin-adapted/eom_dsrg.cc @@ -31,37 +31,41 @@ #include "sa_mrdsrg.h" using namespace psi; namespace forte { -std::shared_ptr SA_MRDSRG::compute_eom_hbar() { +double SA_MRDSRG::compute_eom() { // IP singles. Should add foptions. size_t nhole = mo_space_info_->dimension("GENERALIZED HOLE").sum(); size_t nocc = mo_space_info_->dimension("RESTRICTED_DOCC").sum(); size_t nact = mo_space_info_->dimension("ACTIVE").sum(); - ambit::BlockedTensor EOM_Hbar = BTF_->build(tensor_type_, "EOM-Hbar", {"hh"}, true); + auto EOM_Hbar = BTF_->build(tensor_type_, "EOM-Hbar", {"hh"}, true); EOM_Hbar_mat_ = std::make_shared("EOM-Hbar-Matrx", nhole, nhole); + /// Should do spin adaptation. - EOM_Hbar["nm"] = -Hbar1_["nm"]; - E0M_Hbar["mv"] = -Hbar1_["mu"] * L1_["uv"] + Hbar2_["mwux"] * L2_["uxwv"]; - EOM_Hbar["wx"] = -Hbar1_["vu"] * L1_["ux"] * L1_["wv"] + Hbar1_["vu"] * L2_["uwvx"] + - 0.5 * Hbar2_["yzuv"] * L1_["wy"] * L2_["uvzx"] - - 0.5 * Hbar2_["yzuv"] * L1_["vx"] * L2_["uwyz"] + - 0.25 * Hbar2_["yzuv"] * L3_["uvwyzx"]; + EOM_Hbar["nm"] -= Hbar1_["nm"]; + // EOM_Hbar["mv"] = -Hbar1_["mu"] * L1_["uv"] + Hbar2_["mwux"] * L2_["uxwv"]; + // EOM_Hbar["wx"] = -Hbar1_["vu"] * L1_["ux"] * L1_["wv"] + Hbar1_["vu"] * L2_["uwvx"] + + // 0.5 * Hbar2_["yzuv"] * L1_["wy"] * L2_["uvzx"] - + // 0.5 * Hbar2_["yzuv"] * L1_["vx"] * L2_["uwyz"] + + // 0.25 * Hbar2_["yzuv"] * L3_["uvwyzx"]; - EOM_Hbar.iterate([&](const std::vector& i, double& value) { - EOM_Hbar_mat_->set(i[0], i[1], value); - }); + EOM_Hbar.iterate([&](const std::vector& i, const std::vector&, + double& value) { EOM_Hbar_mat_->set(i[0], i[1], value); }); /// Overlap matrix std::shared_ptr S = std::make_shared("EOM-S-sub", nhole, nhole); std::shared_ptr Sevec = std::make_shared("S-evec", nhole, nhole); std::shared_ptr Seval = std::make_shared("S-eval", nhole); S->identity(); - L1_.iterate([&](const std::vector& i, double& value) { + L1_.iterate([&](const std::vector& i, const std::vector&, double& value) { S->set(i[0] + nocc, i[1] + nocc, value); }); S->diagonalize(Sevec, Seval); - EOM_Hbar_mat_ = Sevec->transpose() * EOM_Hbar_mat_ * Sevec; + EOM_Hbar_mat_ = psi::linalg::triplet(Sevec, EOM_Hbar_mat_, Sevec, true, false, false); + + EOM_Hbar_mat_->diagonalize(Sevec, Seval); + + Seval->print(); - return EOM_Hbar_mat_; + return Seval->get(0); } } // namespace forte \ No newline at end of file diff --git a/forte/mrdsrg-spin-adapted/sa_ldsrg2.cc b/forte/mrdsrg-spin-adapted/sa_ldsrg2.cc index 80be91312..a9f5c5770 100644 --- a/forte/mrdsrg-spin-adapted/sa_ldsrg2.cc +++ b/forte/mrdsrg-spin-adapted/sa_ldsrg2.cc @@ -183,6 +183,13 @@ double SA_MRDSRG::compute_energy_ldsrg2() { final.stop(); Hbar0_ = Ecorr; + + bool do_eom = false; + do_eom = foptions_->get_bool("DO_EOM"); + if (do_eom) { + Ecorr = compute_eom(); + } + return Ecorr; } diff --git a/forte/mrdsrg-spin-adapted/sa_mrdsrg.h b/forte/mrdsrg-spin-adapted/sa_mrdsrg.h index daa9698a1..5e7cd200f 100644 --- a/forte/mrdsrg-spin-adapted/sa_mrdsrg.h +++ b/forte/mrdsrg-spin-adapted/sa_mrdsrg.h @@ -160,8 +160,8 @@ class SA_MRDSRG : public SADSRG { void compute_hbar_sequential(); /// Compute DSRG-transformed Hamiltonian truncated to 2-nested commutator void compute_hbar_qc(); - /// Compute EOM-LDSRG2 hbar <\Psi|a_i^{\dagger} Hbar a_j|\Psi> - std::shared_ptr compute_eom_hbar(); + /// Compute EOM-LDSRG2 + double compute_eom(); /// Add H2's Hermitian conjugate to itself, H2 need to contain gGgG block void add_hermitian_conjugate(BlockedTensor& H2); diff --git a/forte/register_forte_options.py b/forte/register_forte_options.py index 833e0b8d9..28e83cf0e 100644 --- a/forte/register_forte_options.py +++ b/forte/register_forte_options.py @@ -637,6 +637,8 @@ def register_dsrg_options(options): "LDSRG2_P3 and QDSRG2_P3 not implemented)" ) + options.add_bool("DO_EOM", False) + options.add_str( "SOURCE", "STANDARD", ["STANDARD", "LABS", "DYSON", "AMP", "EMP2", "LAMP", "LEMP2"], "Source operator used in DSRG (AMP, EMP2, LAMP, LEMP2 " From f915f40c92e19f597244282097e7e7f44927dcff Mon Sep 17 00:00:00 2001 From: Shuhang Li Date: Fri, 15 Mar 2024 15:04:07 -0400 Subject: [PATCH 04/55] First ionization. Spin orbital --- forte/mrdsrg-so/mrdsrg_so.cc | 67 +++++++++++++++++++++++++++++++++ forte/mrdsrg-so/mrdsrg_so.h | 2 + forte/register_forte_options.py | 2 - 3 files changed, 69 insertions(+), 2 deletions(-) diff --git a/forte/mrdsrg-so/mrdsrg_so.cc b/forte/mrdsrg-so/mrdsrg_so.cc index 73d4821f3..cde580e19 100644 --- a/forte/mrdsrg-so/mrdsrg_so.cc +++ b/forte/mrdsrg-so/mrdsrg_so.cc @@ -33,6 +33,9 @@ #include "psi4/libpsi4util/process.h" #include "psi4/libmints/molecule.h" +#include "psi4/libmints/matrix.h" +#include "psi4/libmints/vector.h" + #include "integrals/active_space_integrals.h" #include "base_classes/mo_space_info.h" #include "base_classes/state_info.h" @@ -50,6 +53,7 @@ MRDSRG_SO::MRDSRG_SO(std::shared_ptr rdms, std::shared_ptr scf_in std::shared_ptr mo_space_info) : DynamicCorrelationSolver(rdms, scf_info, options, ints, mo_space_info), BTF_(std::make_shared()), tensor_type_(ambit::CoreTensor) { + BlockedTensor::reset_mo_spaces(); print_method_banner( {"SO-Based Multireference Driven Similarity Renormalization Group", "Chenyang Li"}); startup(); @@ -639,11 +643,74 @@ double MRDSRG_SO::compute_energy() { outfile->Printf("\n\n\n MR-DSRG(2) correlation energy = %25.15f", Etotal - Eref); outfile->Printf("\n * MR-DSRG(2) total energy = %25.15f\n", Etotal); + compute_eom(); + psi::Process::environment.globals["CURRENT ENERGY"] = Etotal; return Etotal; } +double MRDSRG_SO::compute_eom() { + // IP singles + size_t ncore = nc_ / 2; + size_t nactv = na_ / 2; + + auto EOM_Hbar = BTF_->build(tensor_type_, "EOM-Hbar", {"hh"}); + std::shared_ptr EOM_Hbar_mat_ = + std::make_shared("EOM-Hbar-Matrx", nh_, nh_); + + EOM_Hbar["nm"] = -Hbar1["nm"]; + EOM_Hbar["mv"] = -Hbar1["mu"] * Gamma1["uv"]; + EOM_Hbar["mv"] += 0.5 * Hbar2["mwux"] * Lambda2["uxwv"]; + EOM_Hbar["vm"] = EOM_Hbar["mv"]; + EOM_Hbar["wx"] = -Hbar1["vu"] * Gamma1["ux"] * Gamma1["wv"]; + EOM_Hbar["wx"] += Hbar1["vu"] * Lambda2["uwvx"]; + EOM_Hbar["wx"] += 0.5 * Hbar2["yzuv"] * Gamma1["wy"] * Lambda2["uvzx"]; + EOM_Hbar["wx"] -= 0.5 * Hbar2["yzuv"] * Gamma1["vx"] * Lambda2["uwyz"]; + EOM_Hbar["wx"] += 0.25 * Hbar2["yzuv"] * Lambda3["uvwyzx"]; + + EOM_Hbar.iterate([&](const std::vector& i, const std::vector&, + double& value) { EOM_Hbar_mat_->set(i[0], i[1], value); }); + + /// Overlap matrix + std::shared_ptr S = std::make_shared("EOM-S-sub", nh_, nh_); + std::shared_ptr Sevec = std::make_shared("S-evec", nh_, nh_); + std::shared_ptr Seval = std::make_shared("S-eval", nh_); + std::shared_ptr Eevec = std::make_shared("E-evec", nh_, nh_); + std::shared_ptr Eeval = std::make_shared("E-eval", nh_); + S->identity(); + S->print(); + (rdms_->g1a()).citerate([&](const std::vector& i, const double& value) { + S->set(i[0] + ncore, i[1] + ncore, value); + }); + (rdms_->g1b()).citerate([&](const std::vector& i, const double& value) { + std::cout << value << std::endl; + S->set(i[0] + 2 * ncore + nactv, i[1] + 2 * ncore + nactv, value); + }); + S->print(); + S->diagonalize(Sevec, Seval); + + for (size_t i = 0; i < Sevec->coldim(); i++) { + for (size_t j = 0; j < Sevec->rowdim(); j++) { + double value = Sevec->get(j, i) / std::sqrt(Seval->get(i)); + Sevec->set(j, i, value); + } + } + + EOM_Hbar_mat_ = psi::linalg::triplet(Sevec, EOM_Hbar_mat_, Sevec, true, false, false); + + EOM_Hbar_mat_->diagonalize(Eevec, Eeval); + + outfile->Printf("\n " + "----------------------------------------------------------" + "----------------------------------------"); + outfile->Printf("\n\n\n EOM-DSRG "); + + Eeval->print(); + + return Eeval->get(0); +} + void MRDSRG_SO::compute_hbar() { // outfile->Printf("\n\n Computing the similarity-transformed diff --git a/forte/mrdsrg-so/mrdsrg_so.h b/forte/mrdsrg-so/mrdsrg_so.h index 57225e1dc..1424e5355 100644 --- a/forte/mrdsrg-so/mrdsrg_so.h +++ b/forte/mrdsrg-so/mrdsrg_so.h @@ -279,6 +279,8 @@ class MRDSRG_SO : public DynamicCorrelationSolver { /// Compute the DSRG-MRPT2 energy double compute_energy(); + double compute_eom(); + /// DSRG transformed Hamiltonian (not implemented) std::shared_ptr compute_Heff_actv(); diff --git a/forte/register_forte_options.py b/forte/register_forte_options.py index 28e83cf0e..833e0b8d9 100644 --- a/forte/register_forte_options.py +++ b/forte/register_forte_options.py @@ -637,8 +637,6 @@ def register_dsrg_options(options): "LDSRG2_P3 and QDSRG2_P3 not implemented)" ) - options.add_bool("DO_EOM", False) - options.add_str( "SOURCE", "STANDARD", ["STANDARD", "LABS", "DYSON", "AMP", "EMP2", "LAMP", "LEMP2"], "Source operator used in DSRG (AMP, EMP2, LAMP, LEMP2 " From 3ad7579760620ccd9747f06d410468535a84ba67 Mon Sep 17 00:00:00 2001 From: Shuhang Li Date: Mon, 18 Mar 2024 15:46:45 -0400 Subject: [PATCH 05/55] Spin-integration. No Cu3. --- forte/mrdsrg-spin-adapted/eom_dsrg.cc | 70 ++++++------ forte/mrdsrg-spin-adapted/sa_ldsrg2.cc | 10 +- forte/mrdsrg-spin-adapted/sa_mrdsrg.h | 4 +- forte/mrdsrg-spin-adapted/sadsrg.h | 4 +- forte/mrdsrg-spin-integrated/mrdsrg.cc | 7 ++ forte/mrdsrg-spin-integrated/mrdsrg.h | 3 + forte/mrdsrg-spin-integrated/mrdsrg_nonpt.cc | 106 +++++++++++++++++++ forte/register_forte_options.py | 2 + 8 files changed, 162 insertions(+), 44 deletions(-) diff --git a/forte/mrdsrg-spin-adapted/eom_dsrg.cc b/forte/mrdsrg-spin-adapted/eom_dsrg.cc index 96bb7f06e..b879ef3ed 100644 --- a/forte/mrdsrg-spin-adapted/eom_dsrg.cc +++ b/forte/mrdsrg-spin-adapted/eom_dsrg.cc @@ -27,45 +27,45 @@ * @END LICENSE */ -#include "helpers/timer.h" -#include "sa_mrdsrg.h" -using namespace psi; -namespace forte { -double SA_MRDSRG::compute_eom() { - // IP singles. Should add foptions. - size_t nhole = mo_space_info_->dimension("GENERALIZED HOLE").sum(); - size_t nocc = mo_space_info_->dimension("RESTRICTED_DOCC").sum(); - size_t nact = mo_space_info_->dimension("ACTIVE").sum(); - auto EOM_Hbar = BTF_->build(tensor_type_, "EOM-Hbar", {"hh"}, true); - EOM_Hbar_mat_ = std::make_shared("EOM-Hbar-Matrx", nhole, nhole); +// #include "helpers/timer.h" +// #include "sa_mrdsrg.h" +// using namespace psi; +// namespace forte { +// double SA_MRDSRG::compute_eom() { +// // IP singles. Should add foptions. +// size_t nhole = mo_space_info_->dimension("GENERALIZED HOLE").sum(); +// size_t nocc = mo_space_info_->dimension("RESTRICTED_DOCC").sum(); +// size_t nact = mo_space_info_->dimension("ACTIVE").sum(); +// auto EOM_Hbar = BTF_->build(tensor_type_, "EOM-Hbar", {"hh"}, true); +// EOM_Hbar_mat_ = std::make_shared("EOM-Hbar-Matrx", nhole, nhole); - /// Should do spin adaptation. - EOM_Hbar["nm"] -= Hbar1_["nm"]; - // EOM_Hbar["mv"] = -Hbar1_["mu"] * L1_["uv"] + Hbar2_["mwux"] * L2_["uxwv"]; - // EOM_Hbar["wx"] = -Hbar1_["vu"] * L1_["ux"] * L1_["wv"] + Hbar1_["vu"] * L2_["uwvx"] + - // 0.5 * Hbar2_["yzuv"] * L1_["wy"] * L2_["uvzx"] - - // 0.5 * Hbar2_["yzuv"] * L1_["vx"] * L2_["uwyz"] + - // 0.25 * Hbar2_["yzuv"] * L3_["uvwyzx"]; +// /// Should do spin adaptation. +// EOM_Hbar["nm"] -= Hbar1_["nm"]; +// // EOM_Hbar["mv"] = -Hbar1_["mu"] * L1_["uv"] + Hbar2_["mwux"] * L2_["uxwv"]; +// // EOM_Hbar["wx"] = -Hbar1_["vu"] * L1_["ux"] * L1_["wv"] + Hbar1_["vu"] * L2_["uwvx"] + +// // 0.5 * Hbar2_["yzuv"] * L1_["wy"] * L2_["uvzx"] - +// // 0.5 * Hbar2_["yzuv"] * L1_["vx"] * L2_["uwyz"] + +// // 0.25 * Hbar2_["yzuv"] * L3_["uvwyzx"]; - EOM_Hbar.iterate([&](const std::vector& i, const std::vector&, - double& value) { EOM_Hbar_mat_->set(i[0], i[1], value); }); +// EOM_Hbar.iterate([&](const std::vector& i, const std::vector&, +// double& value) { EOM_Hbar_mat_->set(i[0], i[1], value); }); - /// Overlap matrix - std::shared_ptr S = std::make_shared("EOM-S-sub", nhole, nhole); - std::shared_ptr Sevec = std::make_shared("S-evec", nhole, nhole); - std::shared_ptr Seval = std::make_shared("S-eval", nhole); - S->identity(); - L1_.iterate([&](const std::vector& i, const std::vector&, double& value) { - S->set(i[0] + nocc, i[1] + nocc, value); - }); - S->diagonalize(Sevec, Seval); +// /// Overlap matrix +// std::shared_ptr S = std::make_shared("EOM-S-sub", nhole, nhole); +// std::shared_ptr Sevec = std::make_shared("S-evec", nhole, nhole); +// std::shared_ptr Seval = std::make_shared("S-eval", nhole); +// S->identity(); +// L1_.iterate([&](const std::vector& i, const std::vector&, double& value) { +// S->set(i[0] + nocc, i[1] + nocc, value); +// }); +// S->diagonalize(Sevec, Seval); - EOM_Hbar_mat_ = psi::linalg::triplet(Sevec, EOM_Hbar_mat_, Sevec, true, false, false); +// EOM_Hbar_mat_ = psi::linalg::triplet(Sevec, EOM_Hbar_mat_, Sevec, true, false, false); - EOM_Hbar_mat_->diagonalize(Sevec, Seval); +// EOM_Hbar_mat_->diagonalize(Sevec, Seval); - Seval->print(); +// Seval->print(); - return Seval->get(0); -} -} // namespace forte \ No newline at end of file +// return Seval->get(0); +// } +// } // namespace forte \ No newline at end of file diff --git a/forte/mrdsrg-spin-adapted/sa_ldsrg2.cc b/forte/mrdsrg-spin-adapted/sa_ldsrg2.cc index a9f5c5770..a6f0ff09b 100644 --- a/forte/mrdsrg-spin-adapted/sa_ldsrg2.cc +++ b/forte/mrdsrg-spin-adapted/sa_ldsrg2.cc @@ -184,11 +184,11 @@ double SA_MRDSRG::compute_energy_ldsrg2() { Hbar0_ = Ecorr; - bool do_eom = false; - do_eom = foptions_->get_bool("DO_EOM"); - if (do_eom) { - Ecorr = compute_eom(); - } + // bool do_eom = false; + // do_eom = foptions_->get_bool("DO_EOM"); + // if (do_eom) { + // Ecorr = compute_eom(); + // } return Ecorr; } diff --git a/forte/mrdsrg-spin-adapted/sa_mrdsrg.h b/forte/mrdsrg-spin-adapted/sa_mrdsrg.h index 5e7cd200f..e8e60d9cd 100644 --- a/forte/mrdsrg-spin-adapted/sa_mrdsrg.h +++ b/forte/mrdsrg-spin-adapted/sa_mrdsrg.h @@ -160,8 +160,8 @@ class SA_MRDSRG : public SADSRG { void compute_hbar_sequential(); /// Compute DSRG-transformed Hamiltonian truncated to 2-nested commutator void compute_hbar_qc(); - /// Compute EOM-LDSRG2 - double compute_eom(); + // /// Compute EOM-LDSRG2 + // double compute_eom(); /// Add H2's Hermitian conjugate to itself, H2 need to contain gGgG block void add_hermitian_conjugate(BlockedTensor& H2); diff --git a/forte/mrdsrg-spin-adapted/sadsrg.h b/forte/mrdsrg-spin-adapted/sadsrg.h index 986211330..0bfff57bc 100644 --- a/forte/mrdsrg-spin-adapted/sadsrg.h +++ b/forte/mrdsrg-spin-adapted/sadsrg.h @@ -321,8 +321,8 @@ class SADSRG : public DynamicCorrelationSolver { /// DSRG transformed 3-body Hamiltonian (active only in DSRG-PT, but full in MRDSRG) ambit::BlockedTensor Hbar3_; - /// EOM-LDSRG2 Hamiltonian: - std::shared_ptr EOM_Hbar_mat_; + // /// EOM-LDSRG2 Hamiltonian: + // std::shared_ptr EOM_Hbar_mat_; /// Scalar of the DSRG transformed multipoles std::vector Mbar0_; diff --git a/forte/mrdsrg-spin-integrated/mrdsrg.cc b/forte/mrdsrg-spin-integrated/mrdsrg.cc index be4cb6b2e..56d88d161 100644 --- a/forte/mrdsrg-spin-integrated/mrdsrg.cc +++ b/forte/mrdsrg-spin-integrated/mrdsrg.cc @@ -334,6 +334,13 @@ double MRDSRG::compute_energy() { switch (corrlevelmap[corrlv_string_]) { case CORR_LV::LDSRG2: { Etotal += compute_energy_ldsrg2(); + + bool do_eom = false; + do_eom = foptions_->get_bool("DO_EOM"); + if (do_eom) { + compute_eom(); + } + break; } case CORR_LV::LDSRG2_QC: { diff --git a/forte/mrdsrg-spin-integrated/mrdsrg.h b/forte/mrdsrg-spin-integrated/mrdsrg.h index b31fbb29f..2686d183a 100644 --- a/forte/mrdsrg-spin-integrated/mrdsrg.h +++ b/forte/mrdsrg-spin-integrated/mrdsrg.h @@ -348,6 +348,9 @@ class MRDSRG : public MASTER_DSRG { /// Compute MR-LDSRG(2) double compute_energy_ldsrg2(); + /// Compute EOM-LDSRG(2) + void compute_eom(); + /// Zeroth-order Hamiltonian ambit::BlockedTensor H0th_; /// DSRG-MRPT2 zeroth-order Hamiltonian diff --git a/forte/mrdsrg-spin-integrated/mrdsrg_nonpt.cc b/forte/mrdsrg-spin-integrated/mrdsrg_nonpt.cc index f4eb669c4..ac9f46f97 100644 --- a/forte/mrdsrg-spin-integrated/mrdsrg_nonpt.cc +++ b/forte/mrdsrg-spin-integrated/mrdsrg_nonpt.cc @@ -836,6 +836,112 @@ double MRDSRG::compute_energy_ldsrg2() { return Ecorr; } +void MRDSRG::compute_eom() { + // IP singles + size_t ncore = core_mos_.size(); + size_t nactv = actv_mos_.size(); + size_t nh = ncore + nactv; + + ambit::BlockedTensor EOM_Hbar = BTF_->build(tensor_type_, "EOM-Hbar", spin_cases({"hh"})); + ambit::BlockedTensor S = BTF_->build(tensor_type_, "S", spin_cases({"hh"})); + S["uv"] = Gamma1_["uv"]; + S["UV"] = Gamma1_["UV"]; + (S.block("cc")).iterate([&](const std::vector& i, double& value) { + value = (i[0] == i[1] ? 1.0 : 0.0); + }); + (S.block("CC")).iterate([&](const std::vector& i, double& value) { + value = (i[0] == i[1] ? 1.0 : 0.0); + }); + std::shared_ptr EOM_Hbar_mat_ = + std::make_shared("EOM-Hbar-Matrx", 2 * nh, 2 * nh); // Spin orbital. + + // The first term + EOM_Hbar["nm"] = -Hbar1_["nm"]; + EOM_Hbar["NM"] = -Hbar1_["NM"]; + // The second term + EOM_Hbar["mv"] = -Hbar1_["mu"] * Gamma1_["uv"]; + EOM_Hbar["mv"] += 0.5 * Hbar2_["mwux"] * Lambda2_["uxwv"]; + EOM_Hbar["mv"] -= Hbar2_["mWuX"] * Lambda2_["uXvW"]; + EOM_Hbar["vm"] = EOM_Hbar["mv"]; + + EOM_Hbar["MV"] = -Hbar1_["MU"] * Gamma1_["UV"]; + EOM_Hbar["MV"] += 0.5 * Hbar2_["MWUX"] * Lambda2_["UXWV"]; + EOM_Hbar["MV"] -= Hbar2_["wMxU"] * Lambda2_["xUwV"]; + EOM_Hbar["VM"] = EOM_Hbar["MV"]; + + // The third term + EOM_Hbar["wx"] = Hbar1_["vu"] * Gamma1_["ux"] * Gamma1_["wv"]; + EOM_Hbar["wx"] += Hbar1_["vu"] * Lambda2_["uwvx"]; + EOM_Hbar["wx"] += Hbar1_["VU"] * Lambda2_["wUxV"]; + EOM_Hbar["wx"] += 0.5 * Hbar2_["yzuv"] * Gamma1_["wy"] * Lambda2_["uvzx"]; + EOM_Hbar["wx"] -= Hbar2_["yZvU"] * Gamma1_["wy"] * Lambda2_["vUxZ"]; + EOM_Hbar["wx"] -= 0.5 * Hbar2_["yzuv"] * Gamma1_["vx"] * Lambda2_["uwyz"]; + EOM_Hbar["wx"] -= Hbar2_["zYvU"] * Gamma1_["vx"] * Lambda2_["wUzY"]; + // EOM_Hbar["wx"] += 0.25 * Hbar2_.block("aaaa")("yzuv") * L3aaa_("uvwyzx"); + // auto temp2 = 0.25 * Hbar2_.block("AAAA")("YZUV") * L3abb_("wUVxYZ"); + // auto temp3 = 0.5 * Hbar2_.block("aAaA")("yZuV") * L3aab_("uwVyxZ"); + // // EOM_Hbar["wx"] = temp1; + // // EOM_Hbar["wx"] += temp2; + // // EOM_Hbar["wx"] += temp3; + + EOM_Hbar["WX"] = Hbar1_["VU"] * Gamma1_["UX"] * Gamma1_["WV"]; + EOM_Hbar["WX"] += Hbar1_["VU"] * Lambda2_["UWVX"]; + EOM_Hbar["WX"] += Hbar1_["vu"] * Lambda2_["uWvX"]; + EOM_Hbar["WX"] += 0.5 * Hbar2_["YZUV"] * Gamma1_["WY"] * Lambda2_["UVZX"]; + EOM_Hbar["WX"] -= Hbar2_["zYuV"] * Gamma1_["WY"] * Lambda2_["uVzX"]; + EOM_Hbar["WX"] -= 0.5 * Hbar2_["YZUV"] * Gamma1_["VX"] * Lambda2_["UWYZ"]; + EOM_Hbar["WX"] -= Hbar2_["yZuV"] * Gamma1_["VX"] * Lambda2_["uWyZ"]; + // EOM_Hbar["WX"] += 0.25 * Hbar2_["YZUV"] * L3bbb_("UVWYZX"); + // EOM_Hbar["WX"] += 0.25 * Hbar2_["yzuv"] * L3aab_("uvWyzX"); + // EOM_Hbar["WX"] += 0.5 * Hbar2_["zYvU"] * L3abb_("vUWzYX"); + + EOM_Hbar.iterate( + [&](const std::vector& i, const std::vector& spin, double& value) { + if ((spin[0] == AlphaSpin) && (spin[1] == AlphaSpin)) { + EOM_Hbar_mat_->set(i[0], i[1], value); + } else if ((spin[0] == BetaSpin) && (spin[1] == BetaSpin)) { + EOM_Hbar_mat_->set(i[0] + nh, i[1] + nh, value); + } + }); + + /// Overlap matrix + std::shared_ptr S_mat = std::make_shared("EOM-S-sub", 2 * nh, 2 * nh); + std::shared_ptr Sevec = std::make_shared("S-evec", 2 * nh, 2 * nh); + std::shared_ptr Seval = std::make_shared("S-eval", 2 * nh); + // S_mat->identity(); + // Construct S + + S.iterate([&](const std::vector& i, const std::vector& spin, double& value) { + if ((spin[0] == AlphaSpin) && (spin[1] == AlphaSpin)) { + S_mat->set(i[0], i[1], value); + } else if ((spin[0] == BetaSpin) && (spin[1] == BetaSpin)) { + S_mat->set(i[0] + nh, i[1] + nh, value); + } + }); + + S_mat->print(); + S_mat->diagonalize(Sevec, Seval); + + // We need a threshold. + for (size_t i = 0; i < Sevec->coldim(); i++) { + for (size_t j = 0; j < Sevec->rowdim(); j++) { + double value = Sevec->get(j, i) / std::sqrt(Seval->get(i)); + Sevec->set(j, i, value); + } + } + + EOM_Hbar_mat_ = psi::linalg::triplet(Sevec, EOM_Hbar_mat_, Sevec, true, false, false); + + EOM_Hbar_mat_->diagonalize(Sevec, Seval); + + outfile->Printf("\n " + "----------------------------------------------------------" + "----------------------------------------"); + outfile->Printf("\n\n\n EOM-DSRG "); + + Seval->print(); +} + void MRDSRG::compute_hbar_qc() { std::string dsrg_op = foptions_->get_str("DSRG_TRANS_TYPE"); diff --git a/forte/register_forte_options.py b/forte/register_forte_options.py index 833e0b8d9..f1b51152f 100644 --- a/forte/register_forte_options.py +++ b/forte/register_forte_options.py @@ -684,6 +684,8 @@ def register_dsrg_options(options): options.add_bool( "DSRG_DUMP_RELAXED_ENERGIES", False, "Dump the energies after each reference relaxation step to JSON." ) + + options.add_bool("DO_EOM", False, "EOM-LDSRG(2).") options.add_int("TAYLOR_THRESHOLD", 3, "DSRG Taylor expansion threshold for small denominator") From 41f5ec988267af43cf194bb878dc7a14e92e3612 Mon Sep 17 00:00:00 2001 From: Shuhang Li Date: Wed, 20 Mar 2024 11:45:51 -0400 Subject: [PATCH 06/55] Something wrong. --- forte/mrdsrg-so/mrdsrg_so.cc | 46 ++++++++++++------- forte/mrdsrg-spin-integrated/mrdsrg_nonpt.cc | 48 ++++++++++---------- 2 files changed, 54 insertions(+), 40 deletions(-) diff --git a/forte/mrdsrg-so/mrdsrg_so.cc b/forte/mrdsrg-so/mrdsrg_so.cc index cde580e19..327d65512 100644 --- a/forte/mrdsrg-so/mrdsrg_so.cc +++ b/forte/mrdsrg-so/mrdsrg_so.cc @@ -654,6 +654,8 @@ double MRDSRG_SO::compute_eom() { // IP singles size_t ncore = nc_ / 2; size_t nactv = na_ / 2; + size_t nmo = nso_ / 2; + size_t nhole = ncore + nactv; auto EOM_Hbar = BTF_->build(tensor_type_, "EOM-Hbar", {"hh"}); std::shared_ptr EOM_Hbar_mat_ = @@ -669,17 +671,25 @@ double MRDSRG_SO::compute_eom() { EOM_Hbar["wx"] -= 0.5 * Hbar2["yzuv"] * Gamma1["vx"] * Lambda2["uwyz"]; EOM_Hbar["wx"] += 0.25 * Hbar2["yzuv"] * Lambda3["uvwyzx"]; - EOM_Hbar.iterate([&](const std::vector& i, const std::vector&, - double& value) { EOM_Hbar_mat_->set(i[0], i[1], value); }); + EOM_Hbar.iterate( + [&](const std::vector& i, const std::vector&, double& value) { + if (i[0] < nmo && i[1] < nmo) { + EOM_Hbar_mat_->set(i[0], i[1], value); + } + if (i[0] >= nmo && i[1] >= nmo) { + EOM_Hbar_mat_->set(i[0] - nmo + nhole, i[1] - nmo + nhole, value); + } + }); + + EOM_Hbar_mat_->print(); /// Overlap matrix std::shared_ptr S = std::make_shared("EOM-S-sub", nh_, nh_); - std::shared_ptr Sevec = std::make_shared("S-evec", nh_, nh_); - std::shared_ptr Seval = std::make_shared("S-eval", nh_); - std::shared_ptr Eevec = std::make_shared("E-evec", nh_, nh_); - std::shared_ptr Eeval = std::make_shared("E-eval", nh_); + // std::shared_ptr Sevec = std::make_shared("S-evec", nh_, nh_); + // std::shared_ptr Seval = std::make_shared("S-eval", nh_); + // std::shared_ptr Eevec = std::make_shared("E-evec", nh_, nh_); + // std::shared_ptr Eeval = std::make_shared("E-eval", nh_); S->identity(); - S->print(); (rdms_->g1a()).citerate([&](const std::vector& i, const double& value) { S->set(i[0] + ncore, i[1] + ncore, value); }); @@ -688,27 +698,29 @@ double MRDSRG_SO::compute_eom() { S->set(i[0] + 2 * ncore + nactv, i[1] + 2 * ncore + nactv, value); }); S->print(); - S->diagonalize(Sevec, Seval); + // S->diagonalize(Sevec, Seval); + auto Sevec = S->partial_cholesky_factorize(1e-10); + auto Seval = std::make_shared("S-eval", Sevec->rowdim()); - for (size_t i = 0; i < Sevec->coldim(); i++) { - for (size_t j = 0; j < Sevec->rowdim(); j++) { - double value = Sevec->get(j, i) / std::sqrt(Seval->get(i)); - Sevec->set(j, i, value); - } - } + // for (size_t i = 0; i < Sevec->coldim(); i++) { + // for (size_t j = 0; j < Sevec->rowdim(); j++) { + // double value = Sevec->get(j, i) / std::sqrt(Seval->get(i)); + // Sevec->set(j, i, value); + // } + // } EOM_Hbar_mat_ = psi::linalg::triplet(Sevec, EOM_Hbar_mat_, Sevec, true, false, false); - EOM_Hbar_mat_->diagonalize(Eevec, Eeval); + EOM_Hbar_mat_->diagonalize(Sevec, Seval); outfile->Printf("\n " "----------------------------------------------------------" "----------------------------------------"); outfile->Printf("\n\n\n EOM-DSRG "); - Eeval->print(); + Seval->print(); - return Eeval->get(0); + return Seval->get(0); } void MRDSRG_SO::compute_hbar() { diff --git a/forte/mrdsrg-spin-integrated/mrdsrg_nonpt.cc b/forte/mrdsrg-spin-integrated/mrdsrg_nonpt.cc index ac9f46f97..a68c44c1d 100644 --- a/forte/mrdsrg-spin-integrated/mrdsrg_nonpt.cc +++ b/forte/mrdsrg-spin-integrated/mrdsrg_nonpt.cc @@ -870,30 +870,27 @@ void MRDSRG::compute_eom() { EOM_Hbar["VM"] = EOM_Hbar["MV"]; // The third term - EOM_Hbar["wx"] = Hbar1_["vu"] * Gamma1_["ux"] * Gamma1_["wv"]; + EOM_Hbar["wx"] = -Hbar1_["vu"] * Gamma1_["ux"] * Gamma1_["wv"]; EOM_Hbar["wx"] += Hbar1_["vu"] * Lambda2_["uwvx"]; EOM_Hbar["wx"] += Hbar1_["VU"] * Lambda2_["wUxV"]; EOM_Hbar["wx"] += 0.5 * Hbar2_["yzuv"] * Gamma1_["wy"] * Lambda2_["uvzx"]; EOM_Hbar["wx"] -= Hbar2_["yZvU"] * Gamma1_["wy"] * Lambda2_["vUxZ"]; EOM_Hbar["wx"] -= 0.5 * Hbar2_["yzuv"] * Gamma1_["vx"] * Lambda2_["uwyz"]; EOM_Hbar["wx"] -= Hbar2_["zYvU"] * Gamma1_["vx"] * Lambda2_["wUzY"]; - // EOM_Hbar["wx"] += 0.25 * Hbar2_.block("aaaa")("yzuv") * L3aaa_("uvwyzx"); - // auto temp2 = 0.25 * Hbar2_.block("AAAA")("YZUV") * L3abb_("wUVxYZ"); - // auto temp3 = 0.5 * Hbar2_.block("aAaA")("yZuV") * L3aab_("uwVyxZ"); - // // EOM_Hbar["wx"] = temp1; - // // EOM_Hbar["wx"] += temp2; - // // EOM_Hbar["wx"] += temp3; - - EOM_Hbar["WX"] = Hbar1_["VU"] * Gamma1_["UX"] * Gamma1_["WV"]; + EOM_Hbar.block("aa")("wx") += 0.25 * Hbar2_.block("aaaa")("yzuv") * L3aaa_("uvwyzx"); + EOM_Hbar.block("aa")("wx") += 0.25 * Hbar2_.block("AAAA")("YZUV") * L3abb_("wUVxYZ"); + EOM_Hbar.block("aa")("wx") += Hbar2_.block("aAaA")("yZuV") * L3aab_("uwVyxZ"); + + EOM_Hbar["WX"] = -Hbar1_["VU"] * Gamma1_["UX"] * Gamma1_["WV"]; EOM_Hbar["WX"] += Hbar1_["VU"] * Lambda2_["UWVX"]; EOM_Hbar["WX"] += Hbar1_["vu"] * Lambda2_["uWvX"]; EOM_Hbar["WX"] += 0.5 * Hbar2_["YZUV"] * Gamma1_["WY"] * Lambda2_["UVZX"]; EOM_Hbar["WX"] -= Hbar2_["zYuV"] * Gamma1_["WY"] * Lambda2_["uVzX"]; EOM_Hbar["WX"] -= 0.5 * Hbar2_["YZUV"] * Gamma1_["VX"] * Lambda2_["UWYZ"]; EOM_Hbar["WX"] -= Hbar2_["yZuV"] * Gamma1_["VX"] * Lambda2_["uWyZ"]; - // EOM_Hbar["WX"] += 0.25 * Hbar2_["YZUV"] * L3bbb_("UVWYZX"); - // EOM_Hbar["WX"] += 0.25 * Hbar2_["yzuv"] * L3aab_("uvWyzX"); - // EOM_Hbar["WX"] += 0.5 * Hbar2_["zYvU"] * L3abb_("vUWzYX"); + EOM_Hbar.block("AA")("WX") += 0.25 * Hbar2_.block("AAAA")("YZUV") * L3bbb_("UVWYZX"); + EOM_Hbar.block("AA")("WX") += 0.25 * Hbar2_.block("aaaa")("yzuv") * L3aab_("uvWyzX"); + EOM_Hbar.block("AA")("WX") += Hbar2_.block("aAaA")("zYvU") * L3abb_("vUWzYX"); EOM_Hbar.iterate( [&](const std::vector& i, const std::vector& spin, double& value) { @@ -903,11 +900,12 @@ void MRDSRG::compute_eom() { EOM_Hbar_mat_->set(i[0] + nh, i[1] + nh, value); } }); + EOM_Hbar_mat_->print(); /// Overlap matrix std::shared_ptr S_mat = std::make_shared("EOM-S-sub", 2 * nh, 2 * nh); - std::shared_ptr Sevec = std::make_shared("S-evec", 2 * nh, 2 * nh); - std::shared_ptr Seval = std::make_shared("S-eval", 2 * nh); + // std::shared_ptr Sevec = std::make_shared("S-evec", 2 * nh, 2 * nh); + // std::shared_ptr Seval = std::make_shared("S-eval", 2 * nh); // S_mat->identity(); // Construct S @@ -920,15 +918,19 @@ void MRDSRG::compute_eom() { }); S_mat->print(); - S_mat->diagonalize(Sevec, Seval); - - // We need a threshold. - for (size_t i = 0; i < Sevec->coldim(); i++) { - for (size_t j = 0; j < Sevec->rowdim(); j++) { - double value = Sevec->get(j, i) / std::sqrt(Seval->get(i)); - Sevec->set(j, i, value); - } - } + // S_mat->diagonalize(Sevec, Seval); + // Seval->print(); + + // // We need a threshold. Also, inefficient. + // for (size_t i = 0; i < Sevec->coldim(); i++) { + // for (size_t j = 0; j < Sevec->rowdim(); j++) { + // double value = Sevec->get(j, i) / std::sqrt(Seval->get(i)); + // Sevec->set(j, i, value); + // } + // } + auto Sevec = S_mat->partial_cholesky_factorize(1e-10); + + auto Seval = std::make_shared("S-eval", Sevec->rowdim()); EOM_Hbar_mat_ = psi::linalg::triplet(Sevec, EOM_Hbar_mat_, Sevec, true, false, false); From 0436c5248ecf95d8aae8640e201329ddecddae3f Mon Sep 17 00:00:00 2001 From: Shuhang Li Date: Mon, 1 Apr 2024 12:03:56 -0400 Subject: [PATCH 07/55] Wicked contraction. Spin-orbital. --- forte/CMakeLists.txt | 1 + forte/mrdsrg-so/mrdsrg_so.cc | 560 ++++++++-------- forte/mrdsrg-so/wicked_contractions.cc | 882 +++++++++++++++++++++++++ 3 files changed, 1163 insertions(+), 280 deletions(-) create mode 100644 forte/mrdsrg-so/wicked_contractions.cc diff --git a/forte/CMakeLists.txt b/forte/CMakeLists.txt index 0a440ed05..20268d0d4 100644 --- a/forte/CMakeLists.txt +++ b/forte/CMakeLists.txt @@ -151,6 +151,7 @@ mrdsrg-helper/dsrg_time.cc mrdsrg-helper/dsrg_transformed.cc mrdsrg-helper/run_dsrg.cc mrdsrg-so/mrdsrg_so.cc +mrdsrg-so/wicked_contractions.cc mrdsrg-so/so-mrdsrg.cc mrdsrg-spin-adapted/dsrg_mrpt.cc mrdsrg-spin-adapted/dsrg_mrpt_2nd.cc diff --git a/forte/mrdsrg-so/mrdsrg_so.cc b/forte/mrdsrg-so/mrdsrg_so.cc index 327d65512..8717706ea 100644 --- a/forte/mrdsrg-so/mrdsrg_so.cc +++ b/forte/mrdsrg-so/mrdsrg_so.cc @@ -153,9 +153,9 @@ void MRDSRG_SO::startup() { size_t nmo = nso_ / 2; size_t na_mo = na_ / 2; - BTF_->add_mo_space("c", "mn", core_sos, AlphaSpin); - BTF_->add_mo_space("a", "uvwxyz", actv_sos, AlphaSpin); - BTF_->add_mo_space("v", "ef", virt_sos, AlphaSpin); + BTF_->add_mo_space("c", "m,n,c0,c1,c2,c3,c4,c5,c6,c7,c8,c9", core_sos, AlphaSpin); + BTF_->add_mo_space("a", "u,v,w,x,y,z,a0,a1,a2,a3,a4,a5,a6,a7,a8,a9", actv_sos, AlphaSpin); + BTF_->add_mo_space("v", "e,f,g,h,v0,v1,v2,v3,v4,v5,v6,v7,v8,v9", virt_sos, AlphaSpin); BTF_->add_composite_mo_space("h", "ijkl", {"c", "a"}); BTF_->add_composite_mo_space("p", "abcd", {"a", "v"}); @@ -921,283 +921,283 @@ void MRDSRG_SO::compute_qhbar() { // -----------------------------------------------------------------"); } -void MRDSRG_SO::H1_T1_C0(BlockedTensor& H1, BlockedTensor& T1, const double& alpha, double& C0) { - // local_timer timer; - // std::string str = "Computing [Hbar1, T1] -> C0 ..."; - // outfile->Printf("\n %-35s", str.c_str()); - - double E = 0.0; - BlockedTensor temp; - temp = ambit::BlockedTensor::build(tensor_type_, "temp", {"hp"}); - temp["jb"] = T1["ia"] * Eta1["ab"] * Gamma1["ji"]; - E += temp["jb"] * H1["bj"]; - E *= alpha; - C0 += E; - // outfile->Printf(" Done. Timing %10.3f s; Energy = %14.10f Eh", - // timer.get(), E); -} - -void MRDSRG_SO::H2_T1_C0(BlockedTensor& H2, BlockedTensor& T1, const double& alpha, double& C0) { - // local_timer timer; - // std::string str = "Computing [Hbar2, T1] -> C0 ..."; - // outfile->Printf("\n %-35s", str.c_str()); - - double E = 0.0; - BlockedTensor temp; - temp = ambit::BlockedTensor::build(tensor_type_, "temp", {"aaaa"}); - temp["uvxy"] += H2["evxy"] * T1["ue"]; - temp["uvxy"] -= H2["uvmy"] * T1["mx"]; - E += 0.5 * temp["uvxy"] * Lambda2["xyuv"]; - E *= alpha; - C0 += E; - // outfile->Printf(" Done. Timing %10.3f s; Energy = %14.10f Eh", - // timer.get(), E); -} - -void MRDSRG_SO::H1_T2_C0(BlockedTensor& H1, BlockedTensor& T2, const double& alpha, double& C0) { - // local_timer timer; - // std::string str = "Computing [Hbar1, T2] -> C0 ..."; - // outfile->Printf("\n %-35s", str.c_str()); - - double E = 0.0; - BlockedTensor temp; - temp = ambit::BlockedTensor::build(tensor_type_, "temp", {"aaaa"}); - temp["uvxy"] += H1["ex"] * T2["uvey"]; - temp["uvxy"] -= H1["vm"] * T2["umxy"]; - E += 0.5 * temp["uvxy"] * Lambda2["xyuv"]; - E *= alpha; - C0 += E; - // outfile->Printf(" Done. Timing %10.3f s; Energy = %14.10f Eh", - // timer.get(), E); -} - -void MRDSRG_SO::H2_T2_C0(BlockedTensor& H2, BlockedTensor& T2, const double& alpha, double& C0) { - // local_timer timer; - // std::string str = "Computing [Hbar2, T2] -> C0 ..."; - // outfile->Printf("\n %-35s", str.c_str()); - - // <[Hbar2, T2]> (C_2)^4 - double E = 0.25 * H2["efmn"] * T2["mnef"]; - - BlockedTensor temp1 = ambit::BlockedTensor::build(tensor_type_, "temp1", {"hhaa"}); - BlockedTensor temp2 = ambit::BlockedTensor::build(tensor_type_, "temp2", {"hhaa"}); - temp1["klux"] = T2["ijux"] * Gamma1["ki"] * Gamma1["lj"]; - temp2["klvy"] = temp1["klux"] * Eta1["uv"] * Eta1["xy"]; - E += 0.25 * H2["vykl"] * temp2["klvy"]; - - temp1 = ambit::BlockedTensor::build(tensor_type_, "temp1", {"hhav"}); - temp2 = ambit::BlockedTensor::build(tensor_type_, "temp2", {"hhav"}); - temp1["klue"] = T2["ijue"] * Gamma1["ki"] * Gamma1["lj"]; - temp2["klve"] = temp1["klue"] * Eta1["uv"]; - E += 0.5 * H2["vekl"] * temp2["klve"]; - - temp2 = ambit::BlockedTensor::build(tensor_type_, "temp2", {"aaaa"}); - temp2["yvxu"] -= H2["fexu"] * T2["yvef"]; - E += 0.25 * temp2["yvxu"] * Gamma1["xy"] * Gamma1["uv"]; - - temp2 = ambit::BlockedTensor::build(tensor_type_, "temp2", {"aa"}); - temp2["vu"] -= H2["femu"] * T2["mvef"]; - E += 0.5 * temp2["vu"] * Gamma1["uv"]; - - // <[Hbar2, T2]> C_4 (C_2)^2 HH - temp1 = ambit::BlockedTensor::build(tensor_type_, "temp1", {"aahh"}); - temp2 = ambit::BlockedTensor::build(tensor_type_, "temp2", {"aaaa"}); - temp1["uvij"] = H2["uvkl"] * Gamma1["ki"] * Gamma1["lj"]; - temp2["uvxy"] += 0.125 * temp1["uvij"] * T2["ijxy"]; - - // <[Hbar2, T2]> C_4 (C_2)^2 PP - temp1 = ambit::BlockedTensor::build(tensor_type_, "temp1", {"aapp"}); - temp1["uvcd"] = T2["uvab"] * Eta1["ac"] * Eta1["bd"]; - temp2["uvxy"] += 0.125 * temp1["uvcd"] * H2["cdxy"]; - - // <[Hbar2, T2]> C_4 (C_2)^2 PH - temp1 = ambit::BlockedTensor::build(tensor_type_, "temp1", {"hapa"}); - temp1["juby"] = T2["iuay"] * Gamma1["ji"] * Eta1["ab"]; - temp2["uvxy"] += H2["vbjx"] * temp1["juby"]; - E += temp2["uvxy"] * Lambda2["xyuv"]; - - // <[Hbar2, T2]> C_6 C_2 - if (foptions_->get_str("THREEPDC") != "ZERO") { - temp1 = ambit::BlockedTensor::build(tensor_type_, "temp", {"aaaaaa"}); - temp1["uvwxyz"] += H2["uviz"] * T2["iwxy"]; - temp1["uvwxyz"] += H2["waxy"] * T2["uvaz"]; - E += 0.25 * temp1["uvwxyz"] * Lambda3["xyzuvw"]; - } - - E *= alpha; - C0 += E; - // outfile->Printf(" Done. Timing %10.3f s; Energy = %14.10f Eh", - // timer.get(), E); -} - -void MRDSRG_SO::H1_T1_C1(BlockedTensor& H1, BlockedTensor& T1, const double& alpha, - BlockedTensor& C1) { - // local_timer timer; - // std::string str = "Computing [Hbar1, T1] -> C1 ..."; - // outfile->Printf("\n %-35s", str.c_str()); - - C1["ip"] += alpha * H1["ap"] * T1["ia"]; - C1["pa"] -= alpha * H1["pi"] * T1["ia"]; - - // outfile->Printf(" Done. Timing %10.3f s", timer.get()); -} - -void MRDSRG_SO::H2_T1_C1(BlockedTensor& H2, BlockedTensor& T1, const double& alpha, - BlockedTensor& C1) { - // local_timer timer; - // std::string str = "Computing [Hbar2, T1] -> C1 ..."; - // outfile->Printf("\n %-35s", str.c_str()); - - C1["qp"] += alpha * T1["ia"] * H2["qapj"] * Gamma1["ji"]; - C1["qp"] -= alpha * T1["mu"] * H2["qvpm"] * Gamma1["uv"]; - - // outfile->Printf(" Done. Timing %10.3f s", timer.get()); -} - -void MRDSRG_SO::H1_T2_C1(BlockedTensor& H1, BlockedTensor& T2, const double& alpha, - BlockedTensor& C1) { - // local_timer timer; - // std::string str = "Computing [Hbar1, T2] -> C1 ..."; - // outfile->Printf("\n %-35s", str.c_str()); - - C1["ia"] += alpha * T2["ijab"] * H1["bk"] * Gamma1["kj"]; - C1["ia"] -= alpha * T2["ijau"] * H1["vj"] * Gamma1["uv"]; - - // outfile->Printf(" Done. Timing %10.3f s", timer.get()); -} - -void MRDSRG_SO::H2_T2_C1(BlockedTensor& H2, BlockedTensor& T2, const double& alpha, - BlockedTensor& C1) { - // local_timer timer; - // std::string str = "Computing [Hbar2, T2] -> C1 ..."; - // outfile->Printf("\n %-35s", str.c_str()); - - // [Hbar2, T2] (C_2)^3 -> C1 - BlockedTensor temp1 = ambit::BlockedTensor::build(tensor_type_, "temp1", {"hhgh"}); - temp1["ijrk"] = H2["abrk"] * T2["ijab"]; - C1["ir"] += 0.5 * alpha * temp1["ijrk"] * Gamma1["kj"]; - - temp1 = ambit::BlockedTensor::build(tensor_type_, "temp1", {"hhaa"}); - temp1["ijvy"] = T2["ijux"] * Gamma1["uv"] * Gamma1["xy"]; - C1["ir"] += 0.5 * alpha * temp1["ijvy"] * H2["vyrj"]; - - temp1 = ambit::BlockedTensor::build(tensor_type_, "temp1", {"hhap"}); - temp1["ikvb"] = T2["ijub"] * Gamma1["kj"] * Gamma1["uv"]; - C1["ir"] -= alpha * temp1["ikvb"] * H2["vbrk"]; - - temp1 = ambit::BlockedTensor::build(tensor_type_, "temp1", {"hhpa"}); - temp1["ijav"] = T2["ijau"] * Gamma1["uv"]; - C1["pa"] -= 0.5 * alpha * temp1["ijav"] * H2["pvij"]; - - temp1 = ambit::BlockedTensor::build(tensor_type_, "temp1", {"hhpp"}); - temp1["klab"] = T2["ijab"] * Gamma1["ki"] * Gamma1["lj"]; - C1["pa"] -= 0.5 * alpha * temp1["klab"] * H2["pbkl"]; - - temp1 = ambit::BlockedTensor::build(tensor_type_, "temp1", {"hhpa"}); - temp1["ikav"] = T2["ijau"] * Gamma1["uv"] * Gamma1["kj"]; - C1["pa"] += alpha * temp1["ikav"] * H2["pvik"]; - - // [Hbar2, T2] C_4 C_2 2:2 -> C1 - temp1 = ambit::BlockedTensor::build(tensor_type_, "temp1", {"hhaa"}); - temp1["ijuv"] = T2["ijxy"] * Lambda2["xyuv"]; - C1["ir"] += 0.25 * alpha * temp1["ijuv"] * H2["uvrj"]; - - temp1 = ambit::BlockedTensor::build(tensor_type_, "temp1", {"aapp"}); - temp1["xyab"] = T2["uvab"] * Lambda2["xyuv"]; - C1["pa"] -= 0.25 * alpha * temp1["xyab"] * H2["pbxy"]; - - temp1 = ambit::BlockedTensor::build(tensor_type_, "temp1", {"hapa"}); - temp1["iuax"] = T2["iyav"] * Lambda2["uvxy"]; - C1["ir"] += alpha * temp1["iuax"] * H2["axru"]; - C1["pa"] -= alpha * temp1["iuax"] * H2["pxiu"]; - - // [Hbar2, T2] C_4 C_2 1:3 -> C1 - temp1 = ambit::BlockedTensor::build(tensor_type_, "temp1", {"pa"}); - temp1["au"] = H2["avxy"] * Lambda2["xyuv"]; - C1["jb"] += 0.5 * alpha * temp1["au"] * T2["ujab"]; - - temp1 = ambit::BlockedTensor::build(tensor_type_, "temp1", {"ah"}); - temp1["ui"] = H2["xyiv"] * Lambda2["uvxy"]; - C1["jb"] -= 0.5 * alpha * temp1["ui"] * T2["ijub"]; - - temp1 = ambit::BlockedTensor::build(tensor_type_, "temp1", {"av"}); - temp1["xe"] = T2["uvey"] * Lambda2["xyuv"]; - C1["qs"] += 0.5 * alpha * temp1["xe"] * H2["eqxs"]; - - temp1 = ambit::BlockedTensor::build(tensor_type_, "temp1", {"ca"}); - temp1["mx"] = T2["myuv"] * Lambda2["uvxy"]; - C1["qs"] -= 0.5 * alpha * temp1["mx"] * H2["xqms"]; - - // outfile->Printf(" Done. Timing %10.3f s", timer.get()); -} - -void MRDSRG_SO::H1_T2_C2(BlockedTensor& H1, BlockedTensor& T2, const double& alpha, - BlockedTensor& C2) { - // local_timer timer; - // std::string str = "Computing [Hbar1, T2] -> C2 ..."; - // outfile->Printf("\n %-35s", str.c_str()); - - C2["ijpb"] += alpha * T2["ijab"] * H1["ap"]; - C2["ijap"] += alpha * T2["ijab"] * H1["bp"]; - C2["qjab"] -= alpha * T2["ijab"] * H1["qi"]; - C2["iqab"] -= alpha * T2["ijab"] * H1["qj"]; - - // outfile->Printf(" Done. Timing %10.3f s", timer.get()); -} - -void MRDSRG_SO::H2_T1_C2(BlockedTensor& H2, BlockedTensor& T1, const double& alpha, - BlockedTensor& C2) { - // local_timer timer; - // std::string str = "Computing [Hbar2, T1] -> C2 ..."; - // outfile->Printf("\n %-35s", str.c_str()); - - C2["irpq"] += alpha * T1["ia"] * H2["arpq"]; - C2["ripq"] += alpha * T1["ia"] * H2["rapq"]; - C2["rsaq"] -= alpha * T1["ia"] * H2["rsiq"]; - C2["rspa"] -= alpha * T1["ia"] * H2["rspi"]; - - // outfile->Printf(" Done. Timing %10.3f s", timer.get()); -} - -void MRDSRG_SO::H2_T2_C2(BlockedTensor& H2, BlockedTensor& T2, const double& alpha, - BlockedTensor& C2) { - // local_timer timer; - // std::string str = "Computing [Hbar2, T2] -> C2 ..."; - // outfile->Printf("\n %-35s", str.c_str()); - - // particle-particle contractions - C2["ijrs"] += 0.5 * alpha * H2["abrs"] * T2["ijab"]; - - BlockedTensor temp = ambit::BlockedTensor::build(tensor_type_, "temp", {"hhpa"}); - temp["ijby"] = T2["ijbx"] * Gamma1["xy"]; - C2["ijrs"] -= alpha * temp["ijby"] * H2["byrs"]; - - // hole-hole contractions - C2["pqab"] += 0.5 * alpha * H2["pqij"] * T2["ijab"]; - - temp = ambit::BlockedTensor::build(tensor_type_, "temp", {"ahpp"}); - temp["xjab"] = T2["yjab"] * Eta1["xy"]; - C2["pqab"] -= alpha * temp["xjab"] * H2["pqxj"]; - - // particle-hole contractions - temp = ambit::BlockedTensor::build(tensor_type_, "temp", {"hhpp"}); - temp["kjab"] = T2["ijab"] * Gamma1["ki"]; - C2["qjsb"] += alpha * temp["kjab"] * H2["aqks"]; - C2["qjas"] += alpha * temp["kjab"] * H2["bqks"]; - - C2["iqsb"] -= alpha * temp["kiab"] * H2["aqks"]; - C2["iqas"] -= alpha * temp["kiab"] * H2["bqks"]; - - temp = ambit::BlockedTensor::build(tensor_type_, "temp", {"hhap"}); - temp["ijvb"] = T2["ijub"] * Gamma1["uv"]; - C2["qjsb"] -= alpha * temp["ijvb"] * H2["vqis"]; - C2["iqsb"] -= alpha * temp["ijvb"] * H2["vqjs"]; - - C2["qjas"] += alpha * temp["ijva"] * H2["vqis"]; - C2["iqas"] += alpha * temp["ijva"] * H2["vqjs"]; - - // outfile->Printf(" Done. Timing %10.3f s", timer.get()); -} +// void MRDSRG_SO::H1_T1_C0(BlockedTensor& H1, BlockedTensor& T1, const double& alpha, double& C0) { +// // local_timer timer; +// // std::string str = "Computing [Hbar1, T1] -> C0 ..."; +// // outfile->Printf("\n %-35s", str.c_str()); + +// double E = 0.0; +// BlockedTensor temp; +// temp = ambit::BlockedTensor::build(tensor_type_, "temp", {"hp"}); +// temp["jb"] = T1["ia"] * Eta1["ab"] * Gamma1["ji"]; +// E += temp["jb"] * H1["bj"]; +// E *= alpha; +// C0 += E; +// // outfile->Printf(" Done. Timing %10.3f s; Energy = %14.10f Eh", +// // timer.get(), E); +// } + +// void MRDSRG_SO::H2_T1_C0(BlockedTensor& H2, BlockedTensor& T1, const double& alpha, double& C0) { +// // local_timer timer; +// // std::string str = "Computing [Hbar2, T1] -> C0 ..."; +// // outfile->Printf("\n %-35s", str.c_str()); + +// double E = 0.0; +// BlockedTensor temp; +// temp = ambit::BlockedTensor::build(tensor_type_, "temp", {"aaaa"}); +// temp["uvxy"] += H2["evxy"] * T1["ue"]; +// temp["uvxy"] -= H2["uvmy"] * T1["mx"]; +// E += 0.5 * temp["uvxy"] * Lambda2["xyuv"]; +// E *= alpha; +// C0 += E; +// // outfile->Printf(" Done. Timing %10.3f s; Energy = %14.10f Eh", +// // timer.get(), E); +// } + +// void MRDSRG_SO::H1_T2_C0(BlockedTensor& H1, BlockedTensor& T2, const double& alpha, double& C0) { +// // local_timer timer; +// // std::string str = "Computing [Hbar1, T2] -> C0 ..."; +// // outfile->Printf("\n %-35s", str.c_str()); + +// double E = 0.0; +// BlockedTensor temp; +// temp = ambit::BlockedTensor::build(tensor_type_, "temp", {"aaaa"}); +// temp["uvxy"] += H1["ex"] * T2["uvey"]; +// temp["uvxy"] -= H1["vm"] * T2["umxy"]; +// E += 0.5 * temp["uvxy"] * Lambda2["xyuv"]; +// E *= alpha; +// C0 += E; +// // outfile->Printf(" Done. Timing %10.3f s; Energy = %14.10f Eh", +// // timer.get(), E); +// } + +// void MRDSRG_SO::H2_T2_C0(BlockedTensor& H2, BlockedTensor& T2, const double& alpha, double& C0) { +// // local_timer timer; +// // std::string str = "Computing [Hbar2, T2] -> C0 ..."; +// // outfile->Printf("\n %-35s", str.c_str()); + +// // <[Hbar2, T2]> (C_2)^4 +// double E = 0.25 * H2["efmn"] * T2["mnef"]; + +// BlockedTensor temp1 = ambit::BlockedTensor::build(tensor_type_, "temp1", {"hhaa"}); +// BlockedTensor temp2 = ambit::BlockedTensor::build(tensor_type_, "temp2", {"hhaa"}); +// temp1["klux"] = T2["ijux"] * Gamma1["ki"] * Gamma1["lj"]; +// temp2["klvy"] = temp1["klux"] * Eta1["uv"] * Eta1["xy"]; +// E += 0.25 * H2["vykl"] * temp2["klvy"]; + +// temp1 = ambit::BlockedTensor::build(tensor_type_, "temp1", {"hhav"}); +// temp2 = ambit::BlockedTensor::build(tensor_type_, "temp2", {"hhav"}); +// temp1["klue"] = T2["ijue"] * Gamma1["ki"] * Gamma1["lj"]; +// temp2["klve"] = temp1["klue"] * Eta1["uv"]; +// E += 0.5 * H2["vekl"] * temp2["klve"]; + +// temp2 = ambit::BlockedTensor::build(tensor_type_, "temp2", {"aaaa"}); +// temp2["yvxu"] -= H2["fexu"] * T2["yvef"]; +// E += 0.25 * temp2["yvxu"] * Gamma1["xy"] * Gamma1["uv"]; + +// temp2 = ambit::BlockedTensor::build(tensor_type_, "temp2", {"aa"}); +// temp2["vu"] -= H2["femu"] * T2["mvef"]; +// E += 0.5 * temp2["vu"] * Gamma1["uv"]; + +// // <[Hbar2, T2]> C_4 (C_2)^2 HH +// temp1 = ambit::BlockedTensor::build(tensor_type_, "temp1", {"aahh"}); +// temp2 = ambit::BlockedTensor::build(tensor_type_, "temp2", {"aaaa"}); +// temp1["uvij"] = H2["uvkl"] * Gamma1["ki"] * Gamma1["lj"]; +// temp2["uvxy"] += 0.125 * temp1["uvij"] * T2["ijxy"]; + +// // <[Hbar2, T2]> C_4 (C_2)^2 PP +// temp1 = ambit::BlockedTensor::build(tensor_type_, "temp1", {"aapp"}); +// temp1["uvcd"] = T2["uvab"] * Eta1["ac"] * Eta1["bd"]; +// temp2["uvxy"] += 0.125 * temp1["uvcd"] * H2["cdxy"]; + +// // <[Hbar2, T2]> C_4 (C_2)^2 PH +// temp1 = ambit::BlockedTensor::build(tensor_type_, "temp1", {"hapa"}); +// temp1["juby"] = T2["iuay"] * Gamma1["ji"] * Eta1["ab"]; +// temp2["uvxy"] += H2["vbjx"] * temp1["juby"]; +// E += temp2["uvxy"] * Lambda2["xyuv"]; + +// // <[Hbar2, T2]> C_6 C_2 +// if (foptions_->get_str("THREEPDC") != "ZERO") { +// temp1 = ambit::BlockedTensor::build(tensor_type_, "temp", {"aaaaaa"}); +// temp1["uvwxyz"] += H2["uviz"] * T2["iwxy"]; +// temp1["uvwxyz"] += H2["waxy"] * T2["uvaz"]; +// E += 0.25 * temp1["uvwxyz"] * Lambda3["xyzuvw"]; +// } + +// E *= alpha; +// C0 += E; +// // outfile->Printf(" Done. Timing %10.3f s; Energy = %14.10f Eh", +// // timer.get(), E); +// } + +// void MRDSRG_SO::H1_T1_C1(BlockedTensor& H1, BlockedTensor& T1, const double& alpha, +// BlockedTensor& C1) { +// // local_timer timer; +// // std::string str = "Computing [Hbar1, T1] -> C1 ..."; +// // outfile->Printf("\n %-35s", str.c_str()); + +// C1["ip"] += alpha * H1["ap"] * T1["ia"]; +// C1["pa"] -= alpha * H1["pi"] * T1["ia"]; + +// // outfile->Printf(" Done. Timing %10.3f s", timer.get()); +// } + +// void MRDSRG_SO::H2_T1_C1(BlockedTensor& H2, BlockedTensor& T1, const double& alpha, +// BlockedTensor& C1) { +// // local_timer timer; +// // std::string str = "Computing [Hbar2, T1] -> C1 ..."; +// // outfile->Printf("\n %-35s", str.c_str()); + +// C1["qp"] += alpha * T1["ia"] * H2["qapj"] * Gamma1["ji"]; +// C1["qp"] -= alpha * T1["mu"] * H2["qvpm"] * Gamma1["uv"]; + +// // outfile->Printf(" Done. Timing %10.3f s", timer.get()); +// } + +// void MRDSRG_SO::H1_T2_C1(BlockedTensor& H1, BlockedTensor& T2, const double& alpha, +// BlockedTensor& C1) { +// // local_timer timer; +// // std::string str = "Computing [Hbar1, T2] -> C1 ..."; +// // outfile->Printf("\n %-35s", str.c_str()); + +// C1["ia"] += alpha * T2["ijab"] * H1["bk"] * Gamma1["kj"]; +// C1["ia"] -= alpha * T2["ijau"] * H1["vj"] * Gamma1["uv"]; + +// // outfile->Printf(" Done. Timing %10.3f s", timer.get()); +// } + +// void MRDSRG_SO::H2_T2_C1(BlockedTensor& H2, BlockedTensor& T2, const double& alpha, +// BlockedTensor& C1) { +// // local_timer timer; +// // std::string str = "Computing [Hbar2, T2] -> C1 ..."; +// // outfile->Printf("\n %-35s", str.c_str()); + +// // [Hbar2, T2] (C_2)^3 -> C1 +// BlockedTensor temp1 = ambit::BlockedTensor::build(tensor_type_, "temp1", {"hhgh"}); +// temp1["ijrk"] = H2["abrk"] * T2["ijab"]; +// C1["ir"] += 0.5 * alpha * temp1["ijrk"] * Gamma1["kj"]; + +// temp1 = ambit::BlockedTensor::build(tensor_type_, "temp1", {"hhaa"}); +// temp1["ijvy"] = T2["ijux"] * Gamma1["uv"] * Gamma1["xy"]; +// C1["ir"] += 0.5 * alpha * temp1["ijvy"] * H2["vyrj"]; + +// temp1 = ambit::BlockedTensor::build(tensor_type_, "temp1", {"hhap"}); +// temp1["ikvb"] = T2["ijub"] * Gamma1["kj"] * Gamma1["uv"]; +// C1["ir"] -= alpha * temp1["ikvb"] * H2["vbrk"]; + +// temp1 = ambit::BlockedTensor::build(tensor_type_, "temp1", {"hhpa"}); +// temp1["ijav"] = T2["ijau"] * Gamma1["uv"]; +// C1["pa"] -= 0.5 * alpha * temp1["ijav"] * H2["pvij"]; + +// temp1 = ambit::BlockedTensor::build(tensor_type_, "temp1", {"hhpp"}); +// temp1["klab"] = T2["ijab"] * Gamma1["ki"] * Gamma1["lj"]; +// C1["pa"] -= 0.5 * alpha * temp1["klab"] * H2["pbkl"]; + +// temp1 = ambit::BlockedTensor::build(tensor_type_, "temp1", {"hhpa"}); +// temp1["ikav"] = T2["ijau"] * Gamma1["uv"] * Gamma1["kj"]; +// C1["pa"] += alpha * temp1["ikav"] * H2["pvik"]; + +// // [Hbar2, T2] C_4 C_2 2:2 -> C1 +// temp1 = ambit::BlockedTensor::build(tensor_type_, "temp1", {"hhaa"}); +// temp1["ijuv"] = T2["ijxy"] * Lambda2["xyuv"]; +// C1["ir"] += 0.25 * alpha * temp1["ijuv"] * H2["uvrj"]; + +// temp1 = ambit::BlockedTensor::build(tensor_type_, "temp1", {"aapp"}); +// temp1["xyab"] = T2["uvab"] * Lambda2["xyuv"]; +// C1["pa"] -= 0.25 * alpha * temp1["xyab"] * H2["pbxy"]; + +// temp1 = ambit::BlockedTensor::build(tensor_type_, "temp1", {"hapa"}); +// temp1["iuax"] = T2["iyav"] * Lambda2["uvxy"]; +// C1["ir"] += alpha * temp1["iuax"] * H2["axru"]; +// C1["pa"] -= alpha * temp1["iuax"] * H2["pxiu"]; + +// // [Hbar2, T2] C_4 C_2 1:3 -> C1 +// temp1 = ambit::BlockedTensor::build(tensor_type_, "temp1", {"pa"}); +// temp1["au"] = H2["avxy"] * Lambda2["xyuv"]; +// C1["jb"] += 0.5 * alpha * temp1["au"] * T2["ujab"]; + +// temp1 = ambit::BlockedTensor::build(tensor_type_, "temp1", {"ah"}); +// temp1["ui"] = H2["xyiv"] * Lambda2["uvxy"]; +// C1["jb"] -= 0.5 * alpha * temp1["ui"] * T2["ijub"]; + +// temp1 = ambit::BlockedTensor::build(tensor_type_, "temp1", {"av"}); +// temp1["xe"] = T2["uvey"] * Lambda2["xyuv"]; +// C1["qs"] += 0.5 * alpha * temp1["xe"] * H2["eqxs"]; + +// temp1 = ambit::BlockedTensor::build(tensor_type_, "temp1", {"ca"}); +// temp1["mx"] = T2["myuv"] * Lambda2["uvxy"]; +// C1["qs"] -= 0.5 * alpha * temp1["mx"] * H2["xqms"]; + +// // outfile->Printf(" Done. Timing %10.3f s", timer.get()); +// } + +// void MRDSRG_SO::H1_T2_C2(BlockedTensor& H1, BlockedTensor& T2, const double& alpha, +// BlockedTensor& C2) { +// // local_timer timer; +// // std::string str = "Computing [Hbar1, T2] -> C2 ..."; +// // outfile->Printf("\n %-35s", str.c_str()); + +// C2["ijpb"] += alpha * T2["ijab"] * H1["ap"]; +// C2["ijap"] += alpha * T2["ijab"] * H1["bp"]; +// C2["qjab"] -= alpha * T2["ijab"] * H1["qi"]; +// C2["iqab"] -= alpha * T2["ijab"] * H1["qj"]; + +// // outfile->Printf(" Done. Timing %10.3f s", timer.get()); +// } + +// void MRDSRG_SO::H2_T1_C2(BlockedTensor& H2, BlockedTensor& T1, const double& alpha, +// BlockedTensor& C2) { +// // local_timer timer; +// // std::string str = "Computing [Hbar2, T1] -> C2 ..."; +// // outfile->Printf("\n %-35s", str.c_str()); + +// C2["irpq"] += alpha * T1["ia"] * H2["arpq"]; +// C2["ripq"] += alpha * T1["ia"] * H2["rapq"]; +// C2["rsaq"] -= alpha * T1["ia"] * H2["rsiq"]; +// C2["rspa"] -= alpha * T1["ia"] * H2["rspi"]; + +// // outfile->Printf(" Done. Timing %10.3f s", timer.get()); +// } + +// void MRDSRG_SO::H2_T2_C2(BlockedTensor& H2, BlockedTensor& T2, const double& alpha, +// BlockedTensor& C2) { +// // local_timer timer; +// // std::string str = "Computing [Hbar2, T2] -> C2 ..."; +// // outfile->Printf("\n %-35s", str.c_str()); + +// // particle-particle contractions +// C2["ijrs"] += 0.5 * alpha * H2["abrs"] * T2["ijab"]; + +// BlockedTensor temp = ambit::BlockedTensor::build(tensor_type_, "temp", {"hhpa"}); +// temp["ijby"] = T2["ijbx"] * Gamma1["xy"]; +// C2["ijrs"] -= alpha * temp["ijby"] * H2["byrs"]; + +// // hole-hole contractions +// C2["pqab"] += 0.5 * alpha * H2["pqij"] * T2["ijab"]; + +// temp = ambit::BlockedTensor::build(tensor_type_, "temp", {"ahpp"}); +// temp["xjab"] = T2["yjab"] * Eta1["xy"]; +// C2["pqab"] -= alpha * temp["xjab"] * H2["pqxj"]; + +// // particle-hole contractions +// temp = ambit::BlockedTensor::build(tensor_type_, "temp", {"hhpp"}); +// temp["kjab"] = T2["ijab"] * Gamma1["ki"]; +// C2["qjsb"] += alpha * temp["kjab"] * H2["aqks"]; +// C2["qjas"] += alpha * temp["kjab"] * H2["bqks"]; + +// C2["iqsb"] -= alpha * temp["kiab"] * H2["aqks"]; +// C2["iqas"] -= alpha * temp["kiab"] * H2["bqks"]; + +// temp = ambit::BlockedTensor::build(tensor_type_, "temp", {"hhap"}); +// temp["ijvb"] = T2["ijub"] * Gamma1["uv"]; +// C2["qjsb"] -= alpha * temp["ijvb"] * H2["vqis"]; +// C2["iqsb"] -= alpha * temp["ijvb"] * H2["vqjs"]; + +// C2["qjas"] += alpha * temp["ijva"] * H2["vqis"]; +// C2["iqas"] += alpha * temp["ijva"] * H2["vqjs"]; + +// // outfile->Printf(" Done. Timing %10.3f s", timer.get()); +// } void MRDSRG_SO::H2_T2_C3(BlockedTensor& H2, BlockedTensor& T2, const double& alpha, BlockedTensor& C3) { diff --git a/forte/mrdsrg-so/wicked_contractions.cc b/forte/mrdsrg-so/wicked_contractions.cc new file mode 100644 index 000000000..9c6cae7c7 --- /dev/null +++ b/forte/mrdsrg-so/wicked_contractions.cc @@ -0,0 +1,882 @@ +#include +#include "psi4/libpsi4util/PsiOutStream.h" +#include "helpers/timer.h" +#include "mrdsrg_so.h" + +using namespace psi; + +namespace forte { + +void MRDSRG_SO::H1_T1_C0(BlockedTensor& H1, BlockedTensor& T1, const double& alpha, double& C0) { + // 3 lines + local_timer timer; + C0 += alpha * +1.00000000 * H1["u,m"] * T1["m,v"] * Eta1["v,u"]; + C0 += alpha * +1.00000000 * H1["e,m"] * T1["m,e"]; + C0 += alpha * +1.00000000 * H1["e,u"] * T1["v,e"] * Gamma1["u,v"]; + + if (print_ > 2) { + outfile -> Printf("\n Time for H1_T1_C0 : %12.3f", timer.get()); + } +} + +void MRDSRG_SO::H1_T2_C0(BlockedTensor& H1, BlockedTensor& T2, const double& alpha, double& C0) { + // 2 lines + local_timer timer; + C0 += alpha * -0.50000000 * H1["u,m"] * T2["m,v,w,x"] * Lambda2["w,x,u,v"]; + C0 += alpha * -0.50000000 * H1["e,u"] * T2["v,w,x,e"] * Lambda2["u,x,v,w"]; + + if (print_ > 2) { + outfile -> Printf("\n Time for H1_T2_C0 : %12.3f", timer.get()); + } +} + +void MRDSRG_SO::H2_T1_C0(BlockedTensor& H2, BlockedTensor& T1, const double& alpha, double& C0) { + // 2 lines + local_timer timer; + C0 += alpha * +0.50000000 * H2["u,v,m,w"] * T1["m,x"] * Lambda2["w,x,u,v"]; + C0 += alpha * +0.50000000 * H2["u,e,v,w"] * T1["x,e"] * Lambda2["v,w,u,x"]; + + if (print_ > 2) { + outfile -> Printf("\n Time for H2_T1_C0 : %12.3f", timer.get()); + } +} + +void MRDSRG_SO::H2_T2_C0(BlockedTensor& H2, BlockedTensor& T2, const double& alpha, double& C0) { + // 17 lines + local_timer timer; + C0 += alpha * +0.25000000 * H2["u,v,m,n"] * T2["m,n,w,x"] * Eta1["x,v"] * Eta1["w,u"]; + C0 += alpha * +0.12500000 * H2["u,v,m,n"] * T2["m,n,w,x"] * Lambda2["w,x,u,v"]; + C0 += alpha * +0.50000000 * H2["u,e,m,n"] * T2["m,n,v,e"] * Eta1["v,u"]; + C0 += alpha * +0.25000000 * H2["e,f,m,n"] * T2["m,n,e,f"]; + C0 += alpha * +0.50000000 * H2["u,v,m,w"] * T2["m,x,y,z"] * Eta1["z,v"] * Eta1["y,u"] * Gamma1["w,x"]; + C0 += alpha * +1.00000000 * H2["u,v,m,w"] * T2["m,x,y,z"] * Eta1["z,v"] * Lambda2["w,y,u,x"]; + C0 += alpha * +0.25000000 * H2["u,v,m,w"] * T2["m,x,y,z"] * Gamma1["w,x"] * Lambda2["y,z,u,v"]; + C0 += alpha * +0.25000000 * H2["u,v,m,w"] * T2["m,x,y,z"] * Lambda3["w,y,z,u,v,x"]; + C0 += alpha * +1.00000000 * H2["u,e,m,v"] * T2["m,w,x,e"] * Eta1["x,u"] * Gamma1["v,w"]; + C0 += alpha * +1.00000000 * H2["u,e,m,v"] * T2["m,w,x,e"] * Lambda2["v,x,u,w"]; + C0 += alpha * +0.50000000 * H2["e,f,m,u"] * T2["m,v,e,f"] * Gamma1["u,v"]; + C0 += alpha * +0.50000000 * H2["u,e,v,w"] * T2["x,y,z,e"] * Eta1["z,u"] * Gamma1["w,y"] * Gamma1["v,x"]; + C0 += alpha * +0.25000000 * H2["u,e,v,w"] * T2["x,y,z,e"] * Eta1["z,u"] * Lambda2["v,w,x,y"]; + C0 += alpha * +1.00000000 * H2["u,e,v,w"] * T2["x,y,z,e"] * Gamma1["w,y"] * Lambda2["v,z,u,x"]; + C0 += alpha * -0.25000000 * H2["u,e,v,w"] * T2["x,y,z,e"] * Lambda3["v,w,z,u,x,y"]; + C0 += alpha * +0.25000000 * H2["e,f,u,v"] * T2["w,x,e,f"] * Gamma1["v,x"] * Gamma1["u,w"]; + C0 += alpha * +0.12500000 * H2["e,f,u,v"] * T2["w,x,e,f"] * Lambda2["u,v,w,x"]; + + if (print_ > 2) { + outfile -> Printf("\n Time for H2_T2_C0 : %12.3f", timer.get()); + } +} + +void MRDSRG_SO::H1_T1_C1(BlockedTensor& H1, BlockedTensor& T1, const double& alpha, BlockedTensor& C1) { + // 24 lines + local_timer timer; + C1["u,v"] += alpha * -1.00000000 * H1["u,m"] * T1["m,v"]; + C1["v,u"] += alpha * +1.00000000 * H1["e,u"] * T1["v,e"]; + C1["u,m"] += alpha * +1.00000000 * H1["e,m"] * T1["u,e"]; + C1["u,e"] += alpha * -1.00000000 * H1["u,m"] * T1["m,e"]; + C1["u,e"] += alpha * -1.00000000 * H1["u,v"] * T1["w,e"] * Eta1["v,w"]; + C1["u,e"] += alpha * -1.00000000 * H1["u,v"] * T1["w,e"] * Gamma1["v,w"]; + C1["u,f"] += alpha * +1.00000000 * H1["e,f"] * T1["u,e"]; + C1["m,u"] += alpha * -1.00000000 * H1["m,n"] * T1["n,u"]; + C1["m,v"] += alpha * +1.00000000 * H1["u,v"] * T1["m,w"] * Eta1["w,u"]; + C1["m,v"] += alpha * +1.00000000 * H1["u,v"] * T1["m,w"] * Gamma1["w,u"]; + C1["m,u"] += alpha * +1.00000000 * H1["e,u"] * T1["m,e"]; + C1["n,m"] += alpha * +1.00000000 * H1["u,m"] * T1["n,v"] * Eta1["v,u"]; + C1["n,m"] += alpha * +1.00000000 * H1["u,m"] * T1["n,v"] * Gamma1["v,u"]; + C1["n,m"] += alpha * +1.00000000 * H1["e,m"] * T1["n,e"]; + C1["m,e"] += alpha * -1.00000000 * H1["m,n"] * T1["n,e"]; + C1["m,e"] += alpha * -1.00000000 * H1["m,u"] * T1["v,e"] * Eta1["u,v"]; + C1["m,e"] += alpha * -1.00000000 * H1["m,u"] * T1["v,e"] * Gamma1["u,v"]; + C1["m,e"] += alpha * +1.00000000 * H1["u,e"] * T1["m,v"] * Eta1["v,u"]; + C1["m,e"] += alpha * +1.00000000 * H1["u,e"] * T1["m,v"] * Gamma1["v,u"]; + C1["m,f"] += alpha * +1.00000000 * H1["e,f"] * T1["m,e"]; + C1["e,u"] += alpha * -1.00000000 * H1["e,m"] * T1["m,u"]; + C1["e,f"] += alpha * -1.00000000 * H1["e,m"] * T1["m,f"]; + C1["e,f"] += alpha * -1.00000000 * H1["e,u"] * T1["v,f"] * Eta1["u,v"]; + C1["e,f"] += alpha * -1.00000000 * H1["e,u"] * T1["v,f"] * Gamma1["u,v"]; + + if (print_ > 2) { + outfile -> Printf("\n Time for H1_T1_C1 : %12.3f", timer.get()); + } +} + +void MRDSRG_SO::H1_T2_C1(BlockedTensor& H1, BlockedTensor& T2, const double& alpha, BlockedTensor& C1) { + // 18 lines + local_timer timer; + C1["v,w"] += alpha * -1.00000000 * H1["u,m"] * T2["m,v,w,x"] * Eta1["x,u"]; + C1["u,v"] += alpha * -1.00000000 * H1["e,m"] * T2["m,u,v,e"]; + C1["v,x"] += alpha * +1.00000000 * H1["e,u"] * T2["v,w,x,e"] * Gamma1["u,w"]; + C1["v,e"] += alpha * +1.00000000 * H1["u,m"] * T2["m,v,w,e"] * Eta1["w,u"]; + C1["u,f"] += alpha * -1.00000000 * H1["e,m"] * T2["m,u,f,e"]; + C1["w,e"] += alpha * -1.00000000 * H1["u,v"] * T2["w,x,y,e"] * Eta1["y,u"] * Gamma1["v,x"]; + C1["w,e"] += alpha * +1.00000000 * H1["u,v"] * T2["w,x,y,e"] * Eta1["v,x"] * Gamma1["y,u"]; + C1["v,f"] += alpha * +1.00000000 * H1["e,u"] * T2["v,w,f,e"] * Gamma1["u,w"]; + C1["n,v"] += alpha * +1.00000000 * H1["u,m"] * T2["n,m,v,w"] * Eta1["w,u"]; + C1["n,u"] += alpha * +1.00000000 * H1["e,m"] * T2["n,m,u,e"]; + C1["m,x"] += alpha * +1.00000000 * H1["u,v"] * T2["m,w,x,y"] * Eta1["y,u"] * Gamma1["v,w"]; + C1["m,x"] += alpha * -1.00000000 * H1["u,v"] * T2["m,w,x,y"] * Eta1["v,w"] * Gamma1["y,u"]; + C1["m,w"] += alpha * +1.00000000 * H1["e,u"] * T2["m,v,w,e"] * Gamma1["u,v"]; + C1["n,e"] += alpha * -1.00000000 * H1["u,m"] * T2["n,m,v,e"] * Eta1["v,u"]; + C1["n,f"] += alpha * +1.00000000 * H1["e,m"] * T2["n,m,f,e"]; + C1["m,e"] += alpha * -1.00000000 * H1["u,v"] * T2["m,w,x,e"] * Eta1["x,u"] * Gamma1["v,w"]; + C1["m,e"] += alpha * +1.00000000 * H1["u,v"] * T2["m,w,x,e"] * Eta1["v,w"] * Gamma1["x,u"]; + C1["m,f"] += alpha * +1.00000000 * H1["e,u"] * T2["m,v,f,e"] * Gamma1["u,v"]; + + if (print_ > 2) { + outfile -> Printf("\n Time for H1_T2_C1 : %12.3f", timer.get()); + } +} + +void MRDSRG_SO::H2_T1_C1(BlockedTensor& H2, BlockedTensor& T1, const double& alpha, BlockedTensor& C1) { + // 27 lines + local_timer timer; + C1["u,w"] += alpha * -1.00000000 * H2["u,v,m,w"] * T1["m,x"] * Eta1["x,v"]; + C1["u,v"] += alpha * -1.00000000 * H2["u,e,m,v"] * T1["m,e"]; + C1["u,v"] += alpha * +1.00000000 * H2["u,e,v,w"] * T1["x,e"] * Gamma1["w,x"]; + C1["u,m"] += alpha * +1.00000000 * H2["u,v,m,n"] * T1["n,w"] * Eta1["w,v"]; + C1["u,m"] += alpha * +1.00000000 * H2["u,e,m,n"] * T1["n,e"]; + C1["u,m"] += alpha * +1.00000000 * H2["u,e,m,v"] * T1["w,e"] * Gamma1["v,w"]; + C1["u,e"] += alpha * -1.00000000 * H2["u,v,m,e"] * T1["m,w"] * Eta1["w,v"]; + C1["u,f"] += alpha * -1.00000000 * H2["u,e,m,f"] * T1["m,e"]; + C1["u,f"] += alpha * -1.00000000 * H2["u,e,v,f"] * T1["w,e"] * Gamma1["v,w"]; + C1["m,v"] += alpha * -1.00000000 * H2["m,u,n,v"] * T1["n,w"] * Eta1["w,u"]; + C1["m,u"] += alpha * -1.00000000 * H2["m,e,n,u"] * T1["n,e"]; + C1["m,u"] += alpha * +1.00000000 * H2["m,e,u,v"] * T1["w,e"] * Gamma1["v,w"]; + C1["m,n"] += alpha * +1.00000000 * H2["m,u,n,c0"] * T1["c0,v"] * Eta1["v,u"]; + C1["m,n"] += alpha * +1.00000000 * H2["m,e,n,c0"] * T1["c0,e"]; + C1["m,n"] += alpha * +1.00000000 * H2["m,e,n,u"] * T1["v,e"] * Gamma1["u,v"]; + C1["m,e"] += alpha * -1.00000000 * H2["m,u,n,e"] * T1["n,v"] * Eta1["v,u"]; + C1["m,f"] += alpha * -1.00000000 * H2["m,e,n,f"] * T1["n,e"]; + C1["m,f"] += alpha * -1.00000000 * H2["m,e,u,f"] * T1["v,e"] * Gamma1["u,v"]; + C1["e,v"] += alpha * +1.00000000 * H2["u,e,m,v"] * T1["m,w"] * Eta1["w,u"]; + C1["e,u"] += alpha * -1.00000000 * H2["e,f,m,u"] * T1["m,f"]; + C1["e,u"] += alpha * +1.00000000 * H2["e,f,u,v"] * T1["w,f"] * Gamma1["v,w"]; + C1["e,m"] += alpha * -1.00000000 * H2["u,e,m,n"] * T1["n,v"] * Eta1["v,u"]; + C1["e,m"] += alpha * +1.00000000 * H2["e,f,m,n"] * T1["n,f"]; + C1["e,m"] += alpha * +1.00000000 * H2["e,f,m,u"] * T1["v,f"] * Gamma1["u,v"]; + C1["e,f"] += alpha * +1.00000000 * H2["u,e,m,f"] * T1["m,v"] * Eta1["v,u"]; + C1["e,g"] += alpha * -1.00000000 * H2["e,f,m,g"] * T1["m,f"]; + C1["e,g"] += alpha * -1.00000000 * H2["e,f,u,g"] * T1["v,f"] * Gamma1["u,v"]; + + if (print_ > 2) { + outfile -> Printf("\n Time for H2_T1_C1 : %12.3f", timer.get()); + } +} + +void MRDSRG_SO::H2_T2_C1(BlockedTensor& H2, BlockedTensor& T2, const double& alpha, BlockedTensor& C1) { + // 158 lines + local_timer timer; + C1["u,w"] += alpha * -0.50000000 * H2["u,v,m,n"] * T2["m,n,w,x"] * Eta1["x,v"]; + C1["u,v"] += alpha * -0.50000000 * H2["u,e,m,n"] * T2["m,n,v,e"]; + C1["u,w"] += alpha * +0.50000000 * H2["u,v,m,w"] * T2["m,x,y,z"] * Lambda2["y,z,v,x"]; + C1["x,w"] += alpha * +0.50000000 * H2["u,v,m,w"] * T2["m,x,y,z"] * Eta1["z,v"] * Eta1["y,u"]; + C1["x,w"] += alpha * +0.25000000 * H2["u,v,m,w"] * T2["m,x,y,z"] * Lambda2["y,z,u,v"]; + C1["w,v"] += alpha * +1.00000000 * H2["u,e,m,v"] * T2["m,w,x,e"] * Eta1["x,u"]; + C1["v,u"] += alpha * +0.50000000 * H2["e,f,m,u"] * T2["m,v,e,f"]; + C1["u,y"] += alpha * -1.00000000 * H2["u,v,m,w"] * T2["m,x,y,z"] * Eta1["z,v"] * Gamma1["w,x"]; + C1["u,y"] += alpha * -1.00000000 * H2["u,v,m,w"] * T2["m,x,y,z"] * Lambda2["w,z,v,x"]; + C1["u,x"] += alpha * -1.00000000 * H2["u,e,m,v"] * T2["m,w,x,e"] * Gamma1["v,w"]; + C1["x,y"] += alpha * -0.50000000 * H2["u,v,m,w"] * T2["m,x,y,z"] * Lambda2["w,z,u,v"]; + C1["u,v"] += alpha * -0.50000000 * H2["u,e,v,w"] * T2["x,y,z,e"] * Lambda2["w,z,x,y"]; + C1["x,v"] += alpha * +1.00000000 * H2["u,e,v,w"] * T2["x,y,z,e"] * Eta1["z,u"] * Gamma1["w,y"]; + C1["x,v"] += alpha * +1.00000000 * H2["u,e,v,w"] * T2["x,y,z,e"] * Lambda2["w,z,u,y"]; + C1["w,u"] += alpha * +0.50000000 * H2["e,f,u,v"] * T2["w,x,e,f"] * Gamma1["v,x"]; + C1["u,z"] += alpha * -0.50000000 * H2["u,e,v,w"] * T2["x,y,z,e"] * Gamma1["w,y"] * Gamma1["v,x"]; + C1["u,z"] += alpha * -0.25000000 * H2["u,e,v,w"] * T2["x,y,z,e"] * Lambda2["v,w,x,y"]; + C1["x,z"] += alpha * +0.50000000 * H2["u,e,v,w"] * T2["x,y,z,e"] * Lambda2["v,w,u,y"]; + C1["u,m"] += alpha * -0.50000000 * H2["u,v,m,n"] * T2["n,w,x,y"] * Lambda2["x,y,v,w"]; + C1["w,m"] += alpha * -0.50000000 * H2["u,v,m,n"] * T2["n,w,x,y"] * Eta1["y,v"] * Eta1["x,u"]; + C1["w,m"] += alpha * -0.25000000 * H2["u,v,m,n"] * T2["n,w,x,y"] * Lambda2["x,y,u,v"]; + C1["v,m"] += alpha * -1.00000000 * H2["u,e,m,n"] * T2["n,v,w,e"] * Eta1["w,u"]; + C1["u,m"] += alpha * -0.50000000 * H2["e,f,m,n"] * T2["n,u,e,f"]; + C1["u,m"] += alpha * -0.50000000 * H2["u,e,m,v"] * T2["w,x,y,e"] * Lambda2["v,y,w,x"]; + C1["w,m"] += alpha * +1.00000000 * H2["u,e,m,v"] * T2["w,x,y,e"] * Eta1["y,u"] * Gamma1["v,x"]; + C1["w,m"] += alpha * +1.00000000 * H2["u,e,m,v"] * T2["w,x,y,e"] * Lambda2["v,y,u,x"]; + C1["v,m"] += alpha * +0.50000000 * H2["e,f,m,u"] * T2["v,w,e,f"] * Gamma1["u,w"]; + C1["u,e"] += alpha * +0.50000000 * H2["u,v,m,n"] * T2["m,n,w,e"] * Eta1["w,v"]; + C1["u,f"] += alpha * -0.50000000 * H2["u,e,m,n"] * T2["m,n,f,e"]; + C1["u,e"] += alpha * +1.00000000 * H2["u,v,m,w"] * T2["m,x,y,e"] * Eta1["y,v"] * Gamma1["w,x"]; + C1["u,e"] += alpha * +1.00000000 * H2["u,v,m,w"] * T2["m,x,y,e"] * Lambda2["w,y,v,x"]; + C1["u,f"] += alpha * -1.00000000 * H2["u,e,m,v"] * T2["m,w,f,e"] * Gamma1["v,w"]; + C1["x,e"] += alpha * +0.50000000 * H2["u,v,m,w"] * T2["m,x,y,e"] * Lambda2["w,y,u,v"]; + C1["u,e"] += alpha * +0.50000000 * H2["u,v,m,e"] * T2["m,w,x,y"] * Lambda2["x,y,v,w"]; + C1["w,e"] += alpha * +0.50000000 * H2["u,v,m,e"] * T2["m,w,x,y"] * Eta1["y,v"] * Eta1["x,u"]; + C1["w,e"] += alpha * +0.25000000 * H2["u,v,m,e"] * T2["m,w,x,y"] * Lambda2["x,y,u,v"]; + C1["v,f"] += alpha * +1.00000000 * H2["u,e,m,f"] * T2["m,v,w,e"] * Eta1["w,u"]; + C1["u,g"] += alpha * +0.50000000 * H2["e,f,m,g"] * T2["m,u,e,f"]; + C1["u,e"] += alpha * +0.50000000 * H2["u,v,w,x"] * T2["y,z,a0,e"] * Eta1["a0,v"] * Gamma1["x,z"] * Gamma1["w,y"]; + C1["u,e"] += alpha * +0.25000000 * H2["u,v,w,x"] * T2["y,z,a0,e"] * Eta1["a0,v"] * Lambda2["w,x,y,z"]; + C1["u,e"] += alpha * +0.50000000 * H2["u,v,w,x"] * T2["y,z,a0,e"] * Eta1["x,z"] * Eta1["w,y"] * Gamma1["a0,v"]; + C1["u,e"] += alpha * +1.00000000 * H2["u,v,w,x"] * T2["y,z,a0,e"] * Eta1["x,z"] * Lambda2["w,a0,v,y"]; + C1["u,e"] += alpha * +0.25000000 * H2["u,v,w,x"] * T2["y,z,a0,e"] * Gamma1["a0,v"] * Lambda2["w,x,y,z"]; + C1["u,e"] += alpha * +1.00000000 * H2["u,v,w,x"] * T2["y,z,a0,e"] * Gamma1["x,z"] * Lambda2["w,a0,v,y"]; + C1["u,f"] += alpha * -0.50000000 * H2["u,e,v,w"] * T2["x,y,f,e"] * Gamma1["w,y"] * Gamma1["v,x"]; + C1["u,f"] += alpha * -0.25000000 * H2["u,e,v,w"] * T2["x,y,f,e"] * Lambda2["v,w,x,y"]; + C1["y,e"] += alpha * -0.50000000 * H2["u,v,w,x"] * T2["y,z,a0,e"] * Eta1["a0,v"] * Lambda2["w,x,u,z"]; + C1["y,e"] += alpha * +0.50000000 * H2["u,v,w,x"] * T2["y,z,a0,e"] * Eta1["x,z"] * Lambda2["w,a0,u,v"]; + C1["y,e"] += alpha * +0.50000000 * H2["u,v,w,x"] * T2["y,z,a0,e"] * Gamma1["a0,u"] * Lambda2["w,x,v,z"]; + C1["y,e"] += alpha * +0.50000000 * H2["u,v,w,x"] * T2["y,z,a0,e"] * Gamma1["x,z"] * Lambda2["w,a0,u,v"]; + C1["x,f"] += alpha * +0.50000000 * H2["u,e,v,w"] * T2["x,y,f,e"] * Lambda2["v,w,u,y"]; + C1["u,f"] += alpha * +0.50000000 * H2["u,e,v,f"] * T2["w,x,y,e"] * Lambda2["v,y,w,x"]; + C1["w,f"] += alpha * -1.00000000 * H2["u,e,v,f"] * T2["w,x,y,e"] * Eta1["y,u"] * Gamma1["v,x"]; + C1["w,f"] += alpha * -1.00000000 * H2["u,e,v,f"] * T2["w,x,y,e"] * Lambda2["v,y,u,x"]; + C1["v,g"] += alpha * -0.50000000 * H2["e,f,u,g"] * T2["v,w,e,f"] * Gamma1["u,w"]; + C1["m,v"] += alpha * -0.50000000 * H2["m,u,n,c0"] * T2["n,c0,v,w"] * Eta1["w,u"]; + C1["m,u"] += alpha * -0.50000000 * H2["m,e,n,c0"] * T2["n,c0,u,e"]; + C1["m,v"] += alpha * +0.50000000 * H2["m,u,n,v"] * T2["n,w,x,y"] * Lambda2["x,y,u,w"]; + C1["n,w"] += alpha * -0.50000000 * H2["u,v,m,w"] * T2["n,m,x,y"] * Eta1["y,v"] * Eta1["x,u"]; + C1["n,w"] += alpha * -0.25000000 * H2["u,v,m,w"] * T2["n,m,x,y"] * Lambda2["x,y,u,v"]; + C1["n,v"] += alpha * -1.00000000 * H2["u,e,m,v"] * T2["n,m,w,e"] * Eta1["w,u"]; + C1["n,u"] += alpha * -0.50000000 * H2["e,f,m,u"] * T2["n,m,e,f"]; + C1["m,x"] += alpha * -1.00000000 * H2["m,u,n,v"] * T2["n,w,x,y"] * Eta1["y,u"] * Gamma1["v,w"]; + C1["m,x"] += alpha * -1.00000000 * H2["m,u,n,v"] * T2["n,w,x,y"] * Lambda2["v,y,u,w"]; + C1["m,w"] += alpha * -1.00000000 * H2["m,e,n,u"] * T2["n,v,w,e"] * Gamma1["u,v"]; + C1["n,x"] += alpha * +0.50000000 * H2["u,v,m,w"] * T2["n,m,x,y"] * Lambda2["w,y,u,v"]; + C1["m,u"] += alpha * -0.50000000 * H2["m,e,u,v"] * T2["w,x,y,e"] * Lambda2["v,y,w,x"]; + C1["m,w"] += alpha * +0.50000000 * H2["u,v,w,x"] * T2["m,y,z,a0"] * Eta1["a0,v"] * Eta1["z,u"] * Gamma1["x,y"]; + C1["m,w"] += alpha * +1.00000000 * H2["u,v,w,x"] * T2["m,y,z,a0"] * Eta1["a0,v"] * Lambda2["x,z,u,y"]; + C1["m,w"] += alpha * +0.50000000 * H2["u,v,w,x"] * T2["m,y,z,a0"] * Eta1["x,y"] * Gamma1["a0,v"] * Gamma1["z,u"]; + C1["m,w"] += alpha * +0.25000000 * H2["u,v,w,x"] * T2["m,y,z,a0"] * Eta1["x,y"] * Lambda2["z,a0,u,v"]; + C1["m,w"] += alpha * +1.00000000 * H2["u,v,w,x"] * T2["m,y,z,a0"] * Gamma1["a0,v"] * Lambda2["x,z,u,y"]; + C1["m,w"] += alpha * +0.25000000 * H2["u,v,w,x"] * T2["m,y,z,a0"] * Gamma1["x,y"] * Lambda2["z,a0,u,v"]; + C1["m,v"] += alpha * +1.00000000 * H2["u,e,v,w"] * T2["m,x,y,e"] * Eta1["y,u"] * Gamma1["w,x"]; + C1["m,v"] += alpha * +1.00000000 * H2["u,e,v,w"] * T2["m,x,y,e"] * Lambda2["w,y,u,x"]; + C1["m,u"] += alpha * +0.50000000 * H2["e,f,u,v"] * T2["m,w,e,f"] * Gamma1["v,w"]; + C1["m,y"] += alpha * -0.50000000 * H2["m,e,u,v"] * T2["w,x,y,e"] * Gamma1["v,x"] * Gamma1["u,w"]; + C1["m,y"] += alpha * -0.25000000 * H2["m,e,u,v"] * T2["w,x,y,e"] * Lambda2["u,v,w,x"]; + C1["m,z"] += alpha * +0.50000000 * H2["u,v,w,x"] * T2["m,y,z,a0"] * Eta1["a0,v"] * Lambda2["w,x,u,y"]; + C1["m,z"] += alpha * -0.50000000 * H2["u,v,w,x"] * T2["m,y,z,a0"] * Eta1["x,y"] * Lambda2["w,a0,u,v"]; + C1["m,z"] += alpha * -0.50000000 * H2["u,v,w,x"] * T2["m,y,z,a0"] * Gamma1["a0,u"] * Lambda2["w,x,v,y"]; + C1["m,z"] += alpha * -0.50000000 * H2["u,v,w,x"] * T2["m,y,z,a0"] * Gamma1["x,y"] * Lambda2["w,a0,u,v"]; + C1["m,y"] += alpha * +0.50000000 * H2["u,e,v,w"] * T2["m,x,y,e"] * Lambda2["v,w,u,x"]; + C1["m,n"] += alpha * -0.50000000 * H2["m,u,n,c0"] * T2["c0,v,w,x"] * Lambda2["w,x,u,v"]; + C1["c0,m"] += alpha * +0.50000000 * H2["u,v,m,n"] * T2["c0,n,w,x"] * Eta1["x,v"] * Eta1["w,u"]; + C1["c0,m"] += alpha * +0.25000000 * H2["u,v,m,n"] * T2["c0,n,w,x"] * Lambda2["w,x,u,v"]; + C1["c0,m"] += alpha * +1.00000000 * H2["u,e,m,n"] * T2["c0,n,v,e"] * Eta1["v,u"]; + C1["c0,m"] += alpha * +0.50000000 * H2["e,f,m,n"] * T2["c0,n,e,f"]; + C1["m,n"] += alpha * -0.50000000 * H2["m,e,n,u"] * T2["v,w,x,e"] * Lambda2["u,x,v,w"]; + C1["n,m"] += alpha * +0.50000000 * H2["u,v,m,w"] * T2["n,x,y,z"] * Eta1["z,v"] * Eta1["y,u"] * Gamma1["w,x"]; + C1["n,m"] += alpha * +1.00000000 * H2["u,v,m,w"] * T2["n,x,y,z"] * Eta1["z,v"] * Lambda2["w,y,u,x"]; + C1["n,m"] += alpha * +0.50000000 * H2["u,v,m,w"] * T2["n,x,y,z"] * Eta1["w,x"] * Gamma1["z,v"] * Gamma1["y,u"]; + C1["n,m"] += alpha * +0.25000000 * H2["u,v,m,w"] * T2["n,x,y,z"] * Eta1["w,x"] * Lambda2["y,z,u,v"]; + C1["n,m"] += alpha * +1.00000000 * H2["u,v,m,w"] * T2["n,x,y,z"] * Gamma1["z,v"] * Lambda2["w,y,u,x"]; + C1["n,m"] += alpha * +0.25000000 * H2["u,v,m,w"] * T2["n,x,y,z"] * Gamma1["w,x"] * Lambda2["y,z,u,v"]; + C1["n,m"] += alpha * +1.00000000 * H2["u,e,m,v"] * T2["n,w,x,e"] * Eta1["x,u"] * Gamma1["v,w"]; + C1["n,m"] += alpha * +1.00000000 * H2["u,e,m,v"] * T2["n,w,x,e"] * Lambda2["v,x,u,w"]; + C1["n,m"] += alpha * +0.50000000 * H2["e,f,m,u"] * T2["n,v,e,f"] * Gamma1["u,v"]; + C1["m,e"] += alpha * +0.50000000 * H2["m,u,n,c0"] * T2["n,c0,v,e"] * Eta1["v,u"]; + C1["m,f"] += alpha * -0.50000000 * H2["m,e,n,c0"] * T2["n,c0,f,e"]; + C1["m,e"] += alpha * +1.00000000 * H2["m,u,n,v"] * T2["n,w,x,e"] * Eta1["x,u"] * Gamma1["v,w"]; + C1["m,e"] += alpha * +1.00000000 * H2["m,u,n,v"] * T2["n,w,x,e"] * Lambda2["v,x,u,w"]; + C1["m,f"] += alpha * -1.00000000 * H2["m,e,n,u"] * T2["n,v,f,e"] * Gamma1["u,v"]; + C1["n,e"] += alpha * -0.50000000 * H2["u,v,m,w"] * T2["n,m,x,e"] * Lambda2["w,x,u,v"]; + C1["m,e"] += alpha * +0.50000000 * H2["m,u,n,e"] * T2["n,v,w,x"] * Lambda2["w,x,u,v"]; + C1["n,e"] += alpha * -0.50000000 * H2["u,v,m,e"] * T2["n,m,w,x"] * Eta1["x,v"] * Eta1["w,u"]; + C1["n,e"] += alpha * -0.25000000 * H2["u,v,m,e"] * T2["n,m,w,x"] * Lambda2["w,x,u,v"]; + C1["n,f"] += alpha * -1.00000000 * H2["u,e,m,f"] * T2["n,m,v,e"] * Eta1["v,u"]; + C1["n,g"] += alpha * -0.50000000 * H2["e,f,m,g"] * T2["n,m,e,f"]; + C1["m,e"] += alpha * +0.50000000 * H2["m,u,v,w"] * T2["x,y,z,e"] * Eta1["z,u"] * Gamma1["w,y"] * Gamma1["v,x"]; + C1["m,e"] += alpha * +0.25000000 * H2["m,u,v,w"] * T2["x,y,z,e"] * Eta1["z,u"] * Lambda2["v,w,x,y"]; + C1["m,e"] += alpha * +0.50000000 * H2["m,u,v,w"] * T2["x,y,z,e"] * Eta1["w,y"] * Eta1["v,x"] * Gamma1["z,u"]; + C1["m,e"] += alpha * +1.00000000 * H2["m,u,v,w"] * T2["x,y,z,e"] * Eta1["w,y"] * Lambda2["v,z,u,x"]; + C1["m,e"] += alpha * +0.25000000 * H2["m,u,v,w"] * T2["x,y,z,e"] * Gamma1["z,u"] * Lambda2["v,w,x,y"]; + C1["m,e"] += alpha * +1.00000000 * H2["m,u,v,w"] * T2["x,y,z,e"] * Gamma1["w,y"] * Lambda2["v,z,u,x"]; + C1["m,f"] += alpha * -0.50000000 * H2["m,e,u,v"] * T2["w,x,f,e"] * Gamma1["v,x"] * Gamma1["u,w"]; + C1["m,f"] += alpha * -0.25000000 * H2["m,e,u,v"] * T2["w,x,f,e"] * Lambda2["u,v,w,x"]; + C1["m,e"] += alpha * -0.50000000 * H2["u,v,w,x"] * T2["m,y,z,e"] * Eta1["z,v"] * Lambda2["w,x,u,y"]; + C1["m,e"] += alpha * +0.50000000 * H2["u,v,w,x"] * T2["m,y,z,e"] * Eta1["x,y"] * Lambda2["w,z,u,v"]; + C1["m,e"] += alpha * +0.50000000 * H2["u,v,w,x"] * T2["m,y,z,e"] * Gamma1["z,u"] * Lambda2["w,x,v,y"]; + C1["m,e"] += alpha * +0.50000000 * H2["u,v,w,x"] * T2["m,y,z,e"] * Gamma1["x,y"] * Lambda2["w,z,u,v"]; + C1["m,f"] += alpha * +0.50000000 * H2["u,e,v,w"] * T2["m,x,f,e"] * Lambda2["v,w,u,x"]; + C1["m,f"] += alpha * +0.50000000 * H2["m,e,u,f"] * T2["v,w,x,e"] * Lambda2["u,x,v,w"]; + C1["m,e"] += alpha * -0.50000000 * H2["u,v,w,e"] * T2["m,x,y,z"] * Eta1["z,v"] * Eta1["y,u"] * Gamma1["w,x"]; + C1["m,e"] += alpha * -1.00000000 * H2["u,v,w,e"] * T2["m,x,y,z"] * Eta1["z,v"] * Lambda2["w,y,u,x"]; + C1["m,e"] += alpha * -0.50000000 * H2["u,v,w,e"] * T2["m,x,y,z"] * Eta1["w,x"] * Gamma1["z,v"] * Gamma1["y,u"]; + C1["m,e"] += alpha * -0.25000000 * H2["u,v,w,e"] * T2["m,x,y,z"] * Eta1["w,x"] * Lambda2["y,z,u,v"]; + C1["m,e"] += alpha * -1.00000000 * H2["u,v,w,e"] * T2["m,x,y,z"] * Gamma1["z,v"] * Lambda2["w,y,u,x"]; + C1["m,e"] += alpha * -0.25000000 * H2["u,v,w,e"] * T2["m,x,y,z"] * Gamma1["w,x"] * Lambda2["y,z,u,v"]; + C1["m,f"] += alpha * -1.00000000 * H2["u,e,v,f"] * T2["m,w,x,e"] * Eta1["x,u"] * Gamma1["v,w"]; + C1["m,f"] += alpha * -1.00000000 * H2["u,e,v,f"] * T2["m,w,x,e"] * Lambda2["v,x,u,w"]; + C1["m,g"] += alpha * -0.50000000 * H2["e,f,u,g"] * T2["m,v,e,f"] * Gamma1["u,v"]; + C1["e,v"] += alpha * +0.50000000 * H2["u,e,m,n"] * T2["m,n,v,w"] * Eta1["w,u"]; + C1["e,u"] += alpha * -0.50000000 * H2["e,f,m,n"] * T2["m,n,u,f"]; + C1["e,v"] += alpha * -0.50000000 * H2["u,e,m,v"] * T2["m,w,x,y"] * Lambda2["x,y,u,w"]; + C1["e,x"] += alpha * +1.00000000 * H2["u,e,m,v"] * T2["m,w,x,y"] * Eta1["y,u"] * Gamma1["v,w"]; + C1["e,x"] += alpha * +1.00000000 * H2["u,e,m,v"] * T2["m,w,x,y"] * Lambda2["v,y,u,w"]; + C1["e,w"] += alpha * -1.00000000 * H2["e,f,m,u"] * T2["m,v,w,f"] * Gamma1["u,v"]; + C1["e,u"] += alpha * -0.50000000 * H2["e,f,u,v"] * T2["w,x,y,f"] * Lambda2["v,y,w,x"]; + C1["e,y"] += alpha * -0.50000000 * H2["e,f,u,v"] * T2["w,x,y,f"] * Gamma1["v,x"] * Gamma1["u,w"]; + C1["e,y"] += alpha * -0.25000000 * H2["e,f,u,v"] * T2["w,x,y,f"] * Lambda2["u,v,w,x"]; + C1["e,m"] += alpha * +0.50000000 * H2["u,e,m,n"] * T2["n,v,w,x"] * Lambda2["w,x,u,v"]; + C1["e,m"] += alpha * -0.50000000 * H2["e,f,m,u"] * T2["v,w,x,f"] * Lambda2["u,x,v,w"]; + C1["e,f"] += alpha * -0.50000000 * H2["u,e,m,n"] * T2["m,n,v,f"] * Eta1["v,u"]; + C1["e,g"] += alpha * -0.50000000 * H2["e,f,m,n"] * T2["m,n,g,f"]; + C1["e,f"] += alpha * -1.00000000 * H2["u,e,m,v"] * T2["m,w,x,f"] * Eta1["x,u"] * Gamma1["v,w"]; + C1["e,f"] += alpha * -1.00000000 * H2["u,e,m,v"] * T2["m,w,x,f"] * Lambda2["v,x,u,w"]; + C1["e,g"] += alpha * -1.00000000 * H2["e,f,m,u"] * T2["m,v,g,f"] * Gamma1["u,v"]; + C1["e,f"] += alpha * -0.50000000 * H2["u,e,m,f"] * T2["m,v,w,x"] * Lambda2["w,x,u,v"]; + C1["e,f"] += alpha * -0.50000000 * H2["u,e,v,w"] * T2["x,y,z,f"] * Eta1["z,u"] * Gamma1["w,y"] * Gamma1["v,x"]; + C1["e,f"] += alpha * -0.25000000 * H2["u,e,v,w"] * T2["x,y,z,f"] * Eta1["z,u"] * Lambda2["v,w,x,y"]; + C1["e,f"] += alpha * -0.50000000 * H2["u,e,v,w"] * T2["x,y,z,f"] * Eta1["w,y"] * Eta1["v,x"] * Gamma1["z,u"]; + C1["e,f"] += alpha * -1.00000000 * H2["u,e,v,w"] * T2["x,y,z,f"] * Eta1["w,y"] * Lambda2["v,z,u,x"]; + C1["e,f"] += alpha * -0.25000000 * H2["u,e,v,w"] * T2["x,y,z,f"] * Gamma1["z,u"] * Lambda2["v,w,x,y"]; + C1["e,f"] += alpha * -1.00000000 * H2["u,e,v,w"] * T2["x,y,z,f"] * Gamma1["w,y"] * Lambda2["v,z,u,x"]; + C1["e,g"] += alpha * -0.50000000 * H2["e,f,u,v"] * T2["w,x,g,f"] * Gamma1["v,x"] * Gamma1["u,w"]; + C1["e,g"] += alpha * -0.25000000 * H2["e,f,u,v"] * T2["w,x,g,f"] * Lambda2["u,v,w,x"]; + C1["e,g"] += alpha * +0.50000000 * H2["e,f,u,g"] * T2["v,w,x,f"] * Lambda2["u,x,v,w"]; + + if (print_ > 2) { + outfile -> Printf("\n Time for H2_T2_C1 : %12.3f", timer.get()); + } +} + +void MRDSRG_SO::H1_T2_C2(BlockedTensor& H1, BlockedTensor& T2, const double& alpha, BlockedTensor& C2) { + // 96 lines + local_timer timer; + C2["u,v,w,x"] += alpha * -0.50000000 * H1["u,m"] * T2["m,v,w,x"]; + C2["v,w,u,x"] += alpha * -0.50000000 * H1["e,u"] * T2["v,w,x,e"]; + C2["u,v,m,w"] += alpha * -0.50000000 * H1["e,m"] * T2["u,v,w,e"]; + C2["u,v,w,e"] += alpha * -1.00000000 * H1["u,m"] * T2["m,v,w,e"]; + C2["w,x,v,e"] += alpha * +0.50000000 * H1["u,v"] * T2["w,x,y,e"] * Eta1["y,u"]; + C2["w,x,v,e"] += alpha * +0.50000000 * H1["u,v"] * T2["w,x,y,e"] * Gamma1["y,u"]; + C2["v,w,u,f"] += alpha * -0.50000000 * H1["e,u"] * T2["v,w,f,e"]; + C2["u,w,y,e"] += alpha * +1.00000000 * H1["u,v"] * T2["w,x,y,e"] * Eta1["v,x"]; + C2["u,w,y,e"] += alpha * +1.00000000 * H1["u,v"] * T2["w,x,y,e"] * Gamma1["v,x"]; + C2["u,v,w,f"] += alpha * +0.50000000 * H1["e,f"] * T2["u,v,w,e"]; + C2["v,w,m,e"] += alpha * +0.50000000 * H1["u,m"] * T2["v,w,x,e"] * Eta1["x,u"]; + C2["v,w,m,e"] += alpha * +0.50000000 * H1["u,m"] * T2["v,w,x,e"] * Gamma1["x,u"]; + C2["u,v,m,f"] += alpha * -0.50000000 * H1["e,m"] * T2["u,v,f,e"]; + C2["u,v,e,f"] += alpha * -0.50000000 * H1["u,m"] * T2["m,v,e,f"]; + C2["u,w,e,f"] += alpha * +0.50000000 * H1["u,v"] * T2["w,x,e,f"] * Eta1["v,x"]; + C2["u,w,e,f"] += alpha * +0.50000000 * H1["u,v"] * T2["w,x,e,f"] * Gamma1["v,x"]; + C2["v,w,e,f"] += alpha * +0.50000000 * H1["u,e"] * T2["v,w,x,f"] * Eta1["x,u"]; + C2["v,w,e,f"] += alpha * +0.50000000 * H1["u,e"] * T2["v,w,x,f"] * Gamma1["x,u"]; + C2["u,v,f,g"] += alpha * -0.50000000 * H1["e,f"] * T2["u,v,g,e"]; + C2["u,e,v,w"] += alpha * +0.50000000 * H1["e,m"] * T2["m,u,v,w"]; + C2["u,e,v,f"] += alpha * +1.00000000 * H1["e,m"] * T2["m,u,v,f"]; + C2["v,e,x,f"] += alpha * -1.00000000 * H1["e,u"] * T2["v,w,x,f"] * Eta1["u,w"]; + C2["v,e,x,f"] += alpha * -1.00000000 * H1["e,u"] * T2["v,w,x,f"] * Gamma1["u,w"]; + C2["u,e,f,g"] += alpha * +0.50000000 * H1["e,m"] * T2["m,u,f,g"]; + C2["v,e,f,g"] += alpha * -0.50000000 * H1["e,u"] * T2["v,w,f,g"] * Eta1["u,w"]; + C2["v,e,f,g"] += alpha * -0.50000000 * H1["e,u"] * T2["v,w,f,g"] * Gamma1["u,w"]; + C2["m,u,v,w"] += alpha * -0.50000000 * H1["m,n"] * T2["n,u,v,w"]; + C2["n,u,v,w"] += alpha * -0.50000000 * H1["u,m"] * T2["n,m,v,w"]; + C2["m,w,v,x"] += alpha * -1.00000000 * H1["u,v"] * T2["m,w,x,y"] * Eta1["y,u"]; + C2["m,w,v,x"] += alpha * -1.00000000 * H1["u,v"] * T2["m,w,x,y"] * Gamma1["y,u"]; + C2["m,v,u,w"] += alpha * -1.00000000 * H1["e,u"] * T2["m,v,w,e"]; + C2["m,u,x,y"] += alpha * -0.50000000 * H1["u,v"] * T2["m,w,x,y"] * Eta1["v,w"]; + C2["m,u,x,y"] += alpha * -0.50000000 * H1["u,v"] * T2["m,w,x,y"] * Gamma1["v,w"]; + C2["n,v,m,w"] += alpha * -1.00000000 * H1["u,m"] * T2["n,v,w,x"] * Eta1["x,u"]; + C2["n,v,m,w"] += alpha * -1.00000000 * H1["u,m"] * T2["n,v,w,x"] * Gamma1["x,u"]; + C2["n,u,m,v"] += alpha * -1.00000000 * H1["e,m"] * T2["n,u,v,e"]; + C2["m,u,v,e"] += alpha * -1.00000000 * H1["m,n"] * T2["n,u,v,e"]; + C2["n,u,v,e"] += alpha * -1.00000000 * H1["u,m"] * T2["n,m,v,e"]; + C2["m,w,v,e"] += alpha * +1.00000000 * H1["u,v"] * T2["m,w,x,e"] * Eta1["x,u"]; + C2["m,w,v,e"] += alpha * +1.00000000 * H1["u,v"] * T2["m,w,x,e"] * Gamma1["x,u"]; + C2["m,v,u,f"] += alpha * -1.00000000 * H1["e,u"] * T2["m,v,f,e"]; + C2["m,v,x,e"] += alpha * +1.00000000 * H1["m,u"] * T2["v,w,x,e"] * Eta1["u,w"]; + C2["m,v,x,e"] += alpha * +1.00000000 * H1["m,u"] * T2["v,w,x,e"] * Gamma1["u,w"]; + C2["m,u,x,e"] += alpha * -1.00000000 * H1["u,v"] * T2["m,w,x,e"] * Eta1["v,w"]; + C2["m,u,x,e"] += alpha * -1.00000000 * H1["u,v"] * T2["m,w,x,e"] * Gamma1["v,w"]; + C2["m,v,w,e"] += alpha * +1.00000000 * H1["u,e"] * T2["m,v,w,x"] * Eta1["x,u"]; + C2["m,v,w,e"] += alpha * +1.00000000 * H1["u,e"] * T2["m,v,w,x"] * Gamma1["x,u"]; + C2["m,u,v,f"] += alpha * +1.00000000 * H1["e,f"] * T2["m,u,v,e"]; + C2["n,v,m,e"] += alpha * +1.00000000 * H1["u,m"] * T2["n,v,w,e"] * Eta1["w,u"]; + C2["n,v,m,e"] += alpha * +1.00000000 * H1["u,m"] * T2["n,v,w,e"] * Gamma1["w,u"]; + C2["n,u,m,f"] += alpha * -1.00000000 * H1["e,m"] * T2["n,u,f,e"]; + C2["m,u,e,f"] += alpha * -0.50000000 * H1["m,n"] * T2["n,u,e,f"]; + C2["n,u,e,f"] += alpha * -0.50000000 * H1["u,m"] * T2["n,m,e,f"]; + C2["m,v,e,f"] += alpha * +0.50000000 * H1["m,u"] * T2["v,w,e,f"] * Eta1["u,w"]; + C2["m,v,e,f"] += alpha * +0.50000000 * H1["m,u"] * T2["v,w,e,f"] * Gamma1["u,w"]; + C2["m,u,e,f"] += alpha * -0.50000000 * H1["u,v"] * T2["m,w,e,f"] * Eta1["v,w"]; + C2["m,u,e,f"] += alpha * -0.50000000 * H1["u,v"] * T2["m,w,e,f"] * Gamma1["v,w"]; + C2["m,v,e,f"] += alpha * +1.00000000 * H1["u,e"] * T2["m,v,w,f"] * Eta1["w,u"]; + C2["m,v,e,f"] += alpha * +1.00000000 * H1["u,e"] * T2["m,v,w,f"] * Gamma1["w,u"]; + C2["m,u,f,g"] += alpha * -1.00000000 * H1["e,f"] * T2["m,u,g,e"]; + C2["m,c0,u,v"] += alpha * +0.50000000 * H1["m,n"] * T2["c0,n,u,v"]; + C2["m,n,v,w"] += alpha * -0.50000000 * H1["u,v"] * T2["m,n,w,x"] * Eta1["x,u"]; + C2["m,n,v,w"] += alpha * -0.50000000 * H1["u,v"] * T2["m,n,w,x"] * Gamma1["x,u"]; + C2["m,n,u,v"] += alpha * -0.50000000 * H1["e,u"] * T2["m,n,v,e"]; + C2["m,n,w,x"] += alpha * +0.50000000 * H1["m,u"] * T2["n,v,w,x"] * Eta1["u,v"]; + C2["m,n,w,x"] += alpha * +0.50000000 * H1["m,u"] * T2["n,v,w,x"] * Gamma1["u,v"]; + C2["n,c0,m,v"] += alpha * -0.50000000 * H1["u,m"] * T2["n,c0,v,w"] * Eta1["w,u"]; + C2["n,c0,m,v"] += alpha * -0.50000000 * H1["u,m"] * T2["n,c0,v,w"] * Gamma1["w,u"]; + C2["n,c0,m,u"] += alpha * -0.50000000 * H1["e,m"] * T2["n,c0,u,e"]; + C2["m,c0,u,e"] += alpha * +1.00000000 * H1["m,n"] * T2["c0,n,u,e"]; + C2["m,n,v,e"] += alpha * +0.50000000 * H1["u,v"] * T2["m,n,w,e"] * Eta1["w,u"]; + C2["m,n,v,e"] += alpha * +0.50000000 * H1["u,v"] * T2["m,n,w,e"] * Gamma1["w,u"]; + C2["m,n,u,f"] += alpha * -0.50000000 * H1["e,u"] * T2["m,n,f,e"]; + C2["m,n,w,e"] += alpha * +1.00000000 * H1["m,u"] * T2["n,v,w,e"] * Eta1["u,v"]; + C2["m,n,w,e"] += alpha * +1.00000000 * H1["m,u"] * T2["n,v,w,e"] * Gamma1["u,v"]; + C2["m,n,v,e"] += alpha * +0.50000000 * H1["u,e"] * T2["m,n,v,w"] * Eta1["w,u"]; + C2["m,n,v,e"] += alpha * +0.50000000 * H1["u,e"] * T2["m,n,v,w"] * Gamma1["w,u"]; + C2["m,n,u,f"] += alpha * +0.50000000 * H1["e,f"] * T2["m,n,u,e"]; + C2["n,c0,m,e"] += alpha * +0.50000000 * H1["u,m"] * T2["n,c0,v,e"] * Eta1["v,u"]; + C2["n,c0,m,e"] += alpha * +0.50000000 * H1["u,m"] * T2["n,c0,v,e"] * Gamma1["v,u"]; + C2["n,c0,m,f"] += alpha * -0.50000000 * H1["e,m"] * T2["n,c0,f,e"]; + C2["m,c0,e,f"] += alpha * +0.50000000 * H1["m,n"] * T2["c0,n,e,f"]; + C2["m,n,e,f"] += alpha * +0.50000000 * H1["m,u"] * T2["n,v,e,f"] * Eta1["u,v"]; + C2["m,n,e,f"] += alpha * +0.50000000 * H1["m,u"] * T2["n,v,e,f"] * Gamma1["u,v"]; + C2["m,n,e,f"] += alpha * +0.50000000 * H1["u,e"] * T2["m,n,v,f"] * Eta1["v,u"]; + C2["m,n,e,f"] += alpha * +0.50000000 * H1["u,e"] * T2["m,n,v,f"] * Gamma1["v,u"]; + C2["m,n,f,g"] += alpha * -0.50000000 * H1["e,f"] * T2["m,n,g,e"]; + C2["n,e,u,v"] += alpha * -0.50000000 * H1["e,m"] * T2["n,m,u,v"]; + C2["m,e,w,x"] += alpha * -0.50000000 * H1["e,u"] * T2["m,v,w,x"] * Eta1["u,v"]; + C2["m,e,w,x"] += alpha * -0.50000000 * H1["e,u"] * T2["m,v,w,x"] * Gamma1["u,v"]; + C2["n,e,u,f"] += alpha * -1.00000000 * H1["e,m"] * T2["n,m,u,f"]; + C2["m,e,w,f"] += alpha * -1.00000000 * H1["e,u"] * T2["m,v,w,f"] * Eta1["u,v"]; + C2["m,e,w,f"] += alpha * -1.00000000 * H1["e,u"] * T2["m,v,w,f"] * Gamma1["u,v"]; + C2["n,e,f,g"] += alpha * -0.50000000 * H1["e,m"] * T2["n,m,f,g"]; + C2["m,e,f,g"] += alpha * -0.50000000 * H1["e,u"] * T2["m,v,f,g"] * Eta1["u,v"]; + C2["m,e,f,g"] += alpha * -0.50000000 * H1["e,u"] * T2["m,v,f,g"] * Gamma1["u,v"]; + + if (print_ > 2) { + outfile -> Printf("\n Time for H1_T2_C2 : %12.3f", timer.get()); + } +} + +void MRDSRG_SO::H2_T1_C2(BlockedTensor& H2, BlockedTensor& T1, const double& alpha, BlockedTensor& C2) { + // 144 lines + local_timer timer; + C2["u,v,w,x"] += alpha * +0.50000000 * H2["u,v,m,w"] * T1["m,x"]; + C2["u,x,v,w"] += alpha * +0.50000000 * H2["u,e,v,w"] * T1["x,e"]; + C2["u,v,m,w"] += alpha * -0.50000000 * H2["u,v,m,n"] * T1["n,w"]; + C2["u,w,m,v"] += alpha * +1.00000000 * H2["u,e,m,v"] * T1["w,e"]; + C2["u,v,m,n"] += alpha * +0.50000000 * H2["u,e,m,n"] * T1["v,e"]; + C2["u,v,w,e"] += alpha * +0.50000000 * H2["u,v,m,w"] * T1["m,e"]; + C2["u,v,w,e"] += alpha * -0.50000000 * H2["u,v,m,e"] * T1["m,w"]; + C2["u,v,w,e"] += alpha * -0.50000000 * H2["u,v,w,x"] * T1["y,e"] * Eta1["x,y"]; + C2["u,v,w,e"] += alpha * -0.50000000 * H2["u,v,w,x"] * T1["y,e"] * Gamma1["x,y"]; + C2["u,w,v,f"] += alpha * +1.00000000 * H2["u,e,v,f"] * T1["w,e"]; + C2["u,v,m,e"] += alpha * -0.50000000 * H2["u,v,m,n"] * T1["n,e"]; + C2["u,v,m,e"] += alpha * -0.50000000 * H2["u,v,m,w"] * T1["x,e"] * Eta1["w,x"]; + C2["u,v,m,e"] += alpha * -0.50000000 * H2["u,v,m,w"] * T1["x,e"] * Gamma1["w,x"]; + C2["u,v,m,f"] += alpha * +1.00000000 * H2["u,e,m,f"] * T1["v,e"]; + C2["u,v,e,f"] += alpha * +0.50000000 * H2["u,v,m,e"] * T1["m,f"]; + C2["u,v,e,f"] += alpha * +0.50000000 * H2["u,v,w,e"] * T1["x,f"] * Eta1["w,x"]; + C2["u,v,e,f"] += alpha * +0.50000000 * H2["u,v,w,e"] * T1["x,f"] * Gamma1["w,x"]; + C2["u,v,f,g"] += alpha * +0.50000000 * H2["u,e,f,g"] * T1["v,e"]; + C2["u,e,v,w"] += alpha * +1.00000000 * H2["u,e,m,v"] * T1["m,w"]; + C2["w,e,u,v"] += alpha * -0.50000000 * H2["e,f,u,v"] * T1["w,f"]; + C2["u,e,m,v"] += alpha * -1.00000000 * H2["u,e,m,n"] * T1["n,v"]; + C2["v,e,m,u"] += alpha * -1.00000000 * H2["e,f,m,u"] * T1["v,f"]; + C2["u,e,m,n"] += alpha * -0.50000000 * H2["e,f,m,n"] * T1["u,f"]; + C2["u,e,v,f"] += alpha * +1.00000000 * H2["u,e,m,v"] * T1["m,f"]; + C2["u,e,v,f"] += alpha * -1.00000000 * H2["u,e,m,f"] * T1["m,v"]; + C2["u,e,v,f"] += alpha * -1.00000000 * H2["u,e,v,w"] * T1["x,f"] * Eta1["w,x"]; + C2["u,e,v,f"] += alpha * -1.00000000 * H2["u,e,v,w"] * T1["x,f"] * Gamma1["w,x"]; + C2["v,e,u,g"] += alpha * -1.00000000 * H2["e,f,u,g"] * T1["v,f"]; + C2["u,e,m,f"] += alpha * -1.00000000 * H2["u,e,m,n"] * T1["n,f"]; + C2["u,e,m,f"] += alpha * -1.00000000 * H2["u,e,m,v"] * T1["w,f"] * Eta1["v,w"]; + C2["u,e,m,f"] += alpha * -1.00000000 * H2["u,e,m,v"] * T1["w,f"] * Gamma1["v,w"]; + C2["u,e,m,g"] += alpha * -1.00000000 * H2["e,f,m,g"] * T1["u,f"]; + C2["u,e,f,g"] += alpha * +1.00000000 * H2["u,e,m,f"] * T1["m,g"]; + C2["u,e,f,g"] += alpha * +1.00000000 * H2["u,e,v,f"] * T1["w,g"] * Eta1["v,w"]; + C2["u,e,f,g"] += alpha * +1.00000000 * H2["u,e,v,f"] * T1["w,g"] * Gamma1["v,w"]; + C2["u,e,g,h"] += alpha * -0.50000000 * H2["e,f,g,h"] * T1["u,f"]; + C2["m,u,v,w"] += alpha * +1.00000000 * H2["m,u,n,v"] * T1["n,w"]; + C2["m,w,u,v"] += alpha * +0.50000000 * H2["m,e,u,v"] * T1["w,e"]; + C2["m,u,w,x"] += alpha * -0.50000000 * H2["u,v,w,x"] * T1["m,y"] * Eta1["y,v"]; + C2["m,u,w,x"] += alpha * -0.50000000 * H2["u,v,w,x"] * T1["m,y"] * Gamma1["y,v"]; + C2["m,u,v,w"] += alpha * -0.50000000 * H2["u,e,v,w"] * T1["m,e"]; + C2["m,u,n,v"] += alpha * -1.00000000 * H2["m,u,n,c0"] * T1["c0,v"]; + C2["m,v,n,u"] += alpha * +1.00000000 * H2["m,e,n,u"] * T1["v,e"]; + C2["n,u,m,w"] += alpha * -1.00000000 * H2["u,v,m,w"] * T1["n,x"] * Eta1["x,v"]; + C2["n,u,m,w"] += alpha * -1.00000000 * H2["u,v,m,w"] * T1["n,x"] * Gamma1["x,v"]; + C2["n,u,m,v"] += alpha * -1.00000000 * H2["u,e,m,v"] * T1["n,e"]; + C2["m,u,n,c0"] += alpha * +0.50000000 * H2["m,e,n,c0"] * T1["u,e"]; + C2["c0,u,m,n"] += alpha * -0.50000000 * H2["u,v,m,n"] * T1["c0,w"] * Eta1["w,v"]; + C2["c0,u,m,n"] += alpha * -0.50000000 * H2["u,v,m,n"] * T1["c0,w"] * Gamma1["w,v"]; + C2["c0,u,m,n"] += alpha * -0.50000000 * H2["u,e,m,n"] * T1["c0,e"]; + C2["m,u,v,e"] += alpha * +1.00000000 * H2["m,u,n,v"] * T1["n,e"]; + C2["m,u,v,e"] += alpha * -1.00000000 * H2["m,u,n,e"] * T1["n,v"]; + C2["m,u,v,e"] += alpha * -1.00000000 * H2["m,u,v,w"] * T1["x,e"] * Eta1["w,x"]; + C2["m,u,v,e"] += alpha * -1.00000000 * H2["m,u,v,w"] * T1["x,e"] * Gamma1["w,x"]; + C2["m,v,u,f"] += alpha * +1.00000000 * H2["m,e,u,f"] * T1["v,e"]; + C2["m,u,w,e"] += alpha * -1.00000000 * H2["u,v,w,e"] * T1["m,x"] * Eta1["x,v"]; + C2["m,u,w,e"] += alpha * -1.00000000 * H2["u,v,w,e"] * T1["m,x"] * Gamma1["x,v"]; + C2["m,u,v,f"] += alpha * -1.00000000 * H2["u,e,v,f"] * T1["m,e"]; + C2["m,u,n,e"] += alpha * -1.00000000 * H2["m,u,n,c0"] * T1["c0,e"]; + C2["m,u,n,e"] += alpha * -1.00000000 * H2["m,u,n,v"] * T1["w,e"] * Eta1["v,w"]; + C2["m,u,n,e"] += alpha * -1.00000000 * H2["m,u,n,v"] * T1["w,e"] * Gamma1["v,w"]; + C2["m,u,n,f"] += alpha * +1.00000000 * H2["m,e,n,f"] * T1["u,e"]; + C2["n,u,m,e"] += alpha * -1.00000000 * H2["u,v,m,e"] * T1["n,w"] * Eta1["w,v"]; + C2["n,u,m,e"] += alpha * -1.00000000 * H2["u,v,m,e"] * T1["n,w"] * Gamma1["w,v"]; + C2["n,u,m,f"] += alpha * -1.00000000 * H2["u,e,m,f"] * T1["n,e"]; + C2["m,u,e,f"] += alpha * +1.00000000 * H2["m,u,n,e"] * T1["n,f"]; + C2["m,u,e,f"] += alpha * +1.00000000 * H2["m,u,v,e"] * T1["w,f"] * Eta1["v,w"]; + C2["m,u,e,f"] += alpha * +1.00000000 * H2["m,u,v,e"] * T1["w,f"] * Gamma1["v,w"]; + C2["m,u,f,g"] += alpha * +0.50000000 * H2["m,e,f,g"] * T1["u,e"]; + C2["m,u,e,f"] += alpha * -0.50000000 * H2["u,v,e,f"] * T1["m,w"] * Eta1["w,v"]; + C2["m,u,e,f"] += alpha * -0.50000000 * H2["u,v,e,f"] * T1["m,w"] * Gamma1["w,v"]; + C2["m,u,f,g"] += alpha * -0.50000000 * H2["u,e,f,g"] * T1["m,e"]; + C2["m,n,u,v"] += alpha * +0.50000000 * H2["m,n,c0,u"] * T1["c0,v"]; + C2["m,n,v,w"] += alpha * +0.50000000 * H2["m,u,v,w"] * T1["n,x"] * Eta1["x,u"]; + C2["m,n,v,w"] += alpha * +0.50000000 * H2["m,u,v,w"] * T1["n,x"] * Gamma1["x,u"]; + C2["m,n,u,v"] += alpha * +0.50000000 * H2["m,e,u,v"] * T1["n,e"]; + C2["m,n,c0,u"] += alpha * -0.50000000 * H2["m,n,c0,c1"] * T1["c1,u"]; + C2["m,c0,n,v"] += alpha * +1.00000000 * H2["m,u,n,v"] * T1["c0,w"] * Eta1["w,u"]; + C2["m,c0,n,v"] += alpha * +1.00000000 * H2["m,u,n,v"] * T1["c0,w"] * Gamma1["w,u"]; + C2["m,c0,n,u"] += alpha * +1.00000000 * H2["m,e,n,u"] * T1["c0,e"]; + C2["m,c1,n,c0"] += alpha * +0.50000000 * H2["m,u,n,c0"] * T1["c1,v"] * Eta1["v,u"]; + C2["m,c1,n,c0"] += alpha * +0.50000000 * H2["m,u,n,c0"] * T1["c1,v"] * Gamma1["v,u"]; + C2["m,c1,n,c0"] += alpha * +0.50000000 * H2["m,e,n,c0"] * T1["c1,e"]; + C2["m,n,u,e"] += alpha * +0.50000000 * H2["m,n,c0,u"] * T1["c0,e"]; + C2["m,n,u,e"] += alpha * -0.50000000 * H2["m,n,c0,e"] * T1["c0,u"]; + C2["m,n,u,e"] += alpha * -0.50000000 * H2["m,n,u,v"] * T1["w,e"] * Eta1["v,w"]; + C2["m,n,u,e"] += alpha * -0.50000000 * H2["m,n,u,v"] * T1["w,e"] * Gamma1["v,w"]; + C2["m,n,v,e"] += alpha * +1.00000000 * H2["m,u,v,e"] * T1["n,w"] * Eta1["w,u"]; + C2["m,n,v,e"] += alpha * +1.00000000 * H2["m,u,v,e"] * T1["n,w"] * Gamma1["w,u"]; + C2["m,n,u,f"] += alpha * +1.00000000 * H2["m,e,u,f"] * T1["n,e"]; + C2["m,n,c0,e"] += alpha * -0.50000000 * H2["m,n,c0,c1"] * T1["c1,e"]; + C2["m,n,c0,e"] += alpha * -0.50000000 * H2["m,n,c0,u"] * T1["v,e"] * Eta1["u,v"]; + C2["m,n,c0,e"] += alpha * -0.50000000 * H2["m,n,c0,u"] * T1["v,e"] * Gamma1["u,v"]; + C2["m,c0,n,e"] += alpha * +1.00000000 * H2["m,u,n,e"] * T1["c0,v"] * Eta1["v,u"]; + C2["m,c0,n,e"] += alpha * +1.00000000 * H2["m,u,n,e"] * T1["c0,v"] * Gamma1["v,u"]; + C2["m,c0,n,f"] += alpha * +1.00000000 * H2["m,e,n,f"] * T1["c0,e"]; + C2["m,n,e,f"] += alpha * +0.50000000 * H2["m,n,c0,e"] * T1["c0,f"]; + C2["m,n,e,f"] += alpha * +0.50000000 * H2["m,n,u,e"] * T1["v,f"] * Eta1["u,v"]; + C2["m,n,e,f"] += alpha * +0.50000000 * H2["m,n,u,e"] * T1["v,f"] * Gamma1["u,v"]; + C2["m,n,e,f"] += alpha * +0.50000000 * H2["m,u,e,f"] * T1["n,v"] * Eta1["v,u"]; + C2["m,n,e,f"] += alpha * +0.50000000 * H2["m,u,e,f"] * T1["n,v"] * Gamma1["v,u"]; + C2["m,n,f,g"] += alpha * +0.50000000 * H2["m,e,f,g"] * T1["n,e"]; + C2["m,e,u,v"] += alpha * +1.00000000 * H2["m,e,n,u"] * T1["n,v"]; + C2["m,e,v,w"] += alpha * +0.50000000 * H2["u,e,v,w"] * T1["m,x"] * Eta1["x,u"]; + C2["m,e,v,w"] += alpha * +0.50000000 * H2["u,e,v,w"] * T1["m,x"] * Gamma1["x,u"]; + C2["m,e,u,v"] += alpha * -0.50000000 * H2["e,f,u,v"] * T1["m,f"]; + C2["m,e,n,u"] += alpha * -1.00000000 * H2["m,e,n,c0"] * T1["c0,u"]; + C2["n,e,m,v"] += alpha * +1.00000000 * H2["u,e,m,v"] * T1["n,w"] * Eta1["w,u"]; + C2["n,e,m,v"] += alpha * +1.00000000 * H2["u,e,m,v"] * T1["n,w"] * Gamma1["w,u"]; + C2["n,e,m,u"] += alpha * -1.00000000 * H2["e,f,m,u"] * T1["n,f"]; + C2["c0,e,m,n"] += alpha * +0.50000000 * H2["u,e,m,n"] * T1["c0,v"] * Eta1["v,u"]; + C2["c0,e,m,n"] += alpha * +0.50000000 * H2["u,e,m,n"] * T1["c0,v"] * Gamma1["v,u"]; + C2["c0,e,m,n"] += alpha * -0.50000000 * H2["e,f,m,n"] * T1["c0,f"]; + C2["m,e,u,f"] += alpha * +1.00000000 * H2["m,e,n,u"] * T1["n,f"]; + C2["m,e,u,f"] += alpha * -1.00000000 * H2["m,e,n,f"] * T1["n,u"]; + C2["m,e,u,f"] += alpha * -1.00000000 * H2["m,e,u,v"] * T1["w,f"] * Eta1["v,w"]; + C2["m,e,u,f"] += alpha * -1.00000000 * H2["m,e,u,v"] * T1["w,f"] * Gamma1["v,w"]; + C2["m,e,v,f"] += alpha * +1.00000000 * H2["u,e,v,f"] * T1["m,w"] * Eta1["w,u"]; + C2["m,e,v,f"] += alpha * +1.00000000 * H2["u,e,v,f"] * T1["m,w"] * Gamma1["w,u"]; + C2["m,e,u,g"] += alpha * -1.00000000 * H2["e,f,u,g"] * T1["m,f"]; + C2["m,e,n,f"] += alpha * -1.00000000 * H2["m,e,n,c0"] * T1["c0,f"]; + C2["m,e,n,f"] += alpha * -1.00000000 * H2["m,e,n,u"] * T1["v,f"] * Eta1["u,v"]; + C2["m,e,n,f"] += alpha * -1.00000000 * H2["m,e,n,u"] * T1["v,f"] * Gamma1["u,v"]; + C2["n,e,m,f"] += alpha * +1.00000000 * H2["u,e,m,f"] * T1["n,v"] * Eta1["v,u"]; + C2["n,e,m,f"] += alpha * +1.00000000 * H2["u,e,m,f"] * T1["n,v"] * Gamma1["v,u"]; + C2["n,e,m,g"] += alpha * -1.00000000 * H2["e,f,m,g"] * T1["n,f"]; + C2["m,e,f,g"] += alpha * +1.00000000 * H2["m,e,n,f"] * T1["n,g"]; + C2["m,e,f,g"] += alpha * +1.00000000 * H2["m,e,u,f"] * T1["v,g"] * Eta1["u,v"]; + C2["m,e,f,g"] += alpha * +1.00000000 * H2["m,e,u,f"] * T1["v,g"] * Gamma1["u,v"]; + C2["m,e,f,g"] += alpha * +0.50000000 * H2["u,e,f,g"] * T1["m,v"] * Eta1["v,u"]; + C2["m,e,f,g"] += alpha * +0.50000000 * H2["u,e,f,g"] * T1["m,v"] * Gamma1["v,u"]; + C2["m,e,g,h"] += alpha * -0.50000000 * H2["e,f,g,h"] * T1["m,f"]; + C2["e,f,u,v"] += alpha * +0.50000000 * H2["e,f,m,u"] * T1["m,v"]; + C2["e,f,m,u"] += alpha * -0.50000000 * H2["e,f,m,n"] * T1["n,u"]; + C2["e,f,u,g"] += alpha * +0.50000000 * H2["e,f,m,u"] * T1["m,g"]; + C2["e,f,u,g"] += alpha * -0.50000000 * H2["e,f,m,g"] * T1["m,u"]; + C2["e,f,u,g"] += alpha * -0.50000000 * H2["e,f,u,v"] * T1["w,g"] * Eta1["v,w"]; + C2["e,f,u,g"] += alpha * -0.50000000 * H2["e,f,u,v"] * T1["w,g"] * Gamma1["v,w"]; + C2["e,f,m,g"] += alpha * -0.50000000 * H2["e,f,m,n"] * T1["n,g"]; + C2["e,f,m,g"] += alpha * -0.50000000 * H2["e,f,m,u"] * T1["v,g"] * Eta1["u,v"]; + C2["e,f,m,g"] += alpha * -0.50000000 * H2["e,f,m,u"] * T1["v,g"] * Gamma1["u,v"]; + C2["e,f,g,h"] += alpha * +0.50000000 * H2["e,f,m,g"] * T1["m,h"]; + C2["e,f,g,h"] += alpha * +0.50000000 * H2["e,f,u,g"] * T1["v,h"] * Eta1["u,v"]; + C2["e,f,g,h"] += alpha * +0.50000000 * H2["e,f,u,g"] * T1["v,h"] * Gamma1["u,v"]; + + if (print_ > 2) { + outfile -> Printf("\n Time for H2_T1_C2 : %12.3f", timer.get()); + } +} + +void MRDSRG_SO::H2_T2_C2(BlockedTensor& H2, BlockedTensor& T2, const double& alpha, BlockedTensor& C2) { + // 282 lines + local_timer timer; + C2["u,v,w,x"] += alpha * +0.12500000 * H2["u,v,m,n"] * T2["m,n,w,x"]; + C2["u,x,w,y"] += alpha * +1.00000000 * H2["u,v,m,w"] * T2["m,x,y,z"] * Eta1["z,v"]; + C2["u,w,v,x"] += alpha * +1.00000000 * H2["u,e,m,v"] * T2["m,w,x,e"]; + C2["u,v,y,z"] += alpha * +0.25000000 * H2["u,v,m,w"] * T2["m,x,y,z"] * Gamma1["w,x"]; + C2["x,y,v,w"] += alpha * +0.25000000 * H2["u,e,v,w"] * T2["x,y,z,e"] * Eta1["z,u"]; + C2["w,x,u,v"] += alpha * +0.12500000 * H2["e,f,u,v"] * T2["w,x,e,f"]; + C2["u,x,v,z"] += alpha * +1.00000000 * H2["u,e,v,w"] * T2["x,y,z,e"] * Gamma1["w,y"]; + C2["u,w,m,x"] += alpha * -1.00000000 * H2["u,v,m,n"] * T2["n,w,x,y"] * Eta1["y,v"]; + C2["u,v,m,w"] += alpha * -1.00000000 * H2["u,e,m,n"] * T2["n,v,w,e"]; + C2["w,x,m,v"] += alpha * +0.50000000 * H2["u,e,m,v"] * T2["w,x,y,e"] * Eta1["y,u"]; + C2["v,w,m,u"] += alpha * +0.25000000 * H2["e,f,m,u"] * T2["v,w,e,f"]; + C2["u,w,m,y"] += alpha * +1.00000000 * H2["u,e,m,v"] * T2["w,x,y,e"] * Gamma1["v,x"]; + C2["v,w,m,n"] += alpha * +0.25000000 * H2["u,e,m,n"] * T2["v,w,x,e"] * Eta1["x,u"]; + C2["u,v,m,n"] += alpha * +0.12500000 * H2["e,f,m,n"] * T2["u,v,e,f"]; + C2["u,v,w,e"] += alpha * +0.25000000 * H2["u,v,m,n"] * T2["m,n,w,e"]; + C2["u,x,w,e"] += alpha * -1.00000000 * H2["u,v,m,w"] * T2["m,x,y,e"] * Eta1["y,v"]; + C2["u,w,v,f"] += alpha * +1.00000000 * H2["u,e,m,v"] * T2["m,w,f,e"]; + C2["u,v,y,e"] += alpha * +0.50000000 * H2["u,v,m,w"] * T2["m,x,y,e"] * Gamma1["w,x"]; + C2["u,w,x,e"] += alpha * -1.00000000 * H2["u,v,m,e"] * T2["m,w,x,y"] * Eta1["y,v"]; + C2["u,v,w,f"] += alpha * -1.00000000 * H2["u,e,m,f"] * T2["m,v,w,e"]; + C2["u,y,w,e"] += alpha * -1.00000000 * H2["u,v,w,x"] * T2["y,z,a0,e"] * Eta1["a0,v"] * Gamma1["x,z"]; + C2["u,y,w,e"] += alpha * +1.00000000 * H2["u,v,w,x"] * T2["y,z,a0,e"] * Eta1["x,z"] * Gamma1["a0,v"]; + C2["u,x,v,f"] += alpha * +1.00000000 * H2["u,e,v,w"] * T2["x,y,f,e"] * Gamma1["w,y"]; + C2["w,x,v,f"] += alpha * +0.50000000 * H2["u,e,v,f"] * T2["w,x,y,e"] * Eta1["y,u"]; + C2["v,w,u,g"] += alpha * +0.25000000 * H2["e,f,u,g"] * T2["v,w,e,f"]; + C2["u,v,a0,e"] += alpha * -0.25000000 * H2["u,v,w,x"] * T2["y,z,a0,e"] * Eta1["x,z"] * Eta1["w,y"]; + C2["u,v,a0,e"] += alpha * +0.25000000 * H2["u,v,w,x"] * T2["y,z,a0,e"] * Gamma1["x,z"] * Gamma1["w,y"]; + C2["u,w,y,f"] += alpha * +1.00000000 * H2["u,e,v,f"] * T2["w,x,y,e"] * Gamma1["v,x"]; + C2["u,w,m,e"] += alpha * +1.00000000 * H2["u,v,m,n"] * T2["n,w,x,e"] * Eta1["x,v"]; + C2["u,v,m,f"] += alpha * -1.00000000 * H2["u,e,m,n"] * T2["n,v,f,e"]; + C2["u,x,m,e"] += alpha * -1.00000000 * H2["u,v,m,w"] * T2["x,y,z,e"] * Eta1["z,v"] * Gamma1["w,y"]; + C2["u,x,m,e"] += alpha * +1.00000000 * H2["u,v,m,w"] * T2["x,y,z,e"] * Eta1["w,y"] * Gamma1["z,v"]; + C2["u,w,m,f"] += alpha * +1.00000000 * H2["u,e,m,v"] * T2["w,x,f,e"] * Gamma1["v,x"]; + C2["v,w,m,f"] += alpha * +0.50000000 * H2["u,e,m,f"] * T2["v,w,x,e"] * Eta1["x,u"]; + C2["u,v,m,g"] += alpha * +0.25000000 * H2["e,f,m,g"] * T2["u,v,e,f"]; + C2["u,v,e,f"] += alpha * +0.12500000 * H2["u,v,m,n"] * T2["m,n,e,f"]; + C2["u,v,e,f"] += alpha * +0.25000000 * H2["u,v,m,w"] * T2["m,x,e,f"] * Gamma1["w,x"]; + C2["u,w,e,f"] += alpha * -1.00000000 * H2["u,v,m,e"] * T2["m,w,x,f"] * Eta1["x,v"]; + C2["u,v,f,g"] += alpha * +1.00000000 * H2["u,e,m,f"] * T2["m,v,g,e"]; + C2["u,v,e,f"] += alpha * -0.12500000 * H2["u,v,w,x"] * T2["y,z,e,f"] * Eta1["x,z"] * Eta1["w,y"]; + C2["u,v,e,f"] += alpha * +0.12500000 * H2["u,v,w,x"] * T2["y,z,e,f"] * Gamma1["x,z"] * Gamma1["w,y"]; + C2["u,x,e,f"] += alpha * +1.00000000 * H2["u,v,w,e"] * T2["x,y,z,f"] * Eta1["z,v"] * Gamma1["w,y"]; + C2["u,x,e,f"] += alpha * -1.00000000 * H2["u,v,w,e"] * T2["x,y,z,f"] * Eta1["w,y"] * Gamma1["z,v"]; + C2["u,w,f,g"] += alpha * -1.00000000 * H2["u,e,v,f"] * T2["w,x,g,e"] * Gamma1["v,x"]; + C2["v,w,f,g"] += alpha * +0.25000000 * H2["u,e,f,g"] * T2["v,w,x,e"] * Eta1["x,u"]; + C2["u,v,g,h"] += alpha * +0.12500000 * H2["e,f,g,h"] * T2["u,v,e,f"]; + C2["u,e,v,w"] += alpha * +0.25000000 * H2["u,e,m,n"] * T2["m,n,v,w"]; + C2["w,e,v,x"] += alpha * +1.00000000 * H2["u,e,m,v"] * T2["m,w,x,y"] * Eta1["y,u"]; + C2["v,e,u,w"] += alpha * -1.00000000 * H2["e,f,m,u"] * T2["m,v,w,f"]; + C2["u,e,x,y"] += alpha * +0.50000000 * H2["u,e,m,v"] * T2["m,w,x,y"] * Gamma1["v,w"]; + C2["w,e,u,y"] += alpha * -1.00000000 * H2["e,f,u,v"] * T2["w,x,y,f"] * Gamma1["v,x"]; + C2["v,e,m,w"] += alpha * -1.00000000 * H2["u,e,m,n"] * T2["n,v,w,x"] * Eta1["x,u"]; + C2["u,e,m,v"] += alpha * +1.00000000 * H2["e,f,m,n"] * T2["n,u,v,f"]; + C2["v,e,m,x"] += alpha * -1.00000000 * H2["e,f,m,u"] * T2["v,w,x,f"] * Gamma1["u,w"]; + C2["u,e,v,f"] += alpha * +0.50000000 * H2["u,e,m,n"] * T2["m,n,v,f"]; + C2["w,e,v,f"] += alpha * -1.00000000 * H2["u,e,m,v"] * T2["m,w,x,f"] * Eta1["x,u"]; + C2["v,e,u,g"] += alpha * -1.00000000 * H2["e,f,m,u"] * T2["m,v,g,f"]; + C2["u,e,x,f"] += alpha * +1.00000000 * H2["u,e,m,v"] * T2["m,w,x,f"] * Gamma1["v,w"]; + C2["v,e,w,f"] += alpha * -1.00000000 * H2["u,e,m,f"] * T2["m,v,w,x"] * Eta1["x,u"]; + C2["u,e,v,g"] += alpha * +1.00000000 * H2["e,f,m,g"] * T2["m,u,v,f"]; + C2["x,e,v,f"] += alpha * -1.00000000 * H2["u,e,v,w"] * T2["x,y,z,f"] * Eta1["z,u"] * Gamma1["w,y"]; + C2["x,e,v,f"] += alpha * +1.00000000 * H2["u,e,v,w"] * T2["x,y,z,f"] * Eta1["w,y"] * Gamma1["z,u"]; + C2["w,e,u,g"] += alpha * -1.00000000 * H2["e,f,u,v"] * T2["w,x,g,f"] * Gamma1["v,x"]; + C2["u,e,z,f"] += alpha * -0.50000000 * H2["u,e,v,w"] * T2["x,y,z,f"] * Eta1["w,y"] * Eta1["v,x"]; + C2["u,e,z,f"] += alpha * +0.50000000 * H2["u,e,v,w"] * T2["x,y,z,f"] * Gamma1["w,y"] * Gamma1["v,x"]; + C2["v,e,x,g"] += alpha * -1.00000000 * H2["e,f,u,g"] * T2["v,w,x,f"] * Gamma1["u,w"]; + C2["v,e,m,f"] += alpha * +1.00000000 * H2["u,e,m,n"] * T2["n,v,w,f"] * Eta1["w,u"]; + C2["u,e,m,g"] += alpha * +1.00000000 * H2["e,f,m,n"] * T2["n,u,g,f"]; + C2["w,e,m,f"] += alpha * -1.00000000 * H2["u,e,m,v"] * T2["w,x,y,f"] * Eta1["y,u"] * Gamma1["v,x"]; + C2["w,e,m,f"] += alpha * +1.00000000 * H2["u,e,m,v"] * T2["w,x,y,f"] * Eta1["v,x"] * Gamma1["y,u"]; + C2["v,e,m,g"] += alpha * -1.00000000 * H2["e,f,m,u"] * T2["v,w,g,f"] * Gamma1["u,w"]; + C2["u,e,f,g"] += alpha * +0.25000000 * H2["u,e,m,n"] * T2["m,n,f,g"]; + C2["u,e,f,g"] += alpha * +0.50000000 * H2["u,e,m,v"] * T2["m,w,f,g"] * Gamma1["v,w"]; + C2["v,e,f,g"] += alpha * -1.00000000 * H2["u,e,m,f"] * T2["m,v,w,g"] * Eta1["w,u"]; + C2["u,e,g,h"] += alpha * -1.00000000 * H2["e,f,m,g"] * T2["m,u,h,f"]; + C2["u,e,f,g"] += alpha * -0.25000000 * H2["u,e,v,w"] * T2["x,y,f,g"] * Eta1["w,y"] * Eta1["v,x"]; + C2["u,e,f,g"] += alpha * +0.25000000 * H2["u,e,v,w"] * T2["x,y,f,g"] * Gamma1["w,y"] * Gamma1["v,x"]; + C2["w,e,f,g"] += alpha * +1.00000000 * H2["u,e,v,f"] * T2["w,x,y,g"] * Eta1["y,u"] * Gamma1["v,x"]; + C2["w,e,f,g"] += alpha * -1.00000000 * H2["u,e,v,f"] * T2["w,x,y,g"] * Eta1["v,x"] * Gamma1["y,u"]; + C2["v,e,g,h"] += alpha * +1.00000000 * H2["e,f,u,g"] * T2["v,w,h,f"] * Gamma1["u,w"]; + C2["m,u,v,w"] += alpha * +0.25000000 * H2["m,u,n,c0"] * T2["n,c0,v,w"]; + C2["m,w,v,x"] += alpha * +1.00000000 * H2["m,u,n,v"] * T2["n,w,x,y"] * Eta1["y,u"]; + C2["m,v,u,w"] += alpha * +1.00000000 * H2["m,e,n,u"] * T2["n,v,w,e"]; + C2["n,u,w,x"] += alpha * +1.00000000 * H2["u,v,m,w"] * T2["n,m,x,y"] * Eta1["y,v"]; + C2["n,u,v,w"] += alpha * +1.00000000 * H2["u,e,m,v"] * T2["n,m,w,e"]; + C2["m,u,x,y"] += alpha * +0.50000000 * H2["m,u,n,v"] * T2["n,w,x,y"] * Gamma1["v,w"]; + C2["m,y,w,x"] += alpha * +0.25000000 * H2["u,v,w,x"] * T2["m,y,z,a0"] * Eta1["a0,v"] * Eta1["z,u"]; + C2["m,y,w,x"] += alpha * -0.25000000 * H2["u,v,w,x"] * T2["m,y,z,a0"] * Gamma1["a0,v"] * Gamma1["z,u"]; + C2["m,x,v,w"] += alpha * +0.50000000 * H2["u,e,v,w"] * T2["m,x,y,e"] * Eta1["y,u"]; + C2["m,w,u,v"] += alpha * +0.25000000 * H2["e,f,u,v"] * T2["m,w,e,f"]; + C2["m,w,u,y"] += alpha * +1.00000000 * H2["m,e,u,v"] * T2["w,x,y,e"] * Gamma1["v,x"]; + C2["m,u,w,z"] += alpha * -1.00000000 * H2["u,v,w,x"] * T2["m,y,z,a0"] * Eta1["a0,v"] * Gamma1["x,y"]; + C2["m,u,w,z"] += alpha * +1.00000000 * H2["u,v,w,x"] * T2["m,y,z,a0"] * Eta1["x,y"] * Gamma1["a0,v"]; + C2["m,u,v,y"] += alpha * -1.00000000 * H2["u,e,v,w"] * T2["m,x,y,e"] * Gamma1["w,x"]; + C2["m,v,n,w"] += alpha * -1.00000000 * H2["m,u,n,c0"] * T2["c0,v,w,x"] * Eta1["x,u"]; + C2["m,u,n,v"] += alpha * -1.00000000 * H2["m,e,n,c0"] * T2["c0,u,v,e"]; + C2["c0,u,m,w"] += alpha * -1.00000000 * H2["u,v,m,n"] * T2["c0,n,w,x"] * Eta1["x,v"]; + C2["c0,u,m,v"] += alpha * -1.00000000 * H2["u,e,m,n"] * T2["c0,n,v,e"]; + C2["n,x,m,w"] += alpha * +0.50000000 * H2["u,v,m,w"] * T2["n,x,y,z"] * Eta1["z,v"] * Eta1["y,u"]; + C2["n,x,m,w"] += alpha * -0.50000000 * H2["u,v,m,w"] * T2["n,x,y,z"] * Gamma1["z,v"] * Gamma1["y,u"]; + C2["n,w,m,v"] += alpha * +1.00000000 * H2["u,e,m,v"] * T2["n,w,x,e"] * Eta1["x,u"]; + C2["n,v,m,u"] += alpha * +0.50000000 * H2["e,f,m,u"] * T2["n,v,e,f"]; + C2["m,v,n,x"] += alpha * +1.00000000 * H2["m,e,n,u"] * T2["v,w,x,e"] * Gamma1["u,w"]; + C2["n,u,m,y"] += alpha * -1.00000000 * H2["u,v,m,w"] * T2["n,x,y,z"] * Eta1["z,v"] * Gamma1["w,x"]; + C2["n,u,m,y"] += alpha * +1.00000000 * H2["u,v,m,w"] * T2["n,x,y,z"] * Eta1["w,x"] * Gamma1["z,v"]; + C2["n,u,m,x"] += alpha * -1.00000000 * H2["u,e,m,v"] * T2["n,w,x,e"] * Gamma1["v,w"]; + C2["c0,w,m,n"] += alpha * +0.25000000 * H2["u,v,m,n"] * T2["c0,w,x,y"] * Eta1["y,v"] * Eta1["x,u"]; + C2["c0,w,m,n"] += alpha * -0.25000000 * H2["u,v,m,n"] * T2["c0,w,x,y"] * Gamma1["y,v"] * Gamma1["x,u"]; + C2["c0,v,m,n"] += alpha * +0.50000000 * H2["u,e,m,n"] * T2["c0,v,w,e"] * Eta1["w,u"]; + C2["c0,u,m,n"] += alpha * +0.25000000 * H2["e,f,m,n"] * T2["c0,u,e,f"]; + C2["m,u,v,e"] += alpha * +0.50000000 * H2["m,u,n,c0"] * T2["n,c0,v,e"]; + C2["m,w,v,e"] += alpha * -1.00000000 * H2["m,u,n,v"] * T2["n,w,x,e"] * Eta1["x,u"]; + C2["m,v,u,f"] += alpha * +1.00000000 * H2["m,e,n,u"] * T2["n,v,f,e"]; + C2["n,u,w,e"] += alpha * -1.00000000 * H2["u,v,m,w"] * T2["n,m,x,e"] * Eta1["x,v"]; + C2["n,u,v,f"] += alpha * +1.00000000 * H2["u,e,m,v"] * T2["n,m,f,e"]; + C2["m,u,x,e"] += alpha * +1.00000000 * H2["m,u,n,v"] * T2["n,w,x,e"] * Gamma1["v,w"]; + C2["m,v,w,e"] += alpha * -1.00000000 * H2["m,u,n,e"] * T2["n,v,w,x"] * Eta1["x,u"]; + C2["m,u,v,f"] += alpha * -1.00000000 * H2["m,e,n,f"] * T2["n,u,v,e"]; + C2["n,u,w,e"] += alpha * -1.00000000 * H2["u,v,m,e"] * T2["n,m,w,x"] * Eta1["x,v"]; + C2["n,u,v,f"] += alpha * -1.00000000 * H2["u,e,m,f"] * T2["n,m,v,e"]; + C2["m,x,v,e"] += alpha * -1.00000000 * H2["m,u,v,w"] * T2["x,y,z,e"] * Eta1["z,u"] * Gamma1["w,y"]; + C2["m,x,v,e"] += alpha * +1.00000000 * H2["m,u,v,w"] * T2["x,y,z,e"] * Eta1["w,y"] * Gamma1["z,u"]; + C2["m,w,u,f"] += alpha * +1.00000000 * H2["m,e,u,v"] * T2["w,x,f,e"] * Gamma1["v,x"]; + C2["m,u,w,e"] += alpha * +1.00000000 * H2["u,v,w,x"] * T2["m,y,z,e"] * Eta1["z,v"] * Gamma1["x,y"]; + C2["m,u,w,e"] += alpha * -1.00000000 * H2["u,v,w,x"] * T2["m,y,z,e"] * Eta1["x,y"] * Gamma1["z,v"]; + C2["m,u,v,f"] += alpha * -1.00000000 * H2["u,e,v,w"] * T2["m,x,f,e"] * Gamma1["w,x"]; + C2["m,x,w,e"] += alpha * +0.50000000 * H2["u,v,w,e"] * T2["m,x,y,z"] * Eta1["z,v"] * Eta1["y,u"]; + C2["m,x,w,e"] += alpha * -0.50000000 * H2["u,v,w,e"] * T2["m,x,y,z"] * Gamma1["z,v"] * Gamma1["y,u"]; + C2["m,w,v,f"] += alpha * +1.00000000 * H2["u,e,v,f"] * T2["m,w,x,e"] * Eta1["x,u"]; + C2["m,v,u,g"] += alpha * +0.50000000 * H2["e,f,u,g"] * T2["m,v,e,f"]; + C2["m,u,z,e"] += alpha * -0.50000000 * H2["m,u,v,w"] * T2["x,y,z,e"] * Eta1["w,y"] * Eta1["v,x"]; + C2["m,u,z,e"] += alpha * +0.50000000 * H2["m,u,v,w"] * T2["x,y,z,e"] * Gamma1["w,y"] * Gamma1["v,x"]; + C2["m,v,x,f"] += alpha * +1.00000000 * H2["m,e,u,f"] * T2["v,w,x,e"] * Gamma1["u,w"]; + C2["m,u,y,e"] += alpha * -1.00000000 * H2["u,v,w,e"] * T2["m,x,y,z"] * Eta1["z,v"] * Gamma1["w,x"]; + C2["m,u,y,e"] += alpha * +1.00000000 * H2["u,v,w,e"] * T2["m,x,y,z"] * Eta1["w,x"] * Gamma1["z,v"]; + C2["m,u,x,f"] += alpha * -1.00000000 * H2["u,e,v,f"] * T2["m,w,x,e"] * Gamma1["v,w"]; + C2["m,v,n,e"] += alpha * +1.00000000 * H2["m,u,n,c0"] * T2["c0,v,w,e"] * Eta1["w,u"]; + C2["m,u,n,f"] += alpha * -1.00000000 * H2["m,e,n,c0"] * T2["c0,u,f,e"]; + C2["c0,u,m,e"] += alpha * +1.00000000 * H2["u,v,m,n"] * T2["c0,n,w,e"] * Eta1["w,v"]; + C2["c0,u,m,f"] += alpha * -1.00000000 * H2["u,e,m,n"] * T2["c0,n,f,e"]; + C2["m,w,n,e"] += alpha * -1.00000000 * H2["m,u,n,v"] * T2["w,x,y,e"] * Eta1["y,u"] * Gamma1["v,x"]; + C2["m,w,n,e"] += alpha * +1.00000000 * H2["m,u,n,v"] * T2["w,x,y,e"] * Eta1["v,x"] * Gamma1["y,u"]; + C2["m,v,n,f"] += alpha * +1.00000000 * H2["m,e,n,u"] * T2["v,w,f,e"] * Gamma1["u,w"]; + C2["n,u,m,e"] += alpha * +1.00000000 * H2["u,v,m,w"] * T2["n,x,y,e"] * Eta1["y,v"] * Gamma1["w,x"]; + C2["n,u,m,e"] += alpha * -1.00000000 * H2["u,v,m,w"] * T2["n,x,y,e"] * Eta1["w,x"] * Gamma1["y,v"]; + C2["n,u,m,f"] += alpha * -1.00000000 * H2["u,e,m,v"] * T2["n,w,f,e"] * Gamma1["v,w"]; + C2["n,w,m,e"] += alpha * +0.50000000 * H2["u,v,m,e"] * T2["n,w,x,y"] * Eta1["y,v"] * Eta1["x,u"]; + C2["n,w,m,e"] += alpha * -0.50000000 * H2["u,v,m,e"] * T2["n,w,x,y"] * Gamma1["y,v"] * Gamma1["x,u"]; + C2["n,v,m,f"] += alpha * +1.00000000 * H2["u,e,m,f"] * T2["n,v,w,e"] * Eta1["w,u"]; + C2["n,u,m,g"] += alpha * +0.50000000 * H2["e,f,m,g"] * T2["n,u,e,f"]; + C2["m,u,e,f"] += alpha * +0.25000000 * H2["m,u,n,c0"] * T2["n,c0,e,f"]; + C2["m,u,e,f"] += alpha * +0.50000000 * H2["m,u,n,v"] * T2["n,w,e,f"] * Gamma1["v,w"]; + C2["m,v,e,f"] += alpha * -1.00000000 * H2["m,u,n,e"] * T2["n,v,w,f"] * Eta1["w,u"]; + C2["m,u,f,g"] += alpha * +1.00000000 * H2["m,e,n,f"] * T2["n,u,g,e"]; + C2["n,u,e,f"] += alpha * -1.00000000 * H2["u,v,m,e"] * T2["n,m,w,f"] * Eta1["w,v"]; + C2["n,u,f,g"] += alpha * +1.00000000 * H2["u,e,m,f"] * T2["n,m,g,e"]; + C2["m,u,e,f"] += alpha * -0.25000000 * H2["m,u,v,w"] * T2["x,y,e,f"] * Eta1["w,y"] * Eta1["v,x"]; + C2["m,u,e,f"] += alpha * +0.25000000 * H2["m,u,v,w"] * T2["x,y,e,f"] * Gamma1["w,y"] * Gamma1["v,x"]; + C2["m,w,e,f"] += alpha * +1.00000000 * H2["m,u,v,e"] * T2["w,x,y,f"] * Eta1["y,u"] * Gamma1["v,x"]; + C2["m,w,e,f"] += alpha * -1.00000000 * H2["m,u,v,e"] * T2["w,x,y,f"] * Eta1["v,x"] * Gamma1["y,u"]; + C2["m,v,f,g"] += alpha * -1.00000000 * H2["m,e,u,f"] * T2["v,w,g,e"] * Gamma1["u,w"]; + C2["m,u,e,f"] += alpha * -1.00000000 * H2["u,v,w,e"] * T2["m,x,y,f"] * Eta1["y,v"] * Gamma1["w,x"]; + C2["m,u,e,f"] += alpha * +1.00000000 * H2["u,v,w,e"] * T2["m,x,y,f"] * Eta1["w,x"] * Gamma1["y,v"]; + C2["m,u,f,g"] += alpha * +1.00000000 * H2["u,e,v,f"] * T2["m,w,g,e"] * Gamma1["v,w"]; + C2["m,w,e,f"] += alpha * +0.25000000 * H2["u,v,e,f"] * T2["m,w,x,y"] * Eta1["y,v"] * Eta1["x,u"]; + C2["m,w,e,f"] += alpha * -0.25000000 * H2["u,v,e,f"] * T2["m,w,x,y"] * Gamma1["y,v"] * Gamma1["x,u"]; + C2["m,v,f,g"] += alpha * +0.50000000 * H2["u,e,f,g"] * T2["m,v,w,e"] * Eta1["w,u"]; + C2["m,u,g,h"] += alpha * +0.25000000 * H2["e,f,g,h"] * T2["m,u,e,f"]; + C2["m,n,u,v"] += alpha * +0.12500000 * H2["m,n,c0,c1"] * T2["c0,c1,u,v"]; + C2["m,c0,v,w"] += alpha * -1.00000000 * H2["m,u,n,v"] * T2["c0,n,w,x"] * Eta1["x,u"]; + C2["m,c0,u,v"] += alpha * -1.00000000 * H2["m,e,n,u"] * T2["c0,n,v,e"]; + C2["m,n,w,x"] += alpha * +0.25000000 * H2["m,n,c0,u"] * T2["c0,v,w,x"] * Gamma1["u,v"]; + C2["m,n,w,x"] += alpha * +0.12500000 * H2["u,v,w,x"] * T2["m,n,y,z"] * Eta1["z,v"] * Eta1["y,u"]; + C2["m,n,w,x"] += alpha * -0.12500000 * H2["u,v,w,x"] * T2["m,n,y,z"] * Gamma1["z,v"] * Gamma1["y,u"]; + C2["m,n,v,w"] += alpha * +0.25000000 * H2["u,e,v,w"] * T2["m,n,x,e"] * Eta1["x,u"]; + C2["m,n,u,v"] += alpha * +0.12500000 * H2["e,f,u,v"] * T2["m,n,e,f"]; + C2["m,n,v,y"] += alpha * +1.00000000 * H2["m,u,v,w"] * T2["n,x,y,z"] * Eta1["z,u"] * Gamma1["w,x"]; + C2["m,n,v,y"] += alpha * -1.00000000 * H2["m,u,v,w"] * T2["n,x,y,z"] * Eta1["w,x"] * Gamma1["z,u"]; + C2["m,n,u,x"] += alpha * +1.00000000 * H2["m,e,u,v"] * T2["n,w,x,e"] * Gamma1["v,w"]; + C2["m,c1,n,v"] += alpha * +1.00000000 * H2["m,u,n,c0"] * T2["c1,c0,v,w"] * Eta1["w,u"]; + C2["m,c1,n,u"] += alpha * +1.00000000 * H2["m,e,n,c0"] * T2["c1,c0,u,e"]; + C2["n,c0,m,w"] += alpha * +0.25000000 * H2["u,v,m,w"] * T2["n,c0,x,y"] * Eta1["y,v"] * Eta1["x,u"]; + C2["n,c0,m,w"] += alpha * -0.25000000 * H2["u,v,m,w"] * T2["n,c0,x,y"] * Gamma1["y,v"] * Gamma1["x,u"]; + C2["n,c0,m,v"] += alpha * +0.50000000 * H2["u,e,m,v"] * T2["n,c0,w,e"] * Eta1["w,u"]; + C2["n,c0,m,u"] += alpha * +0.25000000 * H2["e,f,m,u"] * T2["n,c0,e,f"]; + C2["m,c0,n,x"] += alpha * +1.00000000 * H2["m,u,n,v"] * T2["c0,w,x,y"] * Eta1["y,u"] * Gamma1["v,w"]; + C2["m,c0,n,x"] += alpha * -1.00000000 * H2["m,u,n,v"] * T2["c0,w,x,y"] * Eta1["v,w"] * Gamma1["y,u"]; + C2["m,c0,n,w"] += alpha * +1.00000000 * H2["m,e,n,u"] * T2["c0,v,w,e"] * Gamma1["u,v"]; + C2["c0,c1,m,n"] += alpha * +0.12500000 * H2["u,v,m,n"] * T2["c0,c1,w,x"] * Eta1["x,v"] * Eta1["w,u"]; + C2["c0,c1,m,n"] += alpha * -0.12500000 * H2["u,v,m,n"] * T2["c0,c1,w,x"] * Gamma1["x,v"] * Gamma1["w,u"]; + C2["c0,c1,m,n"] += alpha * +0.25000000 * H2["u,e,m,n"] * T2["c0,c1,v,e"] * Eta1["v,u"]; + C2["c0,c1,m,n"] += alpha * +0.12500000 * H2["e,f,m,n"] * T2["c0,c1,e,f"]; + C2["m,n,u,e"] += alpha * +0.25000000 * H2["m,n,c0,c1"] * T2["c0,c1,u,e"]; + C2["m,c0,v,e"] += alpha * +1.00000000 * H2["m,u,n,v"] * T2["c0,n,w,e"] * Eta1["w,u"]; + C2["m,c0,u,f"] += alpha * -1.00000000 * H2["m,e,n,u"] * T2["c0,n,f,e"]; + C2["m,n,w,e"] += alpha * +0.50000000 * H2["m,n,c0,u"] * T2["c0,v,w,e"] * Gamma1["u,v"]; + C2["m,c0,v,e"] += alpha * +1.00000000 * H2["m,u,n,e"] * T2["c0,n,v,w"] * Eta1["w,u"]; + C2["m,c0,u,f"] += alpha * +1.00000000 * H2["m,e,n,f"] * T2["c0,n,u,e"]; + C2["m,n,v,e"] += alpha * -1.00000000 * H2["m,u,v,w"] * T2["n,x,y,e"] * Eta1["y,u"] * Gamma1["w,x"]; + C2["m,n,v,e"] += alpha * +1.00000000 * H2["m,u,v,w"] * T2["n,x,y,e"] * Eta1["w,x"] * Gamma1["y,u"]; + C2["m,n,u,f"] += alpha * +1.00000000 * H2["m,e,u,v"] * T2["n,w,f,e"] * Gamma1["v,w"]; + C2["m,n,w,e"] += alpha * +0.25000000 * H2["u,v,w,e"] * T2["m,n,x,y"] * Eta1["y,v"] * Eta1["x,u"]; + C2["m,n,w,e"] += alpha * -0.25000000 * H2["u,v,w,e"] * T2["m,n,x,y"] * Gamma1["y,v"] * Gamma1["x,u"]; + C2["m,n,v,f"] += alpha * +0.50000000 * H2["u,e,v,f"] * T2["m,n,w,e"] * Eta1["w,u"]; + C2["m,n,u,g"] += alpha * +0.25000000 * H2["e,f,u,g"] * T2["m,n,e,f"]; + C2["m,n,y,e"] += alpha * -0.25000000 * H2["m,n,u,v"] * T2["w,x,y,e"] * Eta1["v,x"] * Eta1["u,w"]; + C2["m,n,y,e"] += alpha * +0.25000000 * H2["m,n,u,v"] * T2["w,x,y,e"] * Gamma1["v,x"] * Gamma1["u,w"]; + C2["m,n,x,e"] += alpha * +1.00000000 * H2["m,u,v,e"] * T2["n,w,x,y"] * Eta1["y,u"] * Gamma1["v,w"]; + C2["m,n,x,e"] += alpha * -1.00000000 * H2["m,u,v,e"] * T2["n,w,x,y"] * Eta1["v,w"] * Gamma1["y,u"]; + C2["m,n,w,f"] += alpha * +1.00000000 * H2["m,e,u,f"] * T2["n,v,w,e"] * Gamma1["u,v"]; + C2["m,c1,n,e"] += alpha * -1.00000000 * H2["m,u,n,c0"] * T2["c1,c0,v,e"] * Eta1["v,u"]; + C2["m,c1,n,f"] += alpha * +1.00000000 * H2["m,e,n,c0"] * T2["c1,c0,f,e"]; + C2["m,c0,n,e"] += alpha * -1.00000000 * H2["m,u,n,v"] * T2["c0,w,x,e"] * Eta1["x,u"] * Gamma1["v,w"]; + C2["m,c0,n,e"] += alpha * +1.00000000 * H2["m,u,n,v"] * T2["c0,w,x,e"] * Eta1["v,w"] * Gamma1["x,u"]; + C2["m,c0,n,f"] += alpha * +1.00000000 * H2["m,e,n,u"] * T2["c0,v,f,e"] * Gamma1["u,v"]; + C2["n,c0,m,e"] += alpha * +0.25000000 * H2["u,v,m,e"] * T2["n,c0,w,x"] * Eta1["x,v"] * Eta1["w,u"]; + C2["n,c0,m,e"] += alpha * -0.25000000 * H2["u,v,m,e"] * T2["n,c0,w,x"] * Gamma1["x,v"] * Gamma1["w,u"]; + C2["n,c0,m,f"] += alpha * +0.50000000 * H2["u,e,m,f"] * T2["n,c0,v,e"] * Eta1["v,u"]; + C2["n,c0,m,g"] += alpha * +0.25000000 * H2["e,f,m,g"] * T2["n,c0,e,f"]; + C2["m,n,e,f"] += alpha * +0.12500000 * H2["m,n,c0,c1"] * T2["c0,c1,e,f"]; + C2["m,n,e,f"] += alpha * +0.25000000 * H2["m,n,c0,u"] * T2["c0,v,e,f"] * Gamma1["u,v"]; + C2["m,c0,e,f"] += alpha * +1.00000000 * H2["m,u,n,e"] * T2["c0,n,v,f"] * Eta1["v,u"]; + C2["m,c0,f,g"] += alpha * -1.00000000 * H2["m,e,n,f"] * T2["c0,n,g,e"]; + C2["m,n,e,f"] += alpha * -0.12500000 * H2["m,n,u,v"] * T2["w,x,e,f"] * Eta1["v,x"] * Eta1["u,w"]; + C2["m,n,e,f"] += alpha * +0.12500000 * H2["m,n,u,v"] * T2["w,x,e,f"] * Gamma1["v,x"] * Gamma1["u,w"]; + C2["m,n,e,f"] += alpha * +1.00000000 * H2["m,u,v,e"] * T2["n,w,x,f"] * Eta1["x,u"] * Gamma1["v,w"]; + C2["m,n,e,f"] += alpha * -1.00000000 * H2["m,u,v,e"] * T2["n,w,x,f"] * Eta1["v,w"] * Gamma1["x,u"]; + C2["m,n,f,g"] += alpha * -1.00000000 * H2["m,e,u,f"] * T2["n,v,g,e"] * Gamma1["u,v"]; + C2["m,n,e,f"] += alpha * +0.12500000 * H2["u,v,e,f"] * T2["m,n,w,x"] * Eta1["x,v"] * Eta1["w,u"]; + C2["m,n,e,f"] += alpha * -0.12500000 * H2["u,v,e,f"] * T2["m,n,w,x"] * Gamma1["x,v"] * Gamma1["w,u"]; + C2["m,n,f,g"] += alpha * +0.25000000 * H2["u,e,f,g"] * T2["m,n,v,e"] * Eta1["v,u"]; + C2["m,n,g,h"] += alpha * +0.12500000 * H2["e,f,g,h"] * T2["m,n,e,f"]; + C2["m,e,u,v"] += alpha * +0.25000000 * H2["m,e,n,c0"] * T2["n,c0,u,v"]; + C2["n,e,v,w"] += alpha * -1.00000000 * H2["u,e,m,v"] * T2["n,m,w,x"] * Eta1["x,u"]; + C2["n,e,u,v"] += alpha * +1.00000000 * H2["e,f,m,u"] * T2["n,m,v,f"]; + C2["m,e,w,x"] += alpha * +0.50000000 * H2["m,e,n,u"] * T2["n,v,w,x"] * Gamma1["u,v"]; + C2["m,e,v,y"] += alpha * +1.00000000 * H2["u,e,v,w"] * T2["m,x,y,z"] * Eta1["z,u"] * Gamma1["w,x"]; + C2["m,e,v,y"] += alpha * -1.00000000 * H2["u,e,v,w"] * T2["m,x,y,z"] * Eta1["w,x"] * Gamma1["z,u"]; + C2["m,e,u,x"] += alpha * -1.00000000 * H2["e,f,u,v"] * T2["m,w,x,f"] * Gamma1["v,w"]; + C2["c0,e,m,v"] += alpha * +1.00000000 * H2["u,e,m,n"] * T2["c0,n,v,w"] * Eta1["w,u"]; + C2["c0,e,m,u"] += alpha * -1.00000000 * H2["e,f,m,n"] * T2["c0,n,u,f"]; + C2["n,e,m,x"] += alpha * +1.00000000 * H2["u,e,m,v"] * T2["n,w,x,y"] * Eta1["y,u"] * Gamma1["v,w"]; + C2["n,e,m,x"] += alpha * -1.00000000 * H2["u,e,m,v"] * T2["n,w,x,y"] * Eta1["v,w"] * Gamma1["y,u"]; + C2["n,e,m,w"] += alpha * -1.00000000 * H2["e,f,m,u"] * T2["n,v,w,f"] * Gamma1["u,v"]; + C2["m,e,u,f"] += alpha * +0.50000000 * H2["m,e,n,c0"] * T2["n,c0,u,f"]; + C2["n,e,v,f"] += alpha * +1.00000000 * H2["u,e,m,v"] * T2["n,m,w,f"] * Eta1["w,u"]; + C2["n,e,u,g"] += alpha * +1.00000000 * H2["e,f,m,u"] * T2["n,m,g,f"]; + C2["m,e,w,f"] += alpha * +1.00000000 * H2["m,e,n,u"] * T2["n,v,w,f"] * Gamma1["u,v"]; + C2["n,e,v,f"] += alpha * +1.00000000 * H2["u,e,m,f"] * T2["n,m,v,w"] * Eta1["w,u"]; + C2["n,e,u,g"] += alpha * -1.00000000 * H2["e,f,m,g"] * T2["n,m,u,f"]; + C2["m,e,v,f"] += alpha * -1.00000000 * H2["u,e,v,w"] * T2["m,x,y,f"] * Eta1["y,u"] * Gamma1["w,x"]; + C2["m,e,v,f"] += alpha * +1.00000000 * H2["u,e,v,w"] * T2["m,x,y,f"] * Eta1["w,x"] * Gamma1["y,u"]; + C2["m,e,u,g"] += alpha * -1.00000000 * H2["e,f,u,v"] * T2["m,w,g,f"] * Gamma1["v,w"]; + C2["m,e,y,f"] += alpha * -0.50000000 * H2["m,e,u,v"] * T2["w,x,y,f"] * Eta1["v,x"] * Eta1["u,w"]; + C2["m,e,y,f"] += alpha * +0.50000000 * H2["m,e,u,v"] * T2["w,x,y,f"] * Gamma1["v,x"] * Gamma1["u,w"]; + C2["m,e,x,f"] += alpha * +1.00000000 * H2["u,e,v,f"] * T2["m,w,x,y"] * Eta1["y,u"] * Gamma1["v,w"]; + C2["m,e,x,f"] += alpha * -1.00000000 * H2["u,e,v,f"] * T2["m,w,x,y"] * Eta1["v,w"] * Gamma1["y,u"]; + C2["m,e,w,g"] += alpha * -1.00000000 * H2["e,f,u,g"] * T2["m,v,w,f"] * Gamma1["u,v"]; + C2["c0,e,m,f"] += alpha * -1.00000000 * H2["u,e,m,n"] * T2["c0,n,v,f"] * Eta1["v,u"]; + C2["c0,e,m,g"] += alpha * -1.00000000 * H2["e,f,m,n"] * T2["c0,n,g,f"]; + C2["n,e,m,f"] += alpha * -1.00000000 * H2["u,e,m,v"] * T2["n,w,x,f"] * Eta1["x,u"] * Gamma1["v,w"]; + C2["n,e,m,f"] += alpha * +1.00000000 * H2["u,e,m,v"] * T2["n,w,x,f"] * Eta1["v,w"] * Gamma1["x,u"]; + C2["n,e,m,g"] += alpha * -1.00000000 * H2["e,f,m,u"] * T2["n,v,g,f"] * Gamma1["u,v"]; + C2["m,e,f,g"] += alpha * +0.25000000 * H2["m,e,n,c0"] * T2["n,c0,f,g"]; + C2["m,e,f,g"] += alpha * +0.50000000 * H2["m,e,n,u"] * T2["n,v,f,g"] * Gamma1["u,v"]; + C2["n,e,f,g"] += alpha * +1.00000000 * H2["u,e,m,f"] * T2["n,m,v,g"] * Eta1["v,u"]; + C2["n,e,g,h"] += alpha * +1.00000000 * H2["e,f,m,g"] * T2["n,m,h,f"]; + C2["m,e,f,g"] += alpha * -0.25000000 * H2["m,e,u,v"] * T2["w,x,f,g"] * Eta1["v,x"] * Eta1["u,w"]; + C2["m,e,f,g"] += alpha * +0.25000000 * H2["m,e,u,v"] * T2["w,x,f,g"] * Gamma1["v,x"] * Gamma1["u,w"]; + C2["m,e,f,g"] += alpha * +1.00000000 * H2["u,e,v,f"] * T2["m,w,x,g"] * Eta1["x,u"] * Gamma1["v,w"]; + C2["m,e,f,g"] += alpha * -1.00000000 * H2["u,e,v,f"] * T2["m,w,x,g"] * Eta1["v,w"] * Gamma1["x,u"]; + C2["m,e,g,h"] += alpha * +1.00000000 * H2["e,f,u,g"] * T2["m,v,h,f"] * Gamma1["u,v"]; + C2["e,f,u,v"] += alpha * +0.12500000 * H2["e,f,m,n"] * T2["m,n,u,v"]; + C2["e,f,w,x"] += alpha * +0.25000000 * H2["e,f,m,u"] * T2["m,v,w,x"] * Gamma1["u,v"]; + C2["e,f,u,g"] += alpha * +0.25000000 * H2["e,f,m,n"] * T2["m,n,u,g"]; + C2["e,f,w,g"] += alpha * +0.50000000 * H2["e,f,m,u"] * T2["m,v,w,g"] * Gamma1["u,v"]; + C2["e,f,y,g"] += alpha * -0.25000000 * H2["e,f,u,v"] * T2["w,x,y,g"] * Eta1["v,x"] * Eta1["u,w"]; + C2["e,f,y,g"] += alpha * +0.25000000 * H2["e,f,u,v"] * T2["w,x,y,g"] * Gamma1["v,x"] * Gamma1["u,w"]; + C2["e,f,g,h"] += alpha * +0.12500000 * H2["e,f,m,n"] * T2["m,n,g,h"]; + C2["e,f,g,h"] += alpha * +0.25000000 * H2["e,f,m,u"] * T2["m,v,g,h"] * Gamma1["u,v"]; + C2["e,f,g,h"] += alpha * -0.12500000 * H2["e,f,u,v"] * T2["w,x,g,h"] * Eta1["v,x"] * Eta1["u,w"]; + C2["e,f,g,h"] += alpha * +0.12500000 * H2["e,f,u,v"] * T2["w,x,g,h"] * Gamma1["v,x"] * Gamma1["u,w"]; + + if (print_ > 2) { + outfile -> Printf("\n Time for H2_T2_C2 : %12.3f", timer.get()); + } +} + +} // namespace forte \ No newline at end of file From fee7bbd4325c92a35361371717e24b95b78fa856 Mon Sep 17 00:00:00 2001 From: Shuhang Li Date: Tue, 2 Apr 2024 10:44:01 -0400 Subject: [PATCH 08/55] A fast spin-orbital Hbar construction algorithm based on Wick&d. --- forte/mrdsrg-so/mrdsrg_so.cc | 621 ++++---- forte/mrdsrg-so/mrdsrg_so.h | 21 + forte/mrdsrg-so/wicked_contractions.cc | 1835 +++++++++++++----------- forte/register_forte_options.py | 4 +- 4 files changed, 1351 insertions(+), 1130 deletions(-) diff --git a/forte/mrdsrg-so/mrdsrg_so.cc b/forte/mrdsrg-so/mrdsrg_so.cc index 8717706ea..2b785f5d7 100644 --- a/forte/mrdsrg-so/mrdsrg_so.cc +++ b/forte/mrdsrg-so/mrdsrg_so.cc @@ -752,6 +752,8 @@ void MRDSRG_SO::compute_hbar() { BlockedTensor C1 = ambit::BlockedTensor::build(tensor_type_, "C1", {"gg"}); BlockedTensor C2 = ambit::BlockedTensor::build(tensor_type_, "C2", {"gggg"}); + bool do_wicked = foptions_->get_bool("DO_WICKED"); + // compute Hbar recursively for (int n = 1; n <= maxn; ++n) { // prefactor before n-nested commutator @@ -761,23 +763,43 @@ void MRDSRG_SO::compute_hbar() { double C0 = 0.0; C1.zero(); C2.zero(); - - // zero-body - H1_T1_C0(O1, T1, factor, C0); - H1_T2_C0(O1, T2, factor, C0); - H2_T1_C0(O2, T1, factor, C0); - H2_T2_C0(O2, T2, factor, C0); - - // one-body - H1_T1_C1(O1, T1, factor, C1); - H1_T2_C1(O1, T2, factor, C1); - H2_T1_C1(O2, T1, factor, C1); - H2_T2_C1(O2, T2, factor, C1); - - // two-body - H1_T2_C2(O1, T2, factor, C2); - H2_T1_C2(O2, T1, factor, C2); - H2_T2_C2(O2, T2, factor, C2); + if (do_wicked) { + outfile->Printf("\n Wick&d contraction"); + // zero-body + H1_T1_C0(O1, T1, factor, C0); + H1_T2_C0(O1, T2, factor, C0); + H2_T1_C0(O2, T1, factor, C0); + H2_T2_C0(O2, T2, factor, C0); + + // one-body + H1_T1_C1(O1, T1, factor, C1); + H1_T2_C1(O1, T2, factor, C1); + H2_T1_C1(O2, T1, factor, C1); + H2_T2_C1(O2, T2, factor, C1); + + // two-body + H1_T2_C2(O1, T2, factor, C2); + H2_T1_C2(O2, T1, factor, C2); + H2_T2_C2(O2, T2, factor, C2); + } else { + outfile->Printf("\n Original contraction"); + // zero-body + H1_T1_C0_slow(O1, T1, factor, C0); + H1_T2_C0_slow(O1, T2, factor, C0); + H2_T1_C0_slow(O2, T1, factor, C0); + H2_T2_C0_slow(O2, T2, factor, C0); + + // one-body + H1_T1_C1_slow(O1, T1, factor, C1); + H1_T2_C1_slow(O1, T2, factor, C1); + H2_T1_C1_slow(O2, T1, factor, C1); + H2_T2_C1_slow(O2, T2, factor, C1); + + // two-body + H1_T2_C2_slow(O1, T2, factor, C2); + H2_T1_C2_slow(O2, T1, factor, C2); + H2_T2_C2_slow(O2, T2, factor, C2); + } // outfile->Printf("\n H0 = %20.12f", C0); // outfile->Printf("\n |H1| = %20.12f", C1.norm(1)); @@ -791,6 +813,13 @@ void MRDSRG_SO::compute_hbar() { O2["pqrs"] = C2["pqrs"]; C2["pqrs"] += O2["rspq"]; + if (do_wicked) { + O2["pqrs"] = C2["pqrs"]; + C2["pqrs"] -= O2["qprs"]; + C2["pqrs"] -= O2["pqsr"]; + C2["pqrs"] += O2["qpsr"]; + } + // Hbar += C Hbar0 += C0; Hbar1["pq"] += C1["pq"]; @@ -921,283 +950,287 @@ void MRDSRG_SO::compute_qhbar() { // -----------------------------------------------------------------"); } -// void MRDSRG_SO::H1_T1_C0(BlockedTensor& H1, BlockedTensor& T1, const double& alpha, double& C0) { -// // local_timer timer; -// // std::string str = "Computing [Hbar1, T1] -> C0 ..."; -// // outfile->Printf("\n %-35s", str.c_str()); - -// double E = 0.0; -// BlockedTensor temp; -// temp = ambit::BlockedTensor::build(tensor_type_, "temp", {"hp"}); -// temp["jb"] = T1["ia"] * Eta1["ab"] * Gamma1["ji"]; -// E += temp["jb"] * H1["bj"]; -// E *= alpha; -// C0 += E; -// // outfile->Printf(" Done. Timing %10.3f s; Energy = %14.10f Eh", -// // timer.get(), E); -// } - -// void MRDSRG_SO::H2_T1_C0(BlockedTensor& H2, BlockedTensor& T1, const double& alpha, double& C0) { -// // local_timer timer; -// // std::string str = "Computing [Hbar2, T1] -> C0 ..."; -// // outfile->Printf("\n %-35s", str.c_str()); - -// double E = 0.0; -// BlockedTensor temp; -// temp = ambit::BlockedTensor::build(tensor_type_, "temp", {"aaaa"}); -// temp["uvxy"] += H2["evxy"] * T1["ue"]; -// temp["uvxy"] -= H2["uvmy"] * T1["mx"]; -// E += 0.5 * temp["uvxy"] * Lambda2["xyuv"]; -// E *= alpha; -// C0 += E; -// // outfile->Printf(" Done. Timing %10.3f s; Energy = %14.10f Eh", -// // timer.get(), E); -// } - -// void MRDSRG_SO::H1_T2_C0(BlockedTensor& H1, BlockedTensor& T2, const double& alpha, double& C0) { -// // local_timer timer; -// // std::string str = "Computing [Hbar1, T2] -> C0 ..."; -// // outfile->Printf("\n %-35s", str.c_str()); - -// double E = 0.0; -// BlockedTensor temp; -// temp = ambit::BlockedTensor::build(tensor_type_, "temp", {"aaaa"}); -// temp["uvxy"] += H1["ex"] * T2["uvey"]; -// temp["uvxy"] -= H1["vm"] * T2["umxy"]; -// E += 0.5 * temp["uvxy"] * Lambda2["xyuv"]; -// E *= alpha; -// C0 += E; -// // outfile->Printf(" Done. Timing %10.3f s; Energy = %14.10f Eh", -// // timer.get(), E); -// } - -// void MRDSRG_SO::H2_T2_C0(BlockedTensor& H2, BlockedTensor& T2, const double& alpha, double& C0) { -// // local_timer timer; -// // std::string str = "Computing [Hbar2, T2] -> C0 ..."; -// // outfile->Printf("\n %-35s", str.c_str()); - -// // <[Hbar2, T2]> (C_2)^4 -// double E = 0.25 * H2["efmn"] * T2["mnef"]; - -// BlockedTensor temp1 = ambit::BlockedTensor::build(tensor_type_, "temp1", {"hhaa"}); -// BlockedTensor temp2 = ambit::BlockedTensor::build(tensor_type_, "temp2", {"hhaa"}); -// temp1["klux"] = T2["ijux"] * Gamma1["ki"] * Gamma1["lj"]; -// temp2["klvy"] = temp1["klux"] * Eta1["uv"] * Eta1["xy"]; -// E += 0.25 * H2["vykl"] * temp2["klvy"]; - -// temp1 = ambit::BlockedTensor::build(tensor_type_, "temp1", {"hhav"}); -// temp2 = ambit::BlockedTensor::build(tensor_type_, "temp2", {"hhav"}); -// temp1["klue"] = T2["ijue"] * Gamma1["ki"] * Gamma1["lj"]; -// temp2["klve"] = temp1["klue"] * Eta1["uv"]; -// E += 0.5 * H2["vekl"] * temp2["klve"]; - -// temp2 = ambit::BlockedTensor::build(tensor_type_, "temp2", {"aaaa"}); -// temp2["yvxu"] -= H2["fexu"] * T2["yvef"]; -// E += 0.25 * temp2["yvxu"] * Gamma1["xy"] * Gamma1["uv"]; - -// temp2 = ambit::BlockedTensor::build(tensor_type_, "temp2", {"aa"}); -// temp2["vu"] -= H2["femu"] * T2["mvef"]; -// E += 0.5 * temp2["vu"] * Gamma1["uv"]; - -// // <[Hbar2, T2]> C_4 (C_2)^2 HH -// temp1 = ambit::BlockedTensor::build(tensor_type_, "temp1", {"aahh"}); -// temp2 = ambit::BlockedTensor::build(tensor_type_, "temp2", {"aaaa"}); -// temp1["uvij"] = H2["uvkl"] * Gamma1["ki"] * Gamma1["lj"]; -// temp2["uvxy"] += 0.125 * temp1["uvij"] * T2["ijxy"]; - -// // <[Hbar2, T2]> C_4 (C_2)^2 PP -// temp1 = ambit::BlockedTensor::build(tensor_type_, "temp1", {"aapp"}); -// temp1["uvcd"] = T2["uvab"] * Eta1["ac"] * Eta1["bd"]; -// temp2["uvxy"] += 0.125 * temp1["uvcd"] * H2["cdxy"]; - -// // <[Hbar2, T2]> C_4 (C_2)^2 PH -// temp1 = ambit::BlockedTensor::build(tensor_type_, "temp1", {"hapa"}); -// temp1["juby"] = T2["iuay"] * Gamma1["ji"] * Eta1["ab"]; -// temp2["uvxy"] += H2["vbjx"] * temp1["juby"]; -// E += temp2["uvxy"] * Lambda2["xyuv"]; - -// // <[Hbar2, T2]> C_6 C_2 -// if (foptions_->get_str("THREEPDC") != "ZERO") { -// temp1 = ambit::BlockedTensor::build(tensor_type_, "temp", {"aaaaaa"}); -// temp1["uvwxyz"] += H2["uviz"] * T2["iwxy"]; -// temp1["uvwxyz"] += H2["waxy"] * T2["uvaz"]; -// E += 0.25 * temp1["uvwxyz"] * Lambda3["xyzuvw"]; -// } - -// E *= alpha; -// C0 += E; -// // outfile->Printf(" Done. Timing %10.3f s; Energy = %14.10f Eh", -// // timer.get(), E); -// } - -// void MRDSRG_SO::H1_T1_C1(BlockedTensor& H1, BlockedTensor& T1, const double& alpha, -// BlockedTensor& C1) { -// // local_timer timer; -// // std::string str = "Computing [Hbar1, T1] -> C1 ..."; -// // outfile->Printf("\n %-35s", str.c_str()); - -// C1["ip"] += alpha * H1["ap"] * T1["ia"]; -// C1["pa"] -= alpha * H1["pi"] * T1["ia"]; - -// // outfile->Printf(" Done. Timing %10.3f s", timer.get()); -// } - -// void MRDSRG_SO::H2_T1_C1(BlockedTensor& H2, BlockedTensor& T1, const double& alpha, -// BlockedTensor& C1) { -// // local_timer timer; -// // std::string str = "Computing [Hbar2, T1] -> C1 ..."; -// // outfile->Printf("\n %-35s", str.c_str()); - -// C1["qp"] += alpha * T1["ia"] * H2["qapj"] * Gamma1["ji"]; -// C1["qp"] -= alpha * T1["mu"] * H2["qvpm"] * Gamma1["uv"]; - -// // outfile->Printf(" Done. Timing %10.3f s", timer.get()); -// } - -// void MRDSRG_SO::H1_T2_C1(BlockedTensor& H1, BlockedTensor& T2, const double& alpha, -// BlockedTensor& C1) { -// // local_timer timer; -// // std::string str = "Computing [Hbar1, T2] -> C1 ..."; -// // outfile->Printf("\n %-35s", str.c_str()); - -// C1["ia"] += alpha * T2["ijab"] * H1["bk"] * Gamma1["kj"]; -// C1["ia"] -= alpha * T2["ijau"] * H1["vj"] * Gamma1["uv"]; - -// // outfile->Printf(" Done. Timing %10.3f s", timer.get()); -// } - -// void MRDSRG_SO::H2_T2_C1(BlockedTensor& H2, BlockedTensor& T2, const double& alpha, -// BlockedTensor& C1) { -// // local_timer timer; -// // std::string str = "Computing [Hbar2, T2] -> C1 ..."; -// // outfile->Printf("\n %-35s", str.c_str()); - -// // [Hbar2, T2] (C_2)^3 -> C1 -// BlockedTensor temp1 = ambit::BlockedTensor::build(tensor_type_, "temp1", {"hhgh"}); -// temp1["ijrk"] = H2["abrk"] * T2["ijab"]; -// C1["ir"] += 0.5 * alpha * temp1["ijrk"] * Gamma1["kj"]; - -// temp1 = ambit::BlockedTensor::build(tensor_type_, "temp1", {"hhaa"}); -// temp1["ijvy"] = T2["ijux"] * Gamma1["uv"] * Gamma1["xy"]; -// C1["ir"] += 0.5 * alpha * temp1["ijvy"] * H2["vyrj"]; - -// temp1 = ambit::BlockedTensor::build(tensor_type_, "temp1", {"hhap"}); -// temp1["ikvb"] = T2["ijub"] * Gamma1["kj"] * Gamma1["uv"]; -// C1["ir"] -= alpha * temp1["ikvb"] * H2["vbrk"]; - -// temp1 = ambit::BlockedTensor::build(tensor_type_, "temp1", {"hhpa"}); -// temp1["ijav"] = T2["ijau"] * Gamma1["uv"]; -// C1["pa"] -= 0.5 * alpha * temp1["ijav"] * H2["pvij"]; - -// temp1 = ambit::BlockedTensor::build(tensor_type_, "temp1", {"hhpp"}); -// temp1["klab"] = T2["ijab"] * Gamma1["ki"] * Gamma1["lj"]; -// C1["pa"] -= 0.5 * alpha * temp1["klab"] * H2["pbkl"]; - -// temp1 = ambit::BlockedTensor::build(tensor_type_, "temp1", {"hhpa"}); -// temp1["ikav"] = T2["ijau"] * Gamma1["uv"] * Gamma1["kj"]; -// C1["pa"] += alpha * temp1["ikav"] * H2["pvik"]; - -// // [Hbar2, T2] C_4 C_2 2:2 -> C1 -// temp1 = ambit::BlockedTensor::build(tensor_type_, "temp1", {"hhaa"}); -// temp1["ijuv"] = T2["ijxy"] * Lambda2["xyuv"]; -// C1["ir"] += 0.25 * alpha * temp1["ijuv"] * H2["uvrj"]; - -// temp1 = ambit::BlockedTensor::build(tensor_type_, "temp1", {"aapp"}); -// temp1["xyab"] = T2["uvab"] * Lambda2["xyuv"]; -// C1["pa"] -= 0.25 * alpha * temp1["xyab"] * H2["pbxy"]; - -// temp1 = ambit::BlockedTensor::build(tensor_type_, "temp1", {"hapa"}); -// temp1["iuax"] = T2["iyav"] * Lambda2["uvxy"]; -// C1["ir"] += alpha * temp1["iuax"] * H2["axru"]; -// C1["pa"] -= alpha * temp1["iuax"] * H2["pxiu"]; - -// // [Hbar2, T2] C_4 C_2 1:3 -> C1 -// temp1 = ambit::BlockedTensor::build(tensor_type_, "temp1", {"pa"}); -// temp1["au"] = H2["avxy"] * Lambda2["xyuv"]; -// C1["jb"] += 0.5 * alpha * temp1["au"] * T2["ujab"]; - -// temp1 = ambit::BlockedTensor::build(tensor_type_, "temp1", {"ah"}); -// temp1["ui"] = H2["xyiv"] * Lambda2["uvxy"]; -// C1["jb"] -= 0.5 * alpha * temp1["ui"] * T2["ijub"]; - -// temp1 = ambit::BlockedTensor::build(tensor_type_, "temp1", {"av"}); -// temp1["xe"] = T2["uvey"] * Lambda2["xyuv"]; -// C1["qs"] += 0.5 * alpha * temp1["xe"] * H2["eqxs"]; - -// temp1 = ambit::BlockedTensor::build(tensor_type_, "temp1", {"ca"}); -// temp1["mx"] = T2["myuv"] * Lambda2["uvxy"]; -// C1["qs"] -= 0.5 * alpha * temp1["mx"] * H2["xqms"]; - -// // outfile->Printf(" Done. Timing %10.3f s", timer.get()); -// } - -// void MRDSRG_SO::H1_T2_C2(BlockedTensor& H1, BlockedTensor& T2, const double& alpha, -// BlockedTensor& C2) { -// // local_timer timer; -// // std::string str = "Computing [Hbar1, T2] -> C2 ..."; -// // outfile->Printf("\n %-35s", str.c_str()); - -// C2["ijpb"] += alpha * T2["ijab"] * H1["ap"]; -// C2["ijap"] += alpha * T2["ijab"] * H1["bp"]; -// C2["qjab"] -= alpha * T2["ijab"] * H1["qi"]; -// C2["iqab"] -= alpha * T2["ijab"] * H1["qj"]; - -// // outfile->Printf(" Done. Timing %10.3f s", timer.get()); -// } - -// void MRDSRG_SO::H2_T1_C2(BlockedTensor& H2, BlockedTensor& T1, const double& alpha, -// BlockedTensor& C2) { -// // local_timer timer; -// // std::string str = "Computing [Hbar2, T1] -> C2 ..."; -// // outfile->Printf("\n %-35s", str.c_str()); - -// C2["irpq"] += alpha * T1["ia"] * H2["arpq"]; -// C2["ripq"] += alpha * T1["ia"] * H2["rapq"]; -// C2["rsaq"] -= alpha * T1["ia"] * H2["rsiq"]; -// C2["rspa"] -= alpha * T1["ia"] * H2["rspi"]; - -// // outfile->Printf(" Done. Timing %10.3f s", timer.get()); -// } - -// void MRDSRG_SO::H2_T2_C2(BlockedTensor& H2, BlockedTensor& T2, const double& alpha, -// BlockedTensor& C2) { -// // local_timer timer; -// // std::string str = "Computing [Hbar2, T2] -> C2 ..."; -// // outfile->Printf("\n %-35s", str.c_str()); - -// // particle-particle contractions -// C2["ijrs"] += 0.5 * alpha * H2["abrs"] * T2["ijab"]; - -// BlockedTensor temp = ambit::BlockedTensor::build(tensor_type_, "temp", {"hhpa"}); -// temp["ijby"] = T2["ijbx"] * Gamma1["xy"]; -// C2["ijrs"] -= alpha * temp["ijby"] * H2["byrs"]; - -// // hole-hole contractions -// C2["pqab"] += 0.5 * alpha * H2["pqij"] * T2["ijab"]; - -// temp = ambit::BlockedTensor::build(tensor_type_, "temp", {"ahpp"}); -// temp["xjab"] = T2["yjab"] * Eta1["xy"]; -// C2["pqab"] -= alpha * temp["xjab"] * H2["pqxj"]; - -// // particle-hole contractions -// temp = ambit::BlockedTensor::build(tensor_type_, "temp", {"hhpp"}); -// temp["kjab"] = T2["ijab"] * Gamma1["ki"]; -// C2["qjsb"] += alpha * temp["kjab"] * H2["aqks"]; -// C2["qjas"] += alpha * temp["kjab"] * H2["bqks"]; - -// C2["iqsb"] -= alpha * temp["kiab"] * H2["aqks"]; -// C2["iqas"] -= alpha * temp["kiab"] * H2["bqks"]; - -// temp = ambit::BlockedTensor::build(tensor_type_, "temp", {"hhap"}); -// temp["ijvb"] = T2["ijub"] * Gamma1["uv"]; -// C2["qjsb"] -= alpha * temp["ijvb"] * H2["vqis"]; -// C2["iqsb"] -= alpha * temp["ijvb"] * H2["vqjs"]; - -// C2["qjas"] += alpha * temp["ijva"] * H2["vqis"]; -// C2["iqas"] += alpha * temp["ijva"] * H2["vqjs"]; - -// // outfile->Printf(" Done. Timing %10.3f s", timer.get()); -// } +void MRDSRG_SO::H1_T1_C0_slow(BlockedTensor& H1, BlockedTensor& T1, const double& alpha, + double& C0) { + // local_timer timer; + // std::string str = "Computing [Hbar1, T1] -> C0 ..."; + // outfile->Printf("\n %-35s", str.c_str()); + + double E = 0.0; + BlockedTensor temp; + temp = ambit::BlockedTensor::build(tensor_type_, "temp", {"hp"}); + temp["jb"] = T1["ia"] * Eta1["ab"] * Gamma1["ji"]; + E += temp["jb"] * H1["bj"]; + E *= alpha; + C0 += E; + // outfile->Printf(" Done. Timing %10.3f s; Energy = %14.10f Eh", + // timer.get(), E); +} + +void MRDSRG_SO::H2_T1_C0_slow(BlockedTensor& H2, BlockedTensor& T1, const double& alpha, + double& C0) { + // local_timer timer; + // std::string str = "Computing [Hbar2, T1] -> C0 ..."; + // outfile->Printf("\n %-35s", str.c_str()); + + double E = 0.0; + BlockedTensor temp; + temp = ambit::BlockedTensor::build(tensor_type_, "temp", {"aaaa"}); + temp["uvxy"] += H2["evxy"] * T1["ue"]; + temp["uvxy"] -= H2["uvmy"] * T1["mx"]; + E += 0.5 * temp["uvxy"] * Lambda2["xyuv"]; + E *= alpha; + C0 += E; + // outfile->Printf(" Done. Timing %10.3f s; Energy = %14.10f Eh", + // timer.get(), E); +} + +void MRDSRG_SO::H1_T2_C0_slow(BlockedTensor& H1, BlockedTensor& T2, const double& alpha, + double& C0) { + // local_timer timer; + // std::string str = "Computing [Hbar1, T2] -> C0 ..."; + // outfile->Printf("\n %-35s", str.c_str()); + + double E = 0.0; + BlockedTensor temp; + temp = ambit::BlockedTensor::build(tensor_type_, "temp", {"aaaa"}); + temp["uvxy"] += H1["ex"] * T2["uvey"]; + temp["uvxy"] -= H1["vm"] * T2["umxy"]; + E += 0.5 * temp["uvxy"] * Lambda2["xyuv"]; + E *= alpha; + C0 += E; + // outfile->Printf(" Done. Timing %10.3f s; Energy = %14.10f Eh", + // timer.get(), E); +} + +void MRDSRG_SO::H2_T2_C0_slow(BlockedTensor& H2, BlockedTensor& T2, const double& alpha, + double& C0) { + // local_timer timer; + // std::string str = "Computing [Hbar2, T2] -> C0 ..."; + // outfile->Printf("\n %-35s", str.c_str()); + + // <[Hbar2, T2]> (C_2)^4 + double E = 0.25 * H2["efmn"] * T2["mnef"]; + + BlockedTensor temp1 = ambit::BlockedTensor::build(tensor_type_, "temp1", {"hhaa"}); + BlockedTensor temp2 = ambit::BlockedTensor::build(tensor_type_, "temp2", {"hhaa"}); + temp1["klux"] = T2["ijux"] * Gamma1["ki"] * Gamma1["lj"]; + temp2["klvy"] = temp1["klux"] * Eta1["uv"] * Eta1["xy"]; + E += 0.25 * H2["vykl"] * temp2["klvy"]; + + temp1 = ambit::BlockedTensor::build(tensor_type_, "temp1", {"hhav"}); + temp2 = ambit::BlockedTensor::build(tensor_type_, "temp2", {"hhav"}); + temp1["klue"] = T2["ijue"] * Gamma1["ki"] * Gamma1["lj"]; + temp2["klve"] = temp1["klue"] * Eta1["uv"]; + E += 0.5 * H2["vekl"] * temp2["klve"]; + + temp2 = ambit::BlockedTensor::build(tensor_type_, "temp2", {"aaaa"}); + temp2["yvxu"] -= H2["fexu"] * T2["yvef"]; + E += 0.25 * temp2["yvxu"] * Gamma1["xy"] * Gamma1["uv"]; + + temp2 = ambit::BlockedTensor::build(tensor_type_, "temp2", {"aa"}); + temp2["vu"] -= H2["femu"] * T2["mvef"]; + E += 0.5 * temp2["vu"] * Gamma1["uv"]; + + // <[Hbar2, T2]> C_4 (C_2)^2 HH + temp1 = ambit::BlockedTensor::build(tensor_type_, "temp1", {"aahh"}); + temp2 = ambit::BlockedTensor::build(tensor_type_, "temp2", {"aaaa"}); + temp1["uvij"] = H2["uvkl"] * Gamma1["ki"] * Gamma1["lj"]; + temp2["uvxy"] += 0.125 * temp1["uvij"] * T2["ijxy"]; + + // <[Hbar2, T2]> C_4 (C_2)^2 PP + temp1 = ambit::BlockedTensor::build(tensor_type_, "temp1", {"aapp"}); + temp1["uvcd"] = T2["uvab"] * Eta1["ac"] * Eta1["bd"]; + temp2["uvxy"] += 0.125 * temp1["uvcd"] * H2["cdxy"]; + + // <[Hbar2, T2]> C_4 (C_2)^2 PH + temp1 = ambit::BlockedTensor::build(tensor_type_, "temp1", {"hapa"}); + temp1["juby"] = T2["iuay"] * Gamma1["ji"] * Eta1["ab"]; + temp2["uvxy"] += H2["vbjx"] * temp1["juby"]; + E += temp2["uvxy"] * Lambda2["xyuv"]; + + // <[Hbar2, T2]> C_6 C_2 + if (foptions_->get_str("THREEPDC") != "ZERO") { + temp1 = ambit::BlockedTensor::build(tensor_type_, "temp", {"aaaaaa"}); + temp1["uvwxyz"] += H2["uviz"] * T2["iwxy"]; + temp1["uvwxyz"] += H2["waxy"] * T2["uvaz"]; + E += 0.25 * temp1["uvwxyz"] * Lambda3["xyzuvw"]; + } + + E *= alpha; + C0 += E; + // outfile->Printf(" Done. Timing %10.3f s; Energy = %14.10f Eh", + // timer.get(), E); +} + +void MRDSRG_SO::H1_T1_C1_slow(BlockedTensor& H1, BlockedTensor& T1, const double& alpha, + BlockedTensor& C1) { + // local_timer timer; + // std::string str = "Computing [Hbar1, T1] -> C1 ..."; + // outfile->Printf("\n %-35s", str.c_str()); + + C1["ip"] += alpha * H1["ap"] * T1["ia"]; + C1["pa"] -= alpha * H1["pi"] * T1["ia"]; + + // outfile->Printf(" Done. Timing %10.3f s", timer.get()); +} + +void MRDSRG_SO::H2_T1_C1_slow(BlockedTensor& H2, BlockedTensor& T1, const double& alpha, + BlockedTensor& C1) { + // local_timer timer; + // std::string str = "Computing [Hbar2, T1] -> C1 ..."; + // outfile->Printf("\n %-35s", str.c_str()); + + C1["qp"] += alpha * T1["ia"] * H2["qapj"] * Gamma1["ji"]; + C1["qp"] -= alpha * T1["mu"] * H2["qvpm"] * Gamma1["uv"]; + + // outfile->Printf(" Done. Timing %10.3f s", timer.get()); +} + +void MRDSRG_SO::H1_T2_C1_slow(BlockedTensor& H1, BlockedTensor& T2, const double& alpha, + BlockedTensor& C1) { + // local_timer timer; + // std::string str = "Computing [Hbar1, T2] -> C1 ..."; + // outfile->Printf("\n %-35s", str.c_str()); + + C1["ia"] += alpha * T2["ijab"] * H1["bk"] * Gamma1["kj"]; + C1["ia"] -= alpha * T2["ijau"] * H1["vj"] * Gamma1["uv"]; + + // outfile->Printf(" Done. Timing %10.3f s", timer.get()); +} + +void MRDSRG_SO::H2_T2_C1_slow(BlockedTensor& H2, BlockedTensor& T2, const double& alpha, + BlockedTensor& C1) { + // local_timer timer; + // std::string str = "Computing [Hbar2, T2] -> C1 ..."; + // outfile->Printf("\n %-35s", str.c_str()); + + // [Hbar2, T2] (C_2)^3 -> C1 + BlockedTensor temp1 = ambit::BlockedTensor::build(tensor_type_, "temp1", {"hhgh"}); + temp1["ijrk"] = H2["abrk"] * T2["ijab"]; + C1["ir"] += 0.5 * alpha * temp1["ijrk"] * Gamma1["kj"]; + + temp1 = ambit::BlockedTensor::build(tensor_type_, "temp1", {"hhaa"}); + temp1["ijvy"] = T2["ijux"] * Gamma1["uv"] * Gamma1["xy"]; + C1["ir"] += 0.5 * alpha * temp1["ijvy"] * H2["vyrj"]; + + temp1 = ambit::BlockedTensor::build(tensor_type_, "temp1", {"hhap"}); + temp1["ikvb"] = T2["ijub"] * Gamma1["kj"] * Gamma1["uv"]; + C1["ir"] -= alpha * temp1["ikvb"] * H2["vbrk"]; + + temp1 = ambit::BlockedTensor::build(tensor_type_, "temp1", {"hhpa"}); + temp1["ijav"] = T2["ijau"] * Gamma1["uv"]; + C1["pa"] -= 0.5 * alpha * temp1["ijav"] * H2["pvij"]; + + temp1 = ambit::BlockedTensor::build(tensor_type_, "temp1", {"hhpp"}); + temp1["klab"] = T2["ijab"] * Gamma1["ki"] * Gamma1["lj"]; + C1["pa"] -= 0.5 * alpha * temp1["klab"] * H2["pbkl"]; + + temp1 = ambit::BlockedTensor::build(tensor_type_, "temp1", {"hhpa"}); + temp1["ikav"] = T2["ijau"] * Gamma1["uv"] * Gamma1["kj"]; + C1["pa"] += alpha * temp1["ikav"] * H2["pvik"]; + + // [Hbar2, T2] C_4 C_2 2:2 -> C1 + temp1 = ambit::BlockedTensor::build(tensor_type_, "temp1", {"hhaa"}); + temp1["ijuv"] = T2["ijxy"] * Lambda2["xyuv"]; + C1["ir"] += 0.25 * alpha * temp1["ijuv"] * H2["uvrj"]; + + temp1 = ambit::BlockedTensor::build(tensor_type_, "temp1", {"aapp"}); + temp1["xyab"] = T2["uvab"] * Lambda2["xyuv"]; + C1["pa"] -= 0.25 * alpha * temp1["xyab"] * H2["pbxy"]; + + temp1 = ambit::BlockedTensor::build(tensor_type_, "temp1", {"hapa"}); + temp1["iuax"] = T2["iyav"] * Lambda2["uvxy"]; + C1["ir"] += alpha * temp1["iuax"] * H2["axru"]; + C1["pa"] -= alpha * temp1["iuax"] * H2["pxiu"]; + + // [Hbar2, T2] C_4 C_2 1:3 -> C1 + temp1 = ambit::BlockedTensor::build(tensor_type_, "temp1", {"pa"}); + temp1["au"] = H2["avxy"] * Lambda2["xyuv"]; + C1["jb"] += 0.5 * alpha * temp1["au"] * T2["ujab"]; + + temp1 = ambit::BlockedTensor::build(tensor_type_, "temp1", {"ah"}); + temp1["ui"] = H2["xyiv"] * Lambda2["uvxy"]; + C1["jb"] -= 0.5 * alpha * temp1["ui"] * T2["ijub"]; + + temp1 = ambit::BlockedTensor::build(tensor_type_, "temp1", {"av"}); + temp1["xe"] = T2["uvey"] * Lambda2["xyuv"]; + C1["qs"] += 0.5 * alpha * temp1["xe"] * H2["eqxs"]; + + temp1 = ambit::BlockedTensor::build(tensor_type_, "temp1", {"ca"}); + temp1["mx"] = T2["myuv"] * Lambda2["uvxy"]; + C1["qs"] -= 0.5 * alpha * temp1["mx"] * H2["xqms"]; + + // outfile->Printf(" Done. Timing %10.3f s", timer.get()); +} + +void MRDSRG_SO::H1_T2_C2_slow(BlockedTensor& H1, BlockedTensor& T2, const double& alpha, + BlockedTensor& C2) { + // local_timer timer; + // std::string str = "Computing [Hbar1, T2] -> C2 ..."; + // outfile->Printf("\n %-35s", str.c_str()); + + C2["ijpb"] += alpha * T2["ijab"] * H1["ap"]; + C2["ijap"] += alpha * T2["ijab"] * H1["bp"]; + C2["qjab"] -= alpha * T2["ijab"] * H1["qi"]; + C2["iqab"] -= alpha * T2["ijab"] * H1["qj"]; + + // outfile->Printf(" Done. Timing %10.3f s", timer.get()); +} + +void MRDSRG_SO::H2_T1_C2_slow(BlockedTensor& H2, BlockedTensor& T1, const double& alpha, + BlockedTensor& C2) { + // local_timer timer; + // std::string str = "Computing [Hbar2, T1] -> C2 ..."; + // outfile->Printf("\n %-35s", str.c_str()); + + C2["irpq"] += alpha * T1["ia"] * H2["arpq"]; + C2["ripq"] += alpha * T1["ia"] * H2["rapq"]; + C2["rsaq"] -= alpha * T1["ia"] * H2["rsiq"]; + C2["rspa"] -= alpha * T1["ia"] * H2["rspi"]; + + // outfile->Printf(" Done. Timing %10.3f s", timer.get()); +} + +void MRDSRG_SO::H2_T2_C2_slow(BlockedTensor& H2, BlockedTensor& T2, const double& alpha, + BlockedTensor& C2) { + // local_timer timer; + // std::string str = "Computing [Hbar2, T2] -> C2 ..."; + // outfile->Printf("\n %-35s", str.c_str()); + + // particle-particle contractions + C2["ijrs"] += 0.5 * alpha * H2["abrs"] * T2["ijab"]; + + BlockedTensor temp = ambit::BlockedTensor::build(tensor_type_, "temp", {"hhpa"}); + temp["ijby"] = T2["ijbx"] * Gamma1["xy"]; + C2["ijrs"] -= alpha * temp["ijby"] * H2["byrs"]; + + // hole-hole contractions + C2["pqab"] += 0.5 * alpha * H2["pqij"] * T2["ijab"]; + + temp = ambit::BlockedTensor::build(tensor_type_, "temp", {"ahpp"}); + temp["xjab"] = T2["yjab"] * Eta1["xy"]; + C2["pqab"] -= alpha * temp["xjab"] * H2["pqxj"]; + + // particle-hole contractions + temp = ambit::BlockedTensor::build(tensor_type_, "temp", {"hhpp"}); + temp["kjab"] = T2["ijab"] * Gamma1["ki"]; + C2["qjsb"] += alpha * temp["kjab"] * H2["aqks"]; + C2["qjas"] += alpha * temp["kjab"] * H2["bqks"]; + + C2["iqsb"] -= alpha * temp["kiab"] * H2["aqks"]; + C2["iqas"] -= alpha * temp["kiab"] * H2["bqks"]; + + temp = ambit::BlockedTensor::build(tensor_type_, "temp", {"hhap"}); + temp["ijvb"] = T2["ijub"] * Gamma1["uv"]; + C2["qjsb"] -= alpha * temp["ijvb"] * H2["vqis"]; + C2["iqsb"] -= alpha * temp["ijvb"] * H2["vqjs"]; + + C2["qjas"] += alpha * temp["ijva"] * H2["vqis"]; + C2["iqas"] += alpha * temp["ijva"] * H2["vqjs"]; + + // outfile->Printf(" Done. Timing %10.3f s", timer.get()); +} void MRDSRG_SO::H2_T2_C3(BlockedTensor& H2, BlockedTensor& T2, const double& alpha, BlockedTensor& C3) { diff --git a/forte/mrdsrg-so/mrdsrg_so.h b/forte/mrdsrg-so/mrdsrg_so.h index 1424e5355..e257e195c 100644 --- a/forte/mrdsrg-so/mrdsrg_so.h +++ b/forte/mrdsrg-so/mrdsrg_so.h @@ -211,6 +211,11 @@ class MRDSRG_SO : public DynamicCorrelationSolver { void H1_T2_C0(BlockedTensor& H1, BlockedTensor& T2, const double& alpha, double& C0); void H2_T2_C0(BlockedTensor& H2, BlockedTensor& T2, const double& alpha, double& C0); + void H1_T1_C0_slow(BlockedTensor& H1, BlockedTensor& T1, const double& alpha, double& C0); + void H2_T1_C0_slow(BlockedTensor& H2, BlockedTensor& T1, const double& alpha, double& C0); + void H1_T2_C0_slow(BlockedTensor& H1, BlockedTensor& T2, const double& alpha, double& C0); + void H2_T2_C0_slow(BlockedTensor& H2, BlockedTensor& T2, const double& alpha, double& C0); + /// Compute one-body term of commutator [H, T] void H1_T1_C1(BlockedTensor& H1, BlockedTensor& T1, const double& alpha, BlockedTensor& C1); void H1_T2_C1(BlockedTensor& H1, BlockedTensor& T2, const double& alpha, BlockedTensor& C1); @@ -219,6 +224,15 @@ class MRDSRG_SO : public DynamicCorrelationSolver { void H3_T1_C1(BlockedTensor& H3, BlockedTensor& T1, const double& alpha, BlockedTensor& C1); void H3_T2_C1(BlockedTensor& H3, BlockedTensor& T2, const double& alpha, BlockedTensor& C1); + void H1_T1_C1_slow(BlockedTensor& H1, BlockedTensor& T1, const double& alpha, + BlockedTensor& C1); + void H1_T2_C1_slow(BlockedTensor& H1, BlockedTensor& T2, const double& alpha, + BlockedTensor& C1); + void H2_T1_C1_slow(BlockedTensor& H2, BlockedTensor& T1, const double& alpha, + BlockedTensor& C1); + void H2_T2_C1_slow(BlockedTensor& H2, BlockedTensor& T2, const double& alpha, + BlockedTensor& C1); + /// Compute two-body term of commutator [H, T] void H2_T1_C2(BlockedTensor& H2, BlockedTensor& T1, const double& alpha, BlockedTensor& C2); void H1_T2_C2(BlockedTensor& H1, BlockedTensor& T2, const double& alpha, BlockedTensor& C2); @@ -226,6 +240,13 @@ class MRDSRG_SO : public DynamicCorrelationSolver { void H3_T1_C2(BlockedTensor& H3, BlockedTensor& T1, const double& alpha, BlockedTensor& C2); void H3_T2_C2(BlockedTensor& H3, BlockedTensor& T2, const double& alpha, BlockedTensor& C2); + void H2_T1_C2_slow(BlockedTensor& H2, BlockedTensor& T1, const double& alpha, + BlockedTensor& C2); + void H1_T2_C2_slow(BlockedTensor& H1, BlockedTensor& T2, const double& alpha, + BlockedTensor& C2); + void H2_T2_C2_slow(BlockedTensor& H2, BlockedTensor& T2, const double& alpha, + BlockedTensor& C2); + /// Compute three-body term of commutator [H, T] void H2_T2_C3(BlockedTensor& H2, BlockedTensor& T2, const double& alpha, BlockedTensor& C3); diff --git a/forte/mrdsrg-so/wicked_contractions.cc b/forte/mrdsrg-so/wicked_contractions.cc index 9c6cae7c7..7e701f969 100644 --- a/forte/mrdsrg-so/wicked_contractions.cc +++ b/forte/mrdsrg-so/wicked_contractions.cc @@ -8,875 +8,1040 @@ using namespace psi; namespace forte { void MRDSRG_SO::H1_T1_C0(BlockedTensor& H1, BlockedTensor& T1, const double& alpha, double& C0) { - // 3 lines - local_timer timer; - C0 += alpha * +1.00000000 * H1["u,m"] * T1["m,v"] * Eta1["v,u"]; - C0 += alpha * +1.00000000 * H1["e,m"] * T1["m,e"]; - C0 += alpha * +1.00000000 * H1["e,u"] * T1["v,e"] * Gamma1["u,v"]; + // 3 lines + local_timer timer; + C0 += alpha * +1.00000000 * H1["u,m"] * T1["m,v"] * Eta1["v,u"]; + C0 += alpha * +1.00000000 * H1["e,m"] * T1["m,e"]; + C0 += alpha * +1.00000000 * H1["e,u"] * T1["v,e"] * Gamma1["u,v"]; - if (print_ > 2) { - outfile -> Printf("\n Time for H1_T1_C0 : %12.3f", timer.get()); - } + // if (print_ > 2) { + // outfile -> Printf("\n Time for H1_T1_C0 : %12.3f", timer.get()); + //} } void MRDSRG_SO::H1_T2_C0(BlockedTensor& H1, BlockedTensor& T2, const double& alpha, double& C0) { - // 2 lines - local_timer timer; - C0 += alpha * -0.50000000 * H1["u,m"] * T2["m,v,w,x"] * Lambda2["w,x,u,v"]; - C0 += alpha * -0.50000000 * H1["e,u"] * T2["v,w,x,e"] * Lambda2["u,x,v,w"]; + // 2 lines + local_timer timer; + C0 += alpha * -0.50000000 * H1["u,m"] * T2["m,v,w,x"] * Lambda2["w,x,u,v"]; + C0 += alpha * -0.50000000 * H1["e,u"] * T2["v,w,x,e"] * Lambda2["u,x,v,w"]; - if (print_ > 2) { - outfile -> Printf("\n Time for H1_T2_C0 : %12.3f", timer.get()); - } + // if (print_ > 2) { + // outfile -> Printf("\n Time for H1_T2_C0 : %12.3f", timer.get()); + //} } void MRDSRG_SO::H2_T1_C0(BlockedTensor& H2, BlockedTensor& T1, const double& alpha, double& C0) { - // 2 lines - local_timer timer; - C0 += alpha * +0.50000000 * H2["u,v,m,w"] * T1["m,x"] * Lambda2["w,x,u,v"]; - C0 += alpha * +0.50000000 * H2["u,e,v,w"] * T1["x,e"] * Lambda2["v,w,u,x"]; + // 2 lines + local_timer timer; + C0 += alpha * +0.50000000 * H2["u,v,m,w"] * T1["m,x"] * Lambda2["w,x,u,v"]; + C0 += alpha * +0.50000000 * H2["u,e,v,w"] * T1["x,e"] * Lambda2["v,w,u,x"]; - if (print_ > 2) { - outfile -> Printf("\n Time for H2_T1_C0 : %12.3f", timer.get()); - } + // if (print_ > 2) { + // outfile -> Printf("\n Time for H2_T1_C0 : %12.3f", timer.get()); + //} } void MRDSRG_SO::H2_T2_C0(BlockedTensor& H2, BlockedTensor& T2, const double& alpha, double& C0) { - // 17 lines - local_timer timer; - C0 += alpha * +0.25000000 * H2["u,v,m,n"] * T2["m,n,w,x"] * Eta1["x,v"] * Eta1["w,u"]; - C0 += alpha * +0.12500000 * H2["u,v,m,n"] * T2["m,n,w,x"] * Lambda2["w,x,u,v"]; - C0 += alpha * +0.50000000 * H2["u,e,m,n"] * T2["m,n,v,e"] * Eta1["v,u"]; - C0 += alpha * +0.25000000 * H2["e,f,m,n"] * T2["m,n,e,f"]; - C0 += alpha * +0.50000000 * H2["u,v,m,w"] * T2["m,x,y,z"] * Eta1["z,v"] * Eta1["y,u"] * Gamma1["w,x"]; - C0 += alpha * +1.00000000 * H2["u,v,m,w"] * T2["m,x,y,z"] * Eta1["z,v"] * Lambda2["w,y,u,x"]; - C0 += alpha * +0.25000000 * H2["u,v,m,w"] * T2["m,x,y,z"] * Gamma1["w,x"] * Lambda2["y,z,u,v"]; - C0 += alpha * +0.25000000 * H2["u,v,m,w"] * T2["m,x,y,z"] * Lambda3["w,y,z,u,v,x"]; - C0 += alpha * +1.00000000 * H2["u,e,m,v"] * T2["m,w,x,e"] * Eta1["x,u"] * Gamma1["v,w"]; - C0 += alpha * +1.00000000 * H2["u,e,m,v"] * T2["m,w,x,e"] * Lambda2["v,x,u,w"]; - C0 += alpha * +0.50000000 * H2["e,f,m,u"] * T2["m,v,e,f"] * Gamma1["u,v"]; - C0 += alpha * +0.50000000 * H2["u,e,v,w"] * T2["x,y,z,e"] * Eta1["z,u"] * Gamma1["w,y"] * Gamma1["v,x"]; - C0 += alpha * +0.25000000 * H2["u,e,v,w"] * T2["x,y,z,e"] * Eta1["z,u"] * Lambda2["v,w,x,y"]; - C0 += alpha * +1.00000000 * H2["u,e,v,w"] * T2["x,y,z,e"] * Gamma1["w,y"] * Lambda2["v,z,u,x"]; - C0 += alpha * -0.25000000 * H2["u,e,v,w"] * T2["x,y,z,e"] * Lambda3["v,w,z,u,x,y"]; - C0 += alpha * +0.25000000 * H2["e,f,u,v"] * T2["w,x,e,f"] * Gamma1["v,x"] * Gamma1["u,w"]; - C0 += alpha * +0.12500000 * H2["e,f,u,v"] * T2["w,x,e,f"] * Lambda2["u,v,w,x"]; + // 17 lines + local_timer timer; + C0 += alpha * +0.25000000 * H2["u,v,m,n"] * T2["m,n,w,x"] * Eta1["x,v"] * Eta1["w,u"]; + C0 += alpha * +0.12500000 * H2["u,v,m,n"] * T2["m,n,w,x"] * Lambda2["w,x,u,v"]; + C0 += alpha * +0.50000000 * H2["u,e,m,n"] * T2["m,n,v,e"] * Eta1["v,u"]; + C0 += alpha * +0.25000000 * H2["e,f,m,n"] * T2["m,n,e,f"]; + C0 += alpha * +0.50000000 * H2["u,v,m,w"] * T2["m,x,y,z"] * Eta1["z,v"] * Eta1["y,u"] * + Gamma1["w,x"]; + C0 += alpha * +1.00000000 * H2["u,v,m,w"] * T2["m,x,y,z"] * Eta1["z,v"] * Lambda2["w,y,u,x"]; + C0 += alpha * +0.25000000 * H2["u,v,m,w"] * T2["m,x,y,z"] * Gamma1["w,x"] * Lambda2["y,z,u,v"]; + C0 += alpha * +0.25000000 * H2["u,v,m,w"] * T2["m,x,y,z"] * Lambda3["w,y,z,u,v,x"]; + C0 += alpha * +1.00000000 * H2["u,e,m,v"] * T2["m,w,x,e"] * Eta1["x,u"] * Gamma1["v,w"]; + C0 += alpha * +1.00000000 * H2["u,e,m,v"] * T2["m,w,x,e"] * Lambda2["v,x,u,w"]; + C0 += alpha * +0.50000000 * H2["e,f,m,u"] * T2["m,v,e,f"] * Gamma1["u,v"]; + C0 += alpha * +0.50000000 * H2["u,e,v,w"] * T2["x,y,z,e"] * Eta1["z,u"] * Gamma1["w,y"] * + Gamma1["v,x"]; + C0 += alpha * +0.25000000 * H2["u,e,v,w"] * T2["x,y,z,e"] * Eta1["z,u"] * Lambda2["v,w,x,y"]; + C0 += alpha * +1.00000000 * H2["u,e,v,w"] * T2["x,y,z,e"] * Gamma1["w,y"] * Lambda2["v,z,u,x"]; + C0 += alpha * -0.25000000 * H2["u,e,v,w"] * T2["x,y,z,e"] * Lambda3["v,w,z,u,x,y"]; + C0 += alpha * +0.25000000 * H2["e,f,u,v"] * T2["w,x,e,f"] * Gamma1["v,x"] * Gamma1["u,w"]; + C0 += alpha * +0.12500000 * H2["e,f,u,v"] * T2["w,x,e,f"] * Lambda2["u,v,w,x"]; - if (print_ > 2) { - outfile -> Printf("\n Time for H2_T2_C0 : %12.3f", timer.get()); - } + // if (print_ > 2) { + // outfile -> Printf("\n Time for H2_T2_C0 : %12.3f", timer.get()); + //} } -void MRDSRG_SO::H1_T1_C1(BlockedTensor& H1, BlockedTensor& T1, const double& alpha, BlockedTensor& C1) { - // 24 lines - local_timer timer; - C1["u,v"] += alpha * -1.00000000 * H1["u,m"] * T1["m,v"]; - C1["v,u"] += alpha * +1.00000000 * H1["e,u"] * T1["v,e"]; - C1["u,m"] += alpha * +1.00000000 * H1["e,m"] * T1["u,e"]; - C1["u,e"] += alpha * -1.00000000 * H1["u,m"] * T1["m,e"]; - C1["u,e"] += alpha * -1.00000000 * H1["u,v"] * T1["w,e"] * Eta1["v,w"]; - C1["u,e"] += alpha * -1.00000000 * H1["u,v"] * T1["w,e"] * Gamma1["v,w"]; - C1["u,f"] += alpha * +1.00000000 * H1["e,f"] * T1["u,e"]; - C1["m,u"] += alpha * -1.00000000 * H1["m,n"] * T1["n,u"]; - C1["m,v"] += alpha * +1.00000000 * H1["u,v"] * T1["m,w"] * Eta1["w,u"]; - C1["m,v"] += alpha * +1.00000000 * H1["u,v"] * T1["m,w"] * Gamma1["w,u"]; - C1["m,u"] += alpha * +1.00000000 * H1["e,u"] * T1["m,e"]; - C1["n,m"] += alpha * +1.00000000 * H1["u,m"] * T1["n,v"] * Eta1["v,u"]; - C1["n,m"] += alpha * +1.00000000 * H1["u,m"] * T1["n,v"] * Gamma1["v,u"]; - C1["n,m"] += alpha * +1.00000000 * H1["e,m"] * T1["n,e"]; - C1["m,e"] += alpha * -1.00000000 * H1["m,n"] * T1["n,e"]; - C1["m,e"] += alpha * -1.00000000 * H1["m,u"] * T1["v,e"] * Eta1["u,v"]; - C1["m,e"] += alpha * -1.00000000 * H1["m,u"] * T1["v,e"] * Gamma1["u,v"]; - C1["m,e"] += alpha * +1.00000000 * H1["u,e"] * T1["m,v"] * Eta1["v,u"]; - C1["m,e"] += alpha * +1.00000000 * H1["u,e"] * T1["m,v"] * Gamma1["v,u"]; - C1["m,f"] += alpha * +1.00000000 * H1["e,f"] * T1["m,e"]; - C1["e,u"] += alpha * -1.00000000 * H1["e,m"] * T1["m,u"]; - C1["e,f"] += alpha * -1.00000000 * H1["e,m"] * T1["m,f"]; - C1["e,f"] += alpha * -1.00000000 * H1["e,u"] * T1["v,f"] * Eta1["u,v"]; - C1["e,f"] += alpha * -1.00000000 * H1["e,u"] * T1["v,f"] * Gamma1["u,v"]; +void MRDSRG_SO::H1_T1_C1(BlockedTensor& H1, BlockedTensor& T1, const double& alpha, + BlockedTensor& C1) { + // 24 lines + local_timer timer; + C1["u,v"] += alpha * -1.00000000 * H1["u,m"] * T1["m,v"]; + C1["v,u"] += alpha * +1.00000000 * H1["e,u"] * T1["v,e"]; + C1["u,m"] += alpha * +1.00000000 * H1["e,m"] * T1["u,e"]; + C1["u,e"] += alpha * -1.00000000 * H1["u,m"] * T1["m,e"]; + C1["u,e"] += alpha * -1.00000000 * H1["u,v"] * T1["w,e"] * Eta1["v,w"]; + C1["u,e"] += alpha * -1.00000000 * H1["u,v"] * T1["w,e"] * Gamma1["v,w"]; + C1["u,f"] += alpha * +1.00000000 * H1["e,f"] * T1["u,e"]; + C1["m,u"] += alpha * -1.00000000 * H1["m,n"] * T1["n,u"]; + C1["m,v"] += alpha * +1.00000000 * H1["u,v"] * T1["m,w"] * Eta1["w,u"]; + C1["m,v"] += alpha * +1.00000000 * H1["u,v"] * T1["m,w"] * Gamma1["w,u"]; + C1["m,u"] += alpha * +1.00000000 * H1["e,u"] * T1["m,e"]; + C1["n,m"] += alpha * +1.00000000 * H1["u,m"] * T1["n,v"] * Eta1["v,u"]; + C1["n,m"] += alpha * +1.00000000 * H1["u,m"] * T1["n,v"] * Gamma1["v,u"]; + C1["n,m"] += alpha * +1.00000000 * H1["e,m"] * T1["n,e"]; + C1["m,e"] += alpha * -1.00000000 * H1["m,n"] * T1["n,e"]; + C1["m,e"] += alpha * -1.00000000 * H1["m,u"] * T1["v,e"] * Eta1["u,v"]; + C1["m,e"] += alpha * -1.00000000 * H1["m,u"] * T1["v,e"] * Gamma1["u,v"]; + C1["m,e"] += alpha * +1.00000000 * H1["u,e"] * T1["m,v"] * Eta1["v,u"]; + C1["m,e"] += alpha * +1.00000000 * H1["u,e"] * T1["m,v"] * Gamma1["v,u"]; + C1["m,f"] += alpha * +1.00000000 * H1["e,f"] * T1["m,e"]; + C1["e,u"] += alpha * -1.00000000 * H1["e,m"] * T1["m,u"]; + C1["e,f"] += alpha * -1.00000000 * H1["e,m"] * T1["m,f"]; + C1["e,f"] += alpha * -1.00000000 * H1["e,u"] * T1["v,f"] * Eta1["u,v"]; + C1["e,f"] += alpha * -1.00000000 * H1["e,u"] * T1["v,f"] * Gamma1["u,v"]; - if (print_ > 2) { - outfile -> Printf("\n Time for H1_T1_C1 : %12.3f", timer.get()); - } + // if (print_ > 2) { + // outfile -> Printf("\n Time for H1_T1_C1 : %12.3f", timer.get()); + //} } -void MRDSRG_SO::H1_T2_C1(BlockedTensor& H1, BlockedTensor& T2, const double& alpha, BlockedTensor& C1) { - // 18 lines - local_timer timer; - C1["v,w"] += alpha * -1.00000000 * H1["u,m"] * T2["m,v,w,x"] * Eta1["x,u"]; - C1["u,v"] += alpha * -1.00000000 * H1["e,m"] * T2["m,u,v,e"]; - C1["v,x"] += alpha * +1.00000000 * H1["e,u"] * T2["v,w,x,e"] * Gamma1["u,w"]; - C1["v,e"] += alpha * +1.00000000 * H1["u,m"] * T2["m,v,w,e"] * Eta1["w,u"]; - C1["u,f"] += alpha * -1.00000000 * H1["e,m"] * T2["m,u,f,e"]; - C1["w,e"] += alpha * -1.00000000 * H1["u,v"] * T2["w,x,y,e"] * Eta1["y,u"] * Gamma1["v,x"]; - C1["w,e"] += alpha * +1.00000000 * H1["u,v"] * T2["w,x,y,e"] * Eta1["v,x"] * Gamma1["y,u"]; - C1["v,f"] += alpha * +1.00000000 * H1["e,u"] * T2["v,w,f,e"] * Gamma1["u,w"]; - C1["n,v"] += alpha * +1.00000000 * H1["u,m"] * T2["n,m,v,w"] * Eta1["w,u"]; - C1["n,u"] += alpha * +1.00000000 * H1["e,m"] * T2["n,m,u,e"]; - C1["m,x"] += alpha * +1.00000000 * H1["u,v"] * T2["m,w,x,y"] * Eta1["y,u"] * Gamma1["v,w"]; - C1["m,x"] += alpha * -1.00000000 * H1["u,v"] * T2["m,w,x,y"] * Eta1["v,w"] * Gamma1["y,u"]; - C1["m,w"] += alpha * +1.00000000 * H1["e,u"] * T2["m,v,w,e"] * Gamma1["u,v"]; - C1["n,e"] += alpha * -1.00000000 * H1["u,m"] * T2["n,m,v,e"] * Eta1["v,u"]; - C1["n,f"] += alpha * +1.00000000 * H1["e,m"] * T2["n,m,f,e"]; - C1["m,e"] += alpha * -1.00000000 * H1["u,v"] * T2["m,w,x,e"] * Eta1["x,u"] * Gamma1["v,w"]; - C1["m,e"] += alpha * +1.00000000 * H1["u,v"] * T2["m,w,x,e"] * Eta1["v,w"] * Gamma1["x,u"]; - C1["m,f"] += alpha * +1.00000000 * H1["e,u"] * T2["m,v,f,e"] * Gamma1["u,v"]; +void MRDSRG_SO::H1_T2_C1(BlockedTensor& H1, BlockedTensor& T2, const double& alpha, + BlockedTensor& C1) { + // 18 lines + local_timer timer; + C1["v,w"] += alpha * -1.00000000 * H1["u,m"] * T2["m,v,w,x"] * Eta1["x,u"]; + C1["u,v"] += alpha * -1.00000000 * H1["e,m"] * T2["m,u,v,e"]; + C1["v,x"] += alpha * +1.00000000 * H1["e,u"] * T2["v,w,x,e"] * Gamma1["u,w"]; + C1["v,e"] += alpha * +1.00000000 * H1["u,m"] * T2["m,v,w,e"] * Eta1["w,u"]; + C1["u,f"] += alpha * -1.00000000 * H1["e,m"] * T2["m,u,f,e"]; + C1["w,e"] += alpha * -1.00000000 * H1["u,v"] * T2["w,x,y,e"] * Eta1["y,u"] * Gamma1["v,x"]; + C1["w,e"] += alpha * +1.00000000 * H1["u,v"] * T2["w,x,y,e"] * Eta1["v,x"] * Gamma1["y,u"]; + C1["v,f"] += alpha * +1.00000000 * H1["e,u"] * T2["v,w,f,e"] * Gamma1["u,w"]; + C1["n,v"] += alpha * +1.00000000 * H1["u,m"] * T2["n,m,v,w"] * Eta1["w,u"]; + C1["n,u"] += alpha * +1.00000000 * H1["e,m"] * T2["n,m,u,e"]; + C1["m,x"] += alpha * +1.00000000 * H1["u,v"] * T2["m,w,x,y"] * Eta1["y,u"] * Gamma1["v,w"]; + C1["m,x"] += alpha * -1.00000000 * H1["u,v"] * T2["m,w,x,y"] * Eta1["v,w"] * Gamma1["y,u"]; + C1["m,w"] += alpha * +1.00000000 * H1["e,u"] * T2["m,v,w,e"] * Gamma1["u,v"]; + C1["n,e"] += alpha * -1.00000000 * H1["u,m"] * T2["n,m,v,e"] * Eta1["v,u"]; + C1["n,f"] += alpha * +1.00000000 * H1["e,m"] * T2["n,m,f,e"]; + C1["m,e"] += alpha * -1.00000000 * H1["u,v"] * T2["m,w,x,e"] * Eta1["x,u"] * Gamma1["v,w"]; + C1["m,e"] += alpha * +1.00000000 * H1["u,v"] * T2["m,w,x,e"] * Eta1["v,w"] * Gamma1["x,u"]; + C1["m,f"] += alpha * +1.00000000 * H1["e,u"] * T2["m,v,f,e"] * Gamma1["u,v"]; - if (print_ > 2) { - outfile -> Printf("\n Time for H1_T2_C1 : %12.3f", timer.get()); - } + // if (print_ > 2) { + // outfile -> Printf("\n Time for H1_T2_C1 : %12.3f", timer.get()); + //} } -void MRDSRG_SO::H2_T1_C1(BlockedTensor& H2, BlockedTensor& T1, const double& alpha, BlockedTensor& C1) { - // 27 lines - local_timer timer; - C1["u,w"] += alpha * -1.00000000 * H2["u,v,m,w"] * T1["m,x"] * Eta1["x,v"]; - C1["u,v"] += alpha * -1.00000000 * H2["u,e,m,v"] * T1["m,e"]; - C1["u,v"] += alpha * +1.00000000 * H2["u,e,v,w"] * T1["x,e"] * Gamma1["w,x"]; - C1["u,m"] += alpha * +1.00000000 * H2["u,v,m,n"] * T1["n,w"] * Eta1["w,v"]; - C1["u,m"] += alpha * +1.00000000 * H2["u,e,m,n"] * T1["n,e"]; - C1["u,m"] += alpha * +1.00000000 * H2["u,e,m,v"] * T1["w,e"] * Gamma1["v,w"]; - C1["u,e"] += alpha * -1.00000000 * H2["u,v,m,e"] * T1["m,w"] * Eta1["w,v"]; - C1["u,f"] += alpha * -1.00000000 * H2["u,e,m,f"] * T1["m,e"]; - C1["u,f"] += alpha * -1.00000000 * H2["u,e,v,f"] * T1["w,e"] * Gamma1["v,w"]; - C1["m,v"] += alpha * -1.00000000 * H2["m,u,n,v"] * T1["n,w"] * Eta1["w,u"]; - C1["m,u"] += alpha * -1.00000000 * H2["m,e,n,u"] * T1["n,e"]; - C1["m,u"] += alpha * +1.00000000 * H2["m,e,u,v"] * T1["w,e"] * Gamma1["v,w"]; - C1["m,n"] += alpha * +1.00000000 * H2["m,u,n,c0"] * T1["c0,v"] * Eta1["v,u"]; - C1["m,n"] += alpha * +1.00000000 * H2["m,e,n,c0"] * T1["c0,e"]; - C1["m,n"] += alpha * +1.00000000 * H2["m,e,n,u"] * T1["v,e"] * Gamma1["u,v"]; - C1["m,e"] += alpha * -1.00000000 * H2["m,u,n,e"] * T1["n,v"] * Eta1["v,u"]; - C1["m,f"] += alpha * -1.00000000 * H2["m,e,n,f"] * T1["n,e"]; - C1["m,f"] += alpha * -1.00000000 * H2["m,e,u,f"] * T1["v,e"] * Gamma1["u,v"]; - C1["e,v"] += alpha * +1.00000000 * H2["u,e,m,v"] * T1["m,w"] * Eta1["w,u"]; - C1["e,u"] += alpha * -1.00000000 * H2["e,f,m,u"] * T1["m,f"]; - C1["e,u"] += alpha * +1.00000000 * H2["e,f,u,v"] * T1["w,f"] * Gamma1["v,w"]; - C1["e,m"] += alpha * -1.00000000 * H2["u,e,m,n"] * T1["n,v"] * Eta1["v,u"]; - C1["e,m"] += alpha * +1.00000000 * H2["e,f,m,n"] * T1["n,f"]; - C1["e,m"] += alpha * +1.00000000 * H2["e,f,m,u"] * T1["v,f"] * Gamma1["u,v"]; - C1["e,f"] += alpha * +1.00000000 * H2["u,e,m,f"] * T1["m,v"] * Eta1["v,u"]; - C1["e,g"] += alpha * -1.00000000 * H2["e,f,m,g"] * T1["m,f"]; - C1["e,g"] += alpha * -1.00000000 * H2["e,f,u,g"] * T1["v,f"] * Gamma1["u,v"]; +void MRDSRG_SO::H2_T1_C1(BlockedTensor& H2, BlockedTensor& T1, const double& alpha, + BlockedTensor& C1) { + // 27 lines + local_timer timer; + C1["u,w"] += alpha * -1.00000000 * H2["u,v,m,w"] * T1["m,x"] * Eta1["x,v"]; + C1["u,v"] += alpha * -1.00000000 * H2["u,e,m,v"] * T1["m,e"]; + C1["u,v"] += alpha * +1.00000000 * H2["u,e,v,w"] * T1["x,e"] * Gamma1["w,x"]; + C1["u,m"] += alpha * +1.00000000 * H2["u,v,m,n"] * T1["n,w"] * Eta1["w,v"]; + C1["u,m"] += alpha * +1.00000000 * H2["u,e,m,n"] * T1["n,e"]; + C1["u,m"] += alpha * +1.00000000 * H2["u,e,m,v"] * T1["w,e"] * Gamma1["v,w"]; + C1["u,e"] += alpha * -1.00000000 * H2["u,v,m,e"] * T1["m,w"] * Eta1["w,v"]; + C1["u,f"] += alpha * -1.00000000 * H2["u,e,m,f"] * T1["m,e"]; + C1["u,f"] += alpha * -1.00000000 * H2["u,e,v,f"] * T1["w,e"] * Gamma1["v,w"]; + C1["m,v"] += alpha * -1.00000000 * H2["m,u,n,v"] * T1["n,w"] * Eta1["w,u"]; + C1["m,u"] += alpha * -1.00000000 * H2["m,e,n,u"] * T1["n,e"]; + C1["m,u"] += alpha * +1.00000000 * H2["m,e,u,v"] * T1["w,e"] * Gamma1["v,w"]; + C1["m,n"] += alpha * +1.00000000 * H2["m,u,n,c0"] * T1["c0,v"] * Eta1["v,u"]; + C1["m,n"] += alpha * +1.00000000 * H2["m,e,n,c0"] * T1["c0,e"]; + C1["m,n"] += alpha * +1.00000000 * H2["m,e,n,u"] * T1["v,e"] * Gamma1["u,v"]; + C1["m,e"] += alpha * -1.00000000 * H2["m,u,n,e"] * T1["n,v"] * Eta1["v,u"]; + C1["m,f"] += alpha * -1.00000000 * H2["m,e,n,f"] * T1["n,e"]; + C1["m,f"] += alpha * -1.00000000 * H2["m,e,u,f"] * T1["v,e"] * Gamma1["u,v"]; + C1["e,v"] += alpha * +1.00000000 * H2["u,e,m,v"] * T1["m,w"] * Eta1["w,u"]; + C1["e,u"] += alpha * -1.00000000 * H2["e,f,m,u"] * T1["m,f"]; + C1["e,u"] += alpha * +1.00000000 * H2["e,f,u,v"] * T1["w,f"] * Gamma1["v,w"]; + C1["e,m"] += alpha * -1.00000000 * H2["u,e,m,n"] * T1["n,v"] * Eta1["v,u"]; + C1["e,m"] += alpha * +1.00000000 * H2["e,f,m,n"] * T1["n,f"]; + C1["e,m"] += alpha * +1.00000000 * H2["e,f,m,u"] * T1["v,f"] * Gamma1["u,v"]; + C1["e,f"] += alpha * +1.00000000 * H2["u,e,m,f"] * T1["m,v"] * Eta1["v,u"]; + C1["e,g"] += alpha * -1.00000000 * H2["e,f,m,g"] * T1["m,f"]; + C1["e,g"] += alpha * -1.00000000 * H2["e,f,u,g"] * T1["v,f"] * Gamma1["u,v"]; - if (print_ > 2) { - outfile -> Printf("\n Time for H2_T1_C1 : %12.3f", timer.get()); - } + // if (print_ > 2) { + // outfile -> Printf("\n Time for H2_T1_C1 : %12.3f", timer.get()); + //} } -void MRDSRG_SO::H2_T2_C1(BlockedTensor& H2, BlockedTensor& T2, const double& alpha, BlockedTensor& C1) { - // 158 lines - local_timer timer; - C1["u,w"] += alpha * -0.50000000 * H2["u,v,m,n"] * T2["m,n,w,x"] * Eta1["x,v"]; - C1["u,v"] += alpha * -0.50000000 * H2["u,e,m,n"] * T2["m,n,v,e"]; - C1["u,w"] += alpha * +0.50000000 * H2["u,v,m,w"] * T2["m,x,y,z"] * Lambda2["y,z,v,x"]; - C1["x,w"] += alpha * +0.50000000 * H2["u,v,m,w"] * T2["m,x,y,z"] * Eta1["z,v"] * Eta1["y,u"]; - C1["x,w"] += alpha * +0.25000000 * H2["u,v,m,w"] * T2["m,x,y,z"] * Lambda2["y,z,u,v"]; - C1["w,v"] += alpha * +1.00000000 * H2["u,e,m,v"] * T2["m,w,x,e"] * Eta1["x,u"]; - C1["v,u"] += alpha * +0.50000000 * H2["e,f,m,u"] * T2["m,v,e,f"]; - C1["u,y"] += alpha * -1.00000000 * H2["u,v,m,w"] * T2["m,x,y,z"] * Eta1["z,v"] * Gamma1["w,x"]; - C1["u,y"] += alpha * -1.00000000 * H2["u,v,m,w"] * T2["m,x,y,z"] * Lambda2["w,z,v,x"]; - C1["u,x"] += alpha * -1.00000000 * H2["u,e,m,v"] * T2["m,w,x,e"] * Gamma1["v,w"]; - C1["x,y"] += alpha * -0.50000000 * H2["u,v,m,w"] * T2["m,x,y,z"] * Lambda2["w,z,u,v"]; - C1["u,v"] += alpha * -0.50000000 * H2["u,e,v,w"] * T2["x,y,z,e"] * Lambda2["w,z,x,y"]; - C1["x,v"] += alpha * +1.00000000 * H2["u,e,v,w"] * T2["x,y,z,e"] * Eta1["z,u"] * Gamma1["w,y"]; - C1["x,v"] += alpha * +1.00000000 * H2["u,e,v,w"] * T2["x,y,z,e"] * Lambda2["w,z,u,y"]; - C1["w,u"] += alpha * +0.50000000 * H2["e,f,u,v"] * T2["w,x,e,f"] * Gamma1["v,x"]; - C1["u,z"] += alpha * -0.50000000 * H2["u,e,v,w"] * T2["x,y,z,e"] * Gamma1["w,y"] * Gamma1["v,x"]; - C1["u,z"] += alpha * -0.25000000 * H2["u,e,v,w"] * T2["x,y,z,e"] * Lambda2["v,w,x,y"]; - C1["x,z"] += alpha * +0.50000000 * H2["u,e,v,w"] * T2["x,y,z,e"] * Lambda2["v,w,u,y"]; - C1["u,m"] += alpha * -0.50000000 * H2["u,v,m,n"] * T2["n,w,x,y"] * Lambda2["x,y,v,w"]; - C1["w,m"] += alpha * -0.50000000 * H2["u,v,m,n"] * T2["n,w,x,y"] * Eta1["y,v"] * Eta1["x,u"]; - C1["w,m"] += alpha * -0.25000000 * H2["u,v,m,n"] * T2["n,w,x,y"] * Lambda2["x,y,u,v"]; - C1["v,m"] += alpha * -1.00000000 * H2["u,e,m,n"] * T2["n,v,w,e"] * Eta1["w,u"]; - C1["u,m"] += alpha * -0.50000000 * H2["e,f,m,n"] * T2["n,u,e,f"]; - C1["u,m"] += alpha * -0.50000000 * H2["u,e,m,v"] * T2["w,x,y,e"] * Lambda2["v,y,w,x"]; - C1["w,m"] += alpha * +1.00000000 * H2["u,e,m,v"] * T2["w,x,y,e"] * Eta1["y,u"] * Gamma1["v,x"]; - C1["w,m"] += alpha * +1.00000000 * H2["u,e,m,v"] * T2["w,x,y,e"] * Lambda2["v,y,u,x"]; - C1["v,m"] += alpha * +0.50000000 * H2["e,f,m,u"] * T2["v,w,e,f"] * Gamma1["u,w"]; - C1["u,e"] += alpha * +0.50000000 * H2["u,v,m,n"] * T2["m,n,w,e"] * Eta1["w,v"]; - C1["u,f"] += alpha * -0.50000000 * H2["u,e,m,n"] * T2["m,n,f,e"]; - C1["u,e"] += alpha * +1.00000000 * H2["u,v,m,w"] * T2["m,x,y,e"] * Eta1["y,v"] * Gamma1["w,x"]; - C1["u,e"] += alpha * +1.00000000 * H2["u,v,m,w"] * T2["m,x,y,e"] * Lambda2["w,y,v,x"]; - C1["u,f"] += alpha * -1.00000000 * H2["u,e,m,v"] * T2["m,w,f,e"] * Gamma1["v,w"]; - C1["x,e"] += alpha * +0.50000000 * H2["u,v,m,w"] * T2["m,x,y,e"] * Lambda2["w,y,u,v"]; - C1["u,e"] += alpha * +0.50000000 * H2["u,v,m,e"] * T2["m,w,x,y"] * Lambda2["x,y,v,w"]; - C1["w,e"] += alpha * +0.50000000 * H2["u,v,m,e"] * T2["m,w,x,y"] * Eta1["y,v"] * Eta1["x,u"]; - C1["w,e"] += alpha * +0.25000000 * H2["u,v,m,e"] * T2["m,w,x,y"] * Lambda2["x,y,u,v"]; - C1["v,f"] += alpha * +1.00000000 * H2["u,e,m,f"] * T2["m,v,w,e"] * Eta1["w,u"]; - C1["u,g"] += alpha * +0.50000000 * H2["e,f,m,g"] * T2["m,u,e,f"]; - C1["u,e"] += alpha * +0.50000000 * H2["u,v,w,x"] * T2["y,z,a0,e"] * Eta1["a0,v"] * Gamma1["x,z"] * Gamma1["w,y"]; - C1["u,e"] += alpha * +0.25000000 * H2["u,v,w,x"] * T2["y,z,a0,e"] * Eta1["a0,v"] * Lambda2["w,x,y,z"]; - C1["u,e"] += alpha * +0.50000000 * H2["u,v,w,x"] * T2["y,z,a0,e"] * Eta1["x,z"] * Eta1["w,y"] * Gamma1["a0,v"]; - C1["u,e"] += alpha * +1.00000000 * H2["u,v,w,x"] * T2["y,z,a0,e"] * Eta1["x,z"] * Lambda2["w,a0,v,y"]; - C1["u,e"] += alpha * +0.25000000 * H2["u,v,w,x"] * T2["y,z,a0,e"] * Gamma1["a0,v"] * Lambda2["w,x,y,z"]; - C1["u,e"] += alpha * +1.00000000 * H2["u,v,w,x"] * T2["y,z,a0,e"] * Gamma1["x,z"] * Lambda2["w,a0,v,y"]; - C1["u,f"] += alpha * -0.50000000 * H2["u,e,v,w"] * T2["x,y,f,e"] * Gamma1["w,y"] * Gamma1["v,x"]; - C1["u,f"] += alpha * -0.25000000 * H2["u,e,v,w"] * T2["x,y,f,e"] * Lambda2["v,w,x,y"]; - C1["y,e"] += alpha * -0.50000000 * H2["u,v,w,x"] * T2["y,z,a0,e"] * Eta1["a0,v"] * Lambda2["w,x,u,z"]; - C1["y,e"] += alpha * +0.50000000 * H2["u,v,w,x"] * T2["y,z,a0,e"] * Eta1["x,z"] * Lambda2["w,a0,u,v"]; - C1["y,e"] += alpha * +0.50000000 * H2["u,v,w,x"] * T2["y,z,a0,e"] * Gamma1["a0,u"] * Lambda2["w,x,v,z"]; - C1["y,e"] += alpha * +0.50000000 * H2["u,v,w,x"] * T2["y,z,a0,e"] * Gamma1["x,z"] * Lambda2["w,a0,u,v"]; - C1["x,f"] += alpha * +0.50000000 * H2["u,e,v,w"] * T2["x,y,f,e"] * Lambda2["v,w,u,y"]; - C1["u,f"] += alpha * +0.50000000 * H2["u,e,v,f"] * T2["w,x,y,e"] * Lambda2["v,y,w,x"]; - C1["w,f"] += alpha * -1.00000000 * H2["u,e,v,f"] * T2["w,x,y,e"] * Eta1["y,u"] * Gamma1["v,x"]; - C1["w,f"] += alpha * -1.00000000 * H2["u,e,v,f"] * T2["w,x,y,e"] * Lambda2["v,y,u,x"]; - C1["v,g"] += alpha * -0.50000000 * H2["e,f,u,g"] * T2["v,w,e,f"] * Gamma1["u,w"]; - C1["m,v"] += alpha * -0.50000000 * H2["m,u,n,c0"] * T2["n,c0,v,w"] * Eta1["w,u"]; - C1["m,u"] += alpha * -0.50000000 * H2["m,e,n,c0"] * T2["n,c0,u,e"]; - C1["m,v"] += alpha * +0.50000000 * H2["m,u,n,v"] * T2["n,w,x,y"] * Lambda2["x,y,u,w"]; - C1["n,w"] += alpha * -0.50000000 * H2["u,v,m,w"] * T2["n,m,x,y"] * Eta1["y,v"] * Eta1["x,u"]; - C1["n,w"] += alpha * -0.25000000 * H2["u,v,m,w"] * T2["n,m,x,y"] * Lambda2["x,y,u,v"]; - C1["n,v"] += alpha * -1.00000000 * H2["u,e,m,v"] * T2["n,m,w,e"] * Eta1["w,u"]; - C1["n,u"] += alpha * -0.50000000 * H2["e,f,m,u"] * T2["n,m,e,f"]; - C1["m,x"] += alpha * -1.00000000 * H2["m,u,n,v"] * T2["n,w,x,y"] * Eta1["y,u"] * Gamma1["v,w"]; - C1["m,x"] += alpha * -1.00000000 * H2["m,u,n,v"] * T2["n,w,x,y"] * Lambda2["v,y,u,w"]; - C1["m,w"] += alpha * -1.00000000 * H2["m,e,n,u"] * T2["n,v,w,e"] * Gamma1["u,v"]; - C1["n,x"] += alpha * +0.50000000 * H2["u,v,m,w"] * T2["n,m,x,y"] * Lambda2["w,y,u,v"]; - C1["m,u"] += alpha * -0.50000000 * H2["m,e,u,v"] * T2["w,x,y,e"] * Lambda2["v,y,w,x"]; - C1["m,w"] += alpha * +0.50000000 * H2["u,v,w,x"] * T2["m,y,z,a0"] * Eta1["a0,v"] * Eta1["z,u"] * Gamma1["x,y"]; - C1["m,w"] += alpha * +1.00000000 * H2["u,v,w,x"] * T2["m,y,z,a0"] * Eta1["a0,v"] * Lambda2["x,z,u,y"]; - C1["m,w"] += alpha * +0.50000000 * H2["u,v,w,x"] * T2["m,y,z,a0"] * Eta1["x,y"] * Gamma1["a0,v"] * Gamma1["z,u"]; - C1["m,w"] += alpha * +0.25000000 * H2["u,v,w,x"] * T2["m,y,z,a0"] * Eta1["x,y"] * Lambda2["z,a0,u,v"]; - C1["m,w"] += alpha * +1.00000000 * H2["u,v,w,x"] * T2["m,y,z,a0"] * Gamma1["a0,v"] * Lambda2["x,z,u,y"]; - C1["m,w"] += alpha * +0.25000000 * H2["u,v,w,x"] * T2["m,y,z,a0"] * Gamma1["x,y"] * Lambda2["z,a0,u,v"]; - C1["m,v"] += alpha * +1.00000000 * H2["u,e,v,w"] * T2["m,x,y,e"] * Eta1["y,u"] * Gamma1["w,x"]; - C1["m,v"] += alpha * +1.00000000 * H2["u,e,v,w"] * T2["m,x,y,e"] * Lambda2["w,y,u,x"]; - C1["m,u"] += alpha * +0.50000000 * H2["e,f,u,v"] * T2["m,w,e,f"] * Gamma1["v,w"]; - C1["m,y"] += alpha * -0.50000000 * H2["m,e,u,v"] * T2["w,x,y,e"] * Gamma1["v,x"] * Gamma1["u,w"]; - C1["m,y"] += alpha * -0.25000000 * H2["m,e,u,v"] * T2["w,x,y,e"] * Lambda2["u,v,w,x"]; - C1["m,z"] += alpha * +0.50000000 * H2["u,v,w,x"] * T2["m,y,z,a0"] * Eta1["a0,v"] * Lambda2["w,x,u,y"]; - C1["m,z"] += alpha * -0.50000000 * H2["u,v,w,x"] * T2["m,y,z,a0"] * Eta1["x,y"] * Lambda2["w,a0,u,v"]; - C1["m,z"] += alpha * -0.50000000 * H2["u,v,w,x"] * T2["m,y,z,a0"] * Gamma1["a0,u"] * Lambda2["w,x,v,y"]; - C1["m,z"] += alpha * -0.50000000 * H2["u,v,w,x"] * T2["m,y,z,a0"] * Gamma1["x,y"] * Lambda2["w,a0,u,v"]; - C1["m,y"] += alpha * +0.50000000 * H2["u,e,v,w"] * T2["m,x,y,e"] * Lambda2["v,w,u,x"]; - C1["m,n"] += alpha * -0.50000000 * H2["m,u,n,c0"] * T2["c0,v,w,x"] * Lambda2["w,x,u,v"]; - C1["c0,m"] += alpha * +0.50000000 * H2["u,v,m,n"] * T2["c0,n,w,x"] * Eta1["x,v"] * Eta1["w,u"]; - C1["c0,m"] += alpha * +0.25000000 * H2["u,v,m,n"] * T2["c0,n,w,x"] * Lambda2["w,x,u,v"]; - C1["c0,m"] += alpha * +1.00000000 * H2["u,e,m,n"] * T2["c0,n,v,e"] * Eta1["v,u"]; - C1["c0,m"] += alpha * +0.50000000 * H2["e,f,m,n"] * T2["c0,n,e,f"]; - C1["m,n"] += alpha * -0.50000000 * H2["m,e,n,u"] * T2["v,w,x,e"] * Lambda2["u,x,v,w"]; - C1["n,m"] += alpha * +0.50000000 * H2["u,v,m,w"] * T2["n,x,y,z"] * Eta1["z,v"] * Eta1["y,u"] * Gamma1["w,x"]; - C1["n,m"] += alpha * +1.00000000 * H2["u,v,m,w"] * T2["n,x,y,z"] * Eta1["z,v"] * Lambda2["w,y,u,x"]; - C1["n,m"] += alpha * +0.50000000 * H2["u,v,m,w"] * T2["n,x,y,z"] * Eta1["w,x"] * Gamma1["z,v"] * Gamma1["y,u"]; - C1["n,m"] += alpha * +0.25000000 * H2["u,v,m,w"] * T2["n,x,y,z"] * Eta1["w,x"] * Lambda2["y,z,u,v"]; - C1["n,m"] += alpha * +1.00000000 * H2["u,v,m,w"] * T2["n,x,y,z"] * Gamma1["z,v"] * Lambda2["w,y,u,x"]; - C1["n,m"] += alpha * +0.25000000 * H2["u,v,m,w"] * T2["n,x,y,z"] * Gamma1["w,x"] * Lambda2["y,z,u,v"]; - C1["n,m"] += alpha * +1.00000000 * H2["u,e,m,v"] * T2["n,w,x,e"] * Eta1["x,u"] * Gamma1["v,w"]; - C1["n,m"] += alpha * +1.00000000 * H2["u,e,m,v"] * T2["n,w,x,e"] * Lambda2["v,x,u,w"]; - C1["n,m"] += alpha * +0.50000000 * H2["e,f,m,u"] * T2["n,v,e,f"] * Gamma1["u,v"]; - C1["m,e"] += alpha * +0.50000000 * H2["m,u,n,c0"] * T2["n,c0,v,e"] * Eta1["v,u"]; - C1["m,f"] += alpha * -0.50000000 * H2["m,e,n,c0"] * T2["n,c0,f,e"]; - C1["m,e"] += alpha * +1.00000000 * H2["m,u,n,v"] * T2["n,w,x,e"] * Eta1["x,u"] * Gamma1["v,w"]; - C1["m,e"] += alpha * +1.00000000 * H2["m,u,n,v"] * T2["n,w,x,e"] * Lambda2["v,x,u,w"]; - C1["m,f"] += alpha * -1.00000000 * H2["m,e,n,u"] * T2["n,v,f,e"] * Gamma1["u,v"]; - C1["n,e"] += alpha * -0.50000000 * H2["u,v,m,w"] * T2["n,m,x,e"] * Lambda2["w,x,u,v"]; - C1["m,e"] += alpha * +0.50000000 * H2["m,u,n,e"] * T2["n,v,w,x"] * Lambda2["w,x,u,v"]; - C1["n,e"] += alpha * -0.50000000 * H2["u,v,m,e"] * T2["n,m,w,x"] * Eta1["x,v"] * Eta1["w,u"]; - C1["n,e"] += alpha * -0.25000000 * H2["u,v,m,e"] * T2["n,m,w,x"] * Lambda2["w,x,u,v"]; - C1["n,f"] += alpha * -1.00000000 * H2["u,e,m,f"] * T2["n,m,v,e"] * Eta1["v,u"]; - C1["n,g"] += alpha * -0.50000000 * H2["e,f,m,g"] * T2["n,m,e,f"]; - C1["m,e"] += alpha * +0.50000000 * H2["m,u,v,w"] * T2["x,y,z,e"] * Eta1["z,u"] * Gamma1["w,y"] * Gamma1["v,x"]; - C1["m,e"] += alpha * +0.25000000 * H2["m,u,v,w"] * T2["x,y,z,e"] * Eta1["z,u"] * Lambda2["v,w,x,y"]; - C1["m,e"] += alpha * +0.50000000 * H2["m,u,v,w"] * T2["x,y,z,e"] * Eta1["w,y"] * Eta1["v,x"] * Gamma1["z,u"]; - C1["m,e"] += alpha * +1.00000000 * H2["m,u,v,w"] * T2["x,y,z,e"] * Eta1["w,y"] * Lambda2["v,z,u,x"]; - C1["m,e"] += alpha * +0.25000000 * H2["m,u,v,w"] * T2["x,y,z,e"] * Gamma1["z,u"] * Lambda2["v,w,x,y"]; - C1["m,e"] += alpha * +1.00000000 * H2["m,u,v,w"] * T2["x,y,z,e"] * Gamma1["w,y"] * Lambda2["v,z,u,x"]; - C1["m,f"] += alpha * -0.50000000 * H2["m,e,u,v"] * T2["w,x,f,e"] * Gamma1["v,x"] * Gamma1["u,w"]; - C1["m,f"] += alpha * -0.25000000 * H2["m,e,u,v"] * T2["w,x,f,e"] * Lambda2["u,v,w,x"]; - C1["m,e"] += alpha * -0.50000000 * H2["u,v,w,x"] * T2["m,y,z,e"] * Eta1["z,v"] * Lambda2["w,x,u,y"]; - C1["m,e"] += alpha * +0.50000000 * H2["u,v,w,x"] * T2["m,y,z,e"] * Eta1["x,y"] * Lambda2["w,z,u,v"]; - C1["m,e"] += alpha * +0.50000000 * H2["u,v,w,x"] * T2["m,y,z,e"] * Gamma1["z,u"] * Lambda2["w,x,v,y"]; - C1["m,e"] += alpha * +0.50000000 * H2["u,v,w,x"] * T2["m,y,z,e"] * Gamma1["x,y"] * Lambda2["w,z,u,v"]; - C1["m,f"] += alpha * +0.50000000 * H2["u,e,v,w"] * T2["m,x,f,e"] * Lambda2["v,w,u,x"]; - C1["m,f"] += alpha * +0.50000000 * H2["m,e,u,f"] * T2["v,w,x,e"] * Lambda2["u,x,v,w"]; - C1["m,e"] += alpha * -0.50000000 * H2["u,v,w,e"] * T2["m,x,y,z"] * Eta1["z,v"] * Eta1["y,u"] * Gamma1["w,x"]; - C1["m,e"] += alpha * -1.00000000 * H2["u,v,w,e"] * T2["m,x,y,z"] * Eta1["z,v"] * Lambda2["w,y,u,x"]; - C1["m,e"] += alpha * -0.50000000 * H2["u,v,w,e"] * T2["m,x,y,z"] * Eta1["w,x"] * Gamma1["z,v"] * Gamma1["y,u"]; - C1["m,e"] += alpha * -0.25000000 * H2["u,v,w,e"] * T2["m,x,y,z"] * Eta1["w,x"] * Lambda2["y,z,u,v"]; - C1["m,e"] += alpha * -1.00000000 * H2["u,v,w,e"] * T2["m,x,y,z"] * Gamma1["z,v"] * Lambda2["w,y,u,x"]; - C1["m,e"] += alpha * -0.25000000 * H2["u,v,w,e"] * T2["m,x,y,z"] * Gamma1["w,x"] * Lambda2["y,z,u,v"]; - C1["m,f"] += alpha * -1.00000000 * H2["u,e,v,f"] * T2["m,w,x,e"] * Eta1["x,u"] * Gamma1["v,w"]; - C1["m,f"] += alpha * -1.00000000 * H2["u,e,v,f"] * T2["m,w,x,e"] * Lambda2["v,x,u,w"]; - C1["m,g"] += alpha * -0.50000000 * H2["e,f,u,g"] * T2["m,v,e,f"] * Gamma1["u,v"]; - C1["e,v"] += alpha * +0.50000000 * H2["u,e,m,n"] * T2["m,n,v,w"] * Eta1["w,u"]; - C1["e,u"] += alpha * -0.50000000 * H2["e,f,m,n"] * T2["m,n,u,f"]; - C1["e,v"] += alpha * -0.50000000 * H2["u,e,m,v"] * T2["m,w,x,y"] * Lambda2["x,y,u,w"]; - C1["e,x"] += alpha * +1.00000000 * H2["u,e,m,v"] * T2["m,w,x,y"] * Eta1["y,u"] * Gamma1["v,w"]; - C1["e,x"] += alpha * +1.00000000 * H2["u,e,m,v"] * T2["m,w,x,y"] * Lambda2["v,y,u,w"]; - C1["e,w"] += alpha * -1.00000000 * H2["e,f,m,u"] * T2["m,v,w,f"] * Gamma1["u,v"]; - C1["e,u"] += alpha * -0.50000000 * H2["e,f,u,v"] * T2["w,x,y,f"] * Lambda2["v,y,w,x"]; - C1["e,y"] += alpha * -0.50000000 * H2["e,f,u,v"] * T2["w,x,y,f"] * Gamma1["v,x"] * Gamma1["u,w"]; - C1["e,y"] += alpha * -0.25000000 * H2["e,f,u,v"] * T2["w,x,y,f"] * Lambda2["u,v,w,x"]; - C1["e,m"] += alpha * +0.50000000 * H2["u,e,m,n"] * T2["n,v,w,x"] * Lambda2["w,x,u,v"]; - C1["e,m"] += alpha * -0.50000000 * H2["e,f,m,u"] * T2["v,w,x,f"] * Lambda2["u,x,v,w"]; - C1["e,f"] += alpha * -0.50000000 * H2["u,e,m,n"] * T2["m,n,v,f"] * Eta1["v,u"]; - C1["e,g"] += alpha * -0.50000000 * H2["e,f,m,n"] * T2["m,n,g,f"]; - C1["e,f"] += alpha * -1.00000000 * H2["u,e,m,v"] * T2["m,w,x,f"] * Eta1["x,u"] * Gamma1["v,w"]; - C1["e,f"] += alpha * -1.00000000 * H2["u,e,m,v"] * T2["m,w,x,f"] * Lambda2["v,x,u,w"]; - C1["e,g"] += alpha * -1.00000000 * H2["e,f,m,u"] * T2["m,v,g,f"] * Gamma1["u,v"]; - C1["e,f"] += alpha * -0.50000000 * H2["u,e,m,f"] * T2["m,v,w,x"] * Lambda2["w,x,u,v"]; - C1["e,f"] += alpha * -0.50000000 * H2["u,e,v,w"] * T2["x,y,z,f"] * Eta1["z,u"] * Gamma1["w,y"] * Gamma1["v,x"]; - C1["e,f"] += alpha * -0.25000000 * H2["u,e,v,w"] * T2["x,y,z,f"] * Eta1["z,u"] * Lambda2["v,w,x,y"]; - C1["e,f"] += alpha * -0.50000000 * H2["u,e,v,w"] * T2["x,y,z,f"] * Eta1["w,y"] * Eta1["v,x"] * Gamma1["z,u"]; - C1["e,f"] += alpha * -1.00000000 * H2["u,e,v,w"] * T2["x,y,z,f"] * Eta1["w,y"] * Lambda2["v,z,u,x"]; - C1["e,f"] += alpha * -0.25000000 * H2["u,e,v,w"] * T2["x,y,z,f"] * Gamma1["z,u"] * Lambda2["v,w,x,y"]; - C1["e,f"] += alpha * -1.00000000 * H2["u,e,v,w"] * T2["x,y,z,f"] * Gamma1["w,y"] * Lambda2["v,z,u,x"]; - C1["e,g"] += alpha * -0.50000000 * H2["e,f,u,v"] * T2["w,x,g,f"] * Gamma1["v,x"] * Gamma1["u,w"]; - C1["e,g"] += alpha * -0.25000000 * H2["e,f,u,v"] * T2["w,x,g,f"] * Lambda2["u,v,w,x"]; - C1["e,g"] += alpha * +0.50000000 * H2["e,f,u,g"] * T2["v,w,x,f"] * Lambda2["u,x,v,w"]; +void MRDSRG_SO::H2_T2_C1(BlockedTensor& H2, BlockedTensor& T2, const double& alpha, + BlockedTensor& C1) { + // 158 lines + local_timer timer; + C1["u,w"] += alpha * -0.50000000 * H2["u,v,m,n"] * T2["m,n,w,x"] * Eta1["x,v"]; + C1["u,v"] += alpha * -0.50000000 * H2["u,e,m,n"] * T2["m,n,v,e"]; + C1["u,w"] += alpha * +0.50000000 * H2["u,v,m,w"] * T2["m,x,y,z"] * Lambda2["y,z,v,x"]; + C1["x,w"] += alpha * +0.50000000 * H2["u,v,m,w"] * T2["m,x,y,z"] * Eta1["z,v"] * Eta1["y,u"]; + C1["x,w"] += alpha * +0.25000000 * H2["u,v,m,w"] * T2["m,x,y,z"] * Lambda2["y,z,u,v"]; + C1["w,v"] += alpha * +1.00000000 * H2["u,e,m,v"] * T2["m,w,x,e"] * Eta1["x,u"]; + C1["v,u"] += alpha * +0.50000000 * H2["e,f,m,u"] * T2["m,v,e,f"]; + C1["u,y"] += alpha * -1.00000000 * H2["u,v,m,w"] * T2["m,x,y,z"] * Eta1["z,v"] * Gamma1["w,x"]; + C1["u,y"] += alpha * -1.00000000 * H2["u,v,m,w"] * T2["m,x,y,z"] * Lambda2["w,z,v,x"]; + C1["u,x"] += alpha * -1.00000000 * H2["u,e,m,v"] * T2["m,w,x,e"] * Gamma1["v,w"]; + C1["x,y"] += alpha * -0.50000000 * H2["u,v,m,w"] * T2["m,x,y,z"] * Lambda2["w,z,u,v"]; + C1["u,v"] += alpha * -0.50000000 * H2["u,e,v,w"] * T2["x,y,z,e"] * Lambda2["w,z,x,y"]; + C1["x,v"] += alpha * +1.00000000 * H2["u,e,v,w"] * T2["x,y,z,e"] * Eta1["z,u"] * Gamma1["w,y"]; + C1["x,v"] += alpha * +1.00000000 * H2["u,e,v,w"] * T2["x,y,z,e"] * Lambda2["w,z,u,y"]; + C1["w,u"] += alpha * +0.50000000 * H2["e,f,u,v"] * T2["w,x,e,f"] * Gamma1["v,x"]; + C1["u,z"] += + alpha * -0.50000000 * H2["u,e,v,w"] * T2["x,y,z,e"] * Gamma1["w,y"] * Gamma1["v,x"]; + C1["u,z"] += alpha * -0.25000000 * H2["u,e,v,w"] * T2["x,y,z,e"] * Lambda2["v,w,x,y"]; + C1["x,z"] += alpha * +0.50000000 * H2["u,e,v,w"] * T2["x,y,z,e"] * Lambda2["v,w,u,y"]; + C1["u,m"] += alpha * -0.50000000 * H2["u,v,m,n"] * T2["n,w,x,y"] * Lambda2["x,y,v,w"]; + C1["w,m"] += alpha * -0.50000000 * H2["u,v,m,n"] * T2["n,w,x,y"] * Eta1["y,v"] * Eta1["x,u"]; + C1["w,m"] += alpha * -0.25000000 * H2["u,v,m,n"] * T2["n,w,x,y"] * Lambda2["x,y,u,v"]; + C1["v,m"] += alpha * -1.00000000 * H2["u,e,m,n"] * T2["n,v,w,e"] * Eta1["w,u"]; + C1["u,m"] += alpha * -0.50000000 * H2["e,f,m,n"] * T2["n,u,e,f"]; + C1["u,m"] += alpha * -0.50000000 * H2["u,e,m,v"] * T2["w,x,y,e"] * Lambda2["v,y,w,x"]; + C1["w,m"] += alpha * +1.00000000 * H2["u,e,m,v"] * T2["w,x,y,e"] * Eta1["y,u"] * Gamma1["v,x"]; + C1["w,m"] += alpha * +1.00000000 * H2["u,e,m,v"] * T2["w,x,y,e"] * Lambda2["v,y,u,x"]; + C1["v,m"] += alpha * +0.50000000 * H2["e,f,m,u"] * T2["v,w,e,f"] * Gamma1["u,w"]; + C1["u,e"] += alpha * +0.50000000 * H2["u,v,m,n"] * T2["m,n,w,e"] * Eta1["w,v"]; + C1["u,f"] += alpha * -0.50000000 * H2["u,e,m,n"] * T2["m,n,f,e"]; + C1["u,e"] += alpha * +1.00000000 * H2["u,v,m,w"] * T2["m,x,y,e"] * Eta1["y,v"] * Gamma1["w,x"]; + C1["u,e"] += alpha * +1.00000000 * H2["u,v,m,w"] * T2["m,x,y,e"] * Lambda2["w,y,v,x"]; + C1["u,f"] += alpha * -1.00000000 * H2["u,e,m,v"] * T2["m,w,f,e"] * Gamma1["v,w"]; + C1["x,e"] += alpha * +0.50000000 * H2["u,v,m,w"] * T2["m,x,y,e"] * Lambda2["w,y,u,v"]; + C1["u,e"] += alpha * +0.50000000 * H2["u,v,m,e"] * T2["m,w,x,y"] * Lambda2["x,y,v,w"]; + C1["w,e"] += alpha * +0.50000000 * H2["u,v,m,e"] * T2["m,w,x,y"] * Eta1["y,v"] * Eta1["x,u"]; + C1["w,e"] += alpha * +0.25000000 * H2["u,v,m,e"] * T2["m,w,x,y"] * Lambda2["x,y,u,v"]; + C1["v,f"] += alpha * +1.00000000 * H2["u,e,m,f"] * T2["m,v,w,e"] * Eta1["w,u"]; + C1["u,g"] += alpha * +0.50000000 * H2["e,f,m,g"] * T2["m,u,e,f"]; + C1["u,e"] += alpha * +0.50000000 * H2["u,v,w,x"] * T2["y,z,a0,e"] * Eta1["a0,v"] * + Gamma1["x,z"] * Gamma1["w,y"]; + C1["u,e"] += + alpha * +0.25000000 * H2["u,v,w,x"] * T2["y,z,a0,e"] * Eta1["a0,v"] * Lambda2["w,x,y,z"]; + C1["u,e"] += alpha * +0.50000000 * H2["u,v,w,x"] * T2["y,z,a0,e"] * Eta1["x,z"] * Eta1["w,y"] * + Gamma1["a0,v"]; + C1["u,e"] += + alpha * +1.00000000 * H2["u,v,w,x"] * T2["y,z,a0,e"] * Eta1["x,z"] * Lambda2["w,a0,v,y"]; + C1["u,e"] += + alpha * +0.25000000 * H2["u,v,w,x"] * T2["y,z,a0,e"] * Gamma1["a0,v"] * Lambda2["w,x,y,z"]; + C1["u,e"] += + alpha * +1.00000000 * H2["u,v,w,x"] * T2["y,z,a0,e"] * Gamma1["x,z"] * Lambda2["w,a0,v,y"]; + C1["u,f"] += + alpha * -0.50000000 * H2["u,e,v,w"] * T2["x,y,f,e"] * Gamma1["w,y"] * Gamma1["v,x"]; + C1["u,f"] += alpha * -0.25000000 * H2["u,e,v,w"] * T2["x,y,f,e"] * Lambda2["v,w,x,y"]; + C1["y,e"] += + alpha * -0.50000000 * H2["u,v,w,x"] * T2["y,z,a0,e"] * Eta1["a0,v"] * Lambda2["w,x,u,z"]; + C1["y,e"] += + alpha * +0.50000000 * H2["u,v,w,x"] * T2["y,z,a0,e"] * Eta1["x,z"] * Lambda2["w,a0,u,v"]; + C1["y,e"] += + alpha * +0.50000000 * H2["u,v,w,x"] * T2["y,z,a0,e"] * Gamma1["a0,u"] * Lambda2["w,x,v,z"]; + C1["y,e"] += + alpha * +0.50000000 * H2["u,v,w,x"] * T2["y,z,a0,e"] * Gamma1["x,z"] * Lambda2["w,a0,u,v"]; + C1["x,f"] += alpha * +0.50000000 * H2["u,e,v,w"] * T2["x,y,f,e"] * Lambda2["v,w,u,y"]; + C1["u,f"] += alpha * +0.50000000 * H2["u,e,v,f"] * T2["w,x,y,e"] * Lambda2["v,y,w,x"]; + C1["w,f"] += alpha * -1.00000000 * H2["u,e,v,f"] * T2["w,x,y,e"] * Eta1["y,u"] * Gamma1["v,x"]; + C1["w,f"] += alpha * -1.00000000 * H2["u,e,v,f"] * T2["w,x,y,e"] * Lambda2["v,y,u,x"]; + C1["v,g"] += alpha * -0.50000000 * H2["e,f,u,g"] * T2["v,w,e,f"] * Gamma1["u,w"]; + C1["m,v"] += alpha * -0.50000000 * H2["m,u,n,c0"] * T2["n,c0,v,w"] * Eta1["w,u"]; + C1["m,u"] += alpha * -0.50000000 * H2["m,e,n,c0"] * T2["n,c0,u,e"]; + C1["m,v"] += alpha * +0.50000000 * H2["m,u,n,v"] * T2["n,w,x,y"] * Lambda2["x,y,u,w"]; + C1["n,w"] += alpha * -0.50000000 * H2["u,v,m,w"] * T2["n,m,x,y"] * Eta1["y,v"] * Eta1["x,u"]; + C1["n,w"] += alpha * -0.25000000 * H2["u,v,m,w"] * T2["n,m,x,y"] * Lambda2["x,y,u,v"]; + C1["n,v"] += alpha * -1.00000000 * H2["u,e,m,v"] * T2["n,m,w,e"] * Eta1["w,u"]; + C1["n,u"] += alpha * -0.50000000 * H2["e,f,m,u"] * T2["n,m,e,f"]; + C1["m,x"] += alpha * -1.00000000 * H2["m,u,n,v"] * T2["n,w,x,y"] * Eta1["y,u"] * Gamma1["v,w"]; + C1["m,x"] += alpha * -1.00000000 * H2["m,u,n,v"] * T2["n,w,x,y"] * Lambda2["v,y,u,w"]; + C1["m,w"] += alpha * -1.00000000 * H2["m,e,n,u"] * T2["n,v,w,e"] * Gamma1["u,v"]; + C1["n,x"] += alpha * +0.50000000 * H2["u,v,m,w"] * T2["n,m,x,y"] * Lambda2["w,y,u,v"]; + C1["m,u"] += alpha * -0.50000000 * H2["m,e,u,v"] * T2["w,x,y,e"] * Lambda2["v,y,w,x"]; + C1["m,w"] += alpha * +0.50000000 * H2["u,v,w,x"] * T2["m,y,z,a0"] * Eta1["a0,v"] * Eta1["z,u"] * + Gamma1["x,y"]; + C1["m,w"] += + alpha * +1.00000000 * H2["u,v,w,x"] * T2["m,y,z,a0"] * Eta1["a0,v"] * Lambda2["x,z,u,y"]; + C1["m,w"] += alpha * +0.50000000 * H2["u,v,w,x"] * T2["m,y,z,a0"] * Eta1["x,y"] * + Gamma1["a0,v"] * Gamma1["z,u"]; + C1["m,w"] += + alpha * +0.25000000 * H2["u,v,w,x"] * T2["m,y,z,a0"] * Eta1["x,y"] * Lambda2["z,a0,u,v"]; + C1["m,w"] += + alpha * +1.00000000 * H2["u,v,w,x"] * T2["m,y,z,a0"] * Gamma1["a0,v"] * Lambda2["x,z,u,y"]; + C1["m,w"] += + alpha * +0.25000000 * H2["u,v,w,x"] * T2["m,y,z,a0"] * Gamma1["x,y"] * Lambda2["z,a0,u,v"]; + C1["m,v"] += alpha * +1.00000000 * H2["u,e,v,w"] * T2["m,x,y,e"] * Eta1["y,u"] * Gamma1["w,x"]; + C1["m,v"] += alpha * +1.00000000 * H2["u,e,v,w"] * T2["m,x,y,e"] * Lambda2["w,y,u,x"]; + C1["m,u"] += alpha * +0.50000000 * H2["e,f,u,v"] * T2["m,w,e,f"] * Gamma1["v,w"]; + C1["m,y"] += + alpha * -0.50000000 * H2["m,e,u,v"] * T2["w,x,y,e"] * Gamma1["v,x"] * Gamma1["u,w"]; + C1["m,y"] += alpha * -0.25000000 * H2["m,e,u,v"] * T2["w,x,y,e"] * Lambda2["u,v,w,x"]; + C1["m,z"] += + alpha * +0.50000000 * H2["u,v,w,x"] * T2["m,y,z,a0"] * Eta1["a0,v"] * Lambda2["w,x,u,y"]; + C1["m,z"] += + alpha * -0.50000000 * H2["u,v,w,x"] * T2["m,y,z,a0"] * Eta1["x,y"] * Lambda2["w,a0,u,v"]; + C1["m,z"] += + alpha * -0.50000000 * H2["u,v,w,x"] * T2["m,y,z,a0"] * Gamma1["a0,u"] * Lambda2["w,x,v,y"]; + C1["m,z"] += + alpha * -0.50000000 * H2["u,v,w,x"] * T2["m,y,z,a0"] * Gamma1["x,y"] * Lambda2["w,a0,u,v"]; + C1["m,y"] += alpha * +0.50000000 * H2["u,e,v,w"] * T2["m,x,y,e"] * Lambda2["v,w,u,x"]; + C1["m,n"] += alpha * -0.50000000 * H2["m,u,n,c0"] * T2["c0,v,w,x"] * Lambda2["w,x,u,v"]; + C1["c0,m"] += alpha * +0.50000000 * H2["u,v,m,n"] * T2["c0,n,w,x"] * Eta1["x,v"] * Eta1["w,u"]; + C1["c0,m"] += alpha * +0.25000000 * H2["u,v,m,n"] * T2["c0,n,w,x"] * Lambda2["w,x,u,v"]; + C1["c0,m"] += alpha * +1.00000000 * H2["u,e,m,n"] * T2["c0,n,v,e"] * Eta1["v,u"]; + C1["c0,m"] += alpha * +0.50000000 * H2["e,f,m,n"] * T2["c0,n,e,f"]; + C1["m,n"] += alpha * -0.50000000 * H2["m,e,n,u"] * T2["v,w,x,e"] * Lambda2["u,x,v,w"]; + C1["n,m"] += alpha * +0.50000000 * H2["u,v,m,w"] * T2["n,x,y,z"] * Eta1["z,v"] * Eta1["y,u"] * + Gamma1["w,x"]; + C1["n,m"] += + alpha * +1.00000000 * H2["u,v,m,w"] * T2["n,x,y,z"] * Eta1["z,v"] * Lambda2["w,y,u,x"]; + C1["n,m"] += alpha * +0.50000000 * H2["u,v,m,w"] * T2["n,x,y,z"] * Eta1["w,x"] * Gamma1["z,v"] * + Gamma1["y,u"]; + C1["n,m"] += + alpha * +0.25000000 * H2["u,v,m,w"] * T2["n,x,y,z"] * Eta1["w,x"] * Lambda2["y,z,u,v"]; + C1["n,m"] += + alpha * +1.00000000 * H2["u,v,m,w"] * T2["n,x,y,z"] * Gamma1["z,v"] * Lambda2["w,y,u,x"]; + C1["n,m"] += + alpha * +0.25000000 * H2["u,v,m,w"] * T2["n,x,y,z"] * Gamma1["w,x"] * Lambda2["y,z,u,v"]; + C1["n,m"] += alpha * +1.00000000 * H2["u,e,m,v"] * T2["n,w,x,e"] * Eta1["x,u"] * Gamma1["v,w"]; + C1["n,m"] += alpha * +1.00000000 * H2["u,e,m,v"] * T2["n,w,x,e"] * Lambda2["v,x,u,w"]; + C1["n,m"] += alpha * +0.50000000 * H2["e,f,m,u"] * T2["n,v,e,f"] * Gamma1["u,v"]; + C1["m,e"] += alpha * +0.50000000 * H2["m,u,n,c0"] * T2["n,c0,v,e"] * Eta1["v,u"]; + C1["m,f"] += alpha * -0.50000000 * H2["m,e,n,c0"] * T2["n,c0,f,e"]; + C1["m,e"] += alpha * +1.00000000 * H2["m,u,n,v"] * T2["n,w,x,e"] * Eta1["x,u"] * Gamma1["v,w"]; + C1["m,e"] += alpha * +1.00000000 * H2["m,u,n,v"] * T2["n,w,x,e"] * Lambda2["v,x,u,w"]; + C1["m,f"] += alpha * -1.00000000 * H2["m,e,n,u"] * T2["n,v,f,e"] * Gamma1["u,v"]; + C1["n,e"] += alpha * -0.50000000 * H2["u,v,m,w"] * T2["n,m,x,e"] * Lambda2["w,x,u,v"]; + C1["m,e"] += alpha * +0.50000000 * H2["m,u,n,e"] * T2["n,v,w,x"] * Lambda2["w,x,u,v"]; + C1["n,e"] += alpha * -0.50000000 * H2["u,v,m,e"] * T2["n,m,w,x"] * Eta1["x,v"] * Eta1["w,u"]; + C1["n,e"] += alpha * -0.25000000 * H2["u,v,m,e"] * T2["n,m,w,x"] * Lambda2["w,x,u,v"]; + C1["n,f"] += alpha * -1.00000000 * H2["u,e,m,f"] * T2["n,m,v,e"] * Eta1["v,u"]; + C1["n,g"] += alpha * -0.50000000 * H2["e,f,m,g"] * T2["n,m,e,f"]; + C1["m,e"] += alpha * +0.50000000 * H2["m,u,v,w"] * T2["x,y,z,e"] * Eta1["z,u"] * Gamma1["w,y"] * + Gamma1["v,x"]; + C1["m,e"] += + alpha * +0.25000000 * H2["m,u,v,w"] * T2["x,y,z,e"] * Eta1["z,u"] * Lambda2["v,w,x,y"]; + C1["m,e"] += alpha * +0.50000000 * H2["m,u,v,w"] * T2["x,y,z,e"] * Eta1["w,y"] * Eta1["v,x"] * + Gamma1["z,u"]; + C1["m,e"] += + alpha * +1.00000000 * H2["m,u,v,w"] * T2["x,y,z,e"] * Eta1["w,y"] * Lambda2["v,z,u,x"]; + C1["m,e"] += + alpha * +0.25000000 * H2["m,u,v,w"] * T2["x,y,z,e"] * Gamma1["z,u"] * Lambda2["v,w,x,y"]; + C1["m,e"] += + alpha * +1.00000000 * H2["m,u,v,w"] * T2["x,y,z,e"] * Gamma1["w,y"] * Lambda2["v,z,u,x"]; + C1["m,f"] += + alpha * -0.50000000 * H2["m,e,u,v"] * T2["w,x,f,e"] * Gamma1["v,x"] * Gamma1["u,w"]; + C1["m,f"] += alpha * -0.25000000 * H2["m,e,u,v"] * T2["w,x,f,e"] * Lambda2["u,v,w,x"]; + C1["m,e"] += + alpha * -0.50000000 * H2["u,v,w,x"] * T2["m,y,z,e"] * Eta1["z,v"] * Lambda2["w,x,u,y"]; + C1["m,e"] += + alpha * +0.50000000 * H2["u,v,w,x"] * T2["m,y,z,e"] * Eta1["x,y"] * Lambda2["w,z,u,v"]; + C1["m,e"] += + alpha * +0.50000000 * H2["u,v,w,x"] * T2["m,y,z,e"] * Gamma1["z,u"] * Lambda2["w,x,v,y"]; + C1["m,e"] += + alpha * +0.50000000 * H2["u,v,w,x"] * T2["m,y,z,e"] * Gamma1["x,y"] * Lambda2["w,z,u,v"]; + C1["m,f"] += alpha * +0.50000000 * H2["u,e,v,w"] * T2["m,x,f,e"] * Lambda2["v,w,u,x"]; + C1["m,f"] += alpha * +0.50000000 * H2["m,e,u,f"] * T2["v,w,x,e"] * Lambda2["u,x,v,w"]; + C1["m,e"] += alpha * -0.50000000 * H2["u,v,w,e"] * T2["m,x,y,z"] * Eta1["z,v"] * Eta1["y,u"] * + Gamma1["w,x"]; + C1["m,e"] += + alpha * -1.00000000 * H2["u,v,w,e"] * T2["m,x,y,z"] * Eta1["z,v"] * Lambda2["w,y,u,x"]; + C1["m,e"] += alpha * -0.50000000 * H2["u,v,w,e"] * T2["m,x,y,z"] * Eta1["w,x"] * Gamma1["z,v"] * + Gamma1["y,u"]; + C1["m,e"] += + alpha * -0.25000000 * H2["u,v,w,e"] * T2["m,x,y,z"] * Eta1["w,x"] * Lambda2["y,z,u,v"]; + C1["m,e"] += + alpha * -1.00000000 * H2["u,v,w,e"] * T2["m,x,y,z"] * Gamma1["z,v"] * Lambda2["w,y,u,x"]; + C1["m,e"] += + alpha * -0.25000000 * H2["u,v,w,e"] * T2["m,x,y,z"] * Gamma1["w,x"] * Lambda2["y,z,u,v"]; + C1["m,f"] += alpha * -1.00000000 * H2["u,e,v,f"] * T2["m,w,x,e"] * Eta1["x,u"] * Gamma1["v,w"]; + C1["m,f"] += alpha * -1.00000000 * H2["u,e,v,f"] * T2["m,w,x,e"] * Lambda2["v,x,u,w"]; + C1["m,g"] += alpha * -0.50000000 * H2["e,f,u,g"] * T2["m,v,e,f"] * Gamma1["u,v"]; + C1["e,v"] += alpha * +0.50000000 * H2["u,e,m,n"] * T2["m,n,v,w"] * Eta1["w,u"]; + C1["e,u"] += alpha * -0.50000000 * H2["e,f,m,n"] * T2["m,n,u,f"]; + C1["e,v"] += alpha * -0.50000000 * H2["u,e,m,v"] * T2["m,w,x,y"] * Lambda2["x,y,u,w"]; + C1["e,x"] += alpha * +1.00000000 * H2["u,e,m,v"] * T2["m,w,x,y"] * Eta1["y,u"] * Gamma1["v,w"]; + C1["e,x"] += alpha * +1.00000000 * H2["u,e,m,v"] * T2["m,w,x,y"] * Lambda2["v,y,u,w"]; + C1["e,w"] += alpha * -1.00000000 * H2["e,f,m,u"] * T2["m,v,w,f"] * Gamma1["u,v"]; + C1["e,u"] += alpha * -0.50000000 * H2["e,f,u,v"] * T2["w,x,y,f"] * Lambda2["v,y,w,x"]; + C1["e,y"] += + alpha * -0.50000000 * H2["e,f,u,v"] * T2["w,x,y,f"] * Gamma1["v,x"] * Gamma1["u,w"]; + C1["e,y"] += alpha * -0.25000000 * H2["e,f,u,v"] * T2["w,x,y,f"] * Lambda2["u,v,w,x"]; + C1["e,m"] += alpha * +0.50000000 * H2["u,e,m,n"] * T2["n,v,w,x"] * Lambda2["w,x,u,v"]; + C1["e,m"] += alpha * -0.50000000 * H2["e,f,m,u"] * T2["v,w,x,f"] * Lambda2["u,x,v,w"]; + C1["e,f"] += alpha * -0.50000000 * H2["u,e,m,n"] * T2["m,n,v,f"] * Eta1["v,u"]; + C1["e,g"] += alpha * -0.50000000 * H2["e,f,m,n"] * T2["m,n,g,f"]; + C1["e,f"] += alpha * -1.00000000 * H2["u,e,m,v"] * T2["m,w,x,f"] * Eta1["x,u"] * Gamma1["v,w"]; + C1["e,f"] += alpha * -1.00000000 * H2["u,e,m,v"] * T2["m,w,x,f"] * Lambda2["v,x,u,w"]; + C1["e,g"] += alpha * -1.00000000 * H2["e,f,m,u"] * T2["m,v,g,f"] * Gamma1["u,v"]; + C1["e,f"] += alpha * -0.50000000 * H2["u,e,m,f"] * T2["m,v,w,x"] * Lambda2["w,x,u,v"]; + C1["e,f"] += alpha * -0.50000000 * H2["u,e,v,w"] * T2["x,y,z,f"] * Eta1["z,u"] * Gamma1["w,y"] * + Gamma1["v,x"]; + C1["e,f"] += + alpha * -0.25000000 * H2["u,e,v,w"] * T2["x,y,z,f"] * Eta1["z,u"] * Lambda2["v,w,x,y"]; + C1["e,f"] += alpha * -0.50000000 * H2["u,e,v,w"] * T2["x,y,z,f"] * Eta1["w,y"] * Eta1["v,x"] * + Gamma1["z,u"]; + C1["e,f"] += + alpha * -1.00000000 * H2["u,e,v,w"] * T2["x,y,z,f"] * Eta1["w,y"] * Lambda2["v,z,u,x"]; + C1["e,f"] += + alpha * -0.25000000 * H2["u,e,v,w"] * T2["x,y,z,f"] * Gamma1["z,u"] * Lambda2["v,w,x,y"]; + C1["e,f"] += + alpha * -1.00000000 * H2["u,e,v,w"] * T2["x,y,z,f"] * Gamma1["w,y"] * Lambda2["v,z,u,x"]; + C1["e,g"] += + alpha * -0.50000000 * H2["e,f,u,v"] * T2["w,x,g,f"] * Gamma1["v,x"] * Gamma1["u,w"]; + C1["e,g"] += alpha * -0.25000000 * H2["e,f,u,v"] * T2["w,x,g,f"] * Lambda2["u,v,w,x"]; + C1["e,g"] += alpha * +0.50000000 * H2["e,f,u,g"] * T2["v,w,x,f"] * Lambda2["u,x,v,w"]; - if (print_ > 2) { - outfile -> Printf("\n Time for H2_T2_C1 : %12.3f", timer.get()); - } + // if (print_ > 2) { + // outfile -> Printf("\n Time for H2_T2_C1 : %12.3f", timer.get()); + //} } -void MRDSRG_SO::H1_T2_C2(BlockedTensor& H1, BlockedTensor& T2, const double& alpha, BlockedTensor& C2) { - // 96 lines - local_timer timer; - C2["u,v,w,x"] += alpha * -0.50000000 * H1["u,m"] * T2["m,v,w,x"]; - C2["v,w,u,x"] += alpha * -0.50000000 * H1["e,u"] * T2["v,w,x,e"]; - C2["u,v,m,w"] += alpha * -0.50000000 * H1["e,m"] * T2["u,v,w,e"]; - C2["u,v,w,e"] += alpha * -1.00000000 * H1["u,m"] * T2["m,v,w,e"]; - C2["w,x,v,e"] += alpha * +0.50000000 * H1["u,v"] * T2["w,x,y,e"] * Eta1["y,u"]; - C2["w,x,v,e"] += alpha * +0.50000000 * H1["u,v"] * T2["w,x,y,e"] * Gamma1["y,u"]; - C2["v,w,u,f"] += alpha * -0.50000000 * H1["e,u"] * T2["v,w,f,e"]; - C2["u,w,y,e"] += alpha * +1.00000000 * H1["u,v"] * T2["w,x,y,e"] * Eta1["v,x"]; - C2["u,w,y,e"] += alpha * +1.00000000 * H1["u,v"] * T2["w,x,y,e"] * Gamma1["v,x"]; - C2["u,v,w,f"] += alpha * +0.50000000 * H1["e,f"] * T2["u,v,w,e"]; - C2["v,w,m,e"] += alpha * +0.50000000 * H1["u,m"] * T2["v,w,x,e"] * Eta1["x,u"]; - C2["v,w,m,e"] += alpha * +0.50000000 * H1["u,m"] * T2["v,w,x,e"] * Gamma1["x,u"]; - C2["u,v,m,f"] += alpha * -0.50000000 * H1["e,m"] * T2["u,v,f,e"]; - C2["u,v,e,f"] += alpha * -0.50000000 * H1["u,m"] * T2["m,v,e,f"]; - C2["u,w,e,f"] += alpha * +0.50000000 * H1["u,v"] * T2["w,x,e,f"] * Eta1["v,x"]; - C2["u,w,e,f"] += alpha * +0.50000000 * H1["u,v"] * T2["w,x,e,f"] * Gamma1["v,x"]; - C2["v,w,e,f"] += alpha * +0.50000000 * H1["u,e"] * T2["v,w,x,f"] * Eta1["x,u"]; - C2["v,w,e,f"] += alpha * +0.50000000 * H1["u,e"] * T2["v,w,x,f"] * Gamma1["x,u"]; - C2["u,v,f,g"] += alpha * -0.50000000 * H1["e,f"] * T2["u,v,g,e"]; - C2["u,e,v,w"] += alpha * +0.50000000 * H1["e,m"] * T2["m,u,v,w"]; - C2["u,e,v,f"] += alpha * +1.00000000 * H1["e,m"] * T2["m,u,v,f"]; - C2["v,e,x,f"] += alpha * -1.00000000 * H1["e,u"] * T2["v,w,x,f"] * Eta1["u,w"]; - C2["v,e,x,f"] += alpha * -1.00000000 * H1["e,u"] * T2["v,w,x,f"] * Gamma1["u,w"]; - C2["u,e,f,g"] += alpha * +0.50000000 * H1["e,m"] * T2["m,u,f,g"]; - C2["v,e,f,g"] += alpha * -0.50000000 * H1["e,u"] * T2["v,w,f,g"] * Eta1["u,w"]; - C2["v,e,f,g"] += alpha * -0.50000000 * H1["e,u"] * T2["v,w,f,g"] * Gamma1["u,w"]; - C2["m,u,v,w"] += alpha * -0.50000000 * H1["m,n"] * T2["n,u,v,w"]; - C2["n,u,v,w"] += alpha * -0.50000000 * H1["u,m"] * T2["n,m,v,w"]; - C2["m,w,v,x"] += alpha * -1.00000000 * H1["u,v"] * T2["m,w,x,y"] * Eta1["y,u"]; - C2["m,w,v,x"] += alpha * -1.00000000 * H1["u,v"] * T2["m,w,x,y"] * Gamma1["y,u"]; - C2["m,v,u,w"] += alpha * -1.00000000 * H1["e,u"] * T2["m,v,w,e"]; - C2["m,u,x,y"] += alpha * -0.50000000 * H1["u,v"] * T2["m,w,x,y"] * Eta1["v,w"]; - C2["m,u,x,y"] += alpha * -0.50000000 * H1["u,v"] * T2["m,w,x,y"] * Gamma1["v,w"]; - C2["n,v,m,w"] += alpha * -1.00000000 * H1["u,m"] * T2["n,v,w,x"] * Eta1["x,u"]; - C2["n,v,m,w"] += alpha * -1.00000000 * H1["u,m"] * T2["n,v,w,x"] * Gamma1["x,u"]; - C2["n,u,m,v"] += alpha * -1.00000000 * H1["e,m"] * T2["n,u,v,e"]; - C2["m,u,v,e"] += alpha * -1.00000000 * H1["m,n"] * T2["n,u,v,e"]; - C2["n,u,v,e"] += alpha * -1.00000000 * H1["u,m"] * T2["n,m,v,e"]; - C2["m,w,v,e"] += alpha * +1.00000000 * H1["u,v"] * T2["m,w,x,e"] * Eta1["x,u"]; - C2["m,w,v,e"] += alpha * +1.00000000 * H1["u,v"] * T2["m,w,x,e"] * Gamma1["x,u"]; - C2["m,v,u,f"] += alpha * -1.00000000 * H1["e,u"] * T2["m,v,f,e"]; - C2["m,v,x,e"] += alpha * +1.00000000 * H1["m,u"] * T2["v,w,x,e"] * Eta1["u,w"]; - C2["m,v,x,e"] += alpha * +1.00000000 * H1["m,u"] * T2["v,w,x,e"] * Gamma1["u,w"]; - C2["m,u,x,e"] += alpha * -1.00000000 * H1["u,v"] * T2["m,w,x,e"] * Eta1["v,w"]; - C2["m,u,x,e"] += alpha * -1.00000000 * H1["u,v"] * T2["m,w,x,e"] * Gamma1["v,w"]; - C2["m,v,w,e"] += alpha * +1.00000000 * H1["u,e"] * T2["m,v,w,x"] * Eta1["x,u"]; - C2["m,v,w,e"] += alpha * +1.00000000 * H1["u,e"] * T2["m,v,w,x"] * Gamma1["x,u"]; - C2["m,u,v,f"] += alpha * +1.00000000 * H1["e,f"] * T2["m,u,v,e"]; - C2["n,v,m,e"] += alpha * +1.00000000 * H1["u,m"] * T2["n,v,w,e"] * Eta1["w,u"]; - C2["n,v,m,e"] += alpha * +1.00000000 * H1["u,m"] * T2["n,v,w,e"] * Gamma1["w,u"]; - C2["n,u,m,f"] += alpha * -1.00000000 * H1["e,m"] * T2["n,u,f,e"]; - C2["m,u,e,f"] += alpha * -0.50000000 * H1["m,n"] * T2["n,u,e,f"]; - C2["n,u,e,f"] += alpha * -0.50000000 * H1["u,m"] * T2["n,m,e,f"]; - C2["m,v,e,f"] += alpha * +0.50000000 * H1["m,u"] * T2["v,w,e,f"] * Eta1["u,w"]; - C2["m,v,e,f"] += alpha * +0.50000000 * H1["m,u"] * T2["v,w,e,f"] * Gamma1["u,w"]; - C2["m,u,e,f"] += alpha * -0.50000000 * H1["u,v"] * T2["m,w,e,f"] * Eta1["v,w"]; - C2["m,u,e,f"] += alpha * -0.50000000 * H1["u,v"] * T2["m,w,e,f"] * Gamma1["v,w"]; - C2["m,v,e,f"] += alpha * +1.00000000 * H1["u,e"] * T2["m,v,w,f"] * Eta1["w,u"]; - C2["m,v,e,f"] += alpha * +1.00000000 * H1["u,e"] * T2["m,v,w,f"] * Gamma1["w,u"]; - C2["m,u,f,g"] += alpha * -1.00000000 * H1["e,f"] * T2["m,u,g,e"]; - C2["m,c0,u,v"] += alpha * +0.50000000 * H1["m,n"] * T2["c0,n,u,v"]; - C2["m,n,v,w"] += alpha * -0.50000000 * H1["u,v"] * T2["m,n,w,x"] * Eta1["x,u"]; - C2["m,n,v,w"] += alpha * -0.50000000 * H1["u,v"] * T2["m,n,w,x"] * Gamma1["x,u"]; - C2["m,n,u,v"] += alpha * -0.50000000 * H1["e,u"] * T2["m,n,v,e"]; - C2["m,n,w,x"] += alpha * +0.50000000 * H1["m,u"] * T2["n,v,w,x"] * Eta1["u,v"]; - C2["m,n,w,x"] += alpha * +0.50000000 * H1["m,u"] * T2["n,v,w,x"] * Gamma1["u,v"]; - C2["n,c0,m,v"] += alpha * -0.50000000 * H1["u,m"] * T2["n,c0,v,w"] * Eta1["w,u"]; - C2["n,c0,m,v"] += alpha * -0.50000000 * H1["u,m"] * T2["n,c0,v,w"] * Gamma1["w,u"]; - C2["n,c0,m,u"] += alpha * -0.50000000 * H1["e,m"] * T2["n,c0,u,e"]; - C2["m,c0,u,e"] += alpha * +1.00000000 * H1["m,n"] * T2["c0,n,u,e"]; - C2["m,n,v,e"] += alpha * +0.50000000 * H1["u,v"] * T2["m,n,w,e"] * Eta1["w,u"]; - C2["m,n,v,e"] += alpha * +0.50000000 * H1["u,v"] * T2["m,n,w,e"] * Gamma1["w,u"]; - C2["m,n,u,f"] += alpha * -0.50000000 * H1["e,u"] * T2["m,n,f,e"]; - C2["m,n,w,e"] += alpha * +1.00000000 * H1["m,u"] * T2["n,v,w,e"] * Eta1["u,v"]; - C2["m,n,w,e"] += alpha * +1.00000000 * H1["m,u"] * T2["n,v,w,e"] * Gamma1["u,v"]; - C2["m,n,v,e"] += alpha * +0.50000000 * H1["u,e"] * T2["m,n,v,w"] * Eta1["w,u"]; - C2["m,n,v,e"] += alpha * +0.50000000 * H1["u,e"] * T2["m,n,v,w"] * Gamma1["w,u"]; - C2["m,n,u,f"] += alpha * +0.50000000 * H1["e,f"] * T2["m,n,u,e"]; - C2["n,c0,m,e"] += alpha * +0.50000000 * H1["u,m"] * T2["n,c0,v,e"] * Eta1["v,u"]; - C2["n,c0,m,e"] += alpha * +0.50000000 * H1["u,m"] * T2["n,c0,v,e"] * Gamma1["v,u"]; - C2["n,c0,m,f"] += alpha * -0.50000000 * H1["e,m"] * T2["n,c0,f,e"]; - C2["m,c0,e,f"] += alpha * +0.50000000 * H1["m,n"] * T2["c0,n,e,f"]; - C2["m,n,e,f"] += alpha * +0.50000000 * H1["m,u"] * T2["n,v,e,f"] * Eta1["u,v"]; - C2["m,n,e,f"] += alpha * +0.50000000 * H1["m,u"] * T2["n,v,e,f"] * Gamma1["u,v"]; - C2["m,n,e,f"] += alpha * +0.50000000 * H1["u,e"] * T2["m,n,v,f"] * Eta1["v,u"]; - C2["m,n,e,f"] += alpha * +0.50000000 * H1["u,e"] * T2["m,n,v,f"] * Gamma1["v,u"]; - C2["m,n,f,g"] += alpha * -0.50000000 * H1["e,f"] * T2["m,n,g,e"]; - C2["n,e,u,v"] += alpha * -0.50000000 * H1["e,m"] * T2["n,m,u,v"]; - C2["m,e,w,x"] += alpha * -0.50000000 * H1["e,u"] * T2["m,v,w,x"] * Eta1["u,v"]; - C2["m,e,w,x"] += alpha * -0.50000000 * H1["e,u"] * T2["m,v,w,x"] * Gamma1["u,v"]; - C2["n,e,u,f"] += alpha * -1.00000000 * H1["e,m"] * T2["n,m,u,f"]; - C2["m,e,w,f"] += alpha * -1.00000000 * H1["e,u"] * T2["m,v,w,f"] * Eta1["u,v"]; - C2["m,e,w,f"] += alpha * -1.00000000 * H1["e,u"] * T2["m,v,w,f"] * Gamma1["u,v"]; - C2["n,e,f,g"] += alpha * -0.50000000 * H1["e,m"] * T2["n,m,f,g"]; - C2["m,e,f,g"] += alpha * -0.50000000 * H1["e,u"] * T2["m,v,f,g"] * Eta1["u,v"]; - C2["m,e,f,g"] += alpha * -0.50000000 * H1["e,u"] * T2["m,v,f,g"] * Gamma1["u,v"]; +void MRDSRG_SO::H1_T2_C2(BlockedTensor& H1, BlockedTensor& T2, const double& alpha, + BlockedTensor& C2) { + // 96 lines + local_timer timer; + C2["u,v,w,x"] += alpha * -0.50000000 * H1["u,m"] * T2["m,v,w,x"]; + C2["v,w,u,x"] += alpha * -0.50000000 * H1["e,u"] * T2["v,w,x,e"]; + C2["u,v,m,w"] += alpha * -0.50000000 * H1["e,m"] * T2["u,v,w,e"]; + C2["u,v,w,e"] += alpha * -1.00000000 * H1["u,m"] * T2["m,v,w,e"]; + C2["w,x,v,e"] += alpha * +0.50000000 * H1["u,v"] * T2["w,x,y,e"] * Eta1["y,u"]; + C2["w,x,v,e"] += alpha * +0.50000000 * H1["u,v"] * T2["w,x,y,e"] * Gamma1["y,u"]; + C2["v,w,u,f"] += alpha * -0.50000000 * H1["e,u"] * T2["v,w,f,e"]; + C2["u,w,y,e"] += alpha * +1.00000000 * H1["u,v"] * T2["w,x,y,e"] * Eta1["v,x"]; + C2["u,w,y,e"] += alpha * +1.00000000 * H1["u,v"] * T2["w,x,y,e"] * Gamma1["v,x"]; + C2["u,v,w,f"] += alpha * +0.50000000 * H1["e,f"] * T2["u,v,w,e"]; + C2["v,w,m,e"] += alpha * +0.50000000 * H1["u,m"] * T2["v,w,x,e"] * Eta1["x,u"]; + C2["v,w,m,e"] += alpha * +0.50000000 * H1["u,m"] * T2["v,w,x,e"] * Gamma1["x,u"]; + C2["u,v,m,f"] += alpha * -0.50000000 * H1["e,m"] * T2["u,v,f,e"]; + C2["u,v,e,f"] += alpha * -0.50000000 * H1["u,m"] * T2["m,v,e,f"]; + C2["u,w,e,f"] += alpha * +0.50000000 * H1["u,v"] * T2["w,x,e,f"] * Eta1["v,x"]; + C2["u,w,e,f"] += alpha * +0.50000000 * H1["u,v"] * T2["w,x,e,f"] * Gamma1["v,x"]; + C2["v,w,e,f"] += alpha * +0.50000000 * H1["u,e"] * T2["v,w,x,f"] * Eta1["x,u"]; + C2["v,w,e,f"] += alpha * +0.50000000 * H1["u,e"] * T2["v,w,x,f"] * Gamma1["x,u"]; + C2["u,v,f,g"] += alpha * -0.50000000 * H1["e,f"] * T2["u,v,g,e"]; + C2["u,e,v,w"] += alpha * +0.50000000 * H1["e,m"] * T2["m,u,v,w"]; + C2["u,e,v,f"] += alpha * +1.00000000 * H1["e,m"] * T2["m,u,v,f"]; + C2["v,e,x,f"] += alpha * -1.00000000 * H1["e,u"] * T2["v,w,x,f"] * Eta1["u,w"]; + C2["v,e,x,f"] += alpha * -1.00000000 * H1["e,u"] * T2["v,w,x,f"] * Gamma1["u,w"]; + C2["u,e,f,g"] += alpha * +0.50000000 * H1["e,m"] * T2["m,u,f,g"]; + C2["v,e,f,g"] += alpha * -0.50000000 * H1["e,u"] * T2["v,w,f,g"] * Eta1["u,w"]; + C2["v,e,f,g"] += alpha * -0.50000000 * H1["e,u"] * T2["v,w,f,g"] * Gamma1["u,w"]; + C2["m,u,v,w"] += alpha * -0.50000000 * H1["m,n"] * T2["n,u,v,w"]; + C2["n,u,v,w"] += alpha * -0.50000000 * H1["u,m"] * T2["n,m,v,w"]; + C2["m,w,v,x"] += alpha * -1.00000000 * H1["u,v"] * T2["m,w,x,y"] * Eta1["y,u"]; + C2["m,w,v,x"] += alpha * -1.00000000 * H1["u,v"] * T2["m,w,x,y"] * Gamma1["y,u"]; + C2["m,v,u,w"] += alpha * -1.00000000 * H1["e,u"] * T2["m,v,w,e"]; + C2["m,u,x,y"] += alpha * -0.50000000 * H1["u,v"] * T2["m,w,x,y"] * Eta1["v,w"]; + C2["m,u,x,y"] += alpha * -0.50000000 * H1["u,v"] * T2["m,w,x,y"] * Gamma1["v,w"]; + C2["n,v,m,w"] += alpha * -1.00000000 * H1["u,m"] * T2["n,v,w,x"] * Eta1["x,u"]; + C2["n,v,m,w"] += alpha * -1.00000000 * H1["u,m"] * T2["n,v,w,x"] * Gamma1["x,u"]; + C2["n,u,m,v"] += alpha * -1.00000000 * H1["e,m"] * T2["n,u,v,e"]; + C2["m,u,v,e"] += alpha * -1.00000000 * H1["m,n"] * T2["n,u,v,e"]; + C2["n,u,v,e"] += alpha * -1.00000000 * H1["u,m"] * T2["n,m,v,e"]; + C2["m,w,v,e"] += alpha * +1.00000000 * H1["u,v"] * T2["m,w,x,e"] * Eta1["x,u"]; + C2["m,w,v,e"] += alpha * +1.00000000 * H1["u,v"] * T2["m,w,x,e"] * Gamma1["x,u"]; + C2["m,v,u,f"] += alpha * -1.00000000 * H1["e,u"] * T2["m,v,f,e"]; + C2["m,v,x,e"] += alpha * +1.00000000 * H1["m,u"] * T2["v,w,x,e"] * Eta1["u,w"]; + C2["m,v,x,e"] += alpha * +1.00000000 * H1["m,u"] * T2["v,w,x,e"] * Gamma1["u,w"]; + C2["m,u,x,e"] += alpha * -1.00000000 * H1["u,v"] * T2["m,w,x,e"] * Eta1["v,w"]; + C2["m,u,x,e"] += alpha * -1.00000000 * H1["u,v"] * T2["m,w,x,e"] * Gamma1["v,w"]; + C2["m,v,w,e"] += alpha * +1.00000000 * H1["u,e"] * T2["m,v,w,x"] * Eta1["x,u"]; + C2["m,v,w,e"] += alpha * +1.00000000 * H1["u,e"] * T2["m,v,w,x"] * Gamma1["x,u"]; + C2["m,u,v,f"] += alpha * +1.00000000 * H1["e,f"] * T2["m,u,v,e"]; + C2["n,v,m,e"] += alpha * +1.00000000 * H1["u,m"] * T2["n,v,w,e"] * Eta1["w,u"]; + C2["n,v,m,e"] += alpha * +1.00000000 * H1["u,m"] * T2["n,v,w,e"] * Gamma1["w,u"]; + C2["n,u,m,f"] += alpha * -1.00000000 * H1["e,m"] * T2["n,u,f,e"]; + C2["m,u,e,f"] += alpha * -0.50000000 * H1["m,n"] * T2["n,u,e,f"]; + C2["n,u,e,f"] += alpha * -0.50000000 * H1["u,m"] * T2["n,m,e,f"]; + C2["m,v,e,f"] += alpha * +0.50000000 * H1["m,u"] * T2["v,w,e,f"] * Eta1["u,w"]; + C2["m,v,e,f"] += alpha * +0.50000000 * H1["m,u"] * T2["v,w,e,f"] * Gamma1["u,w"]; + C2["m,u,e,f"] += alpha * -0.50000000 * H1["u,v"] * T2["m,w,e,f"] * Eta1["v,w"]; + C2["m,u,e,f"] += alpha * -0.50000000 * H1["u,v"] * T2["m,w,e,f"] * Gamma1["v,w"]; + C2["m,v,e,f"] += alpha * +1.00000000 * H1["u,e"] * T2["m,v,w,f"] * Eta1["w,u"]; + C2["m,v,e,f"] += alpha * +1.00000000 * H1["u,e"] * T2["m,v,w,f"] * Gamma1["w,u"]; + C2["m,u,f,g"] += alpha * -1.00000000 * H1["e,f"] * T2["m,u,g,e"]; + C2["m,c0,u,v"] += alpha * +0.50000000 * H1["m,n"] * T2["c0,n,u,v"]; + C2["m,n,v,w"] += alpha * -0.50000000 * H1["u,v"] * T2["m,n,w,x"] * Eta1["x,u"]; + C2["m,n,v,w"] += alpha * -0.50000000 * H1["u,v"] * T2["m,n,w,x"] * Gamma1["x,u"]; + C2["m,n,u,v"] += alpha * -0.50000000 * H1["e,u"] * T2["m,n,v,e"]; + C2["m,n,w,x"] += alpha * +0.50000000 * H1["m,u"] * T2["n,v,w,x"] * Eta1["u,v"]; + C2["m,n,w,x"] += alpha * +0.50000000 * H1["m,u"] * T2["n,v,w,x"] * Gamma1["u,v"]; + C2["n,c0,m,v"] += alpha * -0.50000000 * H1["u,m"] * T2["n,c0,v,w"] * Eta1["w,u"]; + C2["n,c0,m,v"] += alpha * -0.50000000 * H1["u,m"] * T2["n,c0,v,w"] * Gamma1["w,u"]; + C2["n,c0,m,u"] += alpha * -0.50000000 * H1["e,m"] * T2["n,c0,u,e"]; + C2["m,c0,u,e"] += alpha * +1.00000000 * H1["m,n"] * T2["c0,n,u,e"]; + C2["m,n,v,e"] += alpha * +0.50000000 * H1["u,v"] * T2["m,n,w,e"] * Eta1["w,u"]; + C2["m,n,v,e"] += alpha * +0.50000000 * H1["u,v"] * T2["m,n,w,e"] * Gamma1["w,u"]; + C2["m,n,u,f"] += alpha * -0.50000000 * H1["e,u"] * T2["m,n,f,e"]; + C2["m,n,w,e"] += alpha * +1.00000000 * H1["m,u"] * T2["n,v,w,e"] * Eta1["u,v"]; + C2["m,n,w,e"] += alpha * +1.00000000 * H1["m,u"] * T2["n,v,w,e"] * Gamma1["u,v"]; + C2["m,n,v,e"] += alpha * +0.50000000 * H1["u,e"] * T2["m,n,v,w"] * Eta1["w,u"]; + C2["m,n,v,e"] += alpha * +0.50000000 * H1["u,e"] * T2["m,n,v,w"] * Gamma1["w,u"]; + C2["m,n,u,f"] += alpha * +0.50000000 * H1["e,f"] * T2["m,n,u,e"]; + C2["n,c0,m,e"] += alpha * +0.50000000 * H1["u,m"] * T2["n,c0,v,e"] * Eta1["v,u"]; + C2["n,c0,m,e"] += alpha * +0.50000000 * H1["u,m"] * T2["n,c0,v,e"] * Gamma1["v,u"]; + C2["n,c0,m,f"] += alpha * -0.50000000 * H1["e,m"] * T2["n,c0,f,e"]; + C2["m,c0,e,f"] += alpha * +0.50000000 * H1["m,n"] * T2["c0,n,e,f"]; + C2["m,n,e,f"] += alpha * +0.50000000 * H1["m,u"] * T2["n,v,e,f"] * Eta1["u,v"]; + C2["m,n,e,f"] += alpha * +0.50000000 * H1["m,u"] * T2["n,v,e,f"] * Gamma1["u,v"]; + C2["m,n,e,f"] += alpha * +0.50000000 * H1["u,e"] * T2["m,n,v,f"] * Eta1["v,u"]; + C2["m,n,e,f"] += alpha * +0.50000000 * H1["u,e"] * T2["m,n,v,f"] * Gamma1["v,u"]; + C2["m,n,f,g"] += alpha * -0.50000000 * H1["e,f"] * T2["m,n,g,e"]; + C2["n,e,u,v"] += alpha * -0.50000000 * H1["e,m"] * T2["n,m,u,v"]; + C2["m,e,w,x"] += alpha * -0.50000000 * H1["e,u"] * T2["m,v,w,x"] * Eta1["u,v"]; + C2["m,e,w,x"] += alpha * -0.50000000 * H1["e,u"] * T2["m,v,w,x"] * Gamma1["u,v"]; + C2["n,e,u,f"] += alpha * -1.00000000 * H1["e,m"] * T2["n,m,u,f"]; + C2["m,e,w,f"] += alpha * -1.00000000 * H1["e,u"] * T2["m,v,w,f"] * Eta1["u,v"]; + C2["m,e,w,f"] += alpha * -1.00000000 * H1["e,u"] * T2["m,v,w,f"] * Gamma1["u,v"]; + C2["n,e,f,g"] += alpha * -0.50000000 * H1["e,m"] * T2["n,m,f,g"]; + C2["m,e,f,g"] += alpha * -0.50000000 * H1["e,u"] * T2["m,v,f,g"] * Eta1["u,v"]; + C2["m,e,f,g"] += alpha * -0.50000000 * H1["e,u"] * T2["m,v,f,g"] * Gamma1["u,v"]; - if (print_ > 2) { - outfile -> Printf("\n Time for H1_T2_C2 : %12.3f", timer.get()); - } + // if (print_ > 2) { + // outfile -> Printf("\n Time for H1_T2_C2 : %12.3f", timer.get()); + //} } -void MRDSRG_SO::H2_T1_C2(BlockedTensor& H2, BlockedTensor& T1, const double& alpha, BlockedTensor& C2) { - // 144 lines - local_timer timer; - C2["u,v,w,x"] += alpha * +0.50000000 * H2["u,v,m,w"] * T1["m,x"]; - C2["u,x,v,w"] += alpha * +0.50000000 * H2["u,e,v,w"] * T1["x,e"]; - C2["u,v,m,w"] += alpha * -0.50000000 * H2["u,v,m,n"] * T1["n,w"]; - C2["u,w,m,v"] += alpha * +1.00000000 * H2["u,e,m,v"] * T1["w,e"]; - C2["u,v,m,n"] += alpha * +0.50000000 * H2["u,e,m,n"] * T1["v,e"]; - C2["u,v,w,e"] += alpha * +0.50000000 * H2["u,v,m,w"] * T1["m,e"]; - C2["u,v,w,e"] += alpha * -0.50000000 * H2["u,v,m,e"] * T1["m,w"]; - C2["u,v,w,e"] += alpha * -0.50000000 * H2["u,v,w,x"] * T1["y,e"] * Eta1["x,y"]; - C2["u,v,w,e"] += alpha * -0.50000000 * H2["u,v,w,x"] * T1["y,e"] * Gamma1["x,y"]; - C2["u,w,v,f"] += alpha * +1.00000000 * H2["u,e,v,f"] * T1["w,e"]; - C2["u,v,m,e"] += alpha * -0.50000000 * H2["u,v,m,n"] * T1["n,e"]; - C2["u,v,m,e"] += alpha * -0.50000000 * H2["u,v,m,w"] * T1["x,e"] * Eta1["w,x"]; - C2["u,v,m,e"] += alpha * -0.50000000 * H2["u,v,m,w"] * T1["x,e"] * Gamma1["w,x"]; - C2["u,v,m,f"] += alpha * +1.00000000 * H2["u,e,m,f"] * T1["v,e"]; - C2["u,v,e,f"] += alpha * +0.50000000 * H2["u,v,m,e"] * T1["m,f"]; - C2["u,v,e,f"] += alpha * +0.50000000 * H2["u,v,w,e"] * T1["x,f"] * Eta1["w,x"]; - C2["u,v,e,f"] += alpha * +0.50000000 * H2["u,v,w,e"] * T1["x,f"] * Gamma1["w,x"]; - C2["u,v,f,g"] += alpha * +0.50000000 * H2["u,e,f,g"] * T1["v,e"]; - C2["u,e,v,w"] += alpha * +1.00000000 * H2["u,e,m,v"] * T1["m,w"]; - C2["w,e,u,v"] += alpha * -0.50000000 * H2["e,f,u,v"] * T1["w,f"]; - C2["u,e,m,v"] += alpha * -1.00000000 * H2["u,e,m,n"] * T1["n,v"]; - C2["v,e,m,u"] += alpha * -1.00000000 * H2["e,f,m,u"] * T1["v,f"]; - C2["u,e,m,n"] += alpha * -0.50000000 * H2["e,f,m,n"] * T1["u,f"]; - C2["u,e,v,f"] += alpha * +1.00000000 * H2["u,e,m,v"] * T1["m,f"]; - C2["u,e,v,f"] += alpha * -1.00000000 * H2["u,e,m,f"] * T1["m,v"]; - C2["u,e,v,f"] += alpha * -1.00000000 * H2["u,e,v,w"] * T1["x,f"] * Eta1["w,x"]; - C2["u,e,v,f"] += alpha * -1.00000000 * H2["u,e,v,w"] * T1["x,f"] * Gamma1["w,x"]; - C2["v,e,u,g"] += alpha * -1.00000000 * H2["e,f,u,g"] * T1["v,f"]; - C2["u,e,m,f"] += alpha * -1.00000000 * H2["u,e,m,n"] * T1["n,f"]; - C2["u,e,m,f"] += alpha * -1.00000000 * H2["u,e,m,v"] * T1["w,f"] * Eta1["v,w"]; - C2["u,e,m,f"] += alpha * -1.00000000 * H2["u,e,m,v"] * T1["w,f"] * Gamma1["v,w"]; - C2["u,e,m,g"] += alpha * -1.00000000 * H2["e,f,m,g"] * T1["u,f"]; - C2["u,e,f,g"] += alpha * +1.00000000 * H2["u,e,m,f"] * T1["m,g"]; - C2["u,e,f,g"] += alpha * +1.00000000 * H2["u,e,v,f"] * T1["w,g"] * Eta1["v,w"]; - C2["u,e,f,g"] += alpha * +1.00000000 * H2["u,e,v,f"] * T1["w,g"] * Gamma1["v,w"]; - C2["u,e,g,h"] += alpha * -0.50000000 * H2["e,f,g,h"] * T1["u,f"]; - C2["m,u,v,w"] += alpha * +1.00000000 * H2["m,u,n,v"] * T1["n,w"]; - C2["m,w,u,v"] += alpha * +0.50000000 * H2["m,e,u,v"] * T1["w,e"]; - C2["m,u,w,x"] += alpha * -0.50000000 * H2["u,v,w,x"] * T1["m,y"] * Eta1["y,v"]; - C2["m,u,w,x"] += alpha * -0.50000000 * H2["u,v,w,x"] * T1["m,y"] * Gamma1["y,v"]; - C2["m,u,v,w"] += alpha * -0.50000000 * H2["u,e,v,w"] * T1["m,e"]; - C2["m,u,n,v"] += alpha * -1.00000000 * H2["m,u,n,c0"] * T1["c0,v"]; - C2["m,v,n,u"] += alpha * +1.00000000 * H2["m,e,n,u"] * T1["v,e"]; - C2["n,u,m,w"] += alpha * -1.00000000 * H2["u,v,m,w"] * T1["n,x"] * Eta1["x,v"]; - C2["n,u,m,w"] += alpha * -1.00000000 * H2["u,v,m,w"] * T1["n,x"] * Gamma1["x,v"]; - C2["n,u,m,v"] += alpha * -1.00000000 * H2["u,e,m,v"] * T1["n,e"]; - C2["m,u,n,c0"] += alpha * +0.50000000 * H2["m,e,n,c0"] * T1["u,e"]; - C2["c0,u,m,n"] += alpha * -0.50000000 * H2["u,v,m,n"] * T1["c0,w"] * Eta1["w,v"]; - C2["c0,u,m,n"] += alpha * -0.50000000 * H2["u,v,m,n"] * T1["c0,w"] * Gamma1["w,v"]; - C2["c0,u,m,n"] += alpha * -0.50000000 * H2["u,e,m,n"] * T1["c0,e"]; - C2["m,u,v,e"] += alpha * +1.00000000 * H2["m,u,n,v"] * T1["n,e"]; - C2["m,u,v,e"] += alpha * -1.00000000 * H2["m,u,n,e"] * T1["n,v"]; - C2["m,u,v,e"] += alpha * -1.00000000 * H2["m,u,v,w"] * T1["x,e"] * Eta1["w,x"]; - C2["m,u,v,e"] += alpha * -1.00000000 * H2["m,u,v,w"] * T1["x,e"] * Gamma1["w,x"]; - C2["m,v,u,f"] += alpha * +1.00000000 * H2["m,e,u,f"] * T1["v,e"]; - C2["m,u,w,e"] += alpha * -1.00000000 * H2["u,v,w,e"] * T1["m,x"] * Eta1["x,v"]; - C2["m,u,w,e"] += alpha * -1.00000000 * H2["u,v,w,e"] * T1["m,x"] * Gamma1["x,v"]; - C2["m,u,v,f"] += alpha * -1.00000000 * H2["u,e,v,f"] * T1["m,e"]; - C2["m,u,n,e"] += alpha * -1.00000000 * H2["m,u,n,c0"] * T1["c0,e"]; - C2["m,u,n,e"] += alpha * -1.00000000 * H2["m,u,n,v"] * T1["w,e"] * Eta1["v,w"]; - C2["m,u,n,e"] += alpha * -1.00000000 * H2["m,u,n,v"] * T1["w,e"] * Gamma1["v,w"]; - C2["m,u,n,f"] += alpha * +1.00000000 * H2["m,e,n,f"] * T1["u,e"]; - C2["n,u,m,e"] += alpha * -1.00000000 * H2["u,v,m,e"] * T1["n,w"] * Eta1["w,v"]; - C2["n,u,m,e"] += alpha * -1.00000000 * H2["u,v,m,e"] * T1["n,w"] * Gamma1["w,v"]; - C2["n,u,m,f"] += alpha * -1.00000000 * H2["u,e,m,f"] * T1["n,e"]; - C2["m,u,e,f"] += alpha * +1.00000000 * H2["m,u,n,e"] * T1["n,f"]; - C2["m,u,e,f"] += alpha * +1.00000000 * H2["m,u,v,e"] * T1["w,f"] * Eta1["v,w"]; - C2["m,u,e,f"] += alpha * +1.00000000 * H2["m,u,v,e"] * T1["w,f"] * Gamma1["v,w"]; - C2["m,u,f,g"] += alpha * +0.50000000 * H2["m,e,f,g"] * T1["u,e"]; - C2["m,u,e,f"] += alpha * -0.50000000 * H2["u,v,e,f"] * T1["m,w"] * Eta1["w,v"]; - C2["m,u,e,f"] += alpha * -0.50000000 * H2["u,v,e,f"] * T1["m,w"] * Gamma1["w,v"]; - C2["m,u,f,g"] += alpha * -0.50000000 * H2["u,e,f,g"] * T1["m,e"]; - C2["m,n,u,v"] += alpha * +0.50000000 * H2["m,n,c0,u"] * T1["c0,v"]; - C2["m,n,v,w"] += alpha * +0.50000000 * H2["m,u,v,w"] * T1["n,x"] * Eta1["x,u"]; - C2["m,n,v,w"] += alpha * +0.50000000 * H2["m,u,v,w"] * T1["n,x"] * Gamma1["x,u"]; - C2["m,n,u,v"] += alpha * +0.50000000 * H2["m,e,u,v"] * T1["n,e"]; - C2["m,n,c0,u"] += alpha * -0.50000000 * H2["m,n,c0,c1"] * T1["c1,u"]; - C2["m,c0,n,v"] += alpha * +1.00000000 * H2["m,u,n,v"] * T1["c0,w"] * Eta1["w,u"]; - C2["m,c0,n,v"] += alpha * +1.00000000 * H2["m,u,n,v"] * T1["c0,w"] * Gamma1["w,u"]; - C2["m,c0,n,u"] += alpha * +1.00000000 * H2["m,e,n,u"] * T1["c0,e"]; - C2["m,c1,n,c0"] += alpha * +0.50000000 * H2["m,u,n,c0"] * T1["c1,v"] * Eta1["v,u"]; - C2["m,c1,n,c0"] += alpha * +0.50000000 * H2["m,u,n,c0"] * T1["c1,v"] * Gamma1["v,u"]; - C2["m,c1,n,c0"] += alpha * +0.50000000 * H2["m,e,n,c0"] * T1["c1,e"]; - C2["m,n,u,e"] += alpha * +0.50000000 * H2["m,n,c0,u"] * T1["c0,e"]; - C2["m,n,u,e"] += alpha * -0.50000000 * H2["m,n,c0,e"] * T1["c0,u"]; - C2["m,n,u,e"] += alpha * -0.50000000 * H2["m,n,u,v"] * T1["w,e"] * Eta1["v,w"]; - C2["m,n,u,e"] += alpha * -0.50000000 * H2["m,n,u,v"] * T1["w,e"] * Gamma1["v,w"]; - C2["m,n,v,e"] += alpha * +1.00000000 * H2["m,u,v,e"] * T1["n,w"] * Eta1["w,u"]; - C2["m,n,v,e"] += alpha * +1.00000000 * H2["m,u,v,e"] * T1["n,w"] * Gamma1["w,u"]; - C2["m,n,u,f"] += alpha * +1.00000000 * H2["m,e,u,f"] * T1["n,e"]; - C2["m,n,c0,e"] += alpha * -0.50000000 * H2["m,n,c0,c1"] * T1["c1,e"]; - C2["m,n,c0,e"] += alpha * -0.50000000 * H2["m,n,c0,u"] * T1["v,e"] * Eta1["u,v"]; - C2["m,n,c0,e"] += alpha * -0.50000000 * H2["m,n,c0,u"] * T1["v,e"] * Gamma1["u,v"]; - C2["m,c0,n,e"] += alpha * +1.00000000 * H2["m,u,n,e"] * T1["c0,v"] * Eta1["v,u"]; - C2["m,c0,n,e"] += alpha * +1.00000000 * H2["m,u,n,e"] * T1["c0,v"] * Gamma1["v,u"]; - C2["m,c0,n,f"] += alpha * +1.00000000 * H2["m,e,n,f"] * T1["c0,e"]; - C2["m,n,e,f"] += alpha * +0.50000000 * H2["m,n,c0,e"] * T1["c0,f"]; - C2["m,n,e,f"] += alpha * +0.50000000 * H2["m,n,u,e"] * T1["v,f"] * Eta1["u,v"]; - C2["m,n,e,f"] += alpha * +0.50000000 * H2["m,n,u,e"] * T1["v,f"] * Gamma1["u,v"]; - C2["m,n,e,f"] += alpha * +0.50000000 * H2["m,u,e,f"] * T1["n,v"] * Eta1["v,u"]; - C2["m,n,e,f"] += alpha * +0.50000000 * H2["m,u,e,f"] * T1["n,v"] * Gamma1["v,u"]; - C2["m,n,f,g"] += alpha * +0.50000000 * H2["m,e,f,g"] * T1["n,e"]; - C2["m,e,u,v"] += alpha * +1.00000000 * H2["m,e,n,u"] * T1["n,v"]; - C2["m,e,v,w"] += alpha * +0.50000000 * H2["u,e,v,w"] * T1["m,x"] * Eta1["x,u"]; - C2["m,e,v,w"] += alpha * +0.50000000 * H2["u,e,v,w"] * T1["m,x"] * Gamma1["x,u"]; - C2["m,e,u,v"] += alpha * -0.50000000 * H2["e,f,u,v"] * T1["m,f"]; - C2["m,e,n,u"] += alpha * -1.00000000 * H2["m,e,n,c0"] * T1["c0,u"]; - C2["n,e,m,v"] += alpha * +1.00000000 * H2["u,e,m,v"] * T1["n,w"] * Eta1["w,u"]; - C2["n,e,m,v"] += alpha * +1.00000000 * H2["u,e,m,v"] * T1["n,w"] * Gamma1["w,u"]; - C2["n,e,m,u"] += alpha * -1.00000000 * H2["e,f,m,u"] * T1["n,f"]; - C2["c0,e,m,n"] += alpha * +0.50000000 * H2["u,e,m,n"] * T1["c0,v"] * Eta1["v,u"]; - C2["c0,e,m,n"] += alpha * +0.50000000 * H2["u,e,m,n"] * T1["c0,v"] * Gamma1["v,u"]; - C2["c0,e,m,n"] += alpha * -0.50000000 * H2["e,f,m,n"] * T1["c0,f"]; - C2["m,e,u,f"] += alpha * +1.00000000 * H2["m,e,n,u"] * T1["n,f"]; - C2["m,e,u,f"] += alpha * -1.00000000 * H2["m,e,n,f"] * T1["n,u"]; - C2["m,e,u,f"] += alpha * -1.00000000 * H2["m,e,u,v"] * T1["w,f"] * Eta1["v,w"]; - C2["m,e,u,f"] += alpha * -1.00000000 * H2["m,e,u,v"] * T1["w,f"] * Gamma1["v,w"]; - C2["m,e,v,f"] += alpha * +1.00000000 * H2["u,e,v,f"] * T1["m,w"] * Eta1["w,u"]; - C2["m,e,v,f"] += alpha * +1.00000000 * H2["u,e,v,f"] * T1["m,w"] * Gamma1["w,u"]; - C2["m,e,u,g"] += alpha * -1.00000000 * H2["e,f,u,g"] * T1["m,f"]; - C2["m,e,n,f"] += alpha * -1.00000000 * H2["m,e,n,c0"] * T1["c0,f"]; - C2["m,e,n,f"] += alpha * -1.00000000 * H2["m,e,n,u"] * T1["v,f"] * Eta1["u,v"]; - C2["m,e,n,f"] += alpha * -1.00000000 * H2["m,e,n,u"] * T1["v,f"] * Gamma1["u,v"]; - C2["n,e,m,f"] += alpha * +1.00000000 * H2["u,e,m,f"] * T1["n,v"] * Eta1["v,u"]; - C2["n,e,m,f"] += alpha * +1.00000000 * H2["u,e,m,f"] * T1["n,v"] * Gamma1["v,u"]; - C2["n,e,m,g"] += alpha * -1.00000000 * H2["e,f,m,g"] * T1["n,f"]; - C2["m,e,f,g"] += alpha * +1.00000000 * H2["m,e,n,f"] * T1["n,g"]; - C2["m,e,f,g"] += alpha * +1.00000000 * H2["m,e,u,f"] * T1["v,g"] * Eta1["u,v"]; - C2["m,e,f,g"] += alpha * +1.00000000 * H2["m,e,u,f"] * T1["v,g"] * Gamma1["u,v"]; - C2["m,e,f,g"] += alpha * +0.50000000 * H2["u,e,f,g"] * T1["m,v"] * Eta1["v,u"]; - C2["m,e,f,g"] += alpha * +0.50000000 * H2["u,e,f,g"] * T1["m,v"] * Gamma1["v,u"]; - C2["m,e,g,h"] += alpha * -0.50000000 * H2["e,f,g,h"] * T1["m,f"]; - C2["e,f,u,v"] += alpha * +0.50000000 * H2["e,f,m,u"] * T1["m,v"]; - C2["e,f,m,u"] += alpha * -0.50000000 * H2["e,f,m,n"] * T1["n,u"]; - C2["e,f,u,g"] += alpha * +0.50000000 * H2["e,f,m,u"] * T1["m,g"]; - C2["e,f,u,g"] += alpha * -0.50000000 * H2["e,f,m,g"] * T1["m,u"]; - C2["e,f,u,g"] += alpha * -0.50000000 * H2["e,f,u,v"] * T1["w,g"] * Eta1["v,w"]; - C2["e,f,u,g"] += alpha * -0.50000000 * H2["e,f,u,v"] * T1["w,g"] * Gamma1["v,w"]; - C2["e,f,m,g"] += alpha * -0.50000000 * H2["e,f,m,n"] * T1["n,g"]; - C2["e,f,m,g"] += alpha * -0.50000000 * H2["e,f,m,u"] * T1["v,g"] * Eta1["u,v"]; - C2["e,f,m,g"] += alpha * -0.50000000 * H2["e,f,m,u"] * T1["v,g"] * Gamma1["u,v"]; - C2["e,f,g,h"] += alpha * +0.50000000 * H2["e,f,m,g"] * T1["m,h"]; - C2["e,f,g,h"] += alpha * +0.50000000 * H2["e,f,u,g"] * T1["v,h"] * Eta1["u,v"]; - C2["e,f,g,h"] += alpha * +0.50000000 * H2["e,f,u,g"] * T1["v,h"] * Gamma1["u,v"]; +void MRDSRG_SO::H2_T1_C2(BlockedTensor& H2, BlockedTensor& T1, const double& alpha, + BlockedTensor& C2) { + // 144 lines + local_timer timer; + C2["u,v,w,x"] += alpha * +0.50000000 * H2["u,v,m,w"] * T1["m,x"]; + C2["u,x,v,w"] += alpha * +0.50000000 * H2["u,e,v,w"] * T1["x,e"]; + C2["u,v,m,w"] += alpha * -0.50000000 * H2["u,v,m,n"] * T1["n,w"]; + C2["u,w,m,v"] += alpha * +1.00000000 * H2["u,e,m,v"] * T1["w,e"]; + C2["u,v,m,n"] += alpha * +0.50000000 * H2["u,e,m,n"] * T1["v,e"]; + C2["u,v,w,e"] += alpha * +0.50000000 * H2["u,v,m,w"] * T1["m,e"]; + C2["u,v,w,e"] += alpha * -0.50000000 * H2["u,v,m,e"] * T1["m,w"]; + C2["u,v,w,e"] += alpha * -0.50000000 * H2["u,v,w,x"] * T1["y,e"] * Eta1["x,y"]; + C2["u,v,w,e"] += alpha * -0.50000000 * H2["u,v,w,x"] * T1["y,e"] * Gamma1["x,y"]; + C2["u,w,v,f"] += alpha * +1.00000000 * H2["u,e,v,f"] * T1["w,e"]; + C2["u,v,m,e"] += alpha * -0.50000000 * H2["u,v,m,n"] * T1["n,e"]; + C2["u,v,m,e"] += alpha * -0.50000000 * H2["u,v,m,w"] * T1["x,e"] * Eta1["w,x"]; + C2["u,v,m,e"] += alpha * -0.50000000 * H2["u,v,m,w"] * T1["x,e"] * Gamma1["w,x"]; + C2["u,v,m,f"] += alpha * +1.00000000 * H2["u,e,m,f"] * T1["v,e"]; + C2["u,v,e,f"] += alpha * +0.50000000 * H2["u,v,m,e"] * T1["m,f"]; + C2["u,v,e,f"] += alpha * +0.50000000 * H2["u,v,w,e"] * T1["x,f"] * Eta1["w,x"]; + C2["u,v,e,f"] += alpha * +0.50000000 * H2["u,v,w,e"] * T1["x,f"] * Gamma1["w,x"]; + C2["u,v,f,g"] += alpha * +0.50000000 * H2["u,e,f,g"] * T1["v,e"]; + C2["u,e,v,w"] += alpha * +1.00000000 * H2["u,e,m,v"] * T1["m,w"]; + C2["w,e,u,v"] += alpha * -0.50000000 * H2["e,f,u,v"] * T1["w,f"]; + C2["u,e,m,v"] += alpha * -1.00000000 * H2["u,e,m,n"] * T1["n,v"]; + C2["v,e,m,u"] += alpha * -1.00000000 * H2["e,f,m,u"] * T1["v,f"]; + C2["u,e,m,n"] += alpha * -0.50000000 * H2["e,f,m,n"] * T1["u,f"]; + C2["u,e,v,f"] += alpha * +1.00000000 * H2["u,e,m,v"] * T1["m,f"]; + C2["u,e,v,f"] += alpha * -1.00000000 * H2["u,e,m,f"] * T1["m,v"]; + C2["u,e,v,f"] += alpha * -1.00000000 * H2["u,e,v,w"] * T1["x,f"] * Eta1["w,x"]; + C2["u,e,v,f"] += alpha * -1.00000000 * H2["u,e,v,w"] * T1["x,f"] * Gamma1["w,x"]; + C2["v,e,u,g"] += alpha * -1.00000000 * H2["e,f,u,g"] * T1["v,f"]; + C2["u,e,m,f"] += alpha * -1.00000000 * H2["u,e,m,n"] * T1["n,f"]; + C2["u,e,m,f"] += alpha * -1.00000000 * H2["u,e,m,v"] * T1["w,f"] * Eta1["v,w"]; + C2["u,e,m,f"] += alpha * -1.00000000 * H2["u,e,m,v"] * T1["w,f"] * Gamma1["v,w"]; + C2["u,e,m,g"] += alpha * -1.00000000 * H2["e,f,m,g"] * T1["u,f"]; + C2["u,e,f,g"] += alpha * +1.00000000 * H2["u,e,m,f"] * T1["m,g"]; + C2["u,e,f,g"] += alpha * +1.00000000 * H2["u,e,v,f"] * T1["w,g"] * Eta1["v,w"]; + C2["u,e,f,g"] += alpha * +1.00000000 * H2["u,e,v,f"] * T1["w,g"] * Gamma1["v,w"]; + C2["u,e,g,h"] += alpha * -0.50000000 * H2["e,f,g,h"] * T1["u,f"]; + C2["m,u,v,w"] += alpha * +1.00000000 * H2["m,u,n,v"] * T1["n,w"]; + C2["m,w,u,v"] += alpha * +0.50000000 * H2["m,e,u,v"] * T1["w,e"]; + C2["m,u,w,x"] += alpha * -0.50000000 * H2["u,v,w,x"] * T1["m,y"] * Eta1["y,v"]; + C2["m,u,w,x"] += alpha * -0.50000000 * H2["u,v,w,x"] * T1["m,y"] * Gamma1["y,v"]; + C2["m,u,v,w"] += alpha * -0.50000000 * H2["u,e,v,w"] * T1["m,e"]; + C2["m,u,n,v"] += alpha * -1.00000000 * H2["m,u,n,c0"] * T1["c0,v"]; + C2["m,v,n,u"] += alpha * +1.00000000 * H2["m,e,n,u"] * T1["v,e"]; + C2["n,u,m,w"] += alpha * -1.00000000 * H2["u,v,m,w"] * T1["n,x"] * Eta1["x,v"]; + C2["n,u,m,w"] += alpha * -1.00000000 * H2["u,v,m,w"] * T1["n,x"] * Gamma1["x,v"]; + C2["n,u,m,v"] += alpha * -1.00000000 * H2["u,e,m,v"] * T1["n,e"]; + C2["m,u,n,c0"] += alpha * +0.50000000 * H2["m,e,n,c0"] * T1["u,e"]; + C2["c0,u,m,n"] += alpha * -0.50000000 * H2["u,v,m,n"] * T1["c0,w"] * Eta1["w,v"]; + C2["c0,u,m,n"] += alpha * -0.50000000 * H2["u,v,m,n"] * T1["c0,w"] * Gamma1["w,v"]; + C2["c0,u,m,n"] += alpha * -0.50000000 * H2["u,e,m,n"] * T1["c0,e"]; + C2["m,u,v,e"] += alpha * +1.00000000 * H2["m,u,n,v"] * T1["n,e"]; + C2["m,u,v,e"] += alpha * -1.00000000 * H2["m,u,n,e"] * T1["n,v"]; + C2["m,u,v,e"] += alpha * -1.00000000 * H2["m,u,v,w"] * T1["x,e"] * Eta1["w,x"]; + C2["m,u,v,e"] += alpha * -1.00000000 * H2["m,u,v,w"] * T1["x,e"] * Gamma1["w,x"]; + C2["m,v,u,f"] += alpha * +1.00000000 * H2["m,e,u,f"] * T1["v,e"]; + C2["m,u,w,e"] += alpha * -1.00000000 * H2["u,v,w,e"] * T1["m,x"] * Eta1["x,v"]; + C2["m,u,w,e"] += alpha * -1.00000000 * H2["u,v,w,e"] * T1["m,x"] * Gamma1["x,v"]; + C2["m,u,v,f"] += alpha * -1.00000000 * H2["u,e,v,f"] * T1["m,e"]; + C2["m,u,n,e"] += alpha * -1.00000000 * H2["m,u,n,c0"] * T1["c0,e"]; + C2["m,u,n,e"] += alpha * -1.00000000 * H2["m,u,n,v"] * T1["w,e"] * Eta1["v,w"]; + C2["m,u,n,e"] += alpha * -1.00000000 * H2["m,u,n,v"] * T1["w,e"] * Gamma1["v,w"]; + C2["m,u,n,f"] += alpha * +1.00000000 * H2["m,e,n,f"] * T1["u,e"]; + C2["n,u,m,e"] += alpha * -1.00000000 * H2["u,v,m,e"] * T1["n,w"] * Eta1["w,v"]; + C2["n,u,m,e"] += alpha * -1.00000000 * H2["u,v,m,e"] * T1["n,w"] * Gamma1["w,v"]; + C2["n,u,m,f"] += alpha * -1.00000000 * H2["u,e,m,f"] * T1["n,e"]; + C2["m,u,e,f"] += alpha * +1.00000000 * H2["m,u,n,e"] * T1["n,f"]; + C2["m,u,e,f"] += alpha * +1.00000000 * H2["m,u,v,e"] * T1["w,f"] * Eta1["v,w"]; + C2["m,u,e,f"] += alpha * +1.00000000 * H2["m,u,v,e"] * T1["w,f"] * Gamma1["v,w"]; + C2["m,u,f,g"] += alpha * +0.50000000 * H2["m,e,f,g"] * T1["u,e"]; + C2["m,u,e,f"] += alpha * -0.50000000 * H2["u,v,e,f"] * T1["m,w"] * Eta1["w,v"]; + C2["m,u,e,f"] += alpha * -0.50000000 * H2["u,v,e,f"] * T1["m,w"] * Gamma1["w,v"]; + C2["m,u,f,g"] += alpha * -0.50000000 * H2["u,e,f,g"] * T1["m,e"]; + C2["m,n,u,v"] += alpha * +0.50000000 * H2["m,n,c0,u"] * T1["c0,v"]; + C2["m,n,v,w"] += alpha * +0.50000000 * H2["m,u,v,w"] * T1["n,x"] * Eta1["x,u"]; + C2["m,n,v,w"] += alpha * +0.50000000 * H2["m,u,v,w"] * T1["n,x"] * Gamma1["x,u"]; + C2["m,n,u,v"] += alpha * +0.50000000 * H2["m,e,u,v"] * T1["n,e"]; + C2["m,n,c0,u"] += alpha * -0.50000000 * H2["m,n,c0,c1"] * T1["c1,u"]; + C2["m,c0,n,v"] += alpha * +1.00000000 * H2["m,u,n,v"] * T1["c0,w"] * Eta1["w,u"]; + C2["m,c0,n,v"] += alpha * +1.00000000 * H2["m,u,n,v"] * T1["c0,w"] * Gamma1["w,u"]; + C2["m,c0,n,u"] += alpha * +1.00000000 * H2["m,e,n,u"] * T1["c0,e"]; + C2["m,c1,n,c0"] += alpha * +0.50000000 * H2["m,u,n,c0"] * T1["c1,v"] * Eta1["v,u"]; + C2["m,c1,n,c0"] += alpha * +0.50000000 * H2["m,u,n,c0"] * T1["c1,v"] * Gamma1["v,u"]; + C2["m,c1,n,c0"] += alpha * +0.50000000 * H2["m,e,n,c0"] * T1["c1,e"]; + C2["m,n,u,e"] += alpha * +0.50000000 * H2["m,n,c0,u"] * T1["c0,e"]; + C2["m,n,u,e"] += alpha * -0.50000000 * H2["m,n,c0,e"] * T1["c0,u"]; + C2["m,n,u,e"] += alpha * -0.50000000 * H2["m,n,u,v"] * T1["w,e"] * Eta1["v,w"]; + C2["m,n,u,e"] += alpha * -0.50000000 * H2["m,n,u,v"] * T1["w,e"] * Gamma1["v,w"]; + C2["m,n,v,e"] += alpha * +1.00000000 * H2["m,u,v,e"] * T1["n,w"] * Eta1["w,u"]; + C2["m,n,v,e"] += alpha * +1.00000000 * H2["m,u,v,e"] * T1["n,w"] * Gamma1["w,u"]; + C2["m,n,u,f"] += alpha * +1.00000000 * H2["m,e,u,f"] * T1["n,e"]; + C2["m,n,c0,e"] += alpha * -0.50000000 * H2["m,n,c0,c1"] * T1["c1,e"]; + C2["m,n,c0,e"] += alpha * -0.50000000 * H2["m,n,c0,u"] * T1["v,e"] * Eta1["u,v"]; + C2["m,n,c0,e"] += alpha * -0.50000000 * H2["m,n,c0,u"] * T1["v,e"] * Gamma1["u,v"]; + C2["m,c0,n,e"] += alpha * +1.00000000 * H2["m,u,n,e"] * T1["c0,v"] * Eta1["v,u"]; + C2["m,c0,n,e"] += alpha * +1.00000000 * H2["m,u,n,e"] * T1["c0,v"] * Gamma1["v,u"]; + C2["m,c0,n,f"] += alpha * +1.00000000 * H2["m,e,n,f"] * T1["c0,e"]; + C2["m,n,e,f"] += alpha * +0.50000000 * H2["m,n,c0,e"] * T1["c0,f"]; + C2["m,n,e,f"] += alpha * +0.50000000 * H2["m,n,u,e"] * T1["v,f"] * Eta1["u,v"]; + C2["m,n,e,f"] += alpha * +0.50000000 * H2["m,n,u,e"] * T1["v,f"] * Gamma1["u,v"]; + C2["m,n,e,f"] += alpha * +0.50000000 * H2["m,u,e,f"] * T1["n,v"] * Eta1["v,u"]; + C2["m,n,e,f"] += alpha * +0.50000000 * H2["m,u,e,f"] * T1["n,v"] * Gamma1["v,u"]; + C2["m,n,f,g"] += alpha * +0.50000000 * H2["m,e,f,g"] * T1["n,e"]; + C2["m,e,u,v"] += alpha * +1.00000000 * H2["m,e,n,u"] * T1["n,v"]; + C2["m,e,v,w"] += alpha * +0.50000000 * H2["u,e,v,w"] * T1["m,x"] * Eta1["x,u"]; + C2["m,e,v,w"] += alpha * +0.50000000 * H2["u,e,v,w"] * T1["m,x"] * Gamma1["x,u"]; + C2["m,e,u,v"] += alpha * -0.50000000 * H2["e,f,u,v"] * T1["m,f"]; + C2["m,e,n,u"] += alpha * -1.00000000 * H2["m,e,n,c0"] * T1["c0,u"]; + C2["n,e,m,v"] += alpha * +1.00000000 * H2["u,e,m,v"] * T1["n,w"] * Eta1["w,u"]; + C2["n,e,m,v"] += alpha * +1.00000000 * H2["u,e,m,v"] * T1["n,w"] * Gamma1["w,u"]; + C2["n,e,m,u"] += alpha * -1.00000000 * H2["e,f,m,u"] * T1["n,f"]; + C2["c0,e,m,n"] += alpha * +0.50000000 * H2["u,e,m,n"] * T1["c0,v"] * Eta1["v,u"]; + C2["c0,e,m,n"] += alpha * +0.50000000 * H2["u,e,m,n"] * T1["c0,v"] * Gamma1["v,u"]; + C2["c0,e,m,n"] += alpha * -0.50000000 * H2["e,f,m,n"] * T1["c0,f"]; + C2["m,e,u,f"] += alpha * +1.00000000 * H2["m,e,n,u"] * T1["n,f"]; + C2["m,e,u,f"] += alpha * -1.00000000 * H2["m,e,n,f"] * T1["n,u"]; + C2["m,e,u,f"] += alpha * -1.00000000 * H2["m,e,u,v"] * T1["w,f"] * Eta1["v,w"]; + C2["m,e,u,f"] += alpha * -1.00000000 * H2["m,e,u,v"] * T1["w,f"] * Gamma1["v,w"]; + C2["m,e,v,f"] += alpha * +1.00000000 * H2["u,e,v,f"] * T1["m,w"] * Eta1["w,u"]; + C2["m,e,v,f"] += alpha * +1.00000000 * H2["u,e,v,f"] * T1["m,w"] * Gamma1["w,u"]; + C2["m,e,u,g"] += alpha * -1.00000000 * H2["e,f,u,g"] * T1["m,f"]; + C2["m,e,n,f"] += alpha * -1.00000000 * H2["m,e,n,c0"] * T1["c0,f"]; + C2["m,e,n,f"] += alpha * -1.00000000 * H2["m,e,n,u"] * T1["v,f"] * Eta1["u,v"]; + C2["m,e,n,f"] += alpha * -1.00000000 * H2["m,e,n,u"] * T1["v,f"] * Gamma1["u,v"]; + C2["n,e,m,f"] += alpha * +1.00000000 * H2["u,e,m,f"] * T1["n,v"] * Eta1["v,u"]; + C2["n,e,m,f"] += alpha * +1.00000000 * H2["u,e,m,f"] * T1["n,v"] * Gamma1["v,u"]; + C2["n,e,m,g"] += alpha * -1.00000000 * H2["e,f,m,g"] * T1["n,f"]; + C2["m,e,f,g"] += alpha * +1.00000000 * H2["m,e,n,f"] * T1["n,g"]; + C2["m,e,f,g"] += alpha * +1.00000000 * H2["m,e,u,f"] * T1["v,g"] * Eta1["u,v"]; + C2["m,e,f,g"] += alpha * +1.00000000 * H2["m,e,u,f"] * T1["v,g"] * Gamma1["u,v"]; + C2["m,e,f,g"] += alpha * +0.50000000 * H2["u,e,f,g"] * T1["m,v"] * Eta1["v,u"]; + C2["m,e,f,g"] += alpha * +0.50000000 * H2["u,e,f,g"] * T1["m,v"] * Gamma1["v,u"]; + C2["m,e,g,h"] += alpha * -0.50000000 * H2["e,f,g,h"] * T1["m,f"]; + C2["e,f,u,v"] += alpha * +0.50000000 * H2["e,f,m,u"] * T1["m,v"]; + C2["e,f,m,u"] += alpha * -0.50000000 * H2["e,f,m,n"] * T1["n,u"]; + C2["e,f,u,g"] += alpha * +0.50000000 * H2["e,f,m,u"] * T1["m,g"]; + C2["e,f,u,g"] += alpha * -0.50000000 * H2["e,f,m,g"] * T1["m,u"]; + C2["e,f,u,g"] += alpha * -0.50000000 * H2["e,f,u,v"] * T1["w,g"] * Eta1["v,w"]; + C2["e,f,u,g"] += alpha * -0.50000000 * H2["e,f,u,v"] * T1["w,g"] * Gamma1["v,w"]; + C2["e,f,m,g"] += alpha * -0.50000000 * H2["e,f,m,n"] * T1["n,g"]; + C2["e,f,m,g"] += alpha * -0.50000000 * H2["e,f,m,u"] * T1["v,g"] * Eta1["u,v"]; + C2["e,f,m,g"] += alpha * -0.50000000 * H2["e,f,m,u"] * T1["v,g"] * Gamma1["u,v"]; + C2["e,f,g,h"] += alpha * +0.50000000 * H2["e,f,m,g"] * T1["m,h"]; + C2["e,f,g,h"] += alpha * +0.50000000 * H2["e,f,u,g"] * T1["v,h"] * Eta1["u,v"]; + C2["e,f,g,h"] += alpha * +0.50000000 * H2["e,f,u,g"] * T1["v,h"] * Gamma1["u,v"]; - if (print_ > 2) { - outfile -> Printf("\n Time for H2_T1_C2 : %12.3f", timer.get()); - } + // if (print_ > 2) { + // outfile -> Printf("\n Time for H2_T1_C2 : %12.3f", timer.get()); + //} } -void MRDSRG_SO::H2_T2_C2(BlockedTensor& H2, BlockedTensor& T2, const double& alpha, BlockedTensor& C2) { - // 282 lines - local_timer timer; - C2["u,v,w,x"] += alpha * +0.12500000 * H2["u,v,m,n"] * T2["m,n,w,x"]; - C2["u,x,w,y"] += alpha * +1.00000000 * H2["u,v,m,w"] * T2["m,x,y,z"] * Eta1["z,v"]; - C2["u,w,v,x"] += alpha * +1.00000000 * H2["u,e,m,v"] * T2["m,w,x,e"]; - C2["u,v,y,z"] += alpha * +0.25000000 * H2["u,v,m,w"] * T2["m,x,y,z"] * Gamma1["w,x"]; - C2["x,y,v,w"] += alpha * +0.25000000 * H2["u,e,v,w"] * T2["x,y,z,e"] * Eta1["z,u"]; - C2["w,x,u,v"] += alpha * +0.12500000 * H2["e,f,u,v"] * T2["w,x,e,f"]; - C2["u,x,v,z"] += alpha * +1.00000000 * H2["u,e,v,w"] * T2["x,y,z,e"] * Gamma1["w,y"]; - C2["u,w,m,x"] += alpha * -1.00000000 * H2["u,v,m,n"] * T2["n,w,x,y"] * Eta1["y,v"]; - C2["u,v,m,w"] += alpha * -1.00000000 * H2["u,e,m,n"] * T2["n,v,w,e"]; - C2["w,x,m,v"] += alpha * +0.50000000 * H2["u,e,m,v"] * T2["w,x,y,e"] * Eta1["y,u"]; - C2["v,w,m,u"] += alpha * +0.25000000 * H2["e,f,m,u"] * T2["v,w,e,f"]; - C2["u,w,m,y"] += alpha * +1.00000000 * H2["u,e,m,v"] * T2["w,x,y,e"] * Gamma1["v,x"]; - C2["v,w,m,n"] += alpha * +0.25000000 * H2["u,e,m,n"] * T2["v,w,x,e"] * Eta1["x,u"]; - C2["u,v,m,n"] += alpha * +0.12500000 * H2["e,f,m,n"] * T2["u,v,e,f"]; - C2["u,v,w,e"] += alpha * +0.25000000 * H2["u,v,m,n"] * T2["m,n,w,e"]; - C2["u,x,w,e"] += alpha * -1.00000000 * H2["u,v,m,w"] * T2["m,x,y,e"] * Eta1["y,v"]; - C2["u,w,v,f"] += alpha * +1.00000000 * H2["u,e,m,v"] * T2["m,w,f,e"]; - C2["u,v,y,e"] += alpha * +0.50000000 * H2["u,v,m,w"] * T2["m,x,y,e"] * Gamma1["w,x"]; - C2["u,w,x,e"] += alpha * -1.00000000 * H2["u,v,m,e"] * T2["m,w,x,y"] * Eta1["y,v"]; - C2["u,v,w,f"] += alpha * -1.00000000 * H2["u,e,m,f"] * T2["m,v,w,e"]; - C2["u,y,w,e"] += alpha * -1.00000000 * H2["u,v,w,x"] * T2["y,z,a0,e"] * Eta1["a0,v"] * Gamma1["x,z"]; - C2["u,y,w,e"] += alpha * +1.00000000 * H2["u,v,w,x"] * T2["y,z,a0,e"] * Eta1["x,z"] * Gamma1["a0,v"]; - C2["u,x,v,f"] += alpha * +1.00000000 * H2["u,e,v,w"] * T2["x,y,f,e"] * Gamma1["w,y"]; - C2["w,x,v,f"] += alpha * +0.50000000 * H2["u,e,v,f"] * T2["w,x,y,e"] * Eta1["y,u"]; - C2["v,w,u,g"] += alpha * +0.25000000 * H2["e,f,u,g"] * T2["v,w,e,f"]; - C2["u,v,a0,e"] += alpha * -0.25000000 * H2["u,v,w,x"] * T2["y,z,a0,e"] * Eta1["x,z"] * Eta1["w,y"]; - C2["u,v,a0,e"] += alpha * +0.25000000 * H2["u,v,w,x"] * T2["y,z,a0,e"] * Gamma1["x,z"] * Gamma1["w,y"]; - C2["u,w,y,f"] += alpha * +1.00000000 * H2["u,e,v,f"] * T2["w,x,y,e"] * Gamma1["v,x"]; - C2["u,w,m,e"] += alpha * +1.00000000 * H2["u,v,m,n"] * T2["n,w,x,e"] * Eta1["x,v"]; - C2["u,v,m,f"] += alpha * -1.00000000 * H2["u,e,m,n"] * T2["n,v,f,e"]; - C2["u,x,m,e"] += alpha * -1.00000000 * H2["u,v,m,w"] * T2["x,y,z,e"] * Eta1["z,v"] * Gamma1["w,y"]; - C2["u,x,m,e"] += alpha * +1.00000000 * H2["u,v,m,w"] * T2["x,y,z,e"] * Eta1["w,y"] * Gamma1["z,v"]; - C2["u,w,m,f"] += alpha * +1.00000000 * H2["u,e,m,v"] * T2["w,x,f,e"] * Gamma1["v,x"]; - C2["v,w,m,f"] += alpha * +0.50000000 * H2["u,e,m,f"] * T2["v,w,x,e"] * Eta1["x,u"]; - C2["u,v,m,g"] += alpha * +0.25000000 * H2["e,f,m,g"] * T2["u,v,e,f"]; - C2["u,v,e,f"] += alpha * +0.12500000 * H2["u,v,m,n"] * T2["m,n,e,f"]; - C2["u,v,e,f"] += alpha * +0.25000000 * H2["u,v,m,w"] * T2["m,x,e,f"] * Gamma1["w,x"]; - C2["u,w,e,f"] += alpha * -1.00000000 * H2["u,v,m,e"] * T2["m,w,x,f"] * Eta1["x,v"]; - C2["u,v,f,g"] += alpha * +1.00000000 * H2["u,e,m,f"] * T2["m,v,g,e"]; - C2["u,v,e,f"] += alpha * -0.12500000 * H2["u,v,w,x"] * T2["y,z,e,f"] * Eta1["x,z"] * Eta1["w,y"]; - C2["u,v,e,f"] += alpha * +0.12500000 * H2["u,v,w,x"] * T2["y,z,e,f"] * Gamma1["x,z"] * Gamma1["w,y"]; - C2["u,x,e,f"] += alpha * +1.00000000 * H2["u,v,w,e"] * T2["x,y,z,f"] * Eta1["z,v"] * Gamma1["w,y"]; - C2["u,x,e,f"] += alpha * -1.00000000 * H2["u,v,w,e"] * T2["x,y,z,f"] * Eta1["w,y"] * Gamma1["z,v"]; - C2["u,w,f,g"] += alpha * -1.00000000 * H2["u,e,v,f"] * T2["w,x,g,e"] * Gamma1["v,x"]; - C2["v,w,f,g"] += alpha * +0.25000000 * H2["u,e,f,g"] * T2["v,w,x,e"] * Eta1["x,u"]; - C2["u,v,g,h"] += alpha * +0.12500000 * H2["e,f,g,h"] * T2["u,v,e,f"]; - C2["u,e,v,w"] += alpha * +0.25000000 * H2["u,e,m,n"] * T2["m,n,v,w"]; - C2["w,e,v,x"] += alpha * +1.00000000 * H2["u,e,m,v"] * T2["m,w,x,y"] * Eta1["y,u"]; - C2["v,e,u,w"] += alpha * -1.00000000 * H2["e,f,m,u"] * T2["m,v,w,f"]; - C2["u,e,x,y"] += alpha * +0.50000000 * H2["u,e,m,v"] * T2["m,w,x,y"] * Gamma1["v,w"]; - C2["w,e,u,y"] += alpha * -1.00000000 * H2["e,f,u,v"] * T2["w,x,y,f"] * Gamma1["v,x"]; - C2["v,e,m,w"] += alpha * -1.00000000 * H2["u,e,m,n"] * T2["n,v,w,x"] * Eta1["x,u"]; - C2["u,e,m,v"] += alpha * +1.00000000 * H2["e,f,m,n"] * T2["n,u,v,f"]; - C2["v,e,m,x"] += alpha * -1.00000000 * H2["e,f,m,u"] * T2["v,w,x,f"] * Gamma1["u,w"]; - C2["u,e,v,f"] += alpha * +0.50000000 * H2["u,e,m,n"] * T2["m,n,v,f"]; - C2["w,e,v,f"] += alpha * -1.00000000 * H2["u,e,m,v"] * T2["m,w,x,f"] * Eta1["x,u"]; - C2["v,e,u,g"] += alpha * -1.00000000 * H2["e,f,m,u"] * T2["m,v,g,f"]; - C2["u,e,x,f"] += alpha * +1.00000000 * H2["u,e,m,v"] * T2["m,w,x,f"] * Gamma1["v,w"]; - C2["v,e,w,f"] += alpha * -1.00000000 * H2["u,e,m,f"] * T2["m,v,w,x"] * Eta1["x,u"]; - C2["u,e,v,g"] += alpha * +1.00000000 * H2["e,f,m,g"] * T2["m,u,v,f"]; - C2["x,e,v,f"] += alpha * -1.00000000 * H2["u,e,v,w"] * T2["x,y,z,f"] * Eta1["z,u"] * Gamma1["w,y"]; - C2["x,e,v,f"] += alpha * +1.00000000 * H2["u,e,v,w"] * T2["x,y,z,f"] * Eta1["w,y"] * Gamma1["z,u"]; - C2["w,e,u,g"] += alpha * -1.00000000 * H2["e,f,u,v"] * T2["w,x,g,f"] * Gamma1["v,x"]; - C2["u,e,z,f"] += alpha * -0.50000000 * H2["u,e,v,w"] * T2["x,y,z,f"] * Eta1["w,y"] * Eta1["v,x"]; - C2["u,e,z,f"] += alpha * +0.50000000 * H2["u,e,v,w"] * T2["x,y,z,f"] * Gamma1["w,y"] * Gamma1["v,x"]; - C2["v,e,x,g"] += alpha * -1.00000000 * H2["e,f,u,g"] * T2["v,w,x,f"] * Gamma1["u,w"]; - C2["v,e,m,f"] += alpha * +1.00000000 * H2["u,e,m,n"] * T2["n,v,w,f"] * Eta1["w,u"]; - C2["u,e,m,g"] += alpha * +1.00000000 * H2["e,f,m,n"] * T2["n,u,g,f"]; - C2["w,e,m,f"] += alpha * -1.00000000 * H2["u,e,m,v"] * T2["w,x,y,f"] * Eta1["y,u"] * Gamma1["v,x"]; - C2["w,e,m,f"] += alpha * +1.00000000 * H2["u,e,m,v"] * T2["w,x,y,f"] * Eta1["v,x"] * Gamma1["y,u"]; - C2["v,e,m,g"] += alpha * -1.00000000 * H2["e,f,m,u"] * T2["v,w,g,f"] * Gamma1["u,w"]; - C2["u,e,f,g"] += alpha * +0.25000000 * H2["u,e,m,n"] * T2["m,n,f,g"]; - C2["u,e,f,g"] += alpha * +0.50000000 * H2["u,e,m,v"] * T2["m,w,f,g"] * Gamma1["v,w"]; - C2["v,e,f,g"] += alpha * -1.00000000 * H2["u,e,m,f"] * T2["m,v,w,g"] * Eta1["w,u"]; - C2["u,e,g,h"] += alpha * -1.00000000 * H2["e,f,m,g"] * T2["m,u,h,f"]; - C2["u,e,f,g"] += alpha * -0.25000000 * H2["u,e,v,w"] * T2["x,y,f,g"] * Eta1["w,y"] * Eta1["v,x"]; - C2["u,e,f,g"] += alpha * +0.25000000 * H2["u,e,v,w"] * T2["x,y,f,g"] * Gamma1["w,y"] * Gamma1["v,x"]; - C2["w,e,f,g"] += alpha * +1.00000000 * H2["u,e,v,f"] * T2["w,x,y,g"] * Eta1["y,u"] * Gamma1["v,x"]; - C2["w,e,f,g"] += alpha * -1.00000000 * H2["u,e,v,f"] * T2["w,x,y,g"] * Eta1["v,x"] * Gamma1["y,u"]; - C2["v,e,g,h"] += alpha * +1.00000000 * H2["e,f,u,g"] * T2["v,w,h,f"] * Gamma1["u,w"]; - C2["m,u,v,w"] += alpha * +0.25000000 * H2["m,u,n,c0"] * T2["n,c0,v,w"]; - C2["m,w,v,x"] += alpha * +1.00000000 * H2["m,u,n,v"] * T2["n,w,x,y"] * Eta1["y,u"]; - C2["m,v,u,w"] += alpha * +1.00000000 * H2["m,e,n,u"] * T2["n,v,w,e"]; - C2["n,u,w,x"] += alpha * +1.00000000 * H2["u,v,m,w"] * T2["n,m,x,y"] * Eta1["y,v"]; - C2["n,u,v,w"] += alpha * +1.00000000 * H2["u,e,m,v"] * T2["n,m,w,e"]; - C2["m,u,x,y"] += alpha * +0.50000000 * H2["m,u,n,v"] * T2["n,w,x,y"] * Gamma1["v,w"]; - C2["m,y,w,x"] += alpha * +0.25000000 * H2["u,v,w,x"] * T2["m,y,z,a0"] * Eta1["a0,v"] * Eta1["z,u"]; - C2["m,y,w,x"] += alpha * -0.25000000 * H2["u,v,w,x"] * T2["m,y,z,a0"] * Gamma1["a0,v"] * Gamma1["z,u"]; - C2["m,x,v,w"] += alpha * +0.50000000 * H2["u,e,v,w"] * T2["m,x,y,e"] * Eta1["y,u"]; - C2["m,w,u,v"] += alpha * +0.25000000 * H2["e,f,u,v"] * T2["m,w,e,f"]; - C2["m,w,u,y"] += alpha * +1.00000000 * H2["m,e,u,v"] * T2["w,x,y,e"] * Gamma1["v,x"]; - C2["m,u,w,z"] += alpha * -1.00000000 * H2["u,v,w,x"] * T2["m,y,z,a0"] * Eta1["a0,v"] * Gamma1["x,y"]; - C2["m,u,w,z"] += alpha * +1.00000000 * H2["u,v,w,x"] * T2["m,y,z,a0"] * Eta1["x,y"] * Gamma1["a0,v"]; - C2["m,u,v,y"] += alpha * -1.00000000 * H2["u,e,v,w"] * T2["m,x,y,e"] * Gamma1["w,x"]; - C2["m,v,n,w"] += alpha * -1.00000000 * H2["m,u,n,c0"] * T2["c0,v,w,x"] * Eta1["x,u"]; - C2["m,u,n,v"] += alpha * -1.00000000 * H2["m,e,n,c0"] * T2["c0,u,v,e"]; - C2["c0,u,m,w"] += alpha * -1.00000000 * H2["u,v,m,n"] * T2["c0,n,w,x"] * Eta1["x,v"]; - C2["c0,u,m,v"] += alpha * -1.00000000 * H2["u,e,m,n"] * T2["c0,n,v,e"]; - C2["n,x,m,w"] += alpha * +0.50000000 * H2["u,v,m,w"] * T2["n,x,y,z"] * Eta1["z,v"] * Eta1["y,u"]; - C2["n,x,m,w"] += alpha * -0.50000000 * H2["u,v,m,w"] * T2["n,x,y,z"] * Gamma1["z,v"] * Gamma1["y,u"]; - C2["n,w,m,v"] += alpha * +1.00000000 * H2["u,e,m,v"] * T2["n,w,x,e"] * Eta1["x,u"]; - C2["n,v,m,u"] += alpha * +0.50000000 * H2["e,f,m,u"] * T2["n,v,e,f"]; - C2["m,v,n,x"] += alpha * +1.00000000 * H2["m,e,n,u"] * T2["v,w,x,e"] * Gamma1["u,w"]; - C2["n,u,m,y"] += alpha * -1.00000000 * H2["u,v,m,w"] * T2["n,x,y,z"] * Eta1["z,v"] * Gamma1["w,x"]; - C2["n,u,m,y"] += alpha * +1.00000000 * H2["u,v,m,w"] * T2["n,x,y,z"] * Eta1["w,x"] * Gamma1["z,v"]; - C2["n,u,m,x"] += alpha * -1.00000000 * H2["u,e,m,v"] * T2["n,w,x,e"] * Gamma1["v,w"]; - C2["c0,w,m,n"] += alpha * +0.25000000 * H2["u,v,m,n"] * T2["c0,w,x,y"] * Eta1["y,v"] * Eta1["x,u"]; - C2["c0,w,m,n"] += alpha * -0.25000000 * H2["u,v,m,n"] * T2["c0,w,x,y"] * Gamma1["y,v"] * Gamma1["x,u"]; - C2["c0,v,m,n"] += alpha * +0.50000000 * H2["u,e,m,n"] * T2["c0,v,w,e"] * Eta1["w,u"]; - C2["c0,u,m,n"] += alpha * +0.25000000 * H2["e,f,m,n"] * T2["c0,u,e,f"]; - C2["m,u,v,e"] += alpha * +0.50000000 * H2["m,u,n,c0"] * T2["n,c0,v,e"]; - C2["m,w,v,e"] += alpha * -1.00000000 * H2["m,u,n,v"] * T2["n,w,x,e"] * Eta1["x,u"]; - C2["m,v,u,f"] += alpha * +1.00000000 * H2["m,e,n,u"] * T2["n,v,f,e"]; - C2["n,u,w,e"] += alpha * -1.00000000 * H2["u,v,m,w"] * T2["n,m,x,e"] * Eta1["x,v"]; - C2["n,u,v,f"] += alpha * +1.00000000 * H2["u,e,m,v"] * T2["n,m,f,e"]; - C2["m,u,x,e"] += alpha * +1.00000000 * H2["m,u,n,v"] * T2["n,w,x,e"] * Gamma1["v,w"]; - C2["m,v,w,e"] += alpha * -1.00000000 * H2["m,u,n,e"] * T2["n,v,w,x"] * Eta1["x,u"]; - C2["m,u,v,f"] += alpha * -1.00000000 * H2["m,e,n,f"] * T2["n,u,v,e"]; - C2["n,u,w,e"] += alpha * -1.00000000 * H2["u,v,m,e"] * T2["n,m,w,x"] * Eta1["x,v"]; - C2["n,u,v,f"] += alpha * -1.00000000 * H2["u,e,m,f"] * T2["n,m,v,e"]; - C2["m,x,v,e"] += alpha * -1.00000000 * H2["m,u,v,w"] * T2["x,y,z,e"] * Eta1["z,u"] * Gamma1["w,y"]; - C2["m,x,v,e"] += alpha * +1.00000000 * H2["m,u,v,w"] * T2["x,y,z,e"] * Eta1["w,y"] * Gamma1["z,u"]; - C2["m,w,u,f"] += alpha * +1.00000000 * H2["m,e,u,v"] * T2["w,x,f,e"] * Gamma1["v,x"]; - C2["m,u,w,e"] += alpha * +1.00000000 * H2["u,v,w,x"] * T2["m,y,z,e"] * Eta1["z,v"] * Gamma1["x,y"]; - C2["m,u,w,e"] += alpha * -1.00000000 * H2["u,v,w,x"] * T2["m,y,z,e"] * Eta1["x,y"] * Gamma1["z,v"]; - C2["m,u,v,f"] += alpha * -1.00000000 * H2["u,e,v,w"] * T2["m,x,f,e"] * Gamma1["w,x"]; - C2["m,x,w,e"] += alpha * +0.50000000 * H2["u,v,w,e"] * T2["m,x,y,z"] * Eta1["z,v"] * Eta1["y,u"]; - C2["m,x,w,e"] += alpha * -0.50000000 * H2["u,v,w,e"] * T2["m,x,y,z"] * Gamma1["z,v"] * Gamma1["y,u"]; - C2["m,w,v,f"] += alpha * +1.00000000 * H2["u,e,v,f"] * T2["m,w,x,e"] * Eta1["x,u"]; - C2["m,v,u,g"] += alpha * +0.50000000 * H2["e,f,u,g"] * T2["m,v,e,f"]; - C2["m,u,z,e"] += alpha * -0.50000000 * H2["m,u,v,w"] * T2["x,y,z,e"] * Eta1["w,y"] * Eta1["v,x"]; - C2["m,u,z,e"] += alpha * +0.50000000 * H2["m,u,v,w"] * T2["x,y,z,e"] * Gamma1["w,y"] * Gamma1["v,x"]; - C2["m,v,x,f"] += alpha * +1.00000000 * H2["m,e,u,f"] * T2["v,w,x,e"] * Gamma1["u,w"]; - C2["m,u,y,e"] += alpha * -1.00000000 * H2["u,v,w,e"] * T2["m,x,y,z"] * Eta1["z,v"] * Gamma1["w,x"]; - C2["m,u,y,e"] += alpha * +1.00000000 * H2["u,v,w,e"] * T2["m,x,y,z"] * Eta1["w,x"] * Gamma1["z,v"]; - C2["m,u,x,f"] += alpha * -1.00000000 * H2["u,e,v,f"] * T2["m,w,x,e"] * Gamma1["v,w"]; - C2["m,v,n,e"] += alpha * +1.00000000 * H2["m,u,n,c0"] * T2["c0,v,w,e"] * Eta1["w,u"]; - C2["m,u,n,f"] += alpha * -1.00000000 * H2["m,e,n,c0"] * T2["c0,u,f,e"]; - C2["c0,u,m,e"] += alpha * +1.00000000 * H2["u,v,m,n"] * T2["c0,n,w,e"] * Eta1["w,v"]; - C2["c0,u,m,f"] += alpha * -1.00000000 * H2["u,e,m,n"] * T2["c0,n,f,e"]; - C2["m,w,n,e"] += alpha * -1.00000000 * H2["m,u,n,v"] * T2["w,x,y,e"] * Eta1["y,u"] * Gamma1["v,x"]; - C2["m,w,n,e"] += alpha * +1.00000000 * H2["m,u,n,v"] * T2["w,x,y,e"] * Eta1["v,x"] * Gamma1["y,u"]; - C2["m,v,n,f"] += alpha * +1.00000000 * H2["m,e,n,u"] * T2["v,w,f,e"] * Gamma1["u,w"]; - C2["n,u,m,e"] += alpha * +1.00000000 * H2["u,v,m,w"] * T2["n,x,y,e"] * Eta1["y,v"] * Gamma1["w,x"]; - C2["n,u,m,e"] += alpha * -1.00000000 * H2["u,v,m,w"] * T2["n,x,y,e"] * Eta1["w,x"] * Gamma1["y,v"]; - C2["n,u,m,f"] += alpha * -1.00000000 * H2["u,e,m,v"] * T2["n,w,f,e"] * Gamma1["v,w"]; - C2["n,w,m,e"] += alpha * +0.50000000 * H2["u,v,m,e"] * T2["n,w,x,y"] * Eta1["y,v"] * Eta1["x,u"]; - C2["n,w,m,e"] += alpha * -0.50000000 * H2["u,v,m,e"] * T2["n,w,x,y"] * Gamma1["y,v"] * Gamma1["x,u"]; - C2["n,v,m,f"] += alpha * +1.00000000 * H2["u,e,m,f"] * T2["n,v,w,e"] * Eta1["w,u"]; - C2["n,u,m,g"] += alpha * +0.50000000 * H2["e,f,m,g"] * T2["n,u,e,f"]; - C2["m,u,e,f"] += alpha * +0.25000000 * H2["m,u,n,c0"] * T2["n,c0,e,f"]; - C2["m,u,e,f"] += alpha * +0.50000000 * H2["m,u,n,v"] * T2["n,w,e,f"] * Gamma1["v,w"]; - C2["m,v,e,f"] += alpha * -1.00000000 * H2["m,u,n,e"] * T2["n,v,w,f"] * Eta1["w,u"]; - C2["m,u,f,g"] += alpha * +1.00000000 * H2["m,e,n,f"] * T2["n,u,g,e"]; - C2["n,u,e,f"] += alpha * -1.00000000 * H2["u,v,m,e"] * T2["n,m,w,f"] * Eta1["w,v"]; - C2["n,u,f,g"] += alpha * +1.00000000 * H2["u,e,m,f"] * T2["n,m,g,e"]; - C2["m,u,e,f"] += alpha * -0.25000000 * H2["m,u,v,w"] * T2["x,y,e,f"] * Eta1["w,y"] * Eta1["v,x"]; - C2["m,u,e,f"] += alpha * +0.25000000 * H2["m,u,v,w"] * T2["x,y,e,f"] * Gamma1["w,y"] * Gamma1["v,x"]; - C2["m,w,e,f"] += alpha * +1.00000000 * H2["m,u,v,e"] * T2["w,x,y,f"] * Eta1["y,u"] * Gamma1["v,x"]; - C2["m,w,e,f"] += alpha * -1.00000000 * H2["m,u,v,e"] * T2["w,x,y,f"] * Eta1["v,x"] * Gamma1["y,u"]; - C2["m,v,f,g"] += alpha * -1.00000000 * H2["m,e,u,f"] * T2["v,w,g,e"] * Gamma1["u,w"]; - C2["m,u,e,f"] += alpha * -1.00000000 * H2["u,v,w,e"] * T2["m,x,y,f"] * Eta1["y,v"] * Gamma1["w,x"]; - C2["m,u,e,f"] += alpha * +1.00000000 * H2["u,v,w,e"] * T2["m,x,y,f"] * Eta1["w,x"] * Gamma1["y,v"]; - C2["m,u,f,g"] += alpha * +1.00000000 * H2["u,e,v,f"] * T2["m,w,g,e"] * Gamma1["v,w"]; - C2["m,w,e,f"] += alpha * +0.25000000 * H2["u,v,e,f"] * T2["m,w,x,y"] * Eta1["y,v"] * Eta1["x,u"]; - C2["m,w,e,f"] += alpha * -0.25000000 * H2["u,v,e,f"] * T2["m,w,x,y"] * Gamma1["y,v"] * Gamma1["x,u"]; - C2["m,v,f,g"] += alpha * +0.50000000 * H2["u,e,f,g"] * T2["m,v,w,e"] * Eta1["w,u"]; - C2["m,u,g,h"] += alpha * +0.25000000 * H2["e,f,g,h"] * T2["m,u,e,f"]; - C2["m,n,u,v"] += alpha * +0.12500000 * H2["m,n,c0,c1"] * T2["c0,c1,u,v"]; - C2["m,c0,v,w"] += alpha * -1.00000000 * H2["m,u,n,v"] * T2["c0,n,w,x"] * Eta1["x,u"]; - C2["m,c0,u,v"] += alpha * -1.00000000 * H2["m,e,n,u"] * T2["c0,n,v,e"]; - C2["m,n,w,x"] += alpha * +0.25000000 * H2["m,n,c0,u"] * T2["c0,v,w,x"] * Gamma1["u,v"]; - C2["m,n,w,x"] += alpha * +0.12500000 * H2["u,v,w,x"] * T2["m,n,y,z"] * Eta1["z,v"] * Eta1["y,u"]; - C2["m,n,w,x"] += alpha * -0.12500000 * H2["u,v,w,x"] * T2["m,n,y,z"] * Gamma1["z,v"] * Gamma1["y,u"]; - C2["m,n,v,w"] += alpha * +0.25000000 * H2["u,e,v,w"] * T2["m,n,x,e"] * Eta1["x,u"]; - C2["m,n,u,v"] += alpha * +0.12500000 * H2["e,f,u,v"] * T2["m,n,e,f"]; - C2["m,n,v,y"] += alpha * +1.00000000 * H2["m,u,v,w"] * T2["n,x,y,z"] * Eta1["z,u"] * Gamma1["w,x"]; - C2["m,n,v,y"] += alpha * -1.00000000 * H2["m,u,v,w"] * T2["n,x,y,z"] * Eta1["w,x"] * Gamma1["z,u"]; - C2["m,n,u,x"] += alpha * +1.00000000 * H2["m,e,u,v"] * T2["n,w,x,e"] * Gamma1["v,w"]; - C2["m,c1,n,v"] += alpha * +1.00000000 * H2["m,u,n,c0"] * T2["c1,c0,v,w"] * Eta1["w,u"]; - C2["m,c1,n,u"] += alpha * +1.00000000 * H2["m,e,n,c0"] * T2["c1,c0,u,e"]; - C2["n,c0,m,w"] += alpha * +0.25000000 * H2["u,v,m,w"] * T2["n,c0,x,y"] * Eta1["y,v"] * Eta1["x,u"]; - C2["n,c0,m,w"] += alpha * -0.25000000 * H2["u,v,m,w"] * T2["n,c0,x,y"] * Gamma1["y,v"] * Gamma1["x,u"]; - C2["n,c0,m,v"] += alpha * +0.50000000 * H2["u,e,m,v"] * T2["n,c0,w,e"] * Eta1["w,u"]; - C2["n,c0,m,u"] += alpha * +0.25000000 * H2["e,f,m,u"] * T2["n,c0,e,f"]; - C2["m,c0,n,x"] += alpha * +1.00000000 * H2["m,u,n,v"] * T2["c0,w,x,y"] * Eta1["y,u"] * Gamma1["v,w"]; - C2["m,c0,n,x"] += alpha * -1.00000000 * H2["m,u,n,v"] * T2["c0,w,x,y"] * Eta1["v,w"] * Gamma1["y,u"]; - C2["m,c0,n,w"] += alpha * +1.00000000 * H2["m,e,n,u"] * T2["c0,v,w,e"] * Gamma1["u,v"]; - C2["c0,c1,m,n"] += alpha * +0.12500000 * H2["u,v,m,n"] * T2["c0,c1,w,x"] * Eta1["x,v"] * Eta1["w,u"]; - C2["c0,c1,m,n"] += alpha * -0.12500000 * H2["u,v,m,n"] * T2["c0,c1,w,x"] * Gamma1["x,v"] * Gamma1["w,u"]; - C2["c0,c1,m,n"] += alpha * +0.25000000 * H2["u,e,m,n"] * T2["c0,c1,v,e"] * Eta1["v,u"]; - C2["c0,c1,m,n"] += alpha * +0.12500000 * H2["e,f,m,n"] * T2["c0,c1,e,f"]; - C2["m,n,u,e"] += alpha * +0.25000000 * H2["m,n,c0,c1"] * T2["c0,c1,u,e"]; - C2["m,c0,v,e"] += alpha * +1.00000000 * H2["m,u,n,v"] * T2["c0,n,w,e"] * Eta1["w,u"]; - C2["m,c0,u,f"] += alpha * -1.00000000 * H2["m,e,n,u"] * T2["c0,n,f,e"]; - C2["m,n,w,e"] += alpha * +0.50000000 * H2["m,n,c0,u"] * T2["c0,v,w,e"] * Gamma1["u,v"]; - C2["m,c0,v,e"] += alpha * +1.00000000 * H2["m,u,n,e"] * T2["c0,n,v,w"] * Eta1["w,u"]; - C2["m,c0,u,f"] += alpha * +1.00000000 * H2["m,e,n,f"] * T2["c0,n,u,e"]; - C2["m,n,v,e"] += alpha * -1.00000000 * H2["m,u,v,w"] * T2["n,x,y,e"] * Eta1["y,u"] * Gamma1["w,x"]; - C2["m,n,v,e"] += alpha * +1.00000000 * H2["m,u,v,w"] * T2["n,x,y,e"] * Eta1["w,x"] * Gamma1["y,u"]; - C2["m,n,u,f"] += alpha * +1.00000000 * H2["m,e,u,v"] * T2["n,w,f,e"] * Gamma1["v,w"]; - C2["m,n,w,e"] += alpha * +0.25000000 * H2["u,v,w,e"] * T2["m,n,x,y"] * Eta1["y,v"] * Eta1["x,u"]; - C2["m,n,w,e"] += alpha * -0.25000000 * H2["u,v,w,e"] * T2["m,n,x,y"] * Gamma1["y,v"] * Gamma1["x,u"]; - C2["m,n,v,f"] += alpha * +0.50000000 * H2["u,e,v,f"] * T2["m,n,w,e"] * Eta1["w,u"]; - C2["m,n,u,g"] += alpha * +0.25000000 * H2["e,f,u,g"] * T2["m,n,e,f"]; - C2["m,n,y,e"] += alpha * -0.25000000 * H2["m,n,u,v"] * T2["w,x,y,e"] * Eta1["v,x"] * Eta1["u,w"]; - C2["m,n,y,e"] += alpha * +0.25000000 * H2["m,n,u,v"] * T2["w,x,y,e"] * Gamma1["v,x"] * Gamma1["u,w"]; - C2["m,n,x,e"] += alpha * +1.00000000 * H2["m,u,v,e"] * T2["n,w,x,y"] * Eta1["y,u"] * Gamma1["v,w"]; - C2["m,n,x,e"] += alpha * -1.00000000 * H2["m,u,v,e"] * T2["n,w,x,y"] * Eta1["v,w"] * Gamma1["y,u"]; - C2["m,n,w,f"] += alpha * +1.00000000 * H2["m,e,u,f"] * T2["n,v,w,e"] * Gamma1["u,v"]; - C2["m,c1,n,e"] += alpha * -1.00000000 * H2["m,u,n,c0"] * T2["c1,c0,v,e"] * Eta1["v,u"]; - C2["m,c1,n,f"] += alpha * +1.00000000 * H2["m,e,n,c0"] * T2["c1,c0,f,e"]; - C2["m,c0,n,e"] += alpha * -1.00000000 * H2["m,u,n,v"] * T2["c0,w,x,e"] * Eta1["x,u"] * Gamma1["v,w"]; - C2["m,c0,n,e"] += alpha * +1.00000000 * H2["m,u,n,v"] * T2["c0,w,x,e"] * Eta1["v,w"] * Gamma1["x,u"]; - C2["m,c0,n,f"] += alpha * +1.00000000 * H2["m,e,n,u"] * T2["c0,v,f,e"] * Gamma1["u,v"]; - C2["n,c0,m,e"] += alpha * +0.25000000 * H2["u,v,m,e"] * T2["n,c0,w,x"] * Eta1["x,v"] * Eta1["w,u"]; - C2["n,c0,m,e"] += alpha * -0.25000000 * H2["u,v,m,e"] * T2["n,c0,w,x"] * Gamma1["x,v"] * Gamma1["w,u"]; - C2["n,c0,m,f"] += alpha * +0.50000000 * H2["u,e,m,f"] * T2["n,c0,v,e"] * Eta1["v,u"]; - C2["n,c0,m,g"] += alpha * +0.25000000 * H2["e,f,m,g"] * T2["n,c0,e,f"]; - C2["m,n,e,f"] += alpha * +0.12500000 * H2["m,n,c0,c1"] * T2["c0,c1,e,f"]; - C2["m,n,e,f"] += alpha * +0.25000000 * H2["m,n,c0,u"] * T2["c0,v,e,f"] * Gamma1["u,v"]; - C2["m,c0,e,f"] += alpha * +1.00000000 * H2["m,u,n,e"] * T2["c0,n,v,f"] * Eta1["v,u"]; - C2["m,c0,f,g"] += alpha * -1.00000000 * H2["m,e,n,f"] * T2["c0,n,g,e"]; - C2["m,n,e,f"] += alpha * -0.12500000 * H2["m,n,u,v"] * T2["w,x,e,f"] * Eta1["v,x"] * Eta1["u,w"]; - C2["m,n,e,f"] += alpha * +0.12500000 * H2["m,n,u,v"] * T2["w,x,e,f"] * Gamma1["v,x"] * Gamma1["u,w"]; - C2["m,n,e,f"] += alpha * +1.00000000 * H2["m,u,v,e"] * T2["n,w,x,f"] * Eta1["x,u"] * Gamma1["v,w"]; - C2["m,n,e,f"] += alpha * -1.00000000 * H2["m,u,v,e"] * T2["n,w,x,f"] * Eta1["v,w"] * Gamma1["x,u"]; - C2["m,n,f,g"] += alpha * -1.00000000 * H2["m,e,u,f"] * T2["n,v,g,e"] * Gamma1["u,v"]; - C2["m,n,e,f"] += alpha * +0.12500000 * H2["u,v,e,f"] * T2["m,n,w,x"] * Eta1["x,v"] * Eta1["w,u"]; - C2["m,n,e,f"] += alpha * -0.12500000 * H2["u,v,e,f"] * T2["m,n,w,x"] * Gamma1["x,v"] * Gamma1["w,u"]; - C2["m,n,f,g"] += alpha * +0.25000000 * H2["u,e,f,g"] * T2["m,n,v,e"] * Eta1["v,u"]; - C2["m,n,g,h"] += alpha * +0.12500000 * H2["e,f,g,h"] * T2["m,n,e,f"]; - C2["m,e,u,v"] += alpha * +0.25000000 * H2["m,e,n,c0"] * T2["n,c0,u,v"]; - C2["n,e,v,w"] += alpha * -1.00000000 * H2["u,e,m,v"] * T2["n,m,w,x"] * Eta1["x,u"]; - C2["n,e,u,v"] += alpha * +1.00000000 * H2["e,f,m,u"] * T2["n,m,v,f"]; - C2["m,e,w,x"] += alpha * +0.50000000 * H2["m,e,n,u"] * T2["n,v,w,x"] * Gamma1["u,v"]; - C2["m,e,v,y"] += alpha * +1.00000000 * H2["u,e,v,w"] * T2["m,x,y,z"] * Eta1["z,u"] * Gamma1["w,x"]; - C2["m,e,v,y"] += alpha * -1.00000000 * H2["u,e,v,w"] * T2["m,x,y,z"] * Eta1["w,x"] * Gamma1["z,u"]; - C2["m,e,u,x"] += alpha * -1.00000000 * H2["e,f,u,v"] * T2["m,w,x,f"] * Gamma1["v,w"]; - C2["c0,e,m,v"] += alpha * +1.00000000 * H2["u,e,m,n"] * T2["c0,n,v,w"] * Eta1["w,u"]; - C2["c0,e,m,u"] += alpha * -1.00000000 * H2["e,f,m,n"] * T2["c0,n,u,f"]; - C2["n,e,m,x"] += alpha * +1.00000000 * H2["u,e,m,v"] * T2["n,w,x,y"] * Eta1["y,u"] * Gamma1["v,w"]; - C2["n,e,m,x"] += alpha * -1.00000000 * H2["u,e,m,v"] * T2["n,w,x,y"] * Eta1["v,w"] * Gamma1["y,u"]; - C2["n,e,m,w"] += alpha * -1.00000000 * H2["e,f,m,u"] * T2["n,v,w,f"] * Gamma1["u,v"]; - C2["m,e,u,f"] += alpha * +0.50000000 * H2["m,e,n,c0"] * T2["n,c0,u,f"]; - C2["n,e,v,f"] += alpha * +1.00000000 * H2["u,e,m,v"] * T2["n,m,w,f"] * Eta1["w,u"]; - C2["n,e,u,g"] += alpha * +1.00000000 * H2["e,f,m,u"] * T2["n,m,g,f"]; - C2["m,e,w,f"] += alpha * +1.00000000 * H2["m,e,n,u"] * T2["n,v,w,f"] * Gamma1["u,v"]; - C2["n,e,v,f"] += alpha * +1.00000000 * H2["u,e,m,f"] * T2["n,m,v,w"] * Eta1["w,u"]; - C2["n,e,u,g"] += alpha * -1.00000000 * H2["e,f,m,g"] * T2["n,m,u,f"]; - C2["m,e,v,f"] += alpha * -1.00000000 * H2["u,e,v,w"] * T2["m,x,y,f"] * Eta1["y,u"] * Gamma1["w,x"]; - C2["m,e,v,f"] += alpha * +1.00000000 * H2["u,e,v,w"] * T2["m,x,y,f"] * Eta1["w,x"] * Gamma1["y,u"]; - C2["m,e,u,g"] += alpha * -1.00000000 * H2["e,f,u,v"] * T2["m,w,g,f"] * Gamma1["v,w"]; - C2["m,e,y,f"] += alpha * -0.50000000 * H2["m,e,u,v"] * T2["w,x,y,f"] * Eta1["v,x"] * Eta1["u,w"]; - C2["m,e,y,f"] += alpha * +0.50000000 * H2["m,e,u,v"] * T2["w,x,y,f"] * Gamma1["v,x"] * Gamma1["u,w"]; - C2["m,e,x,f"] += alpha * +1.00000000 * H2["u,e,v,f"] * T2["m,w,x,y"] * Eta1["y,u"] * Gamma1["v,w"]; - C2["m,e,x,f"] += alpha * -1.00000000 * H2["u,e,v,f"] * T2["m,w,x,y"] * Eta1["v,w"] * Gamma1["y,u"]; - C2["m,e,w,g"] += alpha * -1.00000000 * H2["e,f,u,g"] * T2["m,v,w,f"] * Gamma1["u,v"]; - C2["c0,e,m,f"] += alpha * -1.00000000 * H2["u,e,m,n"] * T2["c0,n,v,f"] * Eta1["v,u"]; - C2["c0,e,m,g"] += alpha * -1.00000000 * H2["e,f,m,n"] * T2["c0,n,g,f"]; - C2["n,e,m,f"] += alpha * -1.00000000 * H2["u,e,m,v"] * T2["n,w,x,f"] * Eta1["x,u"] * Gamma1["v,w"]; - C2["n,e,m,f"] += alpha * +1.00000000 * H2["u,e,m,v"] * T2["n,w,x,f"] * Eta1["v,w"] * Gamma1["x,u"]; - C2["n,e,m,g"] += alpha * -1.00000000 * H2["e,f,m,u"] * T2["n,v,g,f"] * Gamma1["u,v"]; - C2["m,e,f,g"] += alpha * +0.25000000 * H2["m,e,n,c0"] * T2["n,c0,f,g"]; - C2["m,e,f,g"] += alpha * +0.50000000 * H2["m,e,n,u"] * T2["n,v,f,g"] * Gamma1["u,v"]; - C2["n,e,f,g"] += alpha * +1.00000000 * H2["u,e,m,f"] * T2["n,m,v,g"] * Eta1["v,u"]; - C2["n,e,g,h"] += alpha * +1.00000000 * H2["e,f,m,g"] * T2["n,m,h,f"]; - C2["m,e,f,g"] += alpha * -0.25000000 * H2["m,e,u,v"] * T2["w,x,f,g"] * Eta1["v,x"] * Eta1["u,w"]; - C2["m,e,f,g"] += alpha * +0.25000000 * H2["m,e,u,v"] * T2["w,x,f,g"] * Gamma1["v,x"] * Gamma1["u,w"]; - C2["m,e,f,g"] += alpha * +1.00000000 * H2["u,e,v,f"] * T2["m,w,x,g"] * Eta1["x,u"] * Gamma1["v,w"]; - C2["m,e,f,g"] += alpha * -1.00000000 * H2["u,e,v,f"] * T2["m,w,x,g"] * Eta1["v,w"] * Gamma1["x,u"]; - C2["m,e,g,h"] += alpha * +1.00000000 * H2["e,f,u,g"] * T2["m,v,h,f"] * Gamma1["u,v"]; - C2["e,f,u,v"] += alpha * +0.12500000 * H2["e,f,m,n"] * T2["m,n,u,v"]; - C2["e,f,w,x"] += alpha * +0.25000000 * H2["e,f,m,u"] * T2["m,v,w,x"] * Gamma1["u,v"]; - C2["e,f,u,g"] += alpha * +0.25000000 * H2["e,f,m,n"] * T2["m,n,u,g"]; - C2["e,f,w,g"] += alpha * +0.50000000 * H2["e,f,m,u"] * T2["m,v,w,g"] * Gamma1["u,v"]; - C2["e,f,y,g"] += alpha * -0.25000000 * H2["e,f,u,v"] * T2["w,x,y,g"] * Eta1["v,x"] * Eta1["u,w"]; - C2["e,f,y,g"] += alpha * +0.25000000 * H2["e,f,u,v"] * T2["w,x,y,g"] * Gamma1["v,x"] * Gamma1["u,w"]; - C2["e,f,g,h"] += alpha * +0.12500000 * H2["e,f,m,n"] * T2["m,n,g,h"]; - C2["e,f,g,h"] += alpha * +0.25000000 * H2["e,f,m,u"] * T2["m,v,g,h"] * Gamma1["u,v"]; - C2["e,f,g,h"] += alpha * -0.12500000 * H2["e,f,u,v"] * T2["w,x,g,h"] * Eta1["v,x"] * Eta1["u,w"]; - C2["e,f,g,h"] += alpha * +0.12500000 * H2["e,f,u,v"] * T2["w,x,g,h"] * Gamma1["v,x"] * Gamma1["u,w"]; +void MRDSRG_SO::H2_T2_C2(BlockedTensor& H2, BlockedTensor& T2, const double& alpha, + BlockedTensor& C2) { + // 282 lines + local_timer timer; + C2["u,v,w,x"] += alpha * +0.12500000 * H2["u,v,m,n"] * T2["m,n,w,x"]; + C2["u,x,w,y"] += alpha * +1.00000000 * H2["u,v,m,w"] * T2["m,x,y,z"] * Eta1["z,v"]; + C2["u,w,v,x"] += alpha * +1.00000000 * H2["u,e,m,v"] * T2["m,w,x,e"]; + C2["u,v,y,z"] += alpha * +0.25000000 * H2["u,v,m,w"] * T2["m,x,y,z"] * Gamma1["w,x"]; + C2["x,y,v,w"] += alpha * +0.25000000 * H2["u,e,v,w"] * T2["x,y,z,e"] * Eta1["z,u"]; + C2["w,x,u,v"] += alpha * +0.12500000 * H2["e,f,u,v"] * T2["w,x,e,f"]; + C2["u,x,v,z"] += alpha * +1.00000000 * H2["u,e,v,w"] * T2["x,y,z,e"] * Gamma1["w,y"]; + C2["u,w,m,x"] += alpha * -1.00000000 * H2["u,v,m,n"] * T2["n,w,x,y"] * Eta1["y,v"]; + C2["u,v,m,w"] += alpha * -1.00000000 * H2["u,e,m,n"] * T2["n,v,w,e"]; + C2["w,x,m,v"] += alpha * +0.50000000 * H2["u,e,m,v"] * T2["w,x,y,e"] * Eta1["y,u"]; + C2["v,w,m,u"] += alpha * +0.25000000 * H2["e,f,m,u"] * T2["v,w,e,f"]; + C2["u,w,m,y"] += alpha * +1.00000000 * H2["u,e,m,v"] * T2["w,x,y,e"] * Gamma1["v,x"]; + C2["v,w,m,n"] += alpha * +0.25000000 * H2["u,e,m,n"] * T2["v,w,x,e"] * Eta1["x,u"]; + C2["u,v,m,n"] += alpha * +0.12500000 * H2["e,f,m,n"] * T2["u,v,e,f"]; + C2["u,v,w,e"] += alpha * +0.25000000 * H2["u,v,m,n"] * T2["m,n,w,e"]; + C2["u,x,w,e"] += alpha * -1.00000000 * H2["u,v,m,w"] * T2["m,x,y,e"] * Eta1["y,v"]; + C2["u,w,v,f"] += alpha * +1.00000000 * H2["u,e,m,v"] * T2["m,w,f,e"]; + C2["u,v,y,e"] += alpha * +0.50000000 * H2["u,v,m,w"] * T2["m,x,y,e"] * Gamma1["w,x"]; + C2["u,w,x,e"] += alpha * -1.00000000 * H2["u,v,m,e"] * T2["m,w,x,y"] * Eta1["y,v"]; + C2["u,v,w,f"] += alpha * -1.00000000 * H2["u,e,m,f"] * T2["m,v,w,e"]; + C2["u,y,w,e"] += + alpha * -1.00000000 * H2["u,v,w,x"] * T2["y,z,a0,e"] * Eta1["a0,v"] * Gamma1["x,z"]; + C2["u,y,w,e"] += + alpha * +1.00000000 * H2["u,v,w,x"] * T2["y,z,a0,e"] * Eta1["x,z"] * Gamma1["a0,v"]; + C2["u,x,v,f"] += alpha * +1.00000000 * H2["u,e,v,w"] * T2["x,y,f,e"] * Gamma1["w,y"]; + C2["w,x,v,f"] += alpha * +0.50000000 * H2["u,e,v,f"] * T2["w,x,y,e"] * Eta1["y,u"]; + C2["v,w,u,g"] += alpha * +0.25000000 * H2["e,f,u,g"] * T2["v,w,e,f"]; + C2["u,v,a0,e"] += + alpha * -0.25000000 * H2["u,v,w,x"] * T2["y,z,a0,e"] * Eta1["x,z"] * Eta1["w,y"]; + C2["u,v,a0,e"] += + alpha * +0.25000000 * H2["u,v,w,x"] * T2["y,z,a0,e"] * Gamma1["x,z"] * Gamma1["w,y"]; + C2["u,w,y,f"] += alpha * +1.00000000 * H2["u,e,v,f"] * T2["w,x,y,e"] * Gamma1["v,x"]; + C2["u,w,m,e"] += alpha * +1.00000000 * H2["u,v,m,n"] * T2["n,w,x,e"] * Eta1["x,v"]; + C2["u,v,m,f"] += alpha * -1.00000000 * H2["u,e,m,n"] * T2["n,v,f,e"]; + C2["u,x,m,e"] += + alpha * -1.00000000 * H2["u,v,m,w"] * T2["x,y,z,e"] * Eta1["z,v"] * Gamma1["w,y"]; + C2["u,x,m,e"] += + alpha * +1.00000000 * H2["u,v,m,w"] * T2["x,y,z,e"] * Eta1["w,y"] * Gamma1["z,v"]; + C2["u,w,m,f"] += alpha * +1.00000000 * H2["u,e,m,v"] * T2["w,x,f,e"] * Gamma1["v,x"]; + C2["v,w,m,f"] += alpha * +0.50000000 * H2["u,e,m,f"] * T2["v,w,x,e"] * Eta1["x,u"]; + C2["u,v,m,g"] += alpha * +0.25000000 * H2["e,f,m,g"] * T2["u,v,e,f"]; + C2["u,v,e,f"] += alpha * +0.12500000 * H2["u,v,m,n"] * T2["m,n,e,f"]; + C2["u,v,e,f"] += alpha * +0.25000000 * H2["u,v,m,w"] * T2["m,x,e,f"] * Gamma1["w,x"]; + C2["u,w,e,f"] += alpha * -1.00000000 * H2["u,v,m,e"] * T2["m,w,x,f"] * Eta1["x,v"]; + C2["u,v,f,g"] += alpha * +1.00000000 * H2["u,e,m,f"] * T2["m,v,g,e"]; + C2["u,v,e,f"] += + alpha * -0.12500000 * H2["u,v,w,x"] * T2["y,z,e,f"] * Eta1["x,z"] * Eta1["w,y"]; + C2["u,v,e,f"] += + alpha * +0.12500000 * H2["u,v,w,x"] * T2["y,z,e,f"] * Gamma1["x,z"] * Gamma1["w,y"]; + C2["u,x,e,f"] += + alpha * +1.00000000 * H2["u,v,w,e"] * T2["x,y,z,f"] * Eta1["z,v"] * Gamma1["w,y"]; + C2["u,x,e,f"] += + alpha * -1.00000000 * H2["u,v,w,e"] * T2["x,y,z,f"] * Eta1["w,y"] * Gamma1["z,v"]; + C2["u,w,f,g"] += alpha * -1.00000000 * H2["u,e,v,f"] * T2["w,x,g,e"] * Gamma1["v,x"]; + C2["v,w,f,g"] += alpha * +0.25000000 * H2["u,e,f,g"] * T2["v,w,x,e"] * Eta1["x,u"]; + C2["u,v,g,h"] += alpha * +0.12500000 * H2["e,f,g,h"] * T2["u,v,e,f"]; + C2["u,e,v,w"] += alpha * +0.25000000 * H2["u,e,m,n"] * T2["m,n,v,w"]; + C2["w,e,v,x"] += alpha * +1.00000000 * H2["u,e,m,v"] * T2["m,w,x,y"] * Eta1["y,u"]; + C2["v,e,u,w"] += alpha * -1.00000000 * H2["e,f,m,u"] * T2["m,v,w,f"]; + C2["u,e,x,y"] += alpha * +0.50000000 * H2["u,e,m,v"] * T2["m,w,x,y"] * Gamma1["v,w"]; + C2["w,e,u,y"] += alpha * -1.00000000 * H2["e,f,u,v"] * T2["w,x,y,f"] * Gamma1["v,x"]; + C2["v,e,m,w"] += alpha * -1.00000000 * H2["u,e,m,n"] * T2["n,v,w,x"] * Eta1["x,u"]; + C2["u,e,m,v"] += alpha * +1.00000000 * H2["e,f,m,n"] * T2["n,u,v,f"]; + C2["v,e,m,x"] += alpha * -1.00000000 * H2["e,f,m,u"] * T2["v,w,x,f"] * Gamma1["u,w"]; + C2["u,e,v,f"] += alpha * +0.50000000 * H2["u,e,m,n"] * T2["m,n,v,f"]; + C2["w,e,v,f"] += alpha * -1.00000000 * H2["u,e,m,v"] * T2["m,w,x,f"] * Eta1["x,u"]; + C2["v,e,u,g"] += alpha * -1.00000000 * H2["e,f,m,u"] * T2["m,v,g,f"]; + C2["u,e,x,f"] += alpha * +1.00000000 * H2["u,e,m,v"] * T2["m,w,x,f"] * Gamma1["v,w"]; + C2["v,e,w,f"] += alpha * -1.00000000 * H2["u,e,m,f"] * T2["m,v,w,x"] * Eta1["x,u"]; + C2["u,e,v,g"] += alpha * +1.00000000 * H2["e,f,m,g"] * T2["m,u,v,f"]; + C2["x,e,v,f"] += + alpha * -1.00000000 * H2["u,e,v,w"] * T2["x,y,z,f"] * Eta1["z,u"] * Gamma1["w,y"]; + C2["x,e,v,f"] += + alpha * +1.00000000 * H2["u,e,v,w"] * T2["x,y,z,f"] * Eta1["w,y"] * Gamma1["z,u"]; + C2["w,e,u,g"] += alpha * -1.00000000 * H2["e,f,u,v"] * T2["w,x,g,f"] * Gamma1["v,x"]; + C2["u,e,z,f"] += + alpha * -0.50000000 * H2["u,e,v,w"] * T2["x,y,z,f"] * Eta1["w,y"] * Eta1["v,x"]; + C2["u,e,z,f"] += + alpha * +0.50000000 * H2["u,e,v,w"] * T2["x,y,z,f"] * Gamma1["w,y"] * Gamma1["v,x"]; + C2["v,e,x,g"] += alpha * -1.00000000 * H2["e,f,u,g"] * T2["v,w,x,f"] * Gamma1["u,w"]; + C2["v,e,m,f"] += alpha * +1.00000000 * H2["u,e,m,n"] * T2["n,v,w,f"] * Eta1["w,u"]; + C2["u,e,m,g"] += alpha * +1.00000000 * H2["e,f,m,n"] * T2["n,u,g,f"]; + C2["w,e,m,f"] += + alpha * -1.00000000 * H2["u,e,m,v"] * T2["w,x,y,f"] * Eta1["y,u"] * Gamma1["v,x"]; + C2["w,e,m,f"] += + alpha * +1.00000000 * H2["u,e,m,v"] * T2["w,x,y,f"] * Eta1["v,x"] * Gamma1["y,u"]; + C2["v,e,m,g"] += alpha * -1.00000000 * H2["e,f,m,u"] * T2["v,w,g,f"] * Gamma1["u,w"]; + C2["u,e,f,g"] += alpha * +0.25000000 * H2["u,e,m,n"] * T2["m,n,f,g"]; + C2["u,e,f,g"] += alpha * +0.50000000 * H2["u,e,m,v"] * T2["m,w,f,g"] * Gamma1["v,w"]; + C2["v,e,f,g"] += alpha * -1.00000000 * H2["u,e,m,f"] * T2["m,v,w,g"] * Eta1["w,u"]; + C2["u,e,g,h"] += alpha * -1.00000000 * H2["e,f,m,g"] * T2["m,u,h,f"]; + C2["u,e,f,g"] += + alpha * -0.25000000 * H2["u,e,v,w"] * T2["x,y,f,g"] * Eta1["w,y"] * Eta1["v,x"]; + C2["u,e,f,g"] += + alpha * +0.25000000 * H2["u,e,v,w"] * T2["x,y,f,g"] * Gamma1["w,y"] * Gamma1["v,x"]; + C2["w,e,f,g"] += + alpha * +1.00000000 * H2["u,e,v,f"] * T2["w,x,y,g"] * Eta1["y,u"] * Gamma1["v,x"]; + C2["w,e,f,g"] += + alpha * -1.00000000 * H2["u,e,v,f"] * T2["w,x,y,g"] * Eta1["v,x"] * Gamma1["y,u"]; + C2["v,e,g,h"] += alpha * +1.00000000 * H2["e,f,u,g"] * T2["v,w,h,f"] * Gamma1["u,w"]; + C2["m,u,v,w"] += alpha * +0.25000000 * H2["m,u,n,c0"] * T2["n,c0,v,w"]; + C2["m,w,v,x"] += alpha * +1.00000000 * H2["m,u,n,v"] * T2["n,w,x,y"] * Eta1["y,u"]; + C2["m,v,u,w"] += alpha * +1.00000000 * H2["m,e,n,u"] * T2["n,v,w,e"]; + C2["n,u,w,x"] += alpha * +1.00000000 * H2["u,v,m,w"] * T2["n,m,x,y"] * Eta1["y,v"]; + C2["n,u,v,w"] += alpha * +1.00000000 * H2["u,e,m,v"] * T2["n,m,w,e"]; + C2["m,u,x,y"] += alpha * +0.50000000 * H2["m,u,n,v"] * T2["n,w,x,y"] * Gamma1["v,w"]; + C2["m,y,w,x"] += + alpha * +0.25000000 * H2["u,v,w,x"] * T2["m,y,z,a0"] * Eta1["a0,v"] * Eta1["z,u"]; + C2["m,y,w,x"] += + alpha * -0.25000000 * H2["u,v,w,x"] * T2["m,y,z,a0"] * Gamma1["a0,v"] * Gamma1["z,u"]; + C2["m,x,v,w"] += alpha * +0.50000000 * H2["u,e,v,w"] * T2["m,x,y,e"] * Eta1["y,u"]; + C2["m,w,u,v"] += alpha * +0.25000000 * H2["e,f,u,v"] * T2["m,w,e,f"]; + C2["m,w,u,y"] += alpha * +1.00000000 * H2["m,e,u,v"] * T2["w,x,y,e"] * Gamma1["v,x"]; + C2["m,u,w,z"] += + alpha * -1.00000000 * H2["u,v,w,x"] * T2["m,y,z,a0"] * Eta1["a0,v"] * Gamma1["x,y"]; + C2["m,u,w,z"] += + alpha * +1.00000000 * H2["u,v,w,x"] * T2["m,y,z,a0"] * Eta1["x,y"] * Gamma1["a0,v"]; + C2["m,u,v,y"] += alpha * -1.00000000 * H2["u,e,v,w"] * T2["m,x,y,e"] * Gamma1["w,x"]; + C2["m,v,n,w"] += alpha * -1.00000000 * H2["m,u,n,c0"] * T2["c0,v,w,x"] * Eta1["x,u"]; + C2["m,u,n,v"] += alpha * -1.00000000 * H2["m,e,n,c0"] * T2["c0,u,v,e"]; + C2["c0,u,m,w"] += alpha * -1.00000000 * H2["u,v,m,n"] * T2["c0,n,w,x"] * Eta1["x,v"]; + C2["c0,u,m,v"] += alpha * -1.00000000 * H2["u,e,m,n"] * T2["c0,n,v,e"]; + C2["n,x,m,w"] += + alpha * +0.50000000 * H2["u,v,m,w"] * T2["n,x,y,z"] * Eta1["z,v"] * Eta1["y,u"]; + C2["n,x,m,w"] += + alpha * -0.50000000 * H2["u,v,m,w"] * T2["n,x,y,z"] * Gamma1["z,v"] * Gamma1["y,u"]; + C2["n,w,m,v"] += alpha * +1.00000000 * H2["u,e,m,v"] * T2["n,w,x,e"] * Eta1["x,u"]; + C2["n,v,m,u"] += alpha * +0.50000000 * H2["e,f,m,u"] * T2["n,v,e,f"]; + C2["m,v,n,x"] += alpha * +1.00000000 * H2["m,e,n,u"] * T2["v,w,x,e"] * Gamma1["u,w"]; + C2["n,u,m,y"] += + alpha * -1.00000000 * H2["u,v,m,w"] * T2["n,x,y,z"] * Eta1["z,v"] * Gamma1["w,x"]; + C2["n,u,m,y"] += + alpha * +1.00000000 * H2["u,v,m,w"] * T2["n,x,y,z"] * Eta1["w,x"] * Gamma1["z,v"]; + C2["n,u,m,x"] += alpha * -1.00000000 * H2["u,e,m,v"] * T2["n,w,x,e"] * Gamma1["v,w"]; + C2["c0,w,m,n"] += + alpha * +0.25000000 * H2["u,v,m,n"] * T2["c0,w,x,y"] * Eta1["y,v"] * Eta1["x,u"]; + C2["c0,w,m,n"] += + alpha * -0.25000000 * H2["u,v,m,n"] * T2["c0,w,x,y"] * Gamma1["y,v"] * Gamma1["x,u"]; + C2["c0,v,m,n"] += alpha * +0.50000000 * H2["u,e,m,n"] * T2["c0,v,w,e"] * Eta1["w,u"]; + C2["c0,u,m,n"] += alpha * +0.25000000 * H2["e,f,m,n"] * T2["c0,u,e,f"]; + C2["m,u,v,e"] += alpha * +0.50000000 * H2["m,u,n,c0"] * T2["n,c0,v,e"]; + C2["m,w,v,e"] += alpha * -1.00000000 * H2["m,u,n,v"] * T2["n,w,x,e"] * Eta1["x,u"]; + C2["m,v,u,f"] += alpha * +1.00000000 * H2["m,e,n,u"] * T2["n,v,f,e"]; + C2["n,u,w,e"] += alpha * -1.00000000 * H2["u,v,m,w"] * T2["n,m,x,e"] * Eta1["x,v"]; + C2["n,u,v,f"] += alpha * +1.00000000 * H2["u,e,m,v"] * T2["n,m,f,e"]; + C2["m,u,x,e"] += alpha * +1.00000000 * H2["m,u,n,v"] * T2["n,w,x,e"] * Gamma1["v,w"]; + C2["m,v,w,e"] += alpha * -1.00000000 * H2["m,u,n,e"] * T2["n,v,w,x"] * Eta1["x,u"]; + C2["m,u,v,f"] += alpha * -1.00000000 * H2["m,e,n,f"] * T2["n,u,v,e"]; + C2["n,u,w,e"] += alpha * -1.00000000 * H2["u,v,m,e"] * T2["n,m,w,x"] * Eta1["x,v"]; + C2["n,u,v,f"] += alpha * -1.00000000 * H2["u,e,m,f"] * T2["n,m,v,e"]; + C2["m,x,v,e"] += + alpha * -1.00000000 * H2["m,u,v,w"] * T2["x,y,z,e"] * Eta1["z,u"] * Gamma1["w,y"]; + C2["m,x,v,e"] += + alpha * +1.00000000 * H2["m,u,v,w"] * T2["x,y,z,e"] * Eta1["w,y"] * Gamma1["z,u"]; + C2["m,w,u,f"] += alpha * +1.00000000 * H2["m,e,u,v"] * T2["w,x,f,e"] * Gamma1["v,x"]; + C2["m,u,w,e"] += + alpha * +1.00000000 * H2["u,v,w,x"] * T2["m,y,z,e"] * Eta1["z,v"] * Gamma1["x,y"]; + C2["m,u,w,e"] += + alpha * -1.00000000 * H2["u,v,w,x"] * T2["m,y,z,e"] * Eta1["x,y"] * Gamma1["z,v"]; + C2["m,u,v,f"] += alpha * -1.00000000 * H2["u,e,v,w"] * T2["m,x,f,e"] * Gamma1["w,x"]; + C2["m,x,w,e"] += + alpha * +0.50000000 * H2["u,v,w,e"] * T2["m,x,y,z"] * Eta1["z,v"] * Eta1["y,u"]; + C2["m,x,w,e"] += + alpha * -0.50000000 * H2["u,v,w,e"] * T2["m,x,y,z"] * Gamma1["z,v"] * Gamma1["y,u"]; + C2["m,w,v,f"] += alpha * +1.00000000 * H2["u,e,v,f"] * T2["m,w,x,e"] * Eta1["x,u"]; + C2["m,v,u,g"] += alpha * +0.50000000 * H2["e,f,u,g"] * T2["m,v,e,f"]; + C2["m,u,z,e"] += + alpha * -0.50000000 * H2["m,u,v,w"] * T2["x,y,z,e"] * Eta1["w,y"] * Eta1["v,x"]; + C2["m,u,z,e"] += + alpha * +0.50000000 * H2["m,u,v,w"] * T2["x,y,z,e"] * Gamma1["w,y"] * Gamma1["v,x"]; + C2["m,v,x,f"] += alpha * +1.00000000 * H2["m,e,u,f"] * T2["v,w,x,e"] * Gamma1["u,w"]; + C2["m,u,y,e"] += + alpha * -1.00000000 * H2["u,v,w,e"] * T2["m,x,y,z"] * Eta1["z,v"] * Gamma1["w,x"]; + C2["m,u,y,e"] += + alpha * +1.00000000 * H2["u,v,w,e"] * T2["m,x,y,z"] * Eta1["w,x"] * Gamma1["z,v"]; + C2["m,u,x,f"] += alpha * -1.00000000 * H2["u,e,v,f"] * T2["m,w,x,e"] * Gamma1["v,w"]; + C2["m,v,n,e"] += alpha * +1.00000000 * H2["m,u,n,c0"] * T2["c0,v,w,e"] * Eta1["w,u"]; + C2["m,u,n,f"] += alpha * -1.00000000 * H2["m,e,n,c0"] * T2["c0,u,f,e"]; + C2["c0,u,m,e"] += alpha * +1.00000000 * H2["u,v,m,n"] * T2["c0,n,w,e"] * Eta1["w,v"]; + C2["c0,u,m,f"] += alpha * -1.00000000 * H2["u,e,m,n"] * T2["c0,n,f,e"]; + C2["m,w,n,e"] += + alpha * -1.00000000 * H2["m,u,n,v"] * T2["w,x,y,e"] * Eta1["y,u"] * Gamma1["v,x"]; + C2["m,w,n,e"] += + alpha * +1.00000000 * H2["m,u,n,v"] * T2["w,x,y,e"] * Eta1["v,x"] * Gamma1["y,u"]; + C2["m,v,n,f"] += alpha * +1.00000000 * H2["m,e,n,u"] * T2["v,w,f,e"] * Gamma1["u,w"]; + C2["n,u,m,e"] += + alpha * +1.00000000 * H2["u,v,m,w"] * T2["n,x,y,e"] * Eta1["y,v"] * Gamma1["w,x"]; + C2["n,u,m,e"] += + alpha * -1.00000000 * H2["u,v,m,w"] * T2["n,x,y,e"] * Eta1["w,x"] * Gamma1["y,v"]; + C2["n,u,m,f"] += alpha * -1.00000000 * H2["u,e,m,v"] * T2["n,w,f,e"] * Gamma1["v,w"]; + C2["n,w,m,e"] += + alpha * +0.50000000 * H2["u,v,m,e"] * T2["n,w,x,y"] * Eta1["y,v"] * Eta1["x,u"]; + C2["n,w,m,e"] += + alpha * -0.50000000 * H2["u,v,m,e"] * T2["n,w,x,y"] * Gamma1["y,v"] * Gamma1["x,u"]; + C2["n,v,m,f"] += alpha * +1.00000000 * H2["u,e,m,f"] * T2["n,v,w,e"] * Eta1["w,u"]; + C2["n,u,m,g"] += alpha * +0.50000000 * H2["e,f,m,g"] * T2["n,u,e,f"]; + C2["m,u,e,f"] += alpha * +0.25000000 * H2["m,u,n,c0"] * T2["n,c0,e,f"]; + C2["m,u,e,f"] += alpha * +0.50000000 * H2["m,u,n,v"] * T2["n,w,e,f"] * Gamma1["v,w"]; + C2["m,v,e,f"] += alpha * -1.00000000 * H2["m,u,n,e"] * T2["n,v,w,f"] * Eta1["w,u"]; + C2["m,u,f,g"] += alpha * +1.00000000 * H2["m,e,n,f"] * T2["n,u,g,e"]; + C2["n,u,e,f"] += alpha * -1.00000000 * H2["u,v,m,e"] * T2["n,m,w,f"] * Eta1["w,v"]; + C2["n,u,f,g"] += alpha * +1.00000000 * H2["u,e,m,f"] * T2["n,m,g,e"]; + C2["m,u,e,f"] += + alpha * -0.25000000 * H2["m,u,v,w"] * T2["x,y,e,f"] * Eta1["w,y"] * Eta1["v,x"]; + C2["m,u,e,f"] += + alpha * +0.25000000 * H2["m,u,v,w"] * T2["x,y,e,f"] * Gamma1["w,y"] * Gamma1["v,x"]; + C2["m,w,e,f"] += + alpha * +1.00000000 * H2["m,u,v,e"] * T2["w,x,y,f"] * Eta1["y,u"] * Gamma1["v,x"]; + C2["m,w,e,f"] += + alpha * -1.00000000 * H2["m,u,v,e"] * T2["w,x,y,f"] * Eta1["v,x"] * Gamma1["y,u"]; + C2["m,v,f,g"] += alpha * -1.00000000 * H2["m,e,u,f"] * T2["v,w,g,e"] * Gamma1["u,w"]; + C2["m,u,e,f"] += + alpha * -1.00000000 * H2["u,v,w,e"] * T2["m,x,y,f"] * Eta1["y,v"] * Gamma1["w,x"]; + C2["m,u,e,f"] += + alpha * +1.00000000 * H2["u,v,w,e"] * T2["m,x,y,f"] * Eta1["w,x"] * Gamma1["y,v"]; + C2["m,u,f,g"] += alpha * +1.00000000 * H2["u,e,v,f"] * T2["m,w,g,e"] * Gamma1["v,w"]; + C2["m,w,e,f"] += + alpha * +0.25000000 * H2["u,v,e,f"] * T2["m,w,x,y"] * Eta1["y,v"] * Eta1["x,u"]; + C2["m,w,e,f"] += + alpha * -0.25000000 * H2["u,v,e,f"] * T2["m,w,x,y"] * Gamma1["y,v"] * Gamma1["x,u"]; + C2["m,v,f,g"] += alpha * +0.50000000 * H2["u,e,f,g"] * T2["m,v,w,e"] * Eta1["w,u"]; + C2["m,u,g,h"] += alpha * +0.25000000 * H2["e,f,g,h"] * T2["m,u,e,f"]; + C2["m,n,u,v"] += alpha * +0.12500000 * H2["m,n,c0,c1"] * T2["c0,c1,u,v"]; + C2["m,c0,v,w"] += alpha * -1.00000000 * H2["m,u,n,v"] * T2["c0,n,w,x"] * Eta1["x,u"]; + C2["m,c0,u,v"] += alpha * -1.00000000 * H2["m,e,n,u"] * T2["c0,n,v,e"]; + C2["m,n,w,x"] += alpha * +0.25000000 * H2["m,n,c0,u"] * T2["c0,v,w,x"] * Gamma1["u,v"]; + C2["m,n,w,x"] += + alpha * +0.12500000 * H2["u,v,w,x"] * T2["m,n,y,z"] * Eta1["z,v"] * Eta1["y,u"]; + C2["m,n,w,x"] += + alpha * -0.12500000 * H2["u,v,w,x"] * T2["m,n,y,z"] * Gamma1["z,v"] * Gamma1["y,u"]; + C2["m,n,v,w"] += alpha * +0.25000000 * H2["u,e,v,w"] * T2["m,n,x,e"] * Eta1["x,u"]; + C2["m,n,u,v"] += alpha * +0.12500000 * H2["e,f,u,v"] * T2["m,n,e,f"]; + C2["m,n,v,y"] += + alpha * +1.00000000 * H2["m,u,v,w"] * T2["n,x,y,z"] * Eta1["z,u"] * Gamma1["w,x"]; + C2["m,n,v,y"] += + alpha * -1.00000000 * H2["m,u,v,w"] * T2["n,x,y,z"] * Eta1["w,x"] * Gamma1["z,u"]; + C2["m,n,u,x"] += alpha * +1.00000000 * H2["m,e,u,v"] * T2["n,w,x,e"] * Gamma1["v,w"]; + C2["m,c1,n,v"] += alpha * +1.00000000 * H2["m,u,n,c0"] * T2["c1,c0,v,w"] * Eta1["w,u"]; + C2["m,c1,n,u"] += alpha * +1.00000000 * H2["m,e,n,c0"] * T2["c1,c0,u,e"]; + C2["n,c0,m,w"] += + alpha * +0.25000000 * H2["u,v,m,w"] * T2["n,c0,x,y"] * Eta1["y,v"] * Eta1["x,u"]; + C2["n,c0,m,w"] += + alpha * -0.25000000 * H2["u,v,m,w"] * T2["n,c0,x,y"] * Gamma1["y,v"] * Gamma1["x,u"]; + C2["n,c0,m,v"] += alpha * +0.50000000 * H2["u,e,m,v"] * T2["n,c0,w,e"] * Eta1["w,u"]; + C2["n,c0,m,u"] += alpha * +0.25000000 * H2["e,f,m,u"] * T2["n,c0,e,f"]; + C2["m,c0,n,x"] += + alpha * +1.00000000 * H2["m,u,n,v"] * T2["c0,w,x,y"] * Eta1["y,u"] * Gamma1["v,w"]; + C2["m,c0,n,x"] += + alpha * -1.00000000 * H2["m,u,n,v"] * T2["c0,w,x,y"] * Eta1["v,w"] * Gamma1["y,u"]; + C2["m,c0,n,w"] += alpha * +1.00000000 * H2["m,e,n,u"] * T2["c0,v,w,e"] * Gamma1["u,v"]; + C2["c0,c1,m,n"] += + alpha * +0.12500000 * H2["u,v,m,n"] * T2["c0,c1,w,x"] * Eta1["x,v"] * Eta1["w,u"]; + C2["c0,c1,m,n"] += + alpha * -0.12500000 * H2["u,v,m,n"] * T2["c0,c1,w,x"] * Gamma1["x,v"] * Gamma1["w,u"]; + C2["c0,c1,m,n"] += alpha * +0.25000000 * H2["u,e,m,n"] * T2["c0,c1,v,e"] * Eta1["v,u"]; + C2["c0,c1,m,n"] += alpha * +0.12500000 * H2["e,f,m,n"] * T2["c0,c1,e,f"]; + C2["m,n,u,e"] += alpha * +0.25000000 * H2["m,n,c0,c1"] * T2["c0,c1,u,e"]; + C2["m,c0,v,e"] += alpha * +1.00000000 * H2["m,u,n,v"] * T2["c0,n,w,e"] * Eta1["w,u"]; + C2["m,c0,u,f"] += alpha * -1.00000000 * H2["m,e,n,u"] * T2["c0,n,f,e"]; + C2["m,n,w,e"] += alpha * +0.50000000 * H2["m,n,c0,u"] * T2["c0,v,w,e"] * Gamma1["u,v"]; + C2["m,c0,v,e"] += alpha * +1.00000000 * H2["m,u,n,e"] * T2["c0,n,v,w"] * Eta1["w,u"]; + C2["m,c0,u,f"] += alpha * +1.00000000 * H2["m,e,n,f"] * T2["c0,n,u,e"]; + C2["m,n,v,e"] += + alpha * -1.00000000 * H2["m,u,v,w"] * T2["n,x,y,e"] * Eta1["y,u"] * Gamma1["w,x"]; + C2["m,n,v,e"] += + alpha * +1.00000000 * H2["m,u,v,w"] * T2["n,x,y,e"] * Eta1["w,x"] * Gamma1["y,u"]; + C2["m,n,u,f"] += alpha * +1.00000000 * H2["m,e,u,v"] * T2["n,w,f,e"] * Gamma1["v,w"]; + C2["m,n,w,e"] += + alpha * +0.25000000 * H2["u,v,w,e"] * T2["m,n,x,y"] * Eta1["y,v"] * Eta1["x,u"]; + C2["m,n,w,e"] += + alpha * -0.25000000 * H2["u,v,w,e"] * T2["m,n,x,y"] * Gamma1["y,v"] * Gamma1["x,u"]; + C2["m,n,v,f"] += alpha * +0.50000000 * H2["u,e,v,f"] * T2["m,n,w,e"] * Eta1["w,u"]; + C2["m,n,u,g"] += alpha * +0.25000000 * H2["e,f,u,g"] * T2["m,n,e,f"]; + C2["m,n,y,e"] += + alpha * -0.25000000 * H2["m,n,u,v"] * T2["w,x,y,e"] * Eta1["v,x"] * Eta1["u,w"]; + C2["m,n,y,e"] += + alpha * +0.25000000 * H2["m,n,u,v"] * T2["w,x,y,e"] * Gamma1["v,x"] * Gamma1["u,w"]; + C2["m,n,x,e"] += + alpha * +1.00000000 * H2["m,u,v,e"] * T2["n,w,x,y"] * Eta1["y,u"] * Gamma1["v,w"]; + C2["m,n,x,e"] += + alpha * -1.00000000 * H2["m,u,v,e"] * T2["n,w,x,y"] * Eta1["v,w"] * Gamma1["y,u"]; + C2["m,n,w,f"] += alpha * +1.00000000 * H2["m,e,u,f"] * T2["n,v,w,e"] * Gamma1["u,v"]; + C2["m,c1,n,e"] += alpha * -1.00000000 * H2["m,u,n,c0"] * T2["c1,c0,v,e"] * Eta1["v,u"]; + C2["m,c1,n,f"] += alpha * +1.00000000 * H2["m,e,n,c0"] * T2["c1,c0,f,e"]; + C2["m,c0,n,e"] += + alpha * -1.00000000 * H2["m,u,n,v"] * T2["c0,w,x,e"] * Eta1["x,u"] * Gamma1["v,w"]; + C2["m,c0,n,e"] += + alpha * +1.00000000 * H2["m,u,n,v"] * T2["c0,w,x,e"] * Eta1["v,w"] * Gamma1["x,u"]; + C2["m,c0,n,f"] += alpha * +1.00000000 * H2["m,e,n,u"] * T2["c0,v,f,e"] * Gamma1["u,v"]; + C2["n,c0,m,e"] += + alpha * +0.25000000 * H2["u,v,m,e"] * T2["n,c0,w,x"] * Eta1["x,v"] * Eta1["w,u"]; + C2["n,c0,m,e"] += + alpha * -0.25000000 * H2["u,v,m,e"] * T2["n,c0,w,x"] * Gamma1["x,v"] * Gamma1["w,u"]; + C2["n,c0,m,f"] += alpha * +0.50000000 * H2["u,e,m,f"] * T2["n,c0,v,e"] * Eta1["v,u"]; + C2["n,c0,m,g"] += alpha * +0.25000000 * H2["e,f,m,g"] * T2["n,c0,e,f"]; + C2["m,n,e,f"] += alpha * +0.12500000 * H2["m,n,c0,c1"] * T2["c0,c1,e,f"]; + C2["m,n,e,f"] += alpha * +0.25000000 * H2["m,n,c0,u"] * T2["c0,v,e,f"] * Gamma1["u,v"]; + C2["m,c0,e,f"] += alpha * +1.00000000 * H2["m,u,n,e"] * T2["c0,n,v,f"] * Eta1["v,u"]; + C2["m,c0,f,g"] += alpha * -1.00000000 * H2["m,e,n,f"] * T2["c0,n,g,e"]; + C2["m,n,e,f"] += + alpha * -0.12500000 * H2["m,n,u,v"] * T2["w,x,e,f"] * Eta1["v,x"] * Eta1["u,w"]; + C2["m,n,e,f"] += + alpha * +0.12500000 * H2["m,n,u,v"] * T2["w,x,e,f"] * Gamma1["v,x"] * Gamma1["u,w"]; + C2["m,n,e,f"] += + alpha * +1.00000000 * H2["m,u,v,e"] * T2["n,w,x,f"] * Eta1["x,u"] * Gamma1["v,w"]; + C2["m,n,e,f"] += + alpha * -1.00000000 * H2["m,u,v,e"] * T2["n,w,x,f"] * Eta1["v,w"] * Gamma1["x,u"]; + C2["m,n,f,g"] += alpha * -1.00000000 * H2["m,e,u,f"] * T2["n,v,g,e"] * Gamma1["u,v"]; + C2["m,n,e,f"] += + alpha * +0.12500000 * H2["u,v,e,f"] * T2["m,n,w,x"] * Eta1["x,v"] * Eta1["w,u"]; + C2["m,n,e,f"] += + alpha * -0.12500000 * H2["u,v,e,f"] * T2["m,n,w,x"] * Gamma1["x,v"] * Gamma1["w,u"]; + C2["m,n,f,g"] += alpha * +0.25000000 * H2["u,e,f,g"] * T2["m,n,v,e"] * Eta1["v,u"]; + C2["m,n,g,h"] += alpha * +0.12500000 * H2["e,f,g,h"] * T2["m,n,e,f"]; + C2["m,e,u,v"] += alpha * +0.25000000 * H2["m,e,n,c0"] * T2["n,c0,u,v"]; + C2["n,e,v,w"] += alpha * -1.00000000 * H2["u,e,m,v"] * T2["n,m,w,x"] * Eta1["x,u"]; + C2["n,e,u,v"] += alpha * +1.00000000 * H2["e,f,m,u"] * T2["n,m,v,f"]; + C2["m,e,w,x"] += alpha * +0.50000000 * H2["m,e,n,u"] * T2["n,v,w,x"] * Gamma1["u,v"]; + C2["m,e,v,y"] += + alpha * +1.00000000 * H2["u,e,v,w"] * T2["m,x,y,z"] * Eta1["z,u"] * Gamma1["w,x"]; + C2["m,e,v,y"] += + alpha * -1.00000000 * H2["u,e,v,w"] * T2["m,x,y,z"] * Eta1["w,x"] * Gamma1["z,u"]; + C2["m,e,u,x"] += alpha * -1.00000000 * H2["e,f,u,v"] * T2["m,w,x,f"] * Gamma1["v,w"]; + C2["c0,e,m,v"] += alpha * +1.00000000 * H2["u,e,m,n"] * T2["c0,n,v,w"] * Eta1["w,u"]; + C2["c0,e,m,u"] += alpha * -1.00000000 * H2["e,f,m,n"] * T2["c0,n,u,f"]; + C2["n,e,m,x"] += + alpha * +1.00000000 * H2["u,e,m,v"] * T2["n,w,x,y"] * Eta1["y,u"] * Gamma1["v,w"]; + C2["n,e,m,x"] += + alpha * -1.00000000 * H2["u,e,m,v"] * T2["n,w,x,y"] * Eta1["v,w"] * Gamma1["y,u"]; + C2["n,e,m,w"] += alpha * -1.00000000 * H2["e,f,m,u"] * T2["n,v,w,f"] * Gamma1["u,v"]; + C2["m,e,u,f"] += alpha * +0.50000000 * H2["m,e,n,c0"] * T2["n,c0,u,f"]; + C2["n,e,v,f"] += alpha * +1.00000000 * H2["u,e,m,v"] * T2["n,m,w,f"] * Eta1["w,u"]; + C2["n,e,u,g"] += alpha * +1.00000000 * H2["e,f,m,u"] * T2["n,m,g,f"]; + C2["m,e,w,f"] += alpha * +1.00000000 * H2["m,e,n,u"] * T2["n,v,w,f"] * Gamma1["u,v"]; + C2["n,e,v,f"] += alpha * +1.00000000 * H2["u,e,m,f"] * T2["n,m,v,w"] * Eta1["w,u"]; + C2["n,e,u,g"] += alpha * -1.00000000 * H2["e,f,m,g"] * T2["n,m,u,f"]; + C2["m,e,v,f"] += + alpha * -1.00000000 * H2["u,e,v,w"] * T2["m,x,y,f"] * Eta1["y,u"] * Gamma1["w,x"]; + C2["m,e,v,f"] += + alpha * +1.00000000 * H2["u,e,v,w"] * T2["m,x,y,f"] * Eta1["w,x"] * Gamma1["y,u"]; + C2["m,e,u,g"] += alpha * -1.00000000 * H2["e,f,u,v"] * T2["m,w,g,f"] * Gamma1["v,w"]; + C2["m,e,y,f"] += + alpha * -0.50000000 * H2["m,e,u,v"] * T2["w,x,y,f"] * Eta1["v,x"] * Eta1["u,w"]; + C2["m,e,y,f"] += + alpha * +0.50000000 * H2["m,e,u,v"] * T2["w,x,y,f"] * Gamma1["v,x"] * Gamma1["u,w"]; + C2["m,e,x,f"] += + alpha * +1.00000000 * H2["u,e,v,f"] * T2["m,w,x,y"] * Eta1["y,u"] * Gamma1["v,w"]; + C2["m,e,x,f"] += + alpha * -1.00000000 * H2["u,e,v,f"] * T2["m,w,x,y"] * Eta1["v,w"] * Gamma1["y,u"]; + C2["m,e,w,g"] += alpha * -1.00000000 * H2["e,f,u,g"] * T2["m,v,w,f"] * Gamma1["u,v"]; + C2["c0,e,m,f"] += alpha * -1.00000000 * H2["u,e,m,n"] * T2["c0,n,v,f"] * Eta1["v,u"]; + C2["c0,e,m,g"] += alpha * -1.00000000 * H2["e,f,m,n"] * T2["c0,n,g,f"]; + C2["n,e,m,f"] += + alpha * -1.00000000 * H2["u,e,m,v"] * T2["n,w,x,f"] * Eta1["x,u"] * Gamma1["v,w"]; + C2["n,e,m,f"] += + alpha * +1.00000000 * H2["u,e,m,v"] * T2["n,w,x,f"] * Eta1["v,w"] * Gamma1["x,u"]; + C2["n,e,m,g"] += alpha * -1.00000000 * H2["e,f,m,u"] * T2["n,v,g,f"] * Gamma1["u,v"]; + C2["m,e,f,g"] += alpha * +0.25000000 * H2["m,e,n,c0"] * T2["n,c0,f,g"]; + C2["m,e,f,g"] += alpha * +0.50000000 * H2["m,e,n,u"] * T2["n,v,f,g"] * Gamma1["u,v"]; + C2["n,e,f,g"] += alpha * +1.00000000 * H2["u,e,m,f"] * T2["n,m,v,g"] * Eta1["v,u"]; + C2["n,e,g,h"] += alpha * +1.00000000 * H2["e,f,m,g"] * T2["n,m,h,f"]; + C2["m,e,f,g"] += + alpha * -0.25000000 * H2["m,e,u,v"] * T2["w,x,f,g"] * Eta1["v,x"] * Eta1["u,w"]; + C2["m,e,f,g"] += + alpha * +0.25000000 * H2["m,e,u,v"] * T2["w,x,f,g"] * Gamma1["v,x"] * Gamma1["u,w"]; + C2["m,e,f,g"] += + alpha * +1.00000000 * H2["u,e,v,f"] * T2["m,w,x,g"] * Eta1["x,u"] * Gamma1["v,w"]; + C2["m,e,f,g"] += + alpha * -1.00000000 * H2["u,e,v,f"] * T2["m,w,x,g"] * Eta1["v,w"] * Gamma1["x,u"]; + C2["m,e,g,h"] += alpha * +1.00000000 * H2["e,f,u,g"] * T2["m,v,h,f"] * Gamma1["u,v"]; + C2["e,f,u,v"] += alpha * +0.12500000 * H2["e,f,m,n"] * T2["m,n,u,v"]; + C2["e,f,w,x"] += alpha * +0.25000000 * H2["e,f,m,u"] * T2["m,v,w,x"] * Gamma1["u,v"]; + C2["e,f,u,g"] += alpha * +0.25000000 * H2["e,f,m,n"] * T2["m,n,u,g"]; + C2["e,f,w,g"] += alpha * +0.50000000 * H2["e,f,m,u"] * T2["m,v,w,g"] * Gamma1["u,v"]; + C2["e,f,y,g"] += + alpha * -0.25000000 * H2["e,f,u,v"] * T2["w,x,y,g"] * Eta1["v,x"] * Eta1["u,w"]; + C2["e,f,y,g"] += + alpha * +0.25000000 * H2["e,f,u,v"] * T2["w,x,y,g"] * Gamma1["v,x"] * Gamma1["u,w"]; + C2["e,f,g,h"] += alpha * +0.12500000 * H2["e,f,m,n"] * T2["m,n,g,h"]; + C2["e,f,g,h"] += alpha * +0.25000000 * H2["e,f,m,u"] * T2["m,v,g,h"] * Gamma1["u,v"]; + C2["e,f,g,h"] += + alpha * -0.12500000 * H2["e,f,u,v"] * T2["w,x,g,h"] * Eta1["v,x"] * Eta1["u,w"]; + C2["e,f,g,h"] += + alpha * +0.12500000 * H2["e,f,u,v"] * T2["w,x,g,h"] * Gamma1["v,x"] * Gamma1["u,w"]; - if (print_ > 2) { - outfile -> Printf("\n Time for H2_T2_C2 : %12.3f", timer.get()); - } + // if (print_ > 2) { + // outfile -> Printf("\n Time for H2_T2_C2 : %12.3f", timer.get()); + //} } } // namespace forte \ No newline at end of file diff --git a/forte/register_forte_options.py b/forte/register_forte_options.py index f1b51152f..62940cd47 100644 --- a/forte/register_forte_options.py +++ b/forte/register_forte_options.py @@ -684,7 +684,9 @@ def register_dsrg_options(options): options.add_bool( "DSRG_DUMP_RELAXED_ENERGIES", False, "Dump the energies after each reference relaxation step to JSON." ) - + + options.add_bool("DO_WICKED", True, "Wick&d contraction") + options.add_bool("DO_EOM", False, "EOM-LDSRG(2).") options.add_int("TAYLOR_THRESHOLD", 3, "DSRG Taylor expansion threshold for small denominator") From afda9ec92db190967890cf30d7b1080736de3dcb Mon Sep 17 00:00:00 2001 From: Shuhang Li Date: Wed, 24 Apr 2024 10:43:50 -0400 Subject: [PATCH 09/55] Save. --- forte/mrdsrg-so/mrdsrg_so.cc | 42 +++++++++++++++++++++++------------- 1 file changed, 27 insertions(+), 15 deletions(-) diff --git a/forte/mrdsrg-so/mrdsrg_so.cc b/forte/mrdsrg-so/mrdsrg_so.cc index 2b785f5d7..007ecbd6a 100644 --- a/forte/mrdsrg-so/mrdsrg_so.cc +++ b/forte/mrdsrg-so/mrdsrg_so.cc @@ -685,8 +685,8 @@ double MRDSRG_SO::compute_eom() { /// Overlap matrix std::shared_ptr S = std::make_shared("EOM-S-sub", nh_, nh_); - // std::shared_ptr Sevec = std::make_shared("S-evec", nh_, nh_); - // std::shared_ptr Seval = std::make_shared("S-eval", nh_); + std::shared_ptr Sevec = std::make_shared("S-evec", nh_, nh_); + std::shared_ptr Seval = std::make_shared("S-eval", nh_); // std::shared_ptr Eevec = std::make_shared("E-evec", nh_, nh_); // std::shared_ptr Eeval = std::make_shared("E-eval", nh_); S->identity(); @@ -698,29 +698,41 @@ double MRDSRG_SO::compute_eom() { S->set(i[0] + 2 * ncore + nactv, i[1] + 2 * ncore + nactv, value); }); S->print(); - // S->diagonalize(Sevec, Seval); - auto Sevec = S->partial_cholesky_factorize(1e-10); - auto Seval = std::make_shared("S-eval", Sevec->rowdim()); + S->diagonalize(Sevec, Seval); + // auto Sevec = S->partial_cholesky_factorize(1e-10); + // auto Seval = std::make_shared("S-eval", Sevec->rowdim()); + + std::vector s_list; + for (size_t i = 0; i < Sevec->coldim(); i++) { + double value = abs(Seval->get(i)); + if (value > 1e-8) { + s_list.push_back(i); + } + } - // for (size_t i = 0; i < Sevec->coldim(); i++) { - // for (size_t j = 0; j < Sevec->rowdim(); j++) { - // double value = Sevec->get(j, i) / std::sqrt(Seval->get(i)); - // Sevec->set(j, i, value); - // } - // } + size_t num_s_list = s_list.size(); + + std::shared_ptr S_new = std::make_shared("S-new", nh_, num_s_list); + for (size_t i = 0; i < num_s_list; i++) { + psi::SharedVector temp = Sevec->get_column(0, s_list[i]); + temp->scale(1.0 / Seval->get(s_list[i])); + S_new->set_column(0, i, temp); + } + std::shared_ptr Eevec = std::make_shared("E-evec", nh_, num_s_list); + std::shared_ptr Eeval = std::make_shared("E-eval", num_s_list); - EOM_Hbar_mat_ = psi::linalg::triplet(Sevec, EOM_Hbar_mat_, Sevec, true, false, false); + EOM_Hbar_mat_ = psi::linalg::triplet(S_new, EOM_Hbar_mat_, S_new, true, false, false); - EOM_Hbar_mat_->diagonalize(Sevec, Seval); + EOM_Hbar_mat_->diagonalize(Eevec, Eeval); outfile->Printf("\n " "----------------------------------------------------------" "----------------------------------------"); outfile->Printf("\n\n\n EOM-DSRG "); - Seval->print(); + Eeval->print(); - return Seval->get(0); + return Eeval->get(0); } void MRDSRG_SO::compute_hbar() { From b445a9a4f9cbb537075ac5597f062ddfcb667352 Mon Sep 17 00:00:00 2001 From: Shuhang Li Date: Mon, 13 May 2024 23:04:51 -0400 Subject: [PATCH 10/55] Full effective Hamiltonian. --- forte/api/forte_python_module.cc | 15 ++ forte/mrdsrg-spin-integrated/master_mrdsrg.cc | 5 + forte/mrdsrg-spin-integrated/master_mrdsrg.h | 3 + forte/proc/dsrg.py | 157 ++++++++++++------ forte/pymodule.py | 126 +++++++++----- forte/register_forte_options.py | 2 + 6 files changed, 216 insertions(+), 92 deletions(-) diff --git a/forte/api/forte_python_module.cc b/forte/api/forte_python_module.cc index b22dd50d5..5af40b775 100644 --- a/forte/api/forte_python_module.cc +++ b/forte/api/forte_python_module.cc @@ -262,6 +262,19 @@ PYBIND11_MODULE(_forte, m) { }, "Return the cumulants of the RDMs in a spinorbital basis. Spinorbitals follow the ordering " "abab..."); + m.def( + "Heff_dict", + [](std::vector Heff) { + py::dict pyints; + for (const auto& int_ : Heff) { + auto labels = int_.block_labels(); + for (const auto& label : labels) { + pyints[py::str(label)] = ambit_to_np(int_.block(label)); + } + } + return pyints; + }, + "Return the full Heff in a dictionary"); // py::class_>(m, "ACI"); @@ -349,6 +362,8 @@ PYBIND11_MODULE(_forte, m) { .def("compute_gradient", &MASTER_DSRG::compute_gradient, "Compute the DSRG gradient") .def("compute_Heff_actv", &MASTER_DSRG::compute_Heff_actv, "Return the DSRG dressed ActiveSpaceIntegrals") + .def("compute_Heff_full", &MASTER_DSRG::compute_Heff_full, + "Return full transformed Hamiltonian") .def("deGNO_DMbar_actv", &MASTER_DSRG::deGNO_DMbar_actv, "Return the DSRG dressed dipole integrals") .def("nuclear_dipole", &MASTER_DSRG::nuclear_dipole, diff --git a/forte/mrdsrg-spin-integrated/master_mrdsrg.cc b/forte/mrdsrg-spin-integrated/master_mrdsrg.cc index dc023692e..da565015e 100644 --- a/forte/mrdsrg-spin-integrated/master_mrdsrg.cc +++ b/forte/mrdsrg-spin-integrated/master_mrdsrg.cc @@ -2282,4 +2282,9 @@ std::vector MASTER_DSRG::re_two_labels() { return labels; } + +std::vector MASTER_DSRG::compute_Heff_full() { + std::vector Heff = {Hbar1_, Hbar2_}; + return Heff; +} } // namespace forte diff --git a/forte/mrdsrg-spin-integrated/master_mrdsrg.h b/forte/mrdsrg-spin-integrated/master_mrdsrg.h index f290be991..85adcc663 100644 --- a/forte/mrdsrg-spin-integrated/master_mrdsrg.h +++ b/forte/mrdsrg-spin-integrated/master_mrdsrg.h @@ -48,6 +48,9 @@ class MASTER_DSRG : public DynamicCorrelationSolver { /// Compute DSRG transformed Hamiltonian virtual std::shared_ptr compute_Heff_actv(); + /// compute DSRG full transformed Hamiltonian + std::vector compute_Heff_full(); + /// De-normal-order DSRG transformed dipole moment std::vector deGNO_DMbar_actv(); diff --git a/forte/proc/dsrg.py b/forte/proc/dsrg.py index 26f650f88..85c5b237c 100644 --- a/forte/proc/dsrg.py +++ b/forte/proc/dsrg.py @@ -58,7 +58,8 @@ def __init__(self, active_space_solver, state_weights_map, mo_space_info, ints, self.do_semicanonical = options.get_bool("SEMI_CANONICAL") - self.do_multi_state = False if options.get_str("CALC_TYPE") == "SS" else True + self.do_multi_state = False if options.get_str( + "CALC_TYPE") == "SS" else True self.relax_ref = options.get_str("RELAX_REF") if self.relax_ref == "NONE" and self.do_multi_state: @@ -70,8 +71,10 @@ def __init__(self, active_space_solver, state_weights_map, mo_space_info, ints, if as_type == "CAS" and self.solver_type in ["SA-MRDSRG", "SA_MRDSRG"]: self.max_rdm_level = 2 else: - psi4.core.print_out(f"\n DSRG 3RDM direct algorithm only available for CAS/SA-MRDSRG") - psi4.core.print_out(f"\n Set DSRG_3RDM_ALGORITHM to 'EXPLICIT' (default)") + psi4.core.print_out( + f"\n DSRG 3RDM direct algorithm only available for CAS/SA-MRDSRG") + psi4.core.print_out( + f"\n Set DSRG_3RDM_ALGORITHM to 'EXPLICIT' (default)") options.set_str("DSRG_3RDM_ALGORITHM", "EXPLICIT") self.relax_convergence = float('inf') @@ -89,36 +92,45 @@ def __init__(self, active_space_solver, state_weights_map, mo_space_info, ints, self.relax_maxiter = options.get_int('MAXITER_RELAX_REF') self.relax_convergence = options.get_double("RELAX_E_CONVERGENCE") - self.save_relax_energies = options.get_bool("DSRG_DUMP_RELAXED_ENERGIES") + self.save_relax_energies = options.get_bool( + "DSRG_DUMP_RELAXED_ENERGIES") # Filter out levels for analytic gradients if options.get_str("DERTYPE") != "NONE": if self.relax_ref != 'NONE' or self.solver_type != 'DSRG-MRPT2': - raise NotImplementedError("Analytic energy gradients are only implemented for unrelaxed DSRG-MRPT2!") + raise NotImplementedError( + "Analytic energy gradients are only implemented for unrelaxed DSRG-MRPT2!") # Filter out some ms-dsrg algorithms ms_dsrg_algorithm = options.get_str("DSRG_MULTI_STATE") if self.do_multi_state and ("SA" not in ms_dsrg_algorithm): - raise NotImplementedError("MS or XMS is disabled due to the reconstruction.") + raise NotImplementedError( + "MS or XMS is disabled due to the reconstruction.") if ms_dsrg_algorithm == "SA_SUB" and self.relax_ref != 'ONCE': - raise NotImplementedError("SA_SUB only supports relax once at present. Relaxed SA density not implemented.") + raise NotImplementedError( + "SA_SUB only supports relax once at present. Relaxed SA density not implemented.") self.multi_state_type = ms_dsrg_algorithm # Filter out some methods for computing dipole moments do_dipole = options.get_bool("DSRG_DIPOLE") if do_dipole and (self.solver_type not in ["DSRG-MRPT2", "DSRG-MRPT3"]): do_dipole = False - psi4.core.print_out(f"\n Skip computation for dipole moment (not implemented for {self.solver_type})!") - warnings.warn(f"Dipole moment is not implemented for {self.solver_type}.", UserWarning) + psi4.core.print_out( + f"\n Skip computation for dipole moment (not implemented for {self.solver_type})!") + warnings.warn( + f"Dipole moment is not implemented for {self.solver_type}.", UserWarning) if do_dipole and self.do_multi_state: do_dipole = False - psi4.core.print_out("\n !DSRG transition dipoles are disabled temporarily.") - warnings.warn("DSRG transition dipoles are disabled temporarily.", UserWarning) + psi4.core.print_out( + "\n !DSRG transition dipoles are disabled temporarily.") + warnings.warn( + "DSRG transition dipoles are disabled temporarily.", UserWarning) self.do_dipole = do_dipole self.dipoles = [] self.max_dipole_level = options.get_int("DSRG_MAX_DIPOLE_LEVEL") - self.max_quadrupole_level = options.get_int("DSRG_MAX_QUADRUPOLE_LEVEL") + self.max_quadrupole_level = options.get_int( + "DSRG_MAX_QUADRUPOLE_LEVEL") # Set up Forte objects self.active_space_solver = active_space_solver @@ -138,7 +150,8 @@ def __init__(self, active_space_solver, state_weights_map, mo_space_info, ints, self.energies_environment = {} # energies pushed to Psi4 environment globals # Compute RDMs from initial ActiveSpaceSolver - self.rdms = active_space_solver.compute_average_rdms(state_weights_map, self.max_rdm_level, self.rdm_type) + self.rdms = active_space_solver.compute_average_rdms( + state_weights_map, self.max_rdm_level, self.rdm_type) # Save a copy CI vectors try: @@ -155,7 +168,8 @@ def __init__(self, active_space_solver, state_weights_map, mo_space_info, ints, def make_dsrg_solver(self): """ Make a DSRG solver. """ - args = (self.rdms, self.scf_info, self.options, self.ints, self.mo_space_info) + args = (self.rdms, self.scf_info, self.options, + self.ints, self.mo_space_info) if self.solver_type in ["MRDSRG", "DSRG-MRPT2", "DSRG-MRPT3", "THREE-DSRG-MRPT2"]: self.dsrg_solver = forte.make_dsrg_method(*args) @@ -205,9 +219,18 @@ def compute_energy(self): self.make_dsrg_solver() self.dsrg_setup() e_dsrg = self.dsrg_solver.compute_energy() + + ################ + if self.options.get_bool('FULL_HBAR'): + Heff = self.dsrg_solver.compute_Heff_full() + Heff_dict = forte.Heff_dict(Heff) + print(Heff_dict) + ################ + psi4.core.set_scalar_variable("UNRELAXED ENERGY", e_dsrg) - self.energies_environment[0] = {k: v for k, v in psi4.core.variables().items() if 'ROOT' in k} + self.energies_environment[0] = { + k: v for k, v in psi4.core.variables().items() if 'ROOT' in k} # Spit out energy if reference relaxation not implemented if not self.Heff_implemented: @@ -227,7 +250,8 @@ def compute_energy(self): if self.options.get_str('ACTIVE_SPACE_SOLVER') == 'EXTERNAL': state_map = forte.to_state_nroots_map(self.state_weights_map) - write_external_active_space_file(ints_dressed, state_map, self.mo_space_info, "dsrg_ints.json") + write_external_active_space_file( + ints_dressed, state_map, self.mo_space_info, "dsrg_ints.json") msg = 'External solver: save DSRG dressed integrals to dsrg_ints.json' print(msg) psi4.core.print_out(msg) @@ -236,13 +260,15 @@ def compute_energy(self): active_space_solver_2 = forte.make_active_space_solver( self.options.get_str('EXT_RELAX_SOLVER'), state_map, self.scf_info, self.mo_space_info, ints_dressed, self.options) active_space_solver_2.set_Uactv(self.Ua, self.Ub) - e_relax = list(active_space_solver_2.compute_energy().values())[0][0] + e_relax = list( + active_space_solver_2.compute_energy().values())[0][0] self.energies.append((e_dsrg, e_relax)) break - + if self.do_multi_state and self.options.get_bool("SAVE_SA_DSRG_INTS"): state_map = forte.to_state_nroots_map(self.state_weights_map) - write_external_active_space_file(ints_dressed, state_map, self.mo_space_info, "dsrg_ints.json") + write_external_active_space_file( + ints_dressed, state_map, self.mo_space_info, "dsrg_ints.json") msg = '\n\nSave SA-DSRG dressed integrals to dsrg_ints.json\n\n' print(msg) psi4.core.print_out(msg) @@ -250,8 +276,10 @@ def compute_energy(self): # Spit out contracted SA-DSRG energy if self.do_multi_state and self.multi_state_type == "SA_SUB": max_rdm_level = 3 if self.options.get_bool("FORM_HBAR3") else 2 - state_energies_list = self.active_space_solver.compute_contracted_energy(ints_dressed, max_rdm_level) - e_relax = forte.compute_average_state_energy(state_energies_list, self.state_weights_map) + state_energies_list = self.active_space_solver.compute_contracted_energy( + ints_dressed, max_rdm_level) + e_relax = forte.compute_average_state_energy( + state_energies_list, self.state_weights_map) self.energies.append((e_dsrg, e_relax)) break @@ -266,7 +294,8 @@ def compute_energy(self): if self.max_dipole_level > 0: self.active_space_solver.compute_dipole_moment(asmpints) if self.max_quadrupole_level > 0: - self.active_space_solver.compute_quadrupole_moment(asmpints); + self.active_space_solver.compute_quadrupole_moment( + asmpints) if self.max_dipole_level > 0: self.active_space_solver.compute_fosc_same_orbs(asmpints) @@ -276,7 +305,8 @@ def compute_energy(self): self.reorder_weights(state_ci_wfn_map) self.state_ci_wfn_map = state_ci_wfn_map - e_relax = forte.compute_average_state_energy(state_energies_list, self.state_weights_map) + e_relax = forte.compute_average_state_energy( + state_energies_list, self.state_weights_map) self.energies.append((e_dsrg, e_relax)) # Compute relaxed dipole @@ -289,7 +319,8 @@ def compute_energy(self): self.dipoles.append((dm_u, dm_r)) # Save energies that have been pushed to Psi4 environment - self.energies_environment[n + 1] = {k: v for k, v in psi4.core.variables().items() if 'ROOT' in k} + self.energies_environment[n + 1] = {k: v for k, + v in psi4.core.variables().items() if 'ROOT' in k} self.energies_environment[n + 1]["DSRG FIXED"] = e_dsrg self.energies_environment[n + 1]["DSRG RELAXED"] = e_relax @@ -331,7 +362,8 @@ def compute_energy(self): # - Compute the DSRG energy self.make_dsrg_solver() self.dsrg_setup() - self.dsrg_solver.set_read_cwd_amps(not self.restart_amps) # don't read from cwd if checkpoint available + # don't read from cwd if checkpoint available + self.dsrg_solver.set_read_cwd_amps(not self.restart_amps) e_dsrg = self.dsrg_solver.compute_energy() self.dsrg_cleanup() @@ -339,7 +371,8 @@ def compute_energy(self): # dump reference relaxation energies to json file if self.save_relax_energies: with open('dsrg_relaxed_energies.json', 'w') as w: - json.dump(self.energies_environment, w, sort_keys=True, indent=4) + json.dump(self.energies_environment, + w, sort_keys=True, indent=4) e_current = e_dsrg if len(self.energies) == 0 else e_relax psi4.core.set_scalar_variable("CURRENT ENERGY", e_current) @@ -352,7 +385,8 @@ def compute_gradient(self, ci_vectors): :param ci_vectors: the wave functions (vector of ambit::Tensor) from an ActiveSpaceSolver """ if self.dsrg_solver is None: - raise ValueError("Please compute energy before calling compute_gradient") + raise ValueError( + "Please compute energy before calling compute_gradient") self.dsrg_solver.set_ci_vectors(ci_vectors) self.dsrg_solver.compute_gradient() @@ -362,7 +396,8 @@ def compute_dipole_relaxed(self): dipole_moments = self.dsrg_solver.nuclear_dipole() dipole_dressed = self.dsrg_solver.deGNO_DMbar_actv() for i in range(3): - dipole_moments[i] += dipole_dressed[i].contract_with_rdms(self.rdms) + dipole_moments[i] += dipole_dressed[i].contract_with_rdms( + self.rdms) dm_total = math.sqrt(sum([i * i for i in dipole_moments])) dipole_moments.append(dm_total) return dipole_moments @@ -409,20 +444,23 @@ def reorder_weights(self, state_ci_wfn_map): continue # compute overlap between two sets of CI vectors - overlap = psi4.core.doublet(state_ci_wfn_map[state], self.state_ci_wfn_map[state], True, False) + overlap = psi4.core.doublet( + state_ci_wfn_map[state], self.state_ci_wfn_map[state], True, False) overlap.name = f"CI Overlap of {state}" # check overlap and determine if we need to permute states overlap_np = np.abs(overlap.to_array()) max_values = np.max(overlap_np, axis=1) permutation = np.argmax(overlap_np, axis=1) - check_pass = len(permutation) == len(set(permutation)) and np.all(max_values > 0.5) + check_pass = len(permutation) == len( + set(permutation)) and np.all(max_values > 0.5) if not check_pass: msg = "Relaxed states are likely wrong. Please increase the number of roots." warnings.warn(f"{msg}", UserWarning) psi4.core.print_out(f"\n\n Forte Warning: {msg}") - psi4.core.print_out(f"\n\n ==> Overlap of CI Vectors <==\n\n") + psi4.core.print_out( + f"\n\n ==> Overlap of CI Vectors <==\n\n") overlap.print_out() else: if list(permutation) == list(range(len(permutation))): @@ -440,13 +478,15 @@ def reorder_weights(self, state_ci_wfn_map): psi4.core.print_out(f"\n {'-' * 24}") for i, w_old in enumerate(weights_old): w_new = weights_new[i] - psi4.core.print_out(f"\n {i:4d} {w_old:9.3e} {w_new:9.3e}") + psi4.core.print_out( + f"\n {i:4d} {w_old:9.3e} {w_new:9.3e}") psi4.core.print_out(f"\n {'-' * 24}\n") # try to fix ms < 0 if twice_ms > 0: state_spin = forte.StateInfo( - state.nb(), state.na(), state.multiplicity(), -twice_ms, state.irrep(), state.irrep_label(), + state.nb(), state.na(), state.multiplicity(), - + twice_ms, state.irrep(), state.irrep_label(), state.gas_min(), state.gas_max() ) if state_spin in self.state_weights_map: @@ -458,7 +498,8 @@ def print_summary(self): return if (not self.do_multi_state) or self.relax_maxiter > 1: - psi4.core.print_out(f"\n\n => {self.solver_type} Reference Relaxation Energy Summary <=\n") + psi4.core.print_out( + f"\n\n => {self.solver_type} Reference Relaxation Energy Summary <=\n") indent = ' ' * 4 dash = '-' * 71 title = f"{indent}{' ':5} {'Fixed Ref. (a.u.)':>31} {'Relaxed Ref. (a.u.)':>31}\n" @@ -470,27 +511,33 @@ def print_summary(self): for n, pair in enumerate(self.energies, 1): e0, e1 = pair e0_diff, e1_diff = e0 - e0_old, e1 - e1_old - psi4.core.print_out(f"\n{indent}{n:>5} {e0:>20.12f} {e0_diff:>10.3e} {e1:>20.12f} {e1_diff:>10.3e}") + psi4.core.print_out( + f"\n{indent}{n:>5} {e0:>20.12f} {e0_diff:>10.3e} {e1:>20.12f} {e1_diff:>10.3e}") e0_old, e1_old = e0, e1 psi4.core.print_out(f"\n{indent}{dash}") def print_dipole(name, dipole_xyzt): out = f"\n {self.solver_type} {name.lower()} dipole moment:" - out += "\n X: {:10.6f} Y: {:10.6f} Z: {:10.6f} Total: {:10.6f}\n".format(*dipole_xyzt) + out += "\n X: {:10.6f} Y: {:10.6f} Z: {:10.6f} Total: {:10.6f}\n".format( + *dipole_xyzt) return out if self.do_dipole and (not self.do_multi_state): - psi4.core.print_out(f"\n\n => {self.solver_type} Reference Relaxation Dipole Summary <=\n") + psi4.core.print_out( + f"\n\n => {self.solver_type} Reference Relaxation Dipole Summary <=\n") psi4.core.print_out(print_dipole("unrelaxed", self.dipoles[0][0])) - psi4.core.print_out(print_dipole("partially relaxed", self.dipoles[0][1])) + psi4.core.print_out(print_dipole( + "partially relaxed", self.dipoles[0][1])) if self.relax_maxiter > 1: - psi4.core.print_out(print_dipole("relaxed", self.dipoles[1][0])) + psi4.core.print_out(print_dipole( + "relaxed", self.dipoles[1][0])) if self.relax_ref == "ITERATE" and self.converged: - psi4.core.print_out(print_dipole("fully relaxed", self.dipoles[-1][1])) + psi4.core.print_out(print_dipole( + "fully relaxed", self.dipoles[-1][1])) def push_to_psi4_environment(self): """ Push results to Psi4 environment. """ @@ -498,24 +545,34 @@ def push_to_psi4_environment(self): return psi4.core.set_scalar_variable('UNRELAXED ENERGY', self.energies[0][0]) - psi4.core.set_scalar_variable('PARTIALLY RELAXED ENERGY', self.energies[0][1]) + psi4.core.set_scalar_variable( + 'PARTIALLY RELAXED ENERGY', self.energies[0][1]) if self.do_dipole and (not self.do_multi_state): - psi4.core.set_scalar_variable('UNRELAXED DIPOLE', self.dipoles[0][0][-1]) - psi4.core.set_scalar_variable('PARTIALLY RELAXED DIPOLE', self.dipoles[0][1][-1]) + psi4.core.set_scalar_variable( + 'UNRELAXED DIPOLE', self.dipoles[0][0][-1]) + psi4.core.set_scalar_variable( + 'PARTIALLY RELAXED DIPOLE', self.dipoles[0][1][-1]) if self.relax_maxiter > 1: - psi4.core.set_scalar_variable('RELAXED ENERGY', self.energies[1][0]) + psi4.core.set_scalar_variable( + 'RELAXED ENERGY', self.energies[1][0]) if self.do_dipole and (not self.do_multi_state): - psi4.core.set_scalar_variable('RELAXED DIPOLE', self.dipoles[1][0][-1]) + psi4.core.set_scalar_variable( + 'RELAXED DIPOLE', self.dipoles[1][0][-1]) if self.relax_ref == "ITERATE": if not self.converged: - psi4.core.set_scalar_variable('CURRENT UNRELAXED ENERGY', self.energies[-1][0]) - psi4.core.set_scalar_variable('CURRENT RELAXED ENERGY', self.energies[-1][1]) - raise psi4.p4util.PsiException(f"DSRG relaxation does not converge in {self.relax_maxiter} cycles") + psi4.core.set_scalar_variable( + 'CURRENT UNRELAXED ENERGY', self.energies[-1][0]) + psi4.core.set_scalar_variable( + 'CURRENT RELAXED ENERGY', self.energies[-1][1]) + raise psi4.p4util.PsiException( + f"DSRG relaxation does not converge in {self.relax_maxiter} cycles") else: - psi4.core.set_scalar_variable('FULLY RELAXED ENERGY', self.energies[-1][1]) + psi4.core.set_scalar_variable( + 'FULLY RELAXED ENERGY', self.energies[-1][1]) if self.do_dipole and (not self.do_multi_state): - psi4.core.set_scalar_variable('FULLY RELAXED DIPOLE', self.dipoles[-1][1][-1]) + psi4.core.set_scalar_variable( + 'FULLY RELAXED DIPOLE', self.dipoles[-1][1][-1]) diff --git a/forte/pymodule.py b/forte/pymodule.py index a7d62e149..1084d9076 100644 --- a/forte/pymodule.py +++ b/forte/pymodule.py @@ -74,7 +74,8 @@ def run_psi4_ref(ref_type, molecule, print_warning=False, **kwargs): elif ref_type in ['casscf', 'rasscf']: wfn = psi4.proc.run_detcas(ref_type, molecule=molecule, **kwargs) else: - raise ValueError(f"Invalid REF_TYPE: {ref_type.upper()} not available!") + raise ValueError( + f"Invalid REF_TYPE: {ref_type.upper()} not available!") return wfn @@ -157,7 +158,8 @@ def prepare_psi4_ref_wfn(options, **kwargs): # no warning printing for MCSCF job_type = options.get_str('JOB_TYPE') - do_mcscf = (job_type in ["CASSCF", "MCSCF_TWO_STEP"] or options.get_bool("CASSCF_REFERENCE")) + do_mcscf = (job_type in ["CASSCF", "MCSCF_TWO_STEP"] + or options.get_bool("CASSCF_REFERENCE")) # run Psi4 SCF or MCSCF ref_wfn = run_psi4_ref(ref_type, molecule, not do_mcscf, **kwargs) @@ -190,7 +192,8 @@ def prepare_psi4_ref_wfn(options, **kwargs): msg = "Invalid orbitals: different basis set / molecule! Check output for more." raise ValueError(msg) - new_S = psi4.core.Wavefunction.build(molecule, options.get_str("BASIS")).S() + new_S = psi4.core.Wavefunction.build( + molecule, options.get_str("BASIS")).S() if check_MO_orthonormality(new_S, Ca): wfn_new = ref_wfn @@ -202,7 +205,8 @@ def prepare_psi4_ref_wfn(options, **kwargs): else: p4print("\n Perform new SCF at current geometry ...\n") - kwargs_copy = {k: v for k, v in kwargs.items() if k != 'ref_wfn'} + kwargs_copy = {k: v for k, + v in kwargs.items() if k != 'ref_wfn'} wfn_new = run_psi4_ref('scf', molecule, False, **kwargs_copy) # orthonormalize orbitals @@ -224,7 +228,8 @@ def prepare_psi4_ref_wfn(options, **kwargs): wfn_new.set_basisset('DF_BASIS_MP2', aux_basis) if options.get_str('MINAO_BASIS'): - minao_basis = psi4.core.BasisSet.build(molecule, 'MINAO_BASIS', options.get_str('MINAO_BASIS')) + minao_basis = psi4.core.BasisSet.build( + molecule, 'MINAO_BASIS', options.get_str('MINAO_BASIS')) wfn_new.set_basisset('MINAO_BASIS', minao_basis) return wfn_new, mo_space_info @@ -281,7 +286,8 @@ def make_state_info_from_fcidump(fcidump, options): twice_ms = int(round(2.0 * options.get_double("MS"))) if (((nel - twice_ms) % 2) != 0): - raise Exception(f'Forte: the value of MS ({twice_ms}/2) is incompatible with the number of electrons ({nel})') + raise Exception( + f'Forte: the value of MS ({twice_ms}/2) is incompatible with the number of electrons ({nel})') na = (nel + twice_ms) // 2 nb = nel - na @@ -296,10 +302,12 @@ def make_state_info_from_fcidump(fcidump, options): def prepare_forte_objects_from_fcidump(options, path='.'): fcidump_file = options.get_str('FCIDUMP_FILE') filename = pathlib.Path(path) / fcidump_file - psi4.core.print_out(f'\n Reading integral information from FCIDUMP file {filename}') + psi4.core.print_out( + f'\n Reading integral information from FCIDUMP file {filename}') fcidump = forte.proc.fcidump_from_file(filename, convert_to_psi4=True) - irrep_size = {'c1': 1, 'ci': 2, 'c2': 2, 'cs': 2, 'd2': 4, 'c2v': 4, 'c2h': 4, 'd2h': 8} + irrep_size = {'c1': 1, 'ci': 2, 'c2': 2, 'cs': 2, + 'd2': 4, 'c2v': 4, 'c2h': 4, 'd2h': 8} nmo = len(fcidump['orbsym']) if 'pntgrp' in fcidump: @@ -333,7 +341,8 @@ def prepare_forte_objects_from_fcidump(options, path='.'): doccpi = options.get_int_list('FCIDUMP_DOCC') soccpi = options.get_int_list('FCIDUMP_SOCC') if len(doccpi) + len(soccpi) == 0: - print('Reading a FCIDUMP file that uses symmetry but no DOCC and SOCC is specified.') + print( + 'Reading a FCIDUMP file that uses symmetry but no DOCC and SOCC is specified.') print('Use the FCIDUMP_DOCC and FCIDUMP_SOCC options to specify the number of occupied orbitals per irrep.') doccpi = psi4.core.Dimension([0] * nirrep) soccpi = psi4.core.Dimension([0] * nirrep) @@ -389,7 +398,8 @@ def make_ints_from_fcidump(fcidump, options, mo_space_info): eri_bb -= np.einsum('iljk->ijkl', eri) return forte.make_custom_ints( - options, mo_space_info, fcidump['enuc'], fcidump['hcore'].flatten(), fcidump['hcore'].flatten(), + options, mo_space_info, fcidump['enuc'], fcidump['hcore'].flatten( + ), fcidump['hcore'].flatten(), eri_aa.flatten(), eri_ab.flatten(), eri_bb.flatten() ) @@ -435,16 +445,20 @@ def prepare_forte_objects(options, name, **kwargs): if 'FCIDUMP' in options.get_str('INT_TYPE'): if 'FIRST' in options.get_str('DERTYPE'): - raise Exception("Energy gradients NOT available for custom integrals!") + raise Exception( + "Energy gradients NOT available for custom integrals!") - psi4.core.print_out('\n Preparing forte objects from a custom source\n') + psi4.core.print_out( + '\n Preparing forte objects from a custom source\n') forte_objects = prepare_forte_objects_from_fcidump(options) state_weights_map, mo_space_info, scf_info, fcidump = forte_objects ref_wfn = None else: - psi4.core.print_out('\n\n Preparing forte objects from a Psi4 Wavefunction object') + psi4.core.print_out( + '\n\n Preparing forte objects from a Psi4 Wavefunction object') ref_wfn, mo_space_info = prepare_psi4_ref_wfn(options, **kwargs) - forte_objects = prepare_forte_objects_from_psi4_wfn(options, ref_wfn, mo_space_info) + forte_objects = prepare_forte_objects_from_psi4_wfn( + options, ref_wfn, mo_space_info) state_weights_map, mo_space_info, scf_info = forte_objects fcidump = None @@ -468,13 +482,15 @@ def forte_driver(state_weights_map, scf_info, options, ints, mo_space_info): # create an active space solver object and compute the energy active_space_solver_type = options.get_str('ACTIVE_SPACE_SOLVER') - as_ints = forte.make_active_space_ints(mo_space_info, ints, "ACTIVE", ["RESTRICTED_DOCC"]) + as_ints = forte.make_active_space_ints( + mo_space_info, ints, "ACTIVE", ["RESTRICTED_DOCC"]) active_space_solver = forte.make_active_space_solver( active_space_solver_type, state_map, scf_info, mo_space_info, as_ints, options ) if active_space_solver_type == 'EXTERNAL': - write_external_active_space_file(as_ints, state_map, mo_space_info, "as_ints.json") + write_external_active_space_file( + as_ints, state_map, mo_space_info, "as_ints.json") msg = 'External solver: save active space integrals to as_ints.json' print(msg) psi4.core.print_out(msg) @@ -490,17 +506,20 @@ def forte_driver(state_weights_map, scf_info, options, ints, mo_space_info): if options.get_bool("WRITE_RDM"): max_rdm_level = 3 # TODO allow the user to change this variable - write_external_rdm_file(active_space_solver, state_weights_map, max_rdm_level) + write_external_rdm_file(active_space_solver, + state_weights_map, max_rdm_level) if options.get_bool('SPIN_ANALYSIS'): - rdms = active_space_solver.compute_average_rdms(state_weights_map, 2, forte.RDMsType.spin_dependent) + rdms = active_space_solver.compute_average_rdms( + state_weights_map, 2, forte.RDMsType.spin_dependent) forte.perform_spin_analysis(rdms, options, mo_space_info, as_ints) # solver for dynamical correlation from DSRG correlation_solver_type = options.get_str('CORRELATION_SOLVER') if correlation_solver_type != 'NONE': - dsrg_proc = ProcedureDSRG(active_space_solver, state_weights_map, mo_space_info, ints, options, scf_info) + dsrg_proc = ProcedureDSRG( + active_space_solver, state_weights_map, mo_space_info, ints, options, scf_info) return_en = dsrg_proc.compute_energy() dsrg_proc.print_summary() dsrg_proc.push_to_psi4_environment() @@ -511,13 +530,15 @@ def forte_driver(state_weights_map, scf_info, options, ints, mo_space_info): # DSRG reads consistent CI coefficients before and after SemiCanonical class. # 2. This is OK only when running ground-state calculations state = list(state_map.keys())[0] - psi4.core.print_out(f"\n ==> Coupling Coefficients for {state} <==") + psi4.core.print_out( + f"\n ==> Coupling Coefficients for {state} <==") ci_vectors = active_space_solver.eigenvectors(state) dsrg_proc.compute_gradient(ci_vectors) else: psi4.core.print_out('\n Semicanonical orbitals must be used!\n') else: - average_energy = forte.compute_average_state_energy(state_energies_list, state_weights_map) + average_energy = forte.compute_average_state_energy( + state_energies_list, state_weights_map) return_en = average_energy return return_en @@ -576,7 +597,8 @@ def run_forte(name, **kwargs): # Rotate orbitals before computation (e.g. localization, MP2 natural orbitals, etc.) orb_type = options.get_str("ORBITAL_TYPE") if orb_type != 'CANONICAL': - orb_t = forte.make_orbital_transformation(orb_type, scf_info, options, ints, mo_space_info) + orb_t = forte.make_orbital_transformation( + orb_type, scf_info, options, ints, mo_space_info) orb_t.compute_transformation() Ua = orb_t.get_Ua() Ub = orb_t.get_Ub() @@ -592,30 +614,37 @@ def run_forte(name, **kwargs): if (options.get_bool("CASSCF_REFERENCE") or job_type == "CASSCF"): if options.get_str('INT_TYPE') == 'FCIDUMP': - raise Exception('Forte: the CASSCF code cannot use integrals read from a FCIDUMP file') + raise Exception( + 'Forte: the CASSCF code cannot use integrals read from a FCIDUMP file') - casscf = forte.make_casscf(state_weights_map, scf_info, options, mo_space_info, ints) + casscf = forte.make_casscf( + state_weights_map, scf_info, options, mo_space_info, ints) energy = casscf.compute_energy() if (job_type == "MCSCF_TWO_STEP"): - casscf = forte.make_mcscf_two_step(state_weights_map, scf_info, options, mo_space_info, ints) + casscf = forte.make_mcscf_two_step( + state_weights_map, scf_info, options, mo_space_info, ints) energy = casscf.compute_energy() - + if (job_type == "TDCI"): state = forte.make_state_info_from_psi(options) - as_ints = forte.make_active_space_ints(mo_space_info, ints, "ACTIVE", ["RESTRICTED_DOCC"]) + as_ints = forte.make_active_space_ints( + mo_space_info, ints, "ACTIVE", ["RESTRICTED_DOCC"]) state_map = forte.to_state_nroots_map(state_weights_map) active_space_method = forte.make_active_space_method( - "ACI", state, options.get_int("NROOT"), scf_info, mo_space_info, as_ints, options + "ACI", state, options.get_int( + "NROOT"), scf_info, mo_space_info, as_ints, options ) active_space_method.set_quiet_mode(True) active_space_method.compute_energy() - tdci = forte.TDCI(active_space_method, scf_info, options, mo_space_info, as_ints) + tdci = forte.TDCI(active_space_method, scf_info, + options, mo_space_info, as_ints) energy = tdci.compute_energy() if (job_type == 'NEWDRIVER'): - energy = forte_driver(state_weights_map, scf_info, options, ints, mo_space_info) + energy = forte_driver(state_weights_map, scf_info, + options, ints, mo_space_info) elif (job_type == 'MR-DSRG-PT2'): energy = mr_dsrg_pt2(job_type, forte_objects, ints, options) @@ -626,15 +655,19 @@ def run_forte(name, **kwargs): psi4.core.set_scalar_variable('CURRENT ENERGY', energy) - psi4.core.print_out(f'\n\n Time to prepare integrals: {start - start_pre_ints:12.3f} seconds') - psi4.core.print_out(f'\n Time to run job : {end - start:12.3f} seconds') - psi4.core.print_out(f'\n Total : {end - start_pre_ints:12.3f} seconds\n') + psi4.core.print_out( + f'\n\n Time to prepare integrals: {start - start_pre_ints:12.3f} seconds') + psi4.core.print_out( + f'\n Time to run job : {end - start:12.3f} seconds') + psi4.core.print_out( + f'\n Total : {end - start_pre_ints:12.3f} seconds\n') if 'FCIDUMP' not in options.get_str('INT_TYPE'): if options.get_bool('DUMP_ORBITALS'): dump_orbitals(ref_wfn) return ref_wfn + def mr_dsrg_pt2(job_type, forte_objects, ints, options): """ Driver to perform a MCSRGPT2_MO computation. @@ -653,11 +686,14 @@ def mr_dsrg_pt2(job_type, forte_objects, ints, options): if actv_type == "CIS" or actv_type == "CISD": raise Exception('Forte: VCIS/VCISD is not supported for MR-DSRG-PT2') max_rdm_level = 2 if options.get_str("THREEPDC") == "ZERO" else 3 - as_ints = forte.make_active_space_ints(mo_space_info, ints, "ACTIVE", ["RESTRICTED_DOCC"]) - ci = forte.make_active_space_solver(cas_type, state_map, scf_info, mo_space_info, as_ints, options) + as_ints = forte.make_active_space_ints( + mo_space_info, ints, "ACTIVE", ["RESTRICTED_DOCC"]) + ci = forte.make_active_space_solver( + cas_type, state_map, scf_info, mo_space_info, as_ints, options) ci.compute_energy() - rdms = ci.compute_average_rdms(state_weights_map, max_rdm_level, forte.RDMsType.spin_dependent) + rdms = ci.compute_average_rdms( + state_weights_map, max_rdm_level, forte.RDMsType.spin_dependent) semi = forte.SemiCanonical(mo_space_info, ints, options) semi.semicanonicalize(rdms) @@ -707,19 +743,22 @@ def gradient_forte(name, **kwargs): # Rotate orbitals before computation orb_type = options.get_str("ORBITAL_TYPE") if orb_type != 'CANONICAL': - orb_t = forte.make_orbital_transformation(orb_type, scf_info, options, ints, mo_space_info) + orb_t = forte.make_orbital_transformation( + orb_type, scf_info, options, ints, mo_space_info) orb_t.compute_transformation() Ua = orb_t.get_Ua() Ub = orb_t.get_Ub() ints.rotate_orbitals(Ua, Ub) if job_type == "CASSCF": - casscf = forte.make_casscf(state_weights_map, scf_info, options, mo_space_info, ints) + casscf = forte.make_casscf( + state_weights_map, scf_info, options, mo_space_info, ints) energy = casscf.compute_energy() casscf.compute_gradient() if job_type == "MCSCF_TWO_STEP": - casscf = forte.make_mcscf_two_step(state_weights_map, scf_info, options, mo_space_info, ints) + casscf = forte.make_mcscf_two_step( + state_weights_map, scf_info, options, mo_space_info, ints) energy = casscf.compute_energy() if job_type == 'NEWDRIVER' and correlation_solver == 'DSRG-MRPT2': @@ -746,13 +785,16 @@ def gradient_forte(name, **kwargs): # Print timings psi4.core.print_out('\n\n ==> Forte Timings <==\n') times = [ - ('prepare integrals', start - time_pre_ints), ('run forte energy', time_pre_deriv - start), + ('prepare integrals', start - + time_pre_ints), ('run forte energy', time_pre_deriv - start), ('compute derivative integrals', end - time_pre_deriv) ] max_key_size = max(len(k) for k, v in times) for key, value in times: - psi4.core.print_out(f'\n Time to {key:{max_key_size}} : {value:12.3f} seconds') - psi4.core.print_out(f'\n {"Total":{max_key_size + 8}} : {end - time_pre_ints:12.3f} seconds\n') + psi4.core.print_out( + f'\n Time to {key:{max_key_size}} : {value:12.3f} seconds') + psi4.core.print_out( + f'\n {"Total":{max_key_size + 8}} : {end - time_pre_ints:12.3f} seconds\n') # Dump orbitals if needed if options.get_bool('DUMP_ORBITALS'): diff --git a/forte/register_forte_options.py b/forte/register_forte_options.py index 62940cd47..789c351b6 100644 --- a/forte/register_forte_options.py +++ b/forte/register_forte_options.py @@ -688,6 +688,8 @@ def register_dsrg_options(options): options.add_bool("DO_WICKED", True, "Wick&d contraction") options.add_bool("DO_EOM", False, "EOM-LDSRG(2).") + + options.add_bool("FULL_HBAR", False, "get full Hbar.") options.add_int("TAYLOR_THRESHOLD", 3, "DSRG Taylor expansion threshold for small denominator") From 973af441d242bb0c2ae7ba543d7644bf22cf85ad Mon Sep 17 00:00:00 2001 From: Shuhang Li Date: Tue, 14 May 2024 14:42:24 -0400 Subject: [PATCH 11/55] Save. --- forte/proc/dsrg.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/forte/proc/dsrg.py b/forte/proc/dsrg.py index 85c5b237c..89af1a1f7 100644 --- a/forte/proc/dsrg.py +++ b/forte/proc/dsrg.py @@ -220,13 +220,6 @@ def compute_energy(self): self.dsrg_setup() e_dsrg = self.dsrg_solver.compute_energy() - ################ - if self.options.get_bool('FULL_HBAR'): - Heff = self.dsrg_solver.compute_Heff_full() - Heff_dict = forte.Heff_dict(Heff) - print(Heff_dict) - ################ - psi4.core.set_scalar_variable("UNRELAXED ENERGY", e_dsrg) self.energies_environment[0] = { @@ -366,6 +359,13 @@ def compute_energy(self): self.dsrg_solver.set_read_cwd_amps(not self.restart_amps) e_dsrg = self.dsrg_solver.compute_energy() + ################ + if self.options.get_bool('FULL_HBAR'): + Heff = self.dsrg_solver.compute_Heff_full() + Heff_dict = forte.Heff_dict(Heff) + np.savez('save_Hbar', **Heff_dict) + ################ + self.dsrg_cleanup() # dump reference relaxation energies to json file From a38b37d910489406194449824c581a8ba3a98445 Mon Sep 17 00:00:00 2001 From: Shuhang Li Date: Thu, 23 May 2024 23:18:47 -0400 Subject: [PATCH 12/55] Full hbar for spin orbital DSRG. --- forte/api/forte_python_module.cc | 4 +++- forte/mrdsrg-so/mrdsrg_so.cc | 4 ++++ forte/mrdsrg-so/mrdsrg_so.h | 2 ++ 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/forte/api/forte_python_module.cc b/forte/api/forte_python_module.cc index 5af40b775..aeceba4b4 100644 --- a/forte/api/forte_python_module.cc +++ b/forte/api/forte_python_module.cc @@ -404,7 +404,9 @@ PYBIND11_MODULE(_forte, m) { py::class_(m, "MRDSRG_SO") .def("compute_energy", &MRDSRG_SO::compute_energy, "Compute DSRG energy") .def("compute_Heff_actv", &MRDSRG_SO::compute_Heff_actv, - "Return the DSRG dressed ActiveSpaceIntegrals"); + "Return the DSRG dressed ActiveSpaceIntegrals") + .def("compute_Heff_full", &MRDSRG_SO::compute_Heff_full, + "Return full transformed Hamiltonian"); // export SOMRDSRG py::class_(m, "SOMRDSRG") diff --git a/forte/mrdsrg-so/mrdsrg_so.cc b/forte/mrdsrg-so/mrdsrg_so.cc index 007ecbd6a..534c9afa5 100644 --- a/forte/mrdsrg-so/mrdsrg_so.cc +++ b/forte/mrdsrg-so/mrdsrg_so.cc @@ -1481,4 +1481,8 @@ void MRDSRG_SO::H3_T2_C2(BlockedTensor& H3, BlockedTensor& T2, const double& alp temp["mx"] += 0.5 * T2["myuv"] * Lambda2["uvxy"]; C2["toqr"] -= alpha * temp["mx"] * H3["xtomqr"]; } +std::vector MRDSRG_SO::compute_Heff_full() { + std::vector Heff = {Hbar1, Hbar2}; + return Heff; +} } // namespace forte diff --git a/forte/mrdsrg-so/mrdsrg_so.h b/forte/mrdsrg-so/mrdsrg_so.h index e257e195c..8440b6ebc 100644 --- a/forte/mrdsrg-so/mrdsrg_so.h +++ b/forte/mrdsrg-so/mrdsrg_so.h @@ -302,6 +302,8 @@ class MRDSRG_SO : public DynamicCorrelationSolver { double compute_eom(); + std::vector compute_Heff_full(); + /// DSRG transformed Hamiltonian (not implemented) std::shared_ptr compute_Heff_actv(); From 50386f1bc654b5db2042d96d144766b1c4702d89 Mon Sep 17 00:00:00 2001 From: Shuhang Li Date: Fri, 24 May 2024 11:01:37 -0400 Subject: [PATCH 13/55] spin orbital rdms --- forte/api/forte_python_module.cc | 16 +++++++++++++++- forte/mrdsrg-so/mrdsrg_so.h | 4 ++++ forte/proc/dsrg.py | 12 ++++++++++++ 3 files changed, 31 insertions(+), 1 deletion(-) diff --git a/forte/api/forte_python_module.cc b/forte/api/forte_python_module.cc index aeceba4b4..b329088d8 100644 --- a/forte/api/forte_python_module.cc +++ b/forte/api/forte_python_module.cc @@ -275,6 +275,16 @@ PYBIND11_MODULE(_forte, m) { return pyints; }, "Return the full Heff in a dictionary"); + m.def( + "rdm_dict", + [](ambit::BlockedTensor rdm) { + py::dict pyrdm; + auto labels = rdm.block_labels(); + for (const auto& label : labels) { + pyrdm[py::str(label)] = ambit_to_np(rdm.block(label)); + } + }, + "Return the RDM in a dictionary"); // py::class_>(m, "ACI"); @@ -406,7 +416,11 @@ PYBIND11_MODULE(_forte, m) { .def("compute_Heff_actv", &MRDSRG_SO::compute_Heff_actv, "Return the DSRG dressed ActiveSpaceIntegrals") .def("compute_Heff_full", &MRDSRG_SO::compute_Heff_full, - "Return full transformed Hamiltonian"); + "Return full transformed Hamiltonian") + .def("get_gamma1", &MRDSRG_SO::get_gamma1, "Return the gamma1 tensor") + .def("get_eta1", &MRDSRG_SO::get_eta1, "Return the eta1 tensor") + .def("get_lambda2", &MRDSRG_SO::get_lambda2, "Return the lambda2 tensor") + .def("get_lambda3", &MRDSRG_SO::get_lambda3, "Return the lambda3 tensor"); // export SOMRDSRG py::class_(m, "SOMRDSRG") diff --git a/forte/mrdsrg-so/mrdsrg_so.h b/forte/mrdsrg-so/mrdsrg_so.h index 8440b6ebc..db074da20 100644 --- a/forte/mrdsrg-so/mrdsrg_so.h +++ b/forte/mrdsrg-so/mrdsrg_so.h @@ -303,6 +303,10 @@ class MRDSRG_SO : public DynamicCorrelationSolver { double compute_eom(); std::vector compute_Heff_full(); + ambit::BlockedTensor get_gamma1() { return Gamma1; } + ambit::BlockedTensor get_eta1() { return Eta1; } + ambit::BlockedTensor get_lambda2() { return Lambda2; } + ambit::BlockedTensor get_lambda3() { return Lambda3; } /// DSRG transformed Hamiltonian (not implemented) std::shared_ptr compute_Heff_actv(); diff --git a/forte/proc/dsrg.py b/forte/proc/dsrg.py index 89af1a1f7..ab2142b50 100644 --- a/forte/proc/dsrg.py +++ b/forte/proc/dsrg.py @@ -364,6 +364,18 @@ def compute_energy(self): Heff = self.dsrg_solver.compute_Heff_full() Heff_dict = forte.Heff_dict(Heff) np.savez('save_Hbar', **Heff_dict) + gamma1 = self.dsrg_solver.get_gamma1() + eta1 = self.dsrg_solver.get_eta1() + lambda2 = self.dsrg_solver.get_lambda2() + lambda3 = self.dsrg_solver.get_lambda3() + gamma1_dict = forte.rdm_dict(gamma1) + eta_1_dict = forte.rdm_dict(eta1) + lambda2_dict = forte.rdm_dict(lambda2) + lambda3_dict = forte.rdm_dict(lambda3) + np.savez('save_gamma1', **gamma1_dict) + np.savez('save_eta1', **eta_1_dict) + np.savez('save_lambda2', **lambda2_dict) + np.savez('save_lambda3', **lambda3_dict) ################ self.dsrg_cleanup() From 6b32d2857226a201d6394c00e6a75e788b8fd95a Mon Sep 17 00:00:00 2001 From: Shuhang Li Date: Fri, 24 May 2024 11:13:20 -0400 Subject: [PATCH 14/55] a small bug --- forte/api/forte_python_module.cc | 1 + 1 file changed, 1 insertion(+) diff --git a/forte/api/forte_python_module.cc b/forte/api/forte_python_module.cc index b329088d8..1d62fd41f 100644 --- a/forte/api/forte_python_module.cc +++ b/forte/api/forte_python_module.cc @@ -283,6 +283,7 @@ PYBIND11_MODULE(_forte, m) { for (const auto& label : labels) { pyrdm[py::str(label)] = ambit_to_np(rdm.block(label)); } + return pyrdm; }, "Return the RDM in a dictionary"); From eb09c97296a06ad72053a8b7d173a97169e05ec0 Mon Sep 17 00:00:00 2001 From: Shuhang Li Date: Thu, 6 Jun 2024 22:42:16 -0400 Subject: [PATCH 15/55] Spin-integrated RDMs. --- forte/api/forte_python_module.cc | 15 +++++++++++++++ forte/mrdsrg-spin-integrated/master_mrdsrg.h | 5 +++++ forte/proc/dsrg.py | 6 +++++- 3 files changed, 25 insertions(+), 1 deletion(-) diff --git a/forte/api/forte_python_module.cc b/forte/api/forte_python_module.cc index 1d62fd41f..d62facc2b 100644 --- a/forte/api/forte_python_module.cc +++ b/forte/api/forte_python_module.cc @@ -286,6 +286,17 @@ PYBIND11_MODULE(_forte, m) { return pyrdm; }, "Return the RDM in a dictionary"); + m.def( + "L3_dict", + [](std::vector rdm) { + py::dict pyrdm; + pyrdm[py::str("aaaaaa")] = ambit_to_np(rdm[0]); + pyrdm[py::str("aaAaaA")] = ambit_to_np(rdm[1]); + pyrdm[py::str("aAAaAA")] = ambit_to_np(rdm[2]); + pyrdm[py::str("AAAAAA")] = ambit_to_np(rdm[3]); + return pyrdm; + }, + "Return the L3 in a dictionary"); // py::class_>(m, "ACI"); @@ -375,6 +386,10 @@ PYBIND11_MODULE(_forte, m) { "Return the DSRG dressed ActiveSpaceIntegrals") .def("compute_Heff_full", &MASTER_DSRG::compute_Heff_full, "Return full transformed Hamiltonian") + .def("get_gamma1", &MASTER_DSRG::get_gamma1, "Return the gamma1 tensor") + .def("get_eta1", &MASTER_DSRG::get_eta1, "Return the eta1 tensor") + .def("get_lambda2", &MASTER_DSRG::get_lambda2, "Return the lambda2 tensor") + .def("get_lambda3", &MASTER_DSRG::get_lambda3, "Return the lambda3 tensor") .def("deGNO_DMbar_actv", &MASTER_DSRG::deGNO_DMbar_actv, "Return the DSRG dressed dipole integrals") .def("nuclear_dipole", &MASTER_DSRG::nuclear_dipole, diff --git a/forte/mrdsrg-spin-integrated/master_mrdsrg.h b/forte/mrdsrg-spin-integrated/master_mrdsrg.h index 85adcc663..874f5c84b 100644 --- a/forte/mrdsrg-spin-integrated/master_mrdsrg.h +++ b/forte/mrdsrg-spin-integrated/master_mrdsrg.h @@ -51,6 +51,11 @@ class MASTER_DSRG : public DynamicCorrelationSolver { /// compute DSRG full transformed Hamiltonian std::vector compute_Heff_full(); + ambit::BlockedTensor get_gamma1() { return Gamma1_; } + ambit::BlockedTensor get_eta1() { return Eta1_; } + ambit::BlockedTensor get_lambda2() { return Lambda2_; } + std::vector get_lambda3() { return {L3aaa_, L3aab_, L3abb_, L3bbb_}; } + /// De-normal-order DSRG transformed dipole moment std::vector deGNO_DMbar_actv(); diff --git a/forte/proc/dsrg.py b/forte/proc/dsrg.py index ab2142b50..42c4cd68b 100644 --- a/forte/proc/dsrg.py +++ b/forte/proc/dsrg.py @@ -371,7 +371,11 @@ def compute_energy(self): gamma1_dict = forte.rdm_dict(gamma1) eta_1_dict = forte.rdm_dict(eta1) lambda2_dict = forte.rdm_dict(lambda2) - lambda3_dict = forte.rdm_dict(lambda3) + if self.solver_type in ["MRDSRG_SO", "MRDSRG-SO"]: + lambda3_dict = forte.rdm_dict(lambda3) + else: + lambda3_dict = forte.L3_dict(lambda3) + np.savez('save_gamma1', **gamma1_dict) np.savez('save_eta1', **eta_1_dict) np.savez('save_lambda2', **lambda2_dict) From 8a50b27eeabecffb02afab3e60984ea228aabd8c Mon Sep 17 00:00:00 2001 From: Shuhang Li Date: Thu, 20 Jun 2024 22:22:21 -0400 Subject: [PATCH 16/55] Clean-up. --- forte/mrdsrg-so/mrdsrg_so.cc | 171 +++++++-------- forte/mrdsrg-so/mrdsrg_so.h | 2 +- forte/mrdsrg-spin-integrated/mrdsrg.cc | 7 - forte/mrdsrg-spin-integrated/mrdsrg.h | 2 +- forte/mrdsrg-spin-integrated/mrdsrg_nonpt.cc | 217 ++++++++++--------- 5 files changed, 198 insertions(+), 201 deletions(-) diff --git a/forte/mrdsrg-so/mrdsrg_so.cc b/forte/mrdsrg-so/mrdsrg_so.cc index 8e373faa3..1811d5cd2 100644 --- a/forte/mrdsrg-so/mrdsrg_so.cc +++ b/forte/mrdsrg-so/mrdsrg_so.cc @@ -645,97 +645,98 @@ double MRDSRG_SO::compute_energy() { outfile->Printf("\n\n\n MR-DSRG(2) correlation energy = %25.15f", Etotal - Eref); outfile->Printf("\n * MR-DSRG(2) total energy = %25.15f\n", Etotal); - compute_eom(); + // compute_eom(); psi::Process::environment.globals["CURRENT ENERGY"] = Etotal; return Etotal; } -double MRDSRG_SO::compute_eom() { - // IP singles - size_t ncore = nc_ / 2; - size_t nactv = na_ / 2; - size_t nmo = nso_ / 2; - size_t nhole = ncore + nactv; - - auto EOM_Hbar = BTF_->build(tensor_type_, "EOM-Hbar", {"hh"}); - std::shared_ptr EOM_Hbar_mat_ = - std::make_shared("EOM-Hbar-Matrx", nh_, nh_); - - EOM_Hbar["nm"] = -Hbar1["nm"]; - EOM_Hbar["mv"] = -Hbar1["mu"] * Gamma1["uv"]; - EOM_Hbar["mv"] += 0.5 * Hbar2["mwux"] * Lambda2["uxwv"]; - EOM_Hbar["vm"] = EOM_Hbar["mv"]; - EOM_Hbar["wx"] = -Hbar1["vu"] * Gamma1["ux"] * Gamma1["wv"]; - EOM_Hbar["wx"] += Hbar1["vu"] * Lambda2["uwvx"]; - EOM_Hbar["wx"] += 0.5 * Hbar2["yzuv"] * Gamma1["wy"] * Lambda2["uvzx"]; - EOM_Hbar["wx"] -= 0.5 * Hbar2["yzuv"] * Gamma1["vx"] * Lambda2["uwyz"]; - EOM_Hbar["wx"] += 0.25 * Hbar2["yzuv"] * Lambda3["uvwyzx"]; - - EOM_Hbar.iterate( - [&](const std::vector& i, const std::vector&, double& value) { - if (i[0] < nmo && i[1] < nmo) { - EOM_Hbar_mat_->set(i[0], i[1], value); - } - if (i[0] >= nmo && i[1] >= nmo) { - EOM_Hbar_mat_->set(i[0] - nmo + nhole, i[1] - nmo + nhole, value); - } - }); - - EOM_Hbar_mat_->print(); - - /// Overlap matrix - std::shared_ptr S = std::make_shared("EOM-S-sub", nh_, nh_); - std::shared_ptr Sevec = std::make_shared("S-evec", nh_, nh_); - std::shared_ptr Seval = std::make_shared("S-eval", nh_); - // std::shared_ptr Eevec = std::make_shared("E-evec", nh_, nh_); - // std::shared_ptr Eeval = std::make_shared("E-eval", nh_); - S->identity(); - (rdms_->g1a()).citerate([&](const std::vector& i, const double& value) { - S->set(i[0] + ncore, i[1] + ncore, value); - }); - (rdms_->g1b()).citerate([&](const std::vector& i, const double& value) { - std::cout << value << std::endl; - S->set(i[0] + 2 * ncore + nactv, i[1] + 2 * ncore + nactv, value); - }); - S->print(); - S->diagonalize(Sevec, Seval); - // auto Sevec = S->partial_cholesky_factorize(1e-10); - // auto Seval = std::make_shared("S-eval", Sevec->rowdim()); - - std::vector s_list; - for (size_t i = 0; i < Sevec->coldim(); i++) { - double value = abs(Seval->get(i)); - if (value > 1e-8) { - s_list.push_back(i); - } - } - - size_t num_s_list = s_list.size(); - - std::shared_ptr S_new = std::make_shared("S-new", nh_, num_s_list); - for (size_t i = 0; i < num_s_list; i++) { - psi::SharedVector temp = Sevec->get_column(0, s_list[i]); - temp->scale(1.0 / Seval->get(s_list[i])); - S_new->set_column(0, i, temp); - } - std::shared_ptr Eevec = std::make_shared("E-evec", nh_, num_s_list); - std::shared_ptr Eeval = std::make_shared("E-eval", num_s_list); - - EOM_Hbar_mat_ = psi::linalg::triplet(S_new, EOM_Hbar_mat_, S_new, true, false, false); - - EOM_Hbar_mat_->diagonalize(Eevec, Eeval); - - outfile->Printf("\n " - "----------------------------------------------------------" - "----------------------------------------"); - outfile->Printf("\n\n\n EOM-DSRG "); - - Eeval->print(); - - return Eeval->get(0); -} +// double MRDSRG_SO::compute_eom() { +// // IP singles +// size_t ncore = nc_ / 2; +// size_t nactv = na_ / 2; +// size_t nmo = nso_ / 2; +// size_t nhole = ncore + nactv; + +// auto EOM_Hbar = BTF_->build(tensor_type_, "EOM-Hbar", {"hh"}); +// std::shared_ptr EOM_Hbar_mat_ = +// std::make_shared("EOM-Hbar-Matrx", nh_, nh_); + +// EOM_Hbar["nm"] = -Hbar1["nm"]; +// EOM_Hbar["mv"] = -Hbar1["mu"] * Gamma1["uv"]; +// EOM_Hbar["mv"] += 0.5 * Hbar2["mwux"] * Lambda2["uxwv"]; +// EOM_Hbar["vm"] = EOM_Hbar["mv"]; +// EOM_Hbar["wx"] = -Hbar1["vu"] * Gamma1["ux"] * Gamma1["wv"]; +// EOM_Hbar["wx"] += Hbar1["vu"] * Lambda2["uwvx"]; +// EOM_Hbar["wx"] += 0.5 * Hbar2["yzuv"] * Gamma1["wy"] * Lambda2["uvzx"]; +// EOM_Hbar["wx"] -= 0.5 * Hbar2["yzuv"] * Gamma1["vx"] * Lambda2["uwyz"]; +// EOM_Hbar["wx"] += 0.25 * Hbar2["yzuv"] * Lambda3["uvwyzx"]; + +// EOM_Hbar.iterate( +// [&](const std::vector& i, const std::vector&, double& value) { +// if (i[0] < nmo && i[1] < nmo) { +// EOM_Hbar_mat_->set(i[0], i[1], value); +// } +// if (i[0] >= nmo && i[1] >= nmo) { +// EOM_Hbar_mat_->set(i[0] - nmo + nhole, i[1] - nmo + nhole, value); +// } +// }); + +// EOM_Hbar_mat_->print(); + +// /// Overlap matrix +// std::shared_ptr S = std::make_shared("EOM-S-sub", nh_, nh_); +// std::shared_ptr Sevec = std::make_shared("S-evec", nh_, nh_); +// std::shared_ptr Seval = std::make_shared("S-eval", nh_); +// // std::shared_ptr Eevec = std::make_shared("E-evec", nh_, nh_); +// // std::shared_ptr Eeval = std::make_shared("E-eval", nh_); +// S->identity(); +// (rdms_->g1a()).citerate([&](const std::vector& i, const double& value) { +// S->set(i[0] + ncore, i[1] + ncore, value); +// }); +// (rdms_->g1b()).citerate([&](const std::vector& i, const double& value) { +// std::cout << value << std::endl; +// S->set(i[0] + 2 * ncore + nactv, i[1] + 2 * ncore + nactv, value); +// }); +// S->print(); +// S->diagonalize(Sevec, Seval); +// // auto Sevec = S->partial_cholesky_factorize(1e-10); +// // auto Seval = std::make_shared("S-eval", Sevec->rowdim()); + +// std::vector s_list; +// for (size_t i = 0; i < Sevec->coldim(); i++) { +// double value = abs(Seval->get(i)); +// if (value > 1e-8) { +// s_list.push_back(i); +// } +// } + +// size_t num_s_list = s_list.size(); + +// std::shared_ptr S_new = std::make_shared("S-new", nh_, num_s_list); +// for (size_t i = 0; i < num_s_list; i++) { +// psi::SharedVector temp = Sevec->get_column(0, s_list[i]); +// temp->scale(1.0 / Seval->get(s_list[i])); +// S_new->set_column(0, i, temp); +// } +// std::shared_ptr Eevec = std::make_shared("E-evec", nh_, +// num_s_list); std::shared_ptr Eeval = std::make_shared("E-eval", +// num_s_list); + +// EOM_Hbar_mat_ = psi::linalg::triplet(S_new, EOM_Hbar_mat_, S_new, true, false, false); + +// EOM_Hbar_mat_->diagonalize(Eevec, Eeval); + +// outfile->Printf("\n " +// "----------------------------------------------------------" +// "----------------------------------------"); +// outfile->Printf("\n\n\n EOM-DSRG "); + +// Eeval->print(); + +// return Eeval->get(0); +// } void MRDSRG_SO::compute_hbar() { diff --git a/forte/mrdsrg-so/mrdsrg_so.h b/forte/mrdsrg-so/mrdsrg_so.h index 93986dc20..6e365caa1 100644 --- a/forte/mrdsrg-so/mrdsrg_so.h +++ b/forte/mrdsrg-so/mrdsrg_so.h @@ -299,7 +299,7 @@ class MRDSRG_SO : public DynamicCorrelationSolver { /// Compute the DSRG-MRPT2 energy double compute_energy(); - double compute_eom(); + // double compute_eom(); std::vector compute_Heff_full(); ambit::BlockedTensor get_gamma1() { return Gamma1; } diff --git a/forte/mrdsrg-spin-integrated/mrdsrg.cc b/forte/mrdsrg-spin-integrated/mrdsrg.cc index 87c23b45d..347c43d64 100644 --- a/forte/mrdsrg-spin-integrated/mrdsrg.cc +++ b/forte/mrdsrg-spin-integrated/mrdsrg.cc @@ -332,13 +332,6 @@ double MRDSRG::compute_energy() { switch (corrlevelmap[corrlv_string_]) { case CORR_LV::LDSRG2: { Etotal += compute_energy_ldsrg2(); - - bool do_eom = false; - do_eom = foptions_->get_bool("DO_EOM"); - if (do_eom) { - compute_eom(); - } - break; } case CORR_LV::LDSRG2_QC: { diff --git a/forte/mrdsrg-spin-integrated/mrdsrg.h b/forte/mrdsrg-spin-integrated/mrdsrg.h index e689bae25..6e0e076a0 100644 --- a/forte/mrdsrg-spin-integrated/mrdsrg.h +++ b/forte/mrdsrg-spin-integrated/mrdsrg.h @@ -348,7 +348,7 @@ class MRDSRG : public MASTER_DSRG { double compute_energy_ldsrg2(); /// Compute EOM-LDSRG(2) - void compute_eom(); + // void compute_eom(); /// Zeroth-order Hamiltonian ambit::BlockedTensor H0th_; diff --git a/forte/mrdsrg-spin-integrated/mrdsrg_nonpt.cc b/forte/mrdsrg-spin-integrated/mrdsrg_nonpt.cc index 9b873b741..c6f1ec5a3 100644 --- a/forte/mrdsrg-spin-integrated/mrdsrg_nonpt.cc +++ b/forte/mrdsrg-spin-integrated/mrdsrg_nonpt.cc @@ -831,113 +831,116 @@ double MRDSRG::compute_energy_ldsrg2() { return Ecorr; } -void MRDSRG::compute_eom() { - // IP singles - size_t ncore = core_mos_.size(); - size_t nactv = actv_mos_.size(); - size_t nh = ncore + nactv; - - ambit::BlockedTensor EOM_Hbar = BTF_->build(tensor_type_, "EOM-Hbar", spin_cases({"hh"})); - ambit::BlockedTensor S = BTF_->build(tensor_type_, "S", spin_cases({"hh"})); - S["uv"] = Gamma1_["uv"]; - S["UV"] = Gamma1_["UV"]; - (S.block("cc")).iterate([&](const std::vector& i, double& value) { - value = (i[0] == i[1] ? 1.0 : 0.0); - }); - (S.block("CC")).iterate([&](const std::vector& i, double& value) { - value = (i[0] == i[1] ? 1.0 : 0.0); - }); - std::shared_ptr EOM_Hbar_mat_ = - std::make_shared("EOM-Hbar-Matrx", 2 * nh, 2 * nh); // Spin orbital. - - // The first term - EOM_Hbar["nm"] = -Hbar1_["nm"]; - EOM_Hbar["NM"] = -Hbar1_["NM"]; - // The second term - EOM_Hbar["mv"] = -Hbar1_["mu"] * Gamma1_["uv"]; - EOM_Hbar["mv"] += 0.5 * Hbar2_["mwux"] * Lambda2_["uxwv"]; - EOM_Hbar["mv"] -= Hbar2_["mWuX"] * Lambda2_["uXvW"]; - EOM_Hbar["vm"] = EOM_Hbar["mv"]; - - EOM_Hbar["MV"] = -Hbar1_["MU"] * Gamma1_["UV"]; - EOM_Hbar["MV"] += 0.5 * Hbar2_["MWUX"] * Lambda2_["UXWV"]; - EOM_Hbar["MV"] -= Hbar2_["wMxU"] * Lambda2_["xUwV"]; - EOM_Hbar["VM"] = EOM_Hbar["MV"]; - - // The third term - EOM_Hbar["wx"] = -Hbar1_["vu"] * Gamma1_["ux"] * Gamma1_["wv"]; - EOM_Hbar["wx"] += Hbar1_["vu"] * Lambda2_["uwvx"]; - EOM_Hbar["wx"] += Hbar1_["VU"] * Lambda2_["wUxV"]; - EOM_Hbar["wx"] += 0.5 * Hbar2_["yzuv"] * Gamma1_["wy"] * Lambda2_["uvzx"]; - EOM_Hbar["wx"] -= Hbar2_["yZvU"] * Gamma1_["wy"] * Lambda2_["vUxZ"]; - EOM_Hbar["wx"] -= 0.5 * Hbar2_["yzuv"] * Gamma1_["vx"] * Lambda2_["uwyz"]; - EOM_Hbar["wx"] -= Hbar2_["zYvU"] * Gamma1_["vx"] * Lambda2_["wUzY"]; - EOM_Hbar.block("aa")("wx") += 0.25 * Hbar2_.block("aaaa")("yzuv") * L3aaa_("uvwyzx"); - EOM_Hbar.block("aa")("wx") += 0.25 * Hbar2_.block("AAAA")("YZUV") * L3abb_("wUVxYZ"); - EOM_Hbar.block("aa")("wx") += Hbar2_.block("aAaA")("yZuV") * L3aab_("uwVyxZ"); - - EOM_Hbar["WX"] = -Hbar1_["VU"] * Gamma1_["UX"] * Gamma1_["WV"]; - EOM_Hbar["WX"] += Hbar1_["VU"] * Lambda2_["UWVX"]; - EOM_Hbar["WX"] += Hbar1_["vu"] * Lambda2_["uWvX"]; - EOM_Hbar["WX"] += 0.5 * Hbar2_["YZUV"] * Gamma1_["WY"] * Lambda2_["UVZX"]; - EOM_Hbar["WX"] -= Hbar2_["zYuV"] * Gamma1_["WY"] * Lambda2_["uVzX"]; - EOM_Hbar["WX"] -= 0.5 * Hbar2_["YZUV"] * Gamma1_["VX"] * Lambda2_["UWYZ"]; - EOM_Hbar["WX"] -= Hbar2_["yZuV"] * Gamma1_["VX"] * Lambda2_["uWyZ"]; - EOM_Hbar.block("AA")("WX") += 0.25 * Hbar2_.block("AAAA")("YZUV") * L3bbb_("UVWYZX"); - EOM_Hbar.block("AA")("WX") += 0.25 * Hbar2_.block("aaaa")("yzuv") * L3aab_("uvWyzX"); - EOM_Hbar.block("AA")("WX") += Hbar2_.block("aAaA")("zYvU") * L3abb_("vUWzYX"); - - EOM_Hbar.iterate( - [&](const std::vector& i, const std::vector& spin, double& value) { - if ((spin[0] == AlphaSpin) && (spin[1] == AlphaSpin)) { - EOM_Hbar_mat_->set(i[0], i[1], value); - } else if ((spin[0] == BetaSpin) && (spin[1] == BetaSpin)) { - EOM_Hbar_mat_->set(i[0] + nh, i[1] + nh, value); - } - }); - EOM_Hbar_mat_->print(); - - /// Overlap matrix - std::shared_ptr S_mat = std::make_shared("EOM-S-sub", 2 * nh, 2 * nh); - // std::shared_ptr Sevec = std::make_shared("S-evec", 2 * nh, 2 * nh); - // std::shared_ptr Seval = std::make_shared("S-eval", 2 * nh); - // S_mat->identity(); - // Construct S - - S.iterate([&](const std::vector& i, const std::vector& spin, double& value) { - if ((spin[0] == AlphaSpin) && (spin[1] == AlphaSpin)) { - S_mat->set(i[0], i[1], value); - } else if ((spin[0] == BetaSpin) && (spin[1] == BetaSpin)) { - S_mat->set(i[0] + nh, i[1] + nh, value); - } - }); - - S_mat->print(); - // S_mat->diagonalize(Sevec, Seval); - // Seval->print(); - - // // We need a threshold. Also, inefficient. - // for (size_t i = 0; i < Sevec->coldim(); i++) { - // for (size_t j = 0; j < Sevec->rowdim(); j++) { - // double value = Sevec->get(j, i) / std::sqrt(Seval->get(i)); - // Sevec->set(j, i, value); - // } - // } - auto Sevec = S_mat->partial_cholesky_factorize(1e-10); - - auto Seval = std::make_shared("S-eval", Sevec->rowdim()); - - EOM_Hbar_mat_ = psi::linalg::triplet(Sevec, EOM_Hbar_mat_, Sevec, true, false, false); - - EOM_Hbar_mat_->diagonalize(Sevec, Seval); - - outfile->Printf("\n " - "----------------------------------------------------------" - "----------------------------------------"); - outfile->Printf("\n\n\n EOM-DSRG "); - - Seval->print(); -} +// void MRDSRG::compute_eom() { +// // IP singles +// size_t ncore = core_mos_.size(); +// size_t nactv = actv_mos_.size(); +// size_t nh = ncore + nactv; + +// ambit::BlockedTensor EOM_Hbar = BTF_->build(tensor_type_, "EOM-Hbar", spin_cases({"hh"})); +// ambit::BlockedTensor S = BTF_->build(tensor_type_, "S", spin_cases({"hh"})); +// S["uv"] = Gamma1_["uv"]; +// S["UV"] = Gamma1_["UV"]; +// (S.block("cc")).iterate([&](const std::vector& i, double& value) { +// value = (i[0] == i[1] ? 1.0 : 0.0); +// }); +// (S.block("CC")).iterate([&](const std::vector& i, double& value) { +// value = (i[0] == i[1] ? 1.0 : 0.0); +// }); +// std::shared_ptr EOM_Hbar_mat_ = +// std::make_shared("EOM-Hbar-Matrx", 2 * nh, 2 * nh); // Spin orbital. + +// // The first term +// EOM_Hbar["nm"] = -Hbar1_["nm"]; +// EOM_Hbar["NM"] = -Hbar1_["NM"]; +// // The second term +// EOM_Hbar["mv"] = -Hbar1_["mu"] * Gamma1_["uv"]; +// EOM_Hbar["mv"] += 0.5 * Hbar2_["mwux"] * Lambda2_["uxwv"]; +// EOM_Hbar["mv"] -= Hbar2_["mWuX"] * Lambda2_["uXvW"]; +// EOM_Hbar["vm"] = EOM_Hbar["mv"]; + +// EOM_Hbar["MV"] = -Hbar1_["MU"] * Gamma1_["UV"]; +// EOM_Hbar["MV"] += 0.5 * Hbar2_["MWUX"] * Lambda2_["UXWV"]; +// EOM_Hbar["MV"] -= Hbar2_["wMxU"] * Lambda2_["xUwV"]; +// EOM_Hbar["VM"] = EOM_Hbar["MV"]; + +// // The third term +// EOM_Hbar["wx"] = -Hbar1_["vu"] * Gamma1_["ux"] * Gamma1_["wv"]; +// EOM_Hbar["wx"] += Hbar1_["vu"] * Lambda2_["uwvx"]; +// EOM_Hbar["wx"] += Hbar1_["VU"] * Lambda2_["wUxV"]; +// EOM_Hbar["wx"] += 0.5 * Hbar2_["yzuv"] * Gamma1_["wy"] * Lambda2_["uvzx"]; +// EOM_Hbar["wx"] -= Hbar2_["yZvU"] * Gamma1_["wy"] * Lambda2_["vUxZ"]; +// EOM_Hbar["wx"] -= 0.5 * Hbar2_["yzuv"] * Gamma1_["vx"] * Lambda2_["uwyz"]; +// EOM_Hbar["wx"] -= Hbar2_["zYvU"] * Gamma1_["vx"] * Lambda2_["wUzY"]; +// EOM_Hbar.block("aa")("wx") += 0.25 * Hbar2_.block("aaaa")("yzuv") * L3aaa_("uvwyzx"); +// EOM_Hbar.block("aa")("wx") += 0.25 * Hbar2_.block("AAAA")("YZUV") * L3abb_("wUVxYZ"); +// EOM_Hbar.block("aa")("wx") += Hbar2_.block("aAaA")("yZuV") * L3aab_("uwVyxZ"); + +// EOM_Hbar["WX"] = -Hbar1_["VU"] * Gamma1_["UX"] * Gamma1_["WV"]; +// EOM_Hbar["WX"] += Hbar1_["VU"] * Lambda2_["UWVX"]; +// EOM_Hbar["WX"] += Hbar1_["vu"] * Lambda2_["uWvX"]; +// EOM_Hbar["WX"] += 0.5 * Hbar2_["YZUV"] * Gamma1_["WY"] * Lambda2_["UVZX"]; +// EOM_Hbar["WX"] -= Hbar2_["zYuV"] * Gamma1_["WY"] * Lambda2_["uVzX"]; +// EOM_Hbar["WX"] -= 0.5 * Hbar2_["YZUV"] * Gamma1_["VX"] * Lambda2_["UWYZ"]; +// EOM_Hbar["WX"] -= Hbar2_["yZuV"] * Gamma1_["VX"] * Lambda2_["uWyZ"]; +// EOM_Hbar.block("AA")("WX") += 0.25 * Hbar2_.block("AAAA")("YZUV") * L3bbb_("UVWYZX"); +// EOM_Hbar.block("AA")("WX") += 0.25 * Hbar2_.block("aaaa")("yzuv") * L3aab_("uvWyzX"); +// EOM_Hbar.block("AA")("WX") += Hbar2_.block("aAaA")("zYvU") * L3abb_("vUWzYX"); + +// EOM_Hbar.iterate( +// [&](const std::vector& i, const std::vector& spin, double& value) { +// if ((spin[0] == AlphaSpin) && (spin[1] == AlphaSpin)) { +// EOM_Hbar_mat_->set(i[0], i[1], value); +// } else if ((spin[0] == BetaSpin) && (spin[1] == BetaSpin)) { +// EOM_Hbar_mat_->set(i[0] + nh, i[1] + nh, value); +// } +// }); +// EOM_Hbar_mat_->print(); + +// /// Overlap matrix +// std::shared_ptr S_mat = std::make_shared("EOM-S-sub", 2 * nh, 2 * +// nh); +// // std::shared_ptr Sevec = std::make_shared("S-evec", 2 * nh, 2 * +// nh); +// // std::shared_ptr Seval = std::make_shared("S-eval", 2 * nh); +// // S_mat->identity(); +// // Construct S + +// S.iterate([&](const std::vector& i, const std::vector& spin, double& value) +// { +// if ((spin[0] == AlphaSpin) && (spin[1] == AlphaSpin)) { +// S_mat->set(i[0], i[1], value); +// } else if ((spin[0] == BetaSpin) && (spin[1] == BetaSpin)) { +// S_mat->set(i[0] + nh, i[1] + nh, value); +// } +// }); + +// S_mat->print(); +// // S_mat->diagonalize(Sevec, Seval); +// // Seval->print(); + +// // // We need a threshold. Also, inefficient. +// // for (size_t i = 0; i < Sevec->coldim(); i++) { +// // for (size_t j = 0; j < Sevec->rowdim(); j++) { +// // double value = Sevec->get(j, i) / std::sqrt(Seval->get(i)); +// // Sevec->set(j, i, value); +// // } +// // } +// auto Sevec = S_mat->partial_cholesky_factorize(1e-10); + +// auto Seval = std::make_shared("S-eval", Sevec->rowdim()); + +// EOM_Hbar_mat_ = psi::linalg::triplet(Sevec, EOM_Hbar_mat_, Sevec, true, false, false); + +// EOM_Hbar_mat_->diagonalize(Sevec, Seval); + +// outfile->Printf("\n " +// "----------------------------------------------------------" +// "----------------------------------------"); +// outfile->Printf("\n\n\n EOM-DSRG "); + +// Seval->print(); +// } void MRDSRG::compute_hbar_qc() { std::string dsrg_op = foptions_->get_str("DSRG_TRANS_TYPE"); From 29b8b0001b79ae866a5bce1d1004a643d122b454 Mon Sep 17 00:00:00 2001 From: Shuhang Li Date: Thu, 20 Jun 2024 22:57:49 -0400 Subject: [PATCH 17/55] add options --- forte/options.yaml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/forte/options.yaml b/forte/options.yaml index ca006b429..fbf562cf1 100644 --- a/forte/options.yaml +++ b/forte/options.yaml @@ -1071,6 +1071,10 @@ DSRG: " - Multi-state approach (currently only for MRPT2)\n" " - MS: form 2nd-order Heff_MN = + 0.5 * [ + ]\n" " - XMS: rotate references such that is diagonal before MS procedure" + FULL_HBAR: + type: bool + default: False + help: "Form full Hbar." FORM_HBAR3: type: bool default: False @@ -1723,4 +1727,4 @@ DEPRECATED: CASSCF_DIE_IF_NOT_CONVERGED: type: deprecated default: None - help: "Replaced by MCSCF_DIE_IF_NOT_CONVERGED" \ No newline at end of file + help: "Replaced by MCSCF_DIE_IF_NOT_CONVERGED" From ec3a22bd0d983962ee59cd26eadd60633548480d Mon Sep 17 00:00:00 2001 From: Shuhang Li Date: Tue, 25 Jun 2024 15:46:37 -0400 Subject: [PATCH 18/55] save --- forte/mrdsrg-so/mrdsrg_so.cc | 1 + forte/mrdsrg-spin-integrated/mrdsrg_nonpt.cc | 4 ++++ forte/options.yaml | 4 ++++ 3 files changed, 9 insertions(+) diff --git a/forte/mrdsrg-so/mrdsrg_so.cc b/forte/mrdsrg-so/mrdsrg_so.cc index 1811d5cd2..1d9f812ee 100644 --- a/forte/mrdsrg-so/mrdsrg_so.cc +++ b/forte/mrdsrg-so/mrdsrg_so.cc @@ -1485,6 +1485,7 @@ void MRDSRG_SO::H3_T2_C2(BlockedTensor& H3, BlockedTensor& T2, const double& alp C2["toqr"] -= alpha * temp["mx"] * H3["xtomqr"]; } std::vector MRDSRG_SO::compute_Heff_full() { + compute_hbar(); std::vector Heff = {Hbar1, Hbar2}; return Heff; } diff --git a/forte/mrdsrg-spin-integrated/mrdsrg_nonpt.cc b/forte/mrdsrg-spin-integrated/mrdsrg_nonpt.cc index c6f1ec5a3..aad156b05 100644 --- a/forte/mrdsrg-spin-integrated/mrdsrg_nonpt.cc +++ b/forte/mrdsrg-spin-integrated/mrdsrg_nonpt.cc @@ -825,6 +825,10 @@ double MRDSRG::compute_energy_ldsrg2() { // dump amplitudes to file dump_amps_to_disk(); + if (foptions_->get_bool("FULL_HBAR")) { + compute_hbar(); + } + final.stop(); Hbar0_ = Ecorr; diff --git a/forte/options.yaml b/forte/options.yaml index fbf562cf1..4dc93432a 100644 --- a/forte/options.yaml +++ b/forte/options.yaml @@ -1075,6 +1075,10 @@ DSRG: type: bool default: False help: "Form full Hbar." + DO_WICKED: + type: bool + default: False + help: "Compute hbar with Wicked. (only for spin orbital ldsrg2)." FORM_HBAR3: type: bool default: False From 58c8a6f37a165351b31a91e1ad712436fc2f490a Mon Sep 17 00:00:00 2001 From: Shuhang Li Date: Thu, 29 Aug 2024 09:36:10 -0400 Subject: [PATCH 19/55] update from the local --- forte/mrdsrg-spin-integrated/mrdsrg_nonpt.cc | 111 ------------------- forte/proc/dsrg.py | 38 ++++++- 2 files changed, 36 insertions(+), 113 deletions(-) diff --git a/forte/mrdsrg-spin-integrated/mrdsrg_nonpt.cc b/forte/mrdsrg-spin-integrated/mrdsrg_nonpt.cc index aad156b05..4fa8299ee 100644 --- a/forte/mrdsrg-spin-integrated/mrdsrg_nonpt.cc +++ b/forte/mrdsrg-spin-integrated/mrdsrg_nonpt.cc @@ -835,117 +835,6 @@ double MRDSRG::compute_energy_ldsrg2() { return Ecorr; } -// void MRDSRG::compute_eom() { -// // IP singles -// size_t ncore = core_mos_.size(); -// size_t nactv = actv_mos_.size(); -// size_t nh = ncore + nactv; - -// ambit::BlockedTensor EOM_Hbar = BTF_->build(tensor_type_, "EOM-Hbar", spin_cases({"hh"})); -// ambit::BlockedTensor S = BTF_->build(tensor_type_, "S", spin_cases({"hh"})); -// S["uv"] = Gamma1_["uv"]; -// S["UV"] = Gamma1_["UV"]; -// (S.block("cc")).iterate([&](const std::vector& i, double& value) { -// value = (i[0] == i[1] ? 1.0 : 0.0); -// }); -// (S.block("CC")).iterate([&](const std::vector& i, double& value) { -// value = (i[0] == i[1] ? 1.0 : 0.0); -// }); -// std::shared_ptr EOM_Hbar_mat_ = -// std::make_shared("EOM-Hbar-Matrx", 2 * nh, 2 * nh); // Spin orbital. - -// // The first term -// EOM_Hbar["nm"] = -Hbar1_["nm"]; -// EOM_Hbar["NM"] = -Hbar1_["NM"]; -// // The second term -// EOM_Hbar["mv"] = -Hbar1_["mu"] * Gamma1_["uv"]; -// EOM_Hbar["mv"] += 0.5 * Hbar2_["mwux"] * Lambda2_["uxwv"]; -// EOM_Hbar["mv"] -= Hbar2_["mWuX"] * Lambda2_["uXvW"]; -// EOM_Hbar["vm"] = EOM_Hbar["mv"]; - -// EOM_Hbar["MV"] = -Hbar1_["MU"] * Gamma1_["UV"]; -// EOM_Hbar["MV"] += 0.5 * Hbar2_["MWUX"] * Lambda2_["UXWV"]; -// EOM_Hbar["MV"] -= Hbar2_["wMxU"] * Lambda2_["xUwV"]; -// EOM_Hbar["VM"] = EOM_Hbar["MV"]; - -// // The third term -// EOM_Hbar["wx"] = -Hbar1_["vu"] * Gamma1_["ux"] * Gamma1_["wv"]; -// EOM_Hbar["wx"] += Hbar1_["vu"] * Lambda2_["uwvx"]; -// EOM_Hbar["wx"] += Hbar1_["VU"] * Lambda2_["wUxV"]; -// EOM_Hbar["wx"] += 0.5 * Hbar2_["yzuv"] * Gamma1_["wy"] * Lambda2_["uvzx"]; -// EOM_Hbar["wx"] -= Hbar2_["yZvU"] * Gamma1_["wy"] * Lambda2_["vUxZ"]; -// EOM_Hbar["wx"] -= 0.5 * Hbar2_["yzuv"] * Gamma1_["vx"] * Lambda2_["uwyz"]; -// EOM_Hbar["wx"] -= Hbar2_["zYvU"] * Gamma1_["vx"] * Lambda2_["wUzY"]; -// EOM_Hbar.block("aa")("wx") += 0.25 * Hbar2_.block("aaaa")("yzuv") * L3aaa_("uvwyzx"); -// EOM_Hbar.block("aa")("wx") += 0.25 * Hbar2_.block("AAAA")("YZUV") * L3abb_("wUVxYZ"); -// EOM_Hbar.block("aa")("wx") += Hbar2_.block("aAaA")("yZuV") * L3aab_("uwVyxZ"); - -// EOM_Hbar["WX"] = -Hbar1_["VU"] * Gamma1_["UX"] * Gamma1_["WV"]; -// EOM_Hbar["WX"] += Hbar1_["VU"] * Lambda2_["UWVX"]; -// EOM_Hbar["WX"] += Hbar1_["vu"] * Lambda2_["uWvX"]; -// EOM_Hbar["WX"] += 0.5 * Hbar2_["YZUV"] * Gamma1_["WY"] * Lambda2_["UVZX"]; -// EOM_Hbar["WX"] -= Hbar2_["zYuV"] * Gamma1_["WY"] * Lambda2_["uVzX"]; -// EOM_Hbar["WX"] -= 0.5 * Hbar2_["YZUV"] * Gamma1_["VX"] * Lambda2_["UWYZ"]; -// EOM_Hbar["WX"] -= Hbar2_["yZuV"] * Gamma1_["VX"] * Lambda2_["uWyZ"]; -// EOM_Hbar.block("AA")("WX") += 0.25 * Hbar2_.block("AAAA")("YZUV") * L3bbb_("UVWYZX"); -// EOM_Hbar.block("AA")("WX") += 0.25 * Hbar2_.block("aaaa")("yzuv") * L3aab_("uvWyzX"); -// EOM_Hbar.block("AA")("WX") += Hbar2_.block("aAaA")("zYvU") * L3abb_("vUWzYX"); - -// EOM_Hbar.iterate( -// [&](const std::vector& i, const std::vector& spin, double& value) { -// if ((spin[0] == AlphaSpin) && (spin[1] == AlphaSpin)) { -// EOM_Hbar_mat_->set(i[0], i[1], value); -// } else if ((spin[0] == BetaSpin) && (spin[1] == BetaSpin)) { -// EOM_Hbar_mat_->set(i[0] + nh, i[1] + nh, value); -// } -// }); -// EOM_Hbar_mat_->print(); - -// /// Overlap matrix -// std::shared_ptr S_mat = std::make_shared("EOM-S-sub", 2 * nh, 2 * -// nh); -// // std::shared_ptr Sevec = std::make_shared("S-evec", 2 * nh, 2 * -// nh); -// // std::shared_ptr Seval = std::make_shared("S-eval", 2 * nh); -// // S_mat->identity(); -// // Construct S - -// S.iterate([&](const std::vector& i, const std::vector& spin, double& value) -// { -// if ((spin[0] == AlphaSpin) && (spin[1] == AlphaSpin)) { -// S_mat->set(i[0], i[1], value); -// } else if ((spin[0] == BetaSpin) && (spin[1] == BetaSpin)) { -// S_mat->set(i[0] + nh, i[1] + nh, value); -// } -// }); - -// S_mat->print(); -// // S_mat->diagonalize(Sevec, Seval); -// // Seval->print(); - -// // // We need a threshold. Also, inefficient. -// // for (size_t i = 0; i < Sevec->coldim(); i++) { -// // for (size_t j = 0; j < Sevec->rowdim(); j++) { -// // double value = Sevec->get(j, i) / std::sqrt(Seval->get(i)); -// // Sevec->set(j, i, value); -// // } -// // } -// auto Sevec = S_mat->partial_cholesky_factorize(1e-10); - -// auto Seval = std::make_shared("S-eval", Sevec->rowdim()); - -// EOM_Hbar_mat_ = psi::linalg::triplet(Sevec, EOM_Hbar_mat_, Sevec, true, false, false); - -// EOM_Hbar_mat_->diagonalize(Sevec, Seval); - -// outfile->Printf("\n " -// "----------------------------------------------------------" -// "----------------------------------------"); -// outfile->Printf("\n\n\n EOM-DSRG "); - -// Seval->print(); -// } - void MRDSRG::compute_hbar_qc() { std::string dsrg_op = foptions_->get_str("DSRG_TRANS_TYPE"); diff --git a/forte/proc/dsrg.py b/forte/proc/dsrg.py index c1da05f01..babfd8505 100644 --- a/forte/proc/dsrg.py +++ b/forte/proc/dsrg.py @@ -73,8 +73,10 @@ def __init__(self, active_space_solver, state_weights_map, mo_space_info, ints, if as_type == "BLOCK2" and self.solver_type in ["SA-MRDSRG", "SA_MRDSRG"]: self.max_rdm_level = 2 else: - psi4.core.print_out("\n DSRG 3RDM direct algorithm only available for BLOCK2/SA-MRDSRG") - psi4.core.print_out("\n Set DSRG_3RDM_ALGORITHM to 'EXPLICIT' (default)") + psi4.core.print_out( + "\n DSRG 3RDM direct algorithm only available for BLOCK2/SA-MRDSRG") + psi4.core.print_out( + "\n Set DSRG_3RDM_ALGORITHM to 'EXPLICIT' (default)") options.set_str("DSRG_3RDM_ALGORITHM", "EXPLICIT") self.relax_convergence = float("inf") @@ -169,6 +171,27 @@ def __init__(self, active_space_solver, state_weights_map, mo_space_info, ints, self.semi.semicanonicalize(self.rdms) self.Ua, self.Ub = self.semi.Ua_t(), self.semi.Ub_t() + # if self.options.get_bool('FULL_HBAR'): + # L1a = self.rdms.L1a() + # L1b = self.rdms.L1b() + # L2aa = self.rdms.L2aa() + # L2ab = self.rdms.L2ab() + # L2bb = self.rdms.L2bb() + # L3aaa = self.rdms.L3aaa() + # L3aab = self.rdms.L3aab() + # L3abb = self.rdms.L3abb() + # L3bbb = self.rdms.L3bbb() + + # np.save("L1a", L1a) + # np.save("L1b", L1b) + # np.save("L2aa", L2aa) + # np.save("L2ab", L2ab) + # np.save("L2bb", L2bb) + # np.save("L3aaa", L3aaa) + # np.save("L3aab", L3aab) + # np.save("L3abb", L3abb) + # np.save("L3bbb", L3bbb) + def make_dsrg_solver(self): """Make a DSRG solver.""" args = (self.rdms, self.scf_info, self.options, @@ -237,6 +260,9 @@ def compute_energy(self): if not self.Heff_implemented: self.relax_maxiter = 0 + if self.options.get_bool('FULL_HBAR'): + self.relax_maxiter = 0 + # Reference relaxation procedure for n in range(self.relax_maxiter): psi4.core.print_out( @@ -398,6 +424,14 @@ def compute_energy(self): np.savez('save_eta1', **eta_1_dict) np.savez('save_lambda2', **lambda2_dict) np.savez('save_lambda3', **lambda3_dict) + + # self.rdms = self.active_space_solver.compute_average_rdms( + # self.state_weights_map, self.max_rdm_level, self.rdm_type + # ) + # self.rdms.rotate(self.Ua, self.Ub) + # gamma1_aa =self.rdms.g1a() + # np.save("gamma1_aa", gamma1_aa) + ################ self.dsrg_cleanup() From bda82dc6be890354bb28a41bf5684c0dfa8a90e3 Mon Sep 17 00:00:00 2001 From: Shuhang Li Date: Mon, 9 Sep 2024 19:59:08 -0400 Subject: [PATCH 20/55] dp1 --- forte/api/integrals_api.cc | 3 ++- forte/proc/dsrg.py | 45 +++++++++++++++++++++++++++++++------- 2 files changed, 39 insertions(+), 9 deletions(-) diff --git a/forte/api/integrals_api.cc b/forte/api/integrals_api.cc index 9d10b75fa..2be0369a1 100644 --- a/forte/api/integrals_api.cc +++ b/forte/api/integrals_api.cc @@ -89,6 +89,7 @@ void export_ForteIntegrals(py::module& m) { .def("set_oei", &ForteIntegrals::set_oei_all, "Set the one-electron integrals") .def("set_tei", &ForteIntegrals::set_tei_all, "Set the two-electron integrals") .def("initialize", &ForteIntegrals::initialize, "Initialize the integrals") - .def("print_ints", &ForteIntegrals::print_ints, "Print the integrals"); + .def("print_ints", &ForteIntegrals::print_ints, "Print the integrals") + .def("mo_dipole_ints", &ForteIntegrals::mo_dipole_ints, "mo_dipole_ints"); } } // namespace forte diff --git a/forte/proc/dsrg.py b/forte/proc/dsrg.py index babfd8505..d59f8f406 100644 --- a/forte/proc/dsrg.py +++ b/forte/proc/dsrg.py @@ -260,8 +260,13 @@ def compute_energy(self): if not self.Heff_implemented: self.relax_maxiter = 0 - if self.options.get_bool('FULL_HBAR'): - self.relax_maxiter = 0 + # if self.options.get_bool('FULL_HBAR'): + # self.relax_maxiter = 0 + + if self.options.get_bool('FULL_HBAR') and self.relax_maxiter == 0: + Heff = self.dsrg_solver.compute_Heff_full() + Heff_dict = forte.Heff_dict(Heff) + np.savez('save_Hbar', **Heff_dict) # Reference relaxation procedure for n in range(self.relax_maxiter): @@ -363,6 +368,10 @@ def compute_energy(self): # Test convergence and break loop if self.test_relaxation_convergence(n): + if self.options.get_bool('FULL_HBAR'): + Heff = self.dsrg_solver.compute_Heff_full() + Heff_dict = forte.Heff_dict(Heff) + np.savez('save_Hbar', **Heff_dict) break # Continue to solve DSRG equations @@ -405,9 +414,9 @@ def compute_energy(self): ################ if self.options.get_bool('FULL_HBAR'): - Heff = self.dsrg_solver.compute_Heff_full() - Heff_dict = forte.Heff_dict(Heff) - np.savez('save_Hbar', **Heff_dict) + # Heff = self.dsrg_solver.compute_Heff_full() + # Heff_dict = forte.Heff_dict(Heff) + # np.savez('save_Hbar', **Heff_dict) gamma1 = self.dsrg_solver.get_gamma1() eta1 = self.dsrg_solver.get_eta1() lambda2 = self.dsrg_solver.get_lambda2() @@ -425,12 +434,32 @@ def compute_energy(self): np.savez('save_lambda2', **lambda2_dict) np.savez('save_lambda3', **lambda3_dict) + dp1 = self.ints.mo_dipole_ints() + np.save('save_dp1', dp1) + # self.rdms = self.active_space_solver.compute_average_rdms( - # self.state_weights_map, self.max_rdm_level, self.rdm_type - # ) + # self.state_weights_map, self.max_rdm_level, self.rdm_type + # ) # self.rdms.rotate(self.Ua, self.Ub) - # gamma1_aa =self.rdms.g1a() + # self.semi.semicanonicalize(self.rdms) + # gamma1_aa = self.rdms.g1a() + # gamma1_bb = self.rdms.g1b() + # lambda2_aa = self.rdms.L2aa() + # lambda2_bb = self.rdms.L2bb() + # lambda2_ab = self.rdms.L2ab() + # lambda3_aaa = self.rdms.L3aaa() + # lambda3_aab = self.rdms.L3aab() + # lambda3_abb = self.rdms.L3abb() + # lambda3_bbb = self.rdms.L3bbb() # np.save("gamma1_aa", gamma1_aa) + # np.save("gamma1_bb", gamma1_bb) + # np.save("lambda2_aa", lambda2_aa) + # np.save("lambda2_bb", lambda2_bb) + # np.save("lambda2_ab", lambda2_ab) + # np.save("lambda3_aaa", lambda3_aaa) + # np.save("lambda3_aab", lambda3_aab) + # np.save("lambda3_abb", lambda3_abb) + # np.save("lambda3_bbb", lambda3_bbb) ################ From 2b9049c79e341033b909a53f3e8850b9bb2d850f Mon Sep 17 00:00:00 2001 From: Brian Zhao Date: Wed, 11 Sep 2024 16:29:53 -0400 Subject: [PATCH 21/55] WIP 4rdm --- forte/fci/string_list_defs.h | 16 ++ forte/genci/genci_string_lists.cc | 12 ++ forte/genci/genci_vector.h | 30 +++- forte/genci/genci_vector_rdm.cc | 269 +++++++++++++++++++++++++++++- 4 files changed, 320 insertions(+), 7 deletions(-) diff --git a/forte/fci/string_list_defs.h b/forte/fci/string_list_defs.h index 2f71a60e0..535820849 100644 --- a/forte/fci/string_list_defs.h +++ b/forte/fci/string_list_defs.h @@ -74,6 +74,18 @@ struct H3StringSubstitution { : sign(sign_), p(p_), q(q_), r(r_), J(J_) {} }; +/// 4-hole string substitution +struct H4StringSubstitution { + const int16_t sign; + const int16_t p; + const int16_t q; + const int16_t r; + const int16_t s; + const size_t J; + H4StringSubstitution(int16_t sign_, int16_t p_, int16_t q_, int16_t r_, int16_t s_, size_t J_) + : sign(sign_), p(p_), q(q_), r(r_), s(s_), J(J_) {} +}; + using StringList = std::vector>; /// Maps the integers (p,q,h) to list of strings connected by a^{+}_p a_q, where the string @@ -111,6 +123,10 @@ using H2List = std::map, std::vector, std::vector>; +/// Maps the integers (h_J, add_J, h_I) to list of strings connected by a_p a_q a_r a_s, where the +/// string I belongs to the irrep h_I and J belongs to the irrep h_J and add_J is the address of J +using H4List = std::map, std::vector>; + using Pair = std::pair; using PairList = std::vector>>; diff --git a/forte/genci/genci_string_lists.cc b/forte/genci/genci_string_lists.cc index 8b5848268..974885347 100644 --- a/forte/genci/genci_string_lists.cc +++ b/forte/genci/genci_string_lists.cc @@ -423,4 +423,16 @@ std::vector& GenCIStringLists::get_beta_3h_list(int h_I, s return beta_3h_list[I_tuple]; } +std::vector& GenCIStringLists::get_alfa_4h_list(int h_I, size_t add_I, + int h_J) { + std::tuple I_tuple(h_I, add_I, h_J); + return alfa_4h_list[I_tuple]; +} + +std::vector& GenCIStringLists::get_beta_4h_list(int h_I, size_t add_I, + int h_J) { + std::tuple I_tuple(h_I, add_I, h_J); + return beta_4h_list[I_tuple]; +} + } // namespace forte \ No newline at end of file diff --git a/forte/genci/genci_vector.h b/forte/genci/genci_vector.h index cfbe68117..9e15cc409 100644 --- a/forte/genci/genci_vector.h +++ b/forte/genci/genci_vector.h @@ -285,6 +285,17 @@ class GenCIVector { return (ncmo * ncmo * ncmo * ncmo * ncmo * p + ncmo * ncmo * ncmo * ncmo * q + ncmo * ncmo * ncmo * r + ncmo * ncmo * s + ncmo * t + u); } + static size_t eight_index(size_t p, size_t q, size_t r, size_t s, size_t t, size_t u, + size_t v, size_t w, size_t ncmo) { + return (ncmo * ncmo * ncmo * ncmo * ncmo * ncmo * ncmo * p + + ncmo * ncmo * ncmo * ncmo * ncmo * ncmo * q + + ncmo * ncmo * ncmo * ncmo * ncmo * r + + ncmo * ncmo * ncmo * ncmo * s + + ncmo * ncmo * ncmo * t + + ncmo * ncmo * u + + ncmo * v + + w); + } /// @brief Apply the scalar part of the Hamiltonian to this vector and add it to the result /// @param result The wave function to add the result to @@ -329,7 +340,7 @@ class GenCIVector { // 3-RDM elements are stored in the format // -> rdm[six_index(p,q,r,s,t,u)] - /// Compute the matrix elements of the same spin 3-RDM (with all indices + /// Compute the matrix elements of the same spin 3-RDM (with all indices /// alpha or beta) static ambit::Tensor compute_3rdm_aaa_same_irrep(GenCIVector& C_left, GenCIVector& C_right, bool alfa); @@ -340,6 +351,23 @@ class GenCIVector { /// a_{tb} a_{sa}> static ambit::Tensor compute_3rdm_abb_same_irrep(GenCIVector& C_left, GenCIVector& C_right); + /// 4-RDM elements are stored in the format + /// -> rdm[eight_index(p,q,r,s,t,u,v,w)] + + /// Compute the matrix elements of the same spin 4-RDM + /// (with all indices alpha or beta) + static ambit::Tensor compute_4rdm_aaaa_same_irrep(GenCIVector& C_left, GenCIVector& C_right, + bool alfa); + /// Compute the matrix elements of the alpha-alpha-alpha-beta 4-RDM + static ambit::Tensor compute_4rdm_aaab_same_irrep(GenCIVector& C_left, GenCIVector& C_right); + /// Compute the matrix elements of the alpha-alpha-beta-beta 4-RDM + static ambit::Tensor compute_4rdm_aabb_same_irrep(GenCIVector& C_left, GenCIVector& C_right); + /// Compute the matrix elements of the alpha-beta-beta-beta 4-RDM + static ambit::Tensor compute_4rdm_abbb_same_irrep(GenCIVector& C_left, GenCIVector& C_right); + public: /// @brief Provide a pointer to the a block of the coefficient matrix in such a way that we can /// use its content in several algorithms (sigma vector, RDMs, etc.) diff --git a/forte/genci/genci_vector_rdm.cc b/forte/genci/genci_vector_rdm.cc index a074fe1b2..2ad00a502 100644 --- a/forte/genci/genci_vector_rdm.cc +++ b/forte/genci/genci_vector_rdm.cc @@ -51,6 +51,13 @@ std::shared_ptr GenCIVector::compute_rdms(GenCIVector& C_left, GenCIVector ambit::Tensor g1a, g1b; ambit::Tensor g2aa, g2ab, g2bb; ambit::Tensor g3aaa, g3aab, g3abb, g3bbb; + ambit::Tensor g4aaaa, g4aaab, g4aabb, g4abbb, g4bbbb; + + if (max_rdm_level >= 5) { + throw std::runtime_error( + "RDMs of order 5 or higher are not implemented in GenCISolver (and " + "more generally in Forte)."); + } if (max_rdm_level >= 1) { local_timer t; @@ -109,6 +116,56 @@ std::shared_ptr GenCIVector::compute_rdms(GenCIVector& C_left, GenCIVector } rdm_timing.push_back(t.get()); } + + if (max_rdm_level >= 4){ + local_timer t; + if (na >= 4) { + local_timer t_aaaa; + g4aaaa = compute_4rdm_aaaa_same_irrep(C_left, C_right, true); + psi::outfile->Printf("\n Timing for 4-RDM (aaaa): %.3f s", t_aaaa.get()); + } else { + g4aaaa = + ambit::Tensor::build(ambit::CoreTensor, "g4aaaa", {nmo, nmo, nmo, nmo, nmo, nmo, nmo, nmo}); + g4aaaa.zero(); + } + if (nb >= 4) { + local_timer t_bbbb; + g4bbbb = compute_4rdm_aaaa_same_irrep(C_left, C_right, false); + psi::outfile->Printf("\n Timing for 4-RDM (bbbb): %.3f s", t_bbbb.get()); + } else { + g4bbbb = + ambit::Tensor::build(ambit::CoreTensor, "g4bbbb", {nmo, nmo, nmo, nmo, nmo, nmo, nmo, nmo}); + g4bbbb.zero(); + } + if ((na >= 3) and (nb >= 1)) { + local_timer t_aaab; + g4aaab = compute_4rdm_aaab_same_irrep(C_left, C_right); + psi::outfile->Printf("\n Timing for 4-RDM (aaab): %.3f s", t_aaab.get()); + } else { + g4aaab = + ambit::Tensor::build(ambit::CoreTensor, "g4aaab", {nmo, nmo, nmo, nmo, nmo, nmo, nmo, nmo}); + g4aaab.zero(); + } + if ((na >= 2) and (nb >= 2)) { + local_timer t_aabb; + g4aabb = compute_4rdm_aabb_same_irrep(C_left, C_right); + psi::outfile->Printf("\n Timing for 4-RDM (aabb): %.3f s", t_aabb.get()); + } else { + g4aabb = + ambit::Tensor::build(ambit::CoreTensor, "g4aabb", {nmo, nmo, nmo, nmo, nmo, nmo, nmo, nmo}); + g4aabb.zero(); + } + if ((na >= 1) and (nb >= 3)) { + local_timer t_abbb; + g4abbb = compute_4rdm_abbb_same_irrep(C_left, C_right); + psi::outfile->Printf("\n Timing for 4-RDM (abbb): %.3f s", t_abbb.get()); + } else { + g4abbb = + ambit::Tensor::build(ambit::CoreTensor, "g4abbb", {nmo, nmo, nmo, nmo, nmo, nmo, nmo, nmo}); + g4abbb.zero(); + } + rdm_timing.push_back(t.get()); + } // for (size_t n = 0; n < rdm_timing.size(); ++n) { // psi::outfile->Printf("\n Timing for %d-RDM: %.3f s", n + 1, rdm_timing[n]); @@ -125,7 +182,16 @@ std::shared_ptr GenCIVector::compute_rdms(GenCIVector& C_left, GenCIVector return std::make_shared(g1a, g1b, g2aa, g2ab, g2bb, g3aaa, g3aab, g3abb, g3bbb); } + if (max_rdm_level == 4) { + return std::make_shared(g1a, g1b, g2aa, g2ab, g2bb, g3aaa, g3aab, + g3abb, g3bbb, g4aaaa, g4aaab, g4aabb, g4abbb, + g4bbbb); + } } else { + if (max_rdm_level == 4) { + throw std::runtime_error( + "Spin-free RDMs of order 4 or higher are not implemented in GenCISolver"); + } g1a("pq") += g1b("pq"); if (max_rdm_level > 1) { @@ -144,12 +210,6 @@ std::shared_ptr GenCIVector::compute_rdms(GenCIVector& C_left, GenCIVector if (max_rdm_level == 3) return std::make_shared(g1a, g2aa, g3aaa); } - - if (max_rdm_level >= 4) { - throw std::runtime_error( - "RDMs of order 4 or higher are not implemented in GenCISolver (and " - "more generally in Forte)."); - } return std::make_shared(); } @@ -620,6 +680,203 @@ ambit::Tensor GenCIVector::compute_3rdm_abb_same_irrep(GenCIVector& C_left, GenC return rdm; } +ambit::Tensor GenCIVector::compute_4rdm_aaaa_same_irrep(GenCIVector& C_left, GenCIVector& C_right, bool alfa) { + size_t ncmo = C_left.ncmo_; + const auto& alfa_address = C_left.alfa_address_; + const auto& beta_address = C_left.beta_address_; + const auto& lists = C_left.lists_; + + auto rdm = ambit::Tensor::build(ambit::CoreTensor, alfa ? "4RDM_AAAA" : "4RDM_BBBB", + {ncmo, ncmo, ncmo, ncmo, ncmo, ncmo, ncmo, ncmo}); + + auto na = alfa_address->nones(); + auto nb = beta_address->nones(); + if ((alfa and (na < 4)) or ((!alfa) and (nb < 4))) + return rdm; + + auto& rdm_data = rdm.data(); + + int num_4h_classes = + alfa ? lists->alfa_address_4h()->nclasses() : lists->beta_address_4h()->nclasses(); + + for (int class_K = 0; class_K < num_4h_classes; ++class_K) { + size_t maxK = alfa ? lists->alfa_address_4h()->strpcls(class_K) + : lists->beta_address_4h()->strpcls(class_K); + + // loop over blocks of matrix C + for (const auto& [nI, class_Ia, class_Ib] : lists->determinant_classes()) { + if (lists->detpblk(nI) == 0) + continue; + + auto Cr = C_right.gather_C_block(CR, alfa, alfa_address, beta_address, class_Ia, + class_Ib, false); + + for (const auto& [nJ, class_Ja, class_Jb] : lists->determinant_classes()) { + // The string class on which we don't act must be the same for I and J + if ((alfa and (class_Ib != class_Jb)) or (not alfa and (class_Ia != class_Ja))) + continue; + if (lists->detpblk(nJ) == 0) + continue; + + // Get a pointer to the correct block of matrix C + auto Cl = C_left.gather_C_block(CL, alfa, alfa_address, beta_address, class_Ja, + class_Jb, false); + + size_t maxL = + alfa ? beta_address->strpcls(class_Ib) : alfa_address->strpcls(class_Ia); + if (maxL > 0) { + for (size_t K = 0; K < maxK; ++K) { + std::vector& Krlist = + alfa ? lists->get_alfa_4h_list(class_K, K, class_Ia) + : lists->get_beta_4h_list(class_K, K, class_Ib); + std::vector& Kllist = + alfa ? lists->get_alfa_4h_list(class_K, K, class_Ja) + : lists->get_beta_4h_list(class_K, K, class_Jb); + for (const auto& [sign_K, p, q, r, s, I] : Krlist) { + for (const auto& [sign_L, t, u, v, w, J] : Kllist) { + rdm_data[eight_index(p, q, r, s, t, u, v, w, ncmo)] += + sign_K * sign_L * psi::C_DDOT(maxL, Cl[J], 1, Cr[I], 1); + } + } + } + } + } + } + } + return rdm; +} + +ambit::Tensor GenCIVector::compute_4rdm_aaab_same_irrep(GenCIVector& C_left, GenCIVector& C_right) { + size_t ncmo = C_left.ncmo_; + const auto& lists = C_left.lists_; + + auto rdm = ambit::Tensor::build(ambit::CoreTensor, "4RDM_AAAB", {ncmo, ncmo, ncmo, ncmo, ncmo, ncmo, ncmo, ncmo}); + rdm.zero(); + auto& rdm_data = rdm.data(); + + int num_3h_class_Ka = lists->alfa_address_3h()->nclasses(); + int num_1h_class_Kb = lists->beta_address_1h()->nclasses(); + + for (int class_Ka = 0; class_Ka < num_3h_class_Ka; ++class_Ka) { + size_t maxKa = lists->alfa_address_3h()->strpcls(class_Ka); + + for (int class_Kb = 0; class_Kb < num_1h_class_Kb; ++class_Kb) { + size_t maxKb = lists->beta_address_1h()->strpcls(class_Kb); + + // loop over blocks of matrix C + for (const auto& [nI, class_Ia, class_Ib] : lists->determinant_classes()) { + if (lists->detpblk(nI) == 0) + continue; + + const auto Cr = C_right.C_[nI]->pointer(); + + for (const auto& [nJ, class_Ja, class_Jb] : lists->determinant_classes()) { + if (lists->detpblk(nJ) == 0) + continue; + + // Get a pointer to the correct block of matrix C + const auto Cl = C_left.C_[nJ]->pointer(); + + for (size_t Ka = 0; Ka < maxKa; ++Ka) { + auto& Ka_right_list = lists->get_alfa_3h_list(class_Ka, Ka, class_Ia); + auto& Ka_left_list = lists->get_alfa_3h_list(class_Ka, Ka, class_Ja); + for (size_t Kb = 0; Kb < maxKb; ++Kb) { + auto& Kb_right_list = lists->get_beta_1h_list(class_Kb, Kb, class_Ib); + auto& Kb_left_list = lists->get_beta_1h_list(class_Kb, Kb, class_Jb); + for (const auto& [sign_pqr, p, q, r, Ja] : Ka_left_list) { + for (const auto& [sign_s, s, Jb] : Kb_left_list) { + const double ClJ = sign_pqr * sign_s * Cl[Ja][Jb]; + for (const auto& [sign_tuv, t, u, v, Ia] : Ka_right_list) { + const auto CrIa = Cr[Ia]; + for (const auto& [sign_w, w, Ib] : Kb_right_list) { + rdm_data[eight_index(p, q, r, s, t, u, v, w, ncmo)] += + sign_tuv * sign_w * ClJ * CrIa[Ib]; + } + } + } + } + } + } + } + } + } + } + for (size_t p = 0; p < ncmo; ++p) { + for (size_t q = 0; q < p; ++q) { + for (size_t r = 0; r < q; ++r) { + for (size_t s = 0; s < ncmo; ++s) { + for (size_t t = 0; t < ncmo; ++t) { + for (size_t u = 0; u < t; ++u) { + for (size_t v = 0; v < u; ++v) { + for (size_t w = 0; w < ncmo; ++w) { + const double rdm_element = + rdm_data[eight_index(p, q, r, s, t, u, v, w, ncmo)]; + rdm_data[eight_index(p, q, r, s, t, v, u, w, ncmo)] = -rdm_element; + rdm_data[eight_index(p, q, r, s, u, t, v, w, ncmo)] = -rdm_element; + rdm_data[eight_index(p, q, r, s, u, v, t, w, ncmo)] = rdm_element; + rdm_data[eight_index(p, q, r, s, v, t, u, w, ncmo)] = rdm_element; + rdm_data[eight_index(p, q, r, s, v, u, t, w, ncmo)] = -rdm_element; + rdm_data[eight_index(p, r, q, s, t, u, v, w, ncmo)] = -rdm_element; + rdm_data[eight_index(p, r, q, s, t, v, u, w, ncmo)] = rdm_element; + rdm_data[eight_index(p, r, q, s, u, t, v, w, ncmo)] = rdm_element; + rdm_data[eight_index(p, r, q, s, u, v, t, w, ncmo)] = -rdm_element; + rdm_data[eight_index(p, r, q, s, v, t, u, w, ncmo)] = -rdm_element; + rdm_data[eight_index(p, r, q, s, v, u, t, w, ncmo)] = rdm_element; + rdm_data[eight_index(q, p, r, s, t, u, v, w, ncmo)] = -rdm_element; + rdm_data[eight_index(q, p, r, s, t, v, u, w, ncmo)] = rdm_element; + rdm_data[eight_index(q, p, r, s, u, t, v, w, ncmo)] = rdm_element; + rdm_data[eight_index(q, p, r, s, u, v, t, w, ncmo)] = -rdm_element; + rdm_data[eight_index(q, p, r, s, v, t, u, w, ncmo)] = -rdm_element; + rdm_data[eight_index(q, p, r, s, v, u, t, w, ncmo)] = rdm_element; + rdm_data[eight_index(q, r, p, s, t, u, v, w, ncmo)] = rdm_element; + rdm_data[eight_index(q, r, p, s, t, v, u, w, ncmo)] = -rdm_element; + rdm_data[eight_index(q, r, p, s, u, t, v, w, ncmo)] = -rdm_element; + rdm_data[eight_index(q, r, p, s, u, v, t, w, ncmo)] = rdm_element; + rdm_data[eight_index(q, r, p, s, v, t, u, w, ncmo)] = rdm_element; + rdm_data[eight_index(q, r, p, s, v, u, t, w, ncmo)] = -rdm_element; + rdm_data[eight_index(r, p, q, s, t, u, v, w, ncmo)] = rdm_element; + rdm_data[eight_index(r, p, q, s, t, v, u, w, ncmo)] = -rdm_element; + rdm_data[eight_index(r, p, q, s, u, t, v, w, ncmo)] = -rdm_element; + rdm_data[eight_index(r, p, q, s, u, v, t, w, ncmo)] = rdm_element; + rdm_data[eight_index(r, p, q, s, v, t, u, w, ncmo)] = rdm_element; + rdm_data[eight_index(r, p, q, s, v, u, t, w, ncmo)] = -rdm_element; + rdm_data[eight_index(r, q, p, s, t, u, v, w, ncmo)] = -rdm_element; + rdm_data[eight_index(r, q, p, s, t, v, u, w, ncmo)] = rdm_element; + rdm_data[eight_index(r, q, p, s, u, t, v, w, ncmo)] = rdm_element; + rdm_data[eight_index(r, q, p, s, u, v, t, w, ncmo)] = -rdm_element; + rdm_data[eight_index(r, q, p, s, v, t, u, w, ncmo)] = -rdm_element; + rdm_data[eight_index(r, q, p, s, v, u, t, w, ncmo)] = rdm_element; + } + } + } + } + } + } + } + } + return rdm; +} + +ambit::Tensor GenCIVector::compute_4rdm_aabb_same_irrep(GenCIVector& C_left, GenCIVector& C_right) { + size_t ncmo = C_left.ncmo_; + const auto& lists = C_left.lists_; + + auto rdm = ambit::Tensor::build(ambit::CoreTensor, "4RDM_AABB", {ncmo, ncmo, ncmo, ncmo, ncmo, ncmo, ncmo, ncmo}); + rdm.zero(); + auto& rdm_data = rdm.data(); + return rdm; +} + +ambit::Tensor GenCIVector::compute_4rdm_abbb_same_irrep(GenCIVector& C_left, GenCIVector& C_right) { + size_t ncmo = C_left.ncmo_; + const auto& lists = C_left.lists_; + + auto rdm = ambit::Tensor::build(ambit::CoreTensor, "4RDM_ABBB", {ncmo, ncmo, ncmo, ncmo, ncmo, ncmo, ncmo, ncmo}); + rdm.zero(); + auto& rdm_data = rdm.data(); + return rdm; +} + void GenCIVector::test_rdms(GenCIVector& Cl, GenCIVector& Cr, int max_rdm_level, RDMsType type, std::shared_ptr rdms) { size_t ncmo = Cl.ncmo_; From 377bb356f8e5545587251e2cc62dce69afc5ee0c Mon Sep 17 00:00:00 2001 From: Shuhang Li Date: Thu, 12 Sep 2024 16:39:27 -0400 Subject: [PATCH 22/55] able to compile --- forte/base_classes/rdms.h | 6 ++ forte/genci/genci_string_lists.cc | 22 ++++++++ forte/genci/genci_string_lists.h | 16 ++++++ forte/genci/string_lists_makers.cc | 91 ++++++++++++++++++++++++++++++ forte/genci/string_lists_makers.h | 3 + 5 files changed, 138 insertions(+) diff --git a/forte/base_classes/rdms.h b/forte/base_classes/rdms.h index 36cd1c31d..c2f6b9bca 100644 --- a/forte/base_classes/rdms.h +++ b/forte/base_classes/rdms.h @@ -281,6 +281,12 @@ class RDMsSpinDependent : public RDMs { RDMsSpinDependent(ambit::Tensor g1a, ambit::Tensor g1b, ambit::Tensor g2aa, ambit::Tensor g2ab, ambit::Tensor g2bb, ambit::Tensor g3aaa, ambit::Tensor g3aab, ambit::Tensor g3abb, ambit::Tensor g3bbb); + /// @brief Construct a RDMsSpinDependent object with the 1-, 2-, 3-, and 4-rdms + RDMsSpinDependent(ambit::Tensor g1a, ambit::Tensor g1b, ambit::Tensor g2aa, ambit::Tensor g2ab, + ambit::Tensor g2bb, ambit::Tensor g3aaa, ambit::Tensor g3aab, + ambit::Tensor g3abb, ambit::Tensor g3bbb, ambit::Tensor g4aaaa, + ambit::Tensor g4aaab, ambit::Tensor g4aabb, ambit::Tensor g4abbb, + ambit::Tensor g4bbbb); /// @return the alpha 1-RDM ambit::Tensor g1a() const override; diff --git a/forte/genci/genci_string_lists.cc b/forte/genci/genci_string_lists.cc index 974885347..aabfb79b5 100644 --- a/forte/genci/genci_string_lists.cc +++ b/forte/genci/genci_string_lists.cc @@ -124,6 +124,7 @@ void GenCIStringLists::startup(std::shared_ptr mo_space_info) { double h1_list_timer = 0.0; double h2_list_timer = 0.0; double h3_list_timer = 0.0; + double h4_list_timer = 0.0; double vovo_list_timer = 0.0; double vvoo_list_timer = 0.0; @@ -154,6 +155,8 @@ void GenCIStringLists::startup(std::shared_ptr mo_space_info) { gas_beta_2h_occupations_ = generate_1h_occupations(gas_beta_1h_occupations_); gas_alfa_3h_occupations_ = generate_1h_occupations(gas_alfa_2h_occupations_); gas_beta_3h_occupations_ = generate_1h_occupations(gas_beta_2h_occupations_); + gas_alfa_4h_occupations_ = generate_1h_occupations(gas_alfa_3h_occupations_); + gas_beta_4h_occupations_ = generate_1h_occupations(gas_beta_3h_occupations_); if (na_ >= 1) { auto alfa_1h_strings = make_strings_with_occupation( @@ -187,6 +190,17 @@ void GenCIStringLists::startup(std::shared_ptr mo_space_info) { beta_address_3h_ = std::make_shared(gas_size_, nb_ - 3, beta_3h_strings); } + if (na_ >= 4) { + auto alfa_4h_strings = make_strings_with_occupation( + ngas_spaces_, nirrep_, gas_size_, gas_mos_, gas_alfa_4h_occupations_, string_class_); + alfa_address_4h_ = std::make_shared(gas_size_, na_ - 4, alfa_4h_strings); + } + if (nb_ >= 4) { + auto beta_4h_strings = make_strings_with_occupation( + ngas_spaces_, nirrep_, gas_size_, gas_mos_, gas_beta_4h_occupations_, string_class_); + beta_address_4h_ = std::make_shared(gas_size_, nb_ - 4, beta_4h_strings); + } + nas_ = 0; nbs_ = 0; @@ -251,6 +265,13 @@ void GenCIStringLists::startup(std::shared_ptr mo_space_info) { h3_list_timer += t.get(); } + { + local_timer t; + alfa_4h_list = make_4h_list(alfa_strings_, alfa_address_, alfa_address_4h_); + beta_4h_list = make_4h_list(beta_strings_, beta_address_, beta_address_4h_); + h4_list_timer += t.get(); + } + double total_time = str_list_timer + nn_list_timer + vo_list_timer + oo_list_timer + vvoo_list_timer + vovo_list_timer; @@ -269,6 +290,7 @@ void GenCIStringLists::startup(std::shared_ptr mo_space_info) { {"timing for 1-hole strings", h1_list_timer}, {"timing for 2-hole strings", h2_list_timer}, {"timing for 3-hole strings", h3_list_timer}, + {"timing for 4-hole strings", h4_list_timer}, {"total timing", total_time}}); } std::string table = printer.get_table("String Lists"); diff --git a/forte/genci/genci_string_lists.h b/forte/genci/genci_string_lists.h index d6136686e..6d027b8e6 100644 --- a/forte/genci/genci_string_lists.h +++ b/forte/genci/genci_string_lists.h @@ -104,6 +104,10 @@ class GenCIStringLists { auto alfa_address_3h() { return alfa_address_3h_; } /// @return the beta string address object for N - 3 electrons auto beta_address_3h() { return beta_address_3h_; } + /// @return the alpha string address object for N - 4 electrons + auto alfa_address_4h() { return alfa_address_4h_; } + /// @return the beta string address object for N - 4 electrons + auto beta_address_4h() { return beta_address_4h_; } /// @return the address of a determinant in the CI vector size_t determinant_address(const Determinant& d) const; @@ -151,6 +155,9 @@ class GenCIStringLists { std::vector& get_alfa_3h_list(int h_I, size_t add_I, int h_J); std::vector& get_beta_3h_list(int h_I, size_t add_I, int h_J); + std::vector& get_alfa_4h_list(int h_I, size_t add_I, int h_J); + std::vector& get_beta_4h_list(int h_I, size_t add_I, int h_J); + Pair get_pair_list(int h, int n) const { return pair_list_[h][n]; } private: @@ -195,6 +202,8 @@ class GenCIStringLists { std::vector> gas_beta_2h_occupations_; std::vector> gas_alfa_3h_occupations_; std::vector> gas_beta_3h_occupations_; + std::vector> gas_alfa_4h_occupations_; + std::vector> gas_beta_4h_occupations_; std::vector> gas_occupations_; @@ -248,6 +257,9 @@ class GenCIStringLists { /// The 3-hole lists H3List alfa_3h_list; H3List beta_3h_list; + /// The 4-hole lists + H4List alfa_4h_list; + H4List beta_4h_list; /// Addressers /// The alpha string address @@ -266,6 +278,10 @@ class GenCIStringLists { std::shared_ptr alfa_address_3h_; /// The beta string address for N - 3 electrons std::shared_ptr beta_address_3h_; + /// The alpha string address for N - 4 electrons + std::shared_ptr alfa_address_4h_; + /// The beta string address for N - 4 electrons + std::shared_ptr beta_address_4h_; // ==> Class Functions <== diff --git a/forte/genci/string_lists_makers.cc b/forte/genci/string_lists_makers.cc index 7ec58c412..50af4be48 100644 --- a/forte/genci/string_lists_makers.cc +++ b/forte/genci/string_lists_makers.cc @@ -387,6 +387,97 @@ H3List make_3h_list(const StringList& strings, std::shared_ptr ad return list; } +H4List make_4h_list(const StringList& strings, std::shared_ptr addresser, + std::shared_ptr addresser_4h) { + H4List list; + int n = addresser->nbits(); + int k = addresser->nones(); + size_t nmo = addresser->nbits(); + + if ((k >= 0) and (k <= n)) { + for (const auto& string_class : strings) { + for (const auto& I : string_class) { + const auto& [add_I, class_I] = addresser->address_and_class(I); + for (size_t s = 0; s < nmo; ++s) { + for (size_t r = s + 1; r < nmo; ++r) { + for (size_t q = r + 1; q < nmo; ++q) { + for (size_t p = q + 1; p < nmo; ++p) { + if (I[p] and I[q] and I[r] and I[s]) { + auto J = I; + J[s] = false; + const auto s_sign = J.slater_sign(s); + J[r] = false; + const auto r_sign = J.slater_sign(r); + J[q] = false; + const auto q_sign = J.slater_sign(q); + J[p] = false; + const auto p_sign = J.slater_sign(p); + if (auto it = addresser_4h->find(J); + it != addresser_4h->end()) { + const auto sign = p_sign * q_sign * r_sign * s_sign; + const auto& [add_J, class_J] = it->second; + std::tuple I_tuple(class_J, add_J, + class_I); + list[I_tuple].push_back( + H4StringSubstitution(-sign, p, q, r, s, add_I)); + list[I_tuple].push_back( + H4StringSubstitution(+sign, p, q, s, r, add_I)); + list[I_tuple].push_back( + H4StringSubstitution(+sign, p, r, q, s, add_I)); + list[I_tuple].push_back( + H4StringSubstitution(-sign, p, r, s, q, add_I)); + list[I_tuple].push_back( + H4StringSubstitution(-sign, p, s, q, r, add_I)); + list[I_tuple].push_back( + H4StringSubstitution(+sign, p, s, r, q, add_I)); + list[I_tuple].push_back( + H4StringSubstitution(+sign, q, p, r, s, add_I)); + list[I_tuple].push_back( + H4StringSubstitution(-sign, q, p, s, r, add_I)); + list[I_tuple].push_back( + H4StringSubstitution(-sign, q, r, p, s, add_I)); + list[I_tuple].push_back( + H4StringSubstitution(+sign, q, r, s, p, add_I)); + list[I_tuple].push_back( + H4StringSubstitution(+sign, q, s, p, r, add_I)); + list[I_tuple].push_back( + H4StringSubstitution(-sign, q, s, r, p, add_I)); + list[I_tuple].push_back( + H4StringSubstitution(-sign, r, p, q, s, add_I)); + list[I_tuple].push_back( + H4StringSubstitution(+sign, r, p, s, q, add_I)); + list[I_tuple].push_back( + H4StringSubstitution(+sign, r, q, p, s, add_I)); + list[I_tuple].push_back( + H4StringSubstitution(-sign, r, q, s, p, add_I)); + list[I_tuple].push_back( + H4StringSubstitution(-sign, r, s, p, q, add_I)); + list[I_tuple].push_back( + H4StringSubstitution(+sign, r, s, q, p, add_I)); + list[I_tuple].push_back( + H4StringSubstitution(+sign, s, p, q, r, add_I)); + list[I_tuple].push_back( + H4StringSubstitution(-sign, s, p, r, q, add_I)); + list[I_tuple].push_back( + H4StringSubstitution(-sign, s, q, p, r, add_I)); + list[I_tuple].push_back( + H4StringSubstitution(+sign, s, q, r, p, add_I)); + list[I_tuple].push_back( + H4StringSubstitution(+sign, s, r, p, q, add_I)); + list[I_tuple].push_back( + H4StringSubstitution(-sign, s, r, q, p, add_I)); + } + } + } + } + } + } + } + } + } + return list; +} + std::map, std::vector>> find_string_map(const GenCIStringLists& list_left, const GenCIStringLists& list_right, bool alfa) { std::map, std::vector>> m; diff --git a/forte/genci/string_lists_makers.h b/forte/genci/string_lists_makers.h index e2a3ee6dd..7857dc53f 100644 --- a/forte/genci/string_lists_makers.h +++ b/forte/genci/string_lists_makers.h @@ -79,5 +79,8 @@ H2List make_2h_list(const StringList& strings, std::shared_ptr ad /// Make 3-hole lists (I -> a_p a_q a_r I = sgn J) H3List make_3h_list(const StringList& strings, std::shared_ptr address, std::shared_ptr address_3h); +/// Make 4-hole lists (I -> a_p a_q a_r a_s I = sgn J) +H4List make_4h_list(const StringList& strings, std::shared_ptr address, + std::shared_ptr address_4h); } // namespace forte From 646e1ebc2fa9ae06914eb34f8ace28e6eec87467 Mon Sep 17 00:00:00 2001 From: Shuhang Li Date: Thu, 12 Sep 2024 20:51:55 -0400 Subject: [PATCH 23/55] Looks good, I think. --- forte/genci/genci_vector_rdm.cc | 384 +++++++++++++++++++++++++++----- 1 file changed, 328 insertions(+), 56 deletions(-) diff --git a/forte/genci/genci_vector_rdm.cc b/forte/genci/genci_vector_rdm.cc index 2ad00a502..7b43e90f6 100644 --- a/forte/genci/genci_vector_rdm.cc +++ b/forte/genci/genci_vector_rdm.cc @@ -54,9 +54,9 @@ std::shared_ptr GenCIVector::compute_rdms(GenCIVector& C_left, GenCIVector ambit::Tensor g4aaaa, g4aaab, g4aabb, g4abbb, g4bbbb; if (max_rdm_level >= 5) { - throw std::runtime_error( - "RDMs of order 5 or higher are not implemented in GenCISolver (and " - "more generally in Forte)."); + throw std::runtime_error( + "RDMs of order 5 or higher are not implemented in GenCISolver (and " + "more generally in Forte)."); } if (max_rdm_level >= 1) { @@ -116,16 +116,16 @@ std::shared_ptr GenCIVector::compute_rdms(GenCIVector& C_left, GenCIVector } rdm_timing.push_back(t.get()); } - - if (max_rdm_level >= 4){ + + if (max_rdm_level >= 4) { local_timer t; if (na >= 4) { local_timer t_aaaa; g4aaaa = compute_4rdm_aaaa_same_irrep(C_left, C_right, true); psi::outfile->Printf("\n Timing for 4-RDM (aaaa): %.3f s", t_aaaa.get()); } else { - g4aaaa = - ambit::Tensor::build(ambit::CoreTensor, "g4aaaa", {nmo, nmo, nmo, nmo, nmo, nmo, nmo, nmo}); + g4aaaa = ambit::Tensor::build(ambit::CoreTensor, "g4aaaa", + {nmo, nmo, nmo, nmo, nmo, nmo, nmo, nmo}); g4aaaa.zero(); } if (nb >= 4) { @@ -133,8 +133,8 @@ std::shared_ptr GenCIVector::compute_rdms(GenCIVector& C_left, GenCIVector g4bbbb = compute_4rdm_aaaa_same_irrep(C_left, C_right, false); psi::outfile->Printf("\n Timing for 4-RDM (bbbb): %.3f s", t_bbbb.get()); } else { - g4bbbb = - ambit::Tensor::build(ambit::CoreTensor, "g4bbbb", {nmo, nmo, nmo, nmo, nmo, nmo, nmo, nmo}); + g4bbbb = ambit::Tensor::build(ambit::CoreTensor, "g4bbbb", + {nmo, nmo, nmo, nmo, nmo, nmo, nmo, nmo}); g4bbbb.zero(); } if ((na >= 3) and (nb >= 1)) { @@ -142,8 +142,8 @@ std::shared_ptr GenCIVector::compute_rdms(GenCIVector& C_left, GenCIVector g4aaab = compute_4rdm_aaab_same_irrep(C_left, C_right); psi::outfile->Printf("\n Timing for 4-RDM (aaab): %.3f s", t_aaab.get()); } else { - g4aaab = - ambit::Tensor::build(ambit::CoreTensor, "g4aaab", {nmo, nmo, nmo, nmo, nmo, nmo, nmo, nmo}); + g4aaab = ambit::Tensor::build(ambit::CoreTensor, "g4aaab", + {nmo, nmo, nmo, nmo, nmo, nmo, nmo, nmo}); g4aaab.zero(); } if ((na >= 2) and (nb >= 2)) { @@ -151,8 +151,8 @@ std::shared_ptr GenCIVector::compute_rdms(GenCIVector& C_left, GenCIVector g4aabb = compute_4rdm_aabb_same_irrep(C_left, C_right); psi::outfile->Printf("\n Timing for 4-RDM (aabb): %.3f s", t_aabb.get()); } else { - g4aabb = - ambit::Tensor::build(ambit::CoreTensor, "g4aabb", {nmo, nmo, nmo, nmo, nmo, nmo, nmo, nmo}); + g4aabb = ambit::Tensor::build(ambit::CoreTensor, "g4aabb", + {nmo, nmo, nmo, nmo, nmo, nmo, nmo, nmo}); g4aabb.zero(); } if ((na >= 1) and (nb >= 3)) { @@ -160,8 +160,8 @@ std::shared_ptr GenCIVector::compute_rdms(GenCIVector& C_left, GenCIVector g4abbb = compute_4rdm_abbb_same_irrep(C_left, C_right); psi::outfile->Printf("\n Timing for 4-RDM (abbb): %.3f s", t_abbb.get()); } else { - g4abbb = - ambit::Tensor::build(ambit::CoreTensor, "g4abbb", {nmo, nmo, nmo, nmo, nmo, nmo, nmo, nmo}); + g4abbb = ambit::Tensor::build(ambit::CoreTensor, "g4abbb", + {nmo, nmo, nmo, nmo, nmo, nmo, nmo, nmo}); g4abbb.zero(); } rdm_timing.push_back(t.get()); @@ -680,7 +680,8 @@ ambit::Tensor GenCIVector::compute_3rdm_abb_same_irrep(GenCIVector& C_left, GenC return rdm; } -ambit::Tensor GenCIVector::compute_4rdm_aaaa_same_irrep(GenCIVector& C_left, GenCIVector& C_right, bool alfa) { +ambit::Tensor GenCIVector::compute_4rdm_aaaa_same_irrep(GenCIVector& C_left, GenCIVector& C_right, + bool alfa) { size_t ncmo = C_left.ncmo_; const auto& alfa_address = C_left.alfa_address_; const auto& beta_address = C_left.beta_address_; @@ -750,7 +751,8 @@ ambit::Tensor GenCIVector::compute_4rdm_aaab_same_irrep(GenCIVector& C_left, Gen size_t ncmo = C_left.ncmo_; const auto& lists = C_left.lists_; - auto rdm = ambit::Tensor::build(ambit::CoreTensor, "4RDM_AAAB", {ncmo, ncmo, ncmo, ncmo, ncmo, ncmo, ncmo, ncmo}); + auto rdm = ambit::Tensor::build(ambit::CoreTensor, "4RDM_AAAB", + {ncmo, ncmo, ncmo, ncmo, ncmo, ncmo, ncmo, ncmo}); rdm.zero(); auto& rdm_data = rdm.data(); @@ -809,43 +811,78 @@ ambit::Tensor GenCIVector::compute_4rdm_aaab_same_irrep(GenCIVector& C_left, Gen for (size_t u = 0; u < t; ++u) { for (size_t v = 0; v < u; ++v) { for (size_t w = 0; w < ncmo; ++w) { - const double rdm_element = - rdm_data[eight_index(p, q, r, s, t, u, v, w, ncmo)]; - rdm_data[eight_index(p, q, r, s, t, v, u, w, ncmo)] = -rdm_element; - rdm_data[eight_index(p, q, r, s, u, t, v, w, ncmo)] = -rdm_element; - rdm_data[eight_index(p, q, r, s, u, v, t, w, ncmo)] = rdm_element; - rdm_data[eight_index(p, q, r, s, v, t, u, w, ncmo)] = rdm_element; - rdm_data[eight_index(p, q, r, s, v, u, t, w, ncmo)] = -rdm_element; - rdm_data[eight_index(p, r, q, s, t, u, v, w, ncmo)] = -rdm_element; - rdm_data[eight_index(p, r, q, s, t, v, u, w, ncmo)] = rdm_element; - rdm_data[eight_index(p, r, q, s, u, t, v, w, ncmo)] = rdm_element; - rdm_data[eight_index(p, r, q, s, u, v, t, w, ncmo)] = -rdm_element; - rdm_data[eight_index(p, r, q, s, v, t, u, w, ncmo)] = -rdm_element; - rdm_data[eight_index(p, r, q, s, v, u, t, w, ncmo)] = rdm_element; - rdm_data[eight_index(q, p, r, s, t, u, v, w, ncmo)] = -rdm_element; - rdm_data[eight_index(q, p, r, s, t, v, u, w, ncmo)] = rdm_element; - rdm_data[eight_index(q, p, r, s, u, t, v, w, ncmo)] = rdm_element; - rdm_data[eight_index(q, p, r, s, u, v, t, w, ncmo)] = -rdm_element; - rdm_data[eight_index(q, p, r, s, v, t, u, w, ncmo)] = -rdm_element; - rdm_data[eight_index(q, p, r, s, v, u, t, w, ncmo)] = rdm_element; - rdm_data[eight_index(q, r, p, s, t, u, v, w, ncmo)] = rdm_element; - rdm_data[eight_index(q, r, p, s, t, v, u, w, ncmo)] = -rdm_element; - rdm_data[eight_index(q, r, p, s, u, t, v, w, ncmo)] = -rdm_element; - rdm_data[eight_index(q, r, p, s, u, v, t, w, ncmo)] = rdm_element; - rdm_data[eight_index(q, r, p, s, v, t, u, w, ncmo)] = rdm_element; - rdm_data[eight_index(q, r, p, s, v, u, t, w, ncmo)] = -rdm_element; - rdm_data[eight_index(r, p, q, s, t, u, v, w, ncmo)] = rdm_element; - rdm_data[eight_index(r, p, q, s, t, v, u, w, ncmo)] = -rdm_element; - rdm_data[eight_index(r, p, q, s, u, t, v, w, ncmo)] = -rdm_element; - rdm_data[eight_index(r, p, q, s, u, v, t, w, ncmo)] = rdm_element; - rdm_data[eight_index(r, p, q, s, v, t, u, w, ncmo)] = rdm_element; - rdm_data[eight_index(r, p, q, s, v, u, t, w, ncmo)] = -rdm_element; - rdm_data[eight_index(r, q, p, s, t, u, v, w, ncmo)] = -rdm_element; - rdm_data[eight_index(r, q, p, s, t, v, u, w, ncmo)] = rdm_element; - rdm_data[eight_index(r, q, p, s, u, t, v, w, ncmo)] = rdm_element; - rdm_data[eight_index(r, q, p, s, u, v, t, w, ncmo)] = -rdm_element; - rdm_data[eight_index(r, q, p, s, v, t, u, w, ncmo)] = -rdm_element; - rdm_data[eight_index(r, q, p, s, v, u, t, w, ncmo)] = rdm_element; + const double rdm_element = + rdm_data[eight_index(p, q, r, s, t, u, v, w, ncmo)]; + rdm_data[eight_index(p, q, r, s, t, v, u, w, ncmo)] = + -rdm_element; + rdm_data[eight_index(p, q, r, s, u, t, v, w, ncmo)] = + -rdm_element; + rdm_data[eight_index(p, q, r, s, u, v, t, w, ncmo)] = + rdm_element; + rdm_data[eight_index(p, q, r, s, v, t, u, w, ncmo)] = + rdm_element; + rdm_data[eight_index(p, q, r, s, v, u, t, w, ncmo)] = + -rdm_element; + rdm_data[eight_index(p, r, q, s, t, u, v, w, ncmo)] = + -rdm_element; + rdm_data[eight_index(p, r, q, s, t, v, u, w, ncmo)] = + rdm_element; + rdm_data[eight_index(p, r, q, s, u, t, v, w, ncmo)] = + rdm_element; + rdm_data[eight_index(p, r, q, s, u, v, t, w, ncmo)] = + -rdm_element; + rdm_data[eight_index(p, r, q, s, v, t, u, w, ncmo)] = + -rdm_element; + rdm_data[eight_index(p, r, q, s, v, u, t, w, ncmo)] = + rdm_element; + rdm_data[eight_index(q, p, r, s, t, u, v, w, ncmo)] = + -rdm_element; + rdm_data[eight_index(q, p, r, s, t, v, u, w, ncmo)] = + rdm_element; + rdm_data[eight_index(q, p, r, s, u, t, v, w, ncmo)] = + rdm_element; + rdm_data[eight_index(q, p, r, s, u, v, t, w, ncmo)] = + -rdm_element; + rdm_data[eight_index(q, p, r, s, v, t, u, w, ncmo)] = + -rdm_element; + rdm_data[eight_index(q, p, r, s, v, u, t, w, ncmo)] = + rdm_element; + rdm_data[eight_index(q, r, p, s, t, u, v, w, ncmo)] = + rdm_element; + rdm_data[eight_index(q, r, p, s, t, v, u, w, ncmo)] = + -rdm_element; + rdm_data[eight_index(q, r, p, s, u, t, v, w, ncmo)] = + -rdm_element; + rdm_data[eight_index(q, r, p, s, u, v, t, w, ncmo)] = + rdm_element; + rdm_data[eight_index(q, r, p, s, v, t, u, w, ncmo)] = + rdm_element; + rdm_data[eight_index(q, r, p, s, v, u, t, w, ncmo)] = + -rdm_element; + rdm_data[eight_index(r, p, q, s, t, u, v, w, ncmo)] = + rdm_element; + rdm_data[eight_index(r, p, q, s, t, v, u, w, ncmo)] = + -rdm_element; + rdm_data[eight_index(r, p, q, s, u, t, v, w, ncmo)] = + -rdm_element; + rdm_data[eight_index(r, p, q, s, u, v, t, w, ncmo)] = + rdm_element; + rdm_data[eight_index(r, p, q, s, v, t, u, w, ncmo)] = + rdm_element; + rdm_data[eight_index(r, p, q, s, v, u, t, w, ncmo)] = + -rdm_element; + rdm_data[eight_index(r, q, p, s, t, u, v, w, ncmo)] = + -rdm_element; + rdm_data[eight_index(r, q, p, s, t, v, u, w, ncmo)] = + rdm_element; + rdm_data[eight_index(r, q, p, s, u, t, v, w, ncmo)] = + rdm_element; + rdm_data[eight_index(r, q, p, s, u, v, t, w, ncmo)] = + -rdm_element; + rdm_data[eight_index(r, q, p, s, v, t, u, w, ncmo)] = + -rdm_element; + rdm_data[eight_index(r, q, p, s, v, u, t, w, ncmo)] = + rdm_element; } } } @@ -861,9 +898,107 @@ ambit::Tensor GenCIVector::compute_4rdm_aabb_same_irrep(GenCIVector& C_left, Gen size_t ncmo = C_left.ncmo_; const auto& lists = C_left.lists_; - auto rdm = ambit::Tensor::build(ambit::CoreTensor, "4RDM_AABB", {ncmo, ncmo, ncmo, ncmo, ncmo, ncmo, ncmo, ncmo}); + auto rdm = ambit::Tensor::build(ambit::CoreTensor, "4RDM_AABB", + {ncmo, ncmo, ncmo, ncmo, ncmo, ncmo, ncmo, ncmo}); rdm.zero(); auto& rdm_data = rdm.data(); + + int num_2h_class_Ka = lists->alfa_address_2h()->nclasses(); + int num_2h_class_Kb = lists->beta_address_2h()->nclasses(); + + for (int class_Ka = 0; class_Ka < num_2h_class_Ka; ++class_Ka) { + size_t maxKa = lists->alfa_address_2h()->strpcls(class_Ka); + + for (int class_Kb = 0; class_Kb < num_2h_class_Kb; ++class_Kb) { + size_t maxKb = lists->beta_address_2h()->strpcls(class_Kb); + + // loop over blocks of matrix C + for (const auto& [nI, class_Ia, class_Ib] : lists->determinant_classes()) { + if (lists->detpblk(nI) == 0) + continue; + + const auto Cr = C_right.C_[nI]->pointer(); + + for (const auto& [nJ, class_Ja, class_Jb] : lists->determinant_classes()) { + if (lists->detpblk(nJ) == 0) + continue; + + // Get a pointer to the correct block of matrix C + const auto Cl = C_left.C_[nJ]->pointer(); + + for (size_t Ka = 0; Ka < maxKa; ++Ka) { + auto& Ka_right_list = lists->get_alfa_2h_list(class_Ka, Ka, class_Ia); + auto& Ka_left_list = lists->get_alfa_2h_list(class_Ka, Ka, class_Ja); + for (size_t Kb = 0; Kb < maxKb; ++Kb) { + auto& Kb_right_list = lists->get_beta_2h_list(class_Kb, Kb, class_Ib); + auto& Kb_left_list = lists->get_beta_2h_list(class_Kb, Kb, class_Jb); + for (const auto& [sign_pq, p, q, Ja] : Ka_left_list) { + for (const auto& [sign_rs, r, s, Jb] : Kb_left_list) { + const double ClJ = sign_pq * sign_rs * Cl[Ja][Jb]; + for (const auto& [sign_tu, t, u, Ia] : Ka_right_list) { + const auto CrIa = Cr[Ia]; + for (const auto& [sign_vw, v, w, Ib] : Kb_right_list) { + rdm_data[eight_index(p, q, r, s, t, u, v, w, ncmo)] += + sign_tu * sign_vw * ClJ * CrIa[Ib]; + } + } + } + } + } + } + } + } + } + } + for (size_t p = 0; p < ncmo; ++p) { + for (size_t q = 0; q < p; ++q) { + for (size_t r = 0; r < ncmo; ++r) { + for (size_t s = 0; s < r; ++s) { + for (size_t t = 0; t < ncmo; ++t) { + for (size_t u = 0; u < t; ++u) { + for (size_t v = 0; v < ncmo; ++v) { + for (size_t w = 0; w < v; ++w) { + const double rdm_element = + rdm_data[eight_index(p, q, r, s, t, u, v, w, ncmo)]; + rdm_data[eight_index(p, q, r, s, t, u, w, v, ncmo)] = + -rdm_element; + rdm_data[eight_index(p, q, r, s, u, t, v, w, ncmo)] = + -rdm_element; + rdm_data[eight_index(p, q, r, s, u, t, w, v, ncmo)] = + rdm_element; + rdm_data[eight_index(p, q, s, r, t, u, v, w, ncmo)] = + -rdm_element; + rdm_data[eight_index(p, q, s, r, t, u, w, v, ncmo)] = + rdm_element; + rdm_data[eight_index(p, q, s, r, u, t, v, w, ncmo)] = + rdm_element; + rdm_data[eight_index(p, q, s, r, u, t, w, v, ncmo)] = + -rdm_element; + rdm_data[eight_index(q, p, r, s, t, u, v, w, ncmo)] = + -rdm_element; + rdm_data[eight_index(q, p, r, s, t, u, w, v, ncmo)] = + rdm_element; + rdm_data[eight_index(q, p, r, s, u, t, v, w, ncmo)] = + rdm_element; + rdm_data[eight_index(q, p, r, s, u, t, w, v, ncmo)] = + -rdm_element; + rdm_data[eight_index(q, p, s, r, t, u, v, w, ncmo)] = + rdm_element; + rdm_data[eight_index(q, p, s, r, t, u, w, v, ncmo)] = + -rdm_element; + rdm_data[eight_index(q, p, s, r, u, t, v, w, ncmo)] = + -rdm_element; + rdm_data[eight_index(q, p, s, r, u, t, w, v, ncmo)] = + rdm_element; + } + } + } + } + } + } + } + } + return rdm; } @@ -871,9 +1006,146 @@ ambit::Tensor GenCIVector::compute_4rdm_abbb_same_irrep(GenCIVector& C_left, Gen size_t ncmo = C_left.ncmo_; const auto& lists = C_left.lists_; - auto rdm = ambit::Tensor::build(ambit::CoreTensor, "4RDM_ABBB", {ncmo, ncmo, ncmo, ncmo, ncmo, ncmo, ncmo, ncmo}); + auto rdm = ambit::Tensor::build(ambit::CoreTensor, "4RDM_ABBB", + {ncmo, ncmo, ncmo, ncmo, ncmo, ncmo, ncmo, ncmo}); rdm.zero(); auto& rdm_data = rdm.data(); + + int num_1h_class_Ka = lists->alfa_address_1h()->nclasses(); + int num_3h_class_Kb = lists->beta_address_3h()->nclasses(); + + for (int class_Ka = 0; class_Ka < num_1h_class_Ka; ++class_Ka) { + size_t maxKa = lists->alfa_address_1h()->strpcls(class_Ka); + + for (int class_Kb = 0; class_Kb < num_3h_class_Kb; ++class_Kb) { + size_t maxKb = lists->beta_address_3h()->strpcls(class_Kb); + + // loop over blocks of matrix C + for (const auto& [nI, class_Ia, class_Ib] : lists->determinant_classes()) { + if (lists->detpblk(nI) == 0) + continue; + + const auto Cr = C_right.C_[nI]->pointer(); + + for (const auto& [nJ, class_Ja, class_Jb] : lists->determinant_classes()) { + if (lists->detpblk(nJ) == 0) + continue; + + // Get a pointer to the correct block of matrix C + const auto Cl = C_left.C_[nJ]->pointer(); + + for (size_t Ka = 0; Ka < maxKa; ++Ka) { + auto& Ka_right_list = lists->get_alfa_1h_list(class_Ka, Ka, class_Ia); + auto& Ka_left_list = lists->get_alfa_1h_list(class_Ka, Ka, class_Ja); + for (size_t Kb = 0; Kb < maxKb; ++Kb) { + auto& Kb_right_list = lists->get_beta_3h_list(class_Kb, Kb, class_Ib); + auto& Kb_left_list = lists->get_beta_3h_list(class_Kb, Kb, class_Jb); + for (const auto& [sign_p, p, Ja] : Ka_left_list) { + for (const auto& [sign_qrs, q, r, s, Jb] : Kb_left_list) { + const double ClJ = sign_p * sign_qrs * Cl[Ja][Jb]; + for (const auto& [sign_t, t, Ia] : Ka_right_list) { + const auto CrIa = Cr[Ia]; + for (const auto& [sign_uvw, u, v, w, Ib] : Kb_right_list) { + rdm_data[eight_index(p, q, r, s, t, u, v, w, ncmo)] += + sign_t * sign_uvw * ClJ * CrIa[Ib]; + } + } + } + } + } + } + } + } + } + } + for (size_t p = 0; p < ncmo; ++p) { + for (size_t q = 0; q < ncmo; ++q) { + for (size_t r = 0; r < q; ++r) { + for (size_t s = 0; s < r; ++s) { + for (size_t t = 0; t < ncmo; ++t) { + for (size_t u = 0; u < ncmo; ++u) { + for (size_t v = 0; v < u; ++v) { + for (size_t w = 0; w < v; ++w) { + const double rdm_element = + rdm_data[eight_index(p, q, r, s, t, u, v, w, ncmo)]; + rdm_data[eight_index(p, q, r, s, t, u, w, v, ncmo)] = + -rdm_element; + rdm_data[eight_index(p, q, r, s, t, v, u, w, ncmo)] = + -rdm_element; + rdm_data[eight_index(p, q, r, s, t, v, w, u, ncmo)] = + rdm_element; + rdm_data[eight_index(p, q, r, s, t, w, u, v, ncmo)] = + rdm_element; + rdm_data[eight_index(p, q, r, s, t, w, v, u, ncmo)] = + -rdm_element; + rdm_data[eight_index(p, q, s, r, t, u, v, w, ncmo)] = + -rdm_element; + rdm_data[eight_index(p, q, s, r, t, u, w, v, ncmo)] = + rdm_element; + rdm_data[eight_index(p, q, s, r, t, v, u, w, ncmo)] = + rdm_element; + rdm_data[eight_index(p, q, s, r, t, v, w, u, ncmo)] = + -rdm_element; + rdm_data[eight_index(p, q, s, r, t, w, u, v, ncmo)] = + -rdm_element; + rdm_data[eight_index(p, q, s, r, t, w, v, u, ncmo)] = + rdm_element; + rdm_data[eight_index(p, r, q, s, t, u, v, w, ncmo)] = + -rdm_element; + rdm_data[eight_index(p, r, q, s, t, u, w, v, ncmo)] = + rdm_element; + rdm_data[eight_index(p, r, q, s, t, v, u, w, ncmo)] = + rdm_element; + rdm_data[eight_index(p, r, q, s, t, v, w, u, ncmo)] = + -rdm_element; + rdm_data[eight_index(p, r, q, s, t, w, u, v, ncmo)] = + -rdm_element; + rdm_data[eight_index(p, r, q, s, t, w, v, u, ncmo)] = + rdm_element; + rdm_data[eight_index(p, r, s, q, t, u, v, w, ncmo)] = + rdm_element; + rdm_data[eight_index(p, r, s, q, t, u, w, v, ncmo)] = + -rdm_element; + rdm_data[eight_index(p, r, s, q, t, v, u, w, ncmo)] = + -rdm_element; + rdm_data[eight_index(p, r, s, q, t, v, w, u, ncmo)] = + rdm_element; + rdm_data[eight_index(p, r, s, q, t, w, u, v, ncmo)] = + rdm_element; + rdm_data[eight_index(p, r, s, q, t, w, v, u, ncmo)] = + -rdm_element; + rdm_data[eight_index(p, s, q, r, t, u, v, w, ncmo)] = + rdm_element; + rdm_data[eight_index(p, s, q, r, t, u, w, v, ncmo)] = + -rdm_element; + rdm_data[eight_index(p, s, q, r, t, v, u, w, ncmo)] = + -rdm_element; + rdm_data[eight_index(p, s, q, r, t, v, w, u, ncmo)] = + rdm_element; + rdm_data[eight_index(p, s, q, r, t, w, u, v, ncmo)] = + rdm_element; + rdm_data[eight_index(p, s, q, r, t, w, v, u, ncmo)] = + -rdm_element; + rdm_data[eight_index(p, s, r, q, t, u, v, w, ncmo)] = + -rdm_element; + rdm_data[eight_index(p, s, r, q, t, u, w, v, ncmo)] = + rdm_element; + rdm_data[eight_index(p, s, r, q, t, v, u, w, ncmo)] = + rdm_element; + rdm_data[eight_index(p, s, r, q, t, v, w, u, ncmo)] = + -rdm_element; + rdm_data[eight_index(p, s, r, q, t, w, u, v, ncmo)] = + -rdm_element; + rdm_data[eight_index(p, s, r, q, t, w, v, u, ncmo)] = + rdm_element; + } + } + } + } + } + } + } + } return rdm; } From d7c51d9a633b97fe07af3fe77ebc9efc4623a385 Mon Sep 17 00:00:00 2001 From: Brian Zhao Date: Fri, 13 Sep 2024 16:39:28 -0400 Subject: [PATCH 24/55] Tests pass --- forte/base_classes/rdms.cc | 70 ++++++++++++++++++++++++++++++++++++++ forte/base_classes/rdms.h | 30 ++++++++++++++++ 2 files changed, 100 insertions(+) diff --git a/forte/base_classes/rdms.cc b/forte/base_classes/rdms.cc index 3c48c0a72..418423b1c 100644 --- a/forte/base_classes/rdms.cc +++ b/forte/base_classes/rdms.cc @@ -456,6 +456,35 @@ RDMsSpinDependent::RDMsSpinDependent(ambit::Tensor g1a, ambit::Tensor g1b, ambit _test_rdm_dims(g3bbb, "g3bbb", 6); } +RDMsSpinDependent::RDMsSpinDependent(ambit::Tensor g1a, ambit::Tensor g1b, ambit::Tensor g2aa, ambit::Tensor g2ab, + ambit::Tensor g2bb, ambit::Tensor g3aaa, ambit::Tensor g3aab, + ambit::Tensor g3abb, ambit::Tensor g3bbb, ambit::Tensor g4aaaa, + ambit::Tensor g4aaab, ambit::Tensor g4aabb, ambit::Tensor g4abbb, + ambit::Tensor g4bbbb) + : g1a_(g1a), g1b_(g1b), g2aa_(g2aa), g2ab_(g2ab), + g2bb_(g2bb), g3aaa_(g3aaa), g3aab_(g3aab), + g3abb_(g3abb), g3bbb_(g3bbb), g4aaaa_(g4aaaa), + g4aaab_(g4aaab), g4aabb_(g4aabb), g4abbb_(g4abbb), + g4bbbb_(g4bbbb) { + max_rdm_ = 4; + type_ = RDMsType::spin_dependent; + n_orbs_ = g1a.dim(0); + _test_rdm_dims(g1a, "g1a", 2); + _test_rdm_dims(g1b, "g1b", 2); + _test_rdm_dims(g2aa, "g2aa", 4); + _test_rdm_dims(g2ab, "g2ab", 4); + _test_rdm_dims(g2bb, "g2bb", 4); + _test_rdm_dims(g3aaa, "g3aaa", 6); + _test_rdm_dims(g3aab, "g3aab", 6); + _test_rdm_dims(g3abb, "g3abb", 6); + _test_rdm_dims(g3bbb, "g3bbb", 6); + _test_rdm_dims(g4aaaa, "g4aaaa", 8); + _test_rdm_dims(g4aaab, "g4aaab", 8); + _test_rdm_dims(g4aabb, "g4aabb", 8); + _test_rdm_dims(g4abbb, "g4abbb", 8); + _test_rdm_dims(g4bbbb, "g4bbbb", 8); +} + ambit::Tensor RDMsSpinDependent::g1a() const { _test_rdm_level(1, "g1a"); return g1a_; @@ -492,6 +521,26 @@ ambit::Tensor RDMsSpinDependent::g3bbb() const { _test_rdm_level(3, "g3bbb"); return g3bbb_; } +ambit::Tensor RDMsSpinDependent::g4aaaa() const { + _test_rdm_level(4, "g4aaaa"); + return g4aaaa_; +} +ambit::Tensor RDMsSpinDependent::g4aaab() const { + _test_rdm_level(4, "g4aaab"); + return g4aaab_; +} +ambit::Tensor RDMsSpinDependent::g4aabb() const { + _test_rdm_level(4, "g4aabb"); + return g4aabb_; +} +ambit::Tensor RDMsSpinDependent::g4abbb() const { + _test_rdm_level(4, "g4abbb"); + return g4abbb_; +} +ambit::Tensor RDMsSpinDependent::g4bbbb() const { + _test_rdm_level(4, "g4bbbb"); + return g4bbbb_; +} ambit::Tensor RDMsSpinDependent::SF_G1() const { _test_rdm_level(1, "SF_G1"); auto G1 = g1a_.clone(); @@ -594,6 +643,13 @@ std::shared_ptr RDMsSpinDependent::clone() { g3abb = g3abb_.clone(); g3bbb = g3bbb_.clone(); } + if (max_rdm_ > 3) { + g4aaaa_ = g4aaaa_.clone(); + g4aaab_ = g4aaab_.clone(); + g4aabb_ = g4aabb_.clone(); + g4abbb_ = g4abbb_.clone(); + g4bbbb_ = g4bbbb_.clone(); + } std::shared_ptr rdms; @@ -626,6 +682,13 @@ void RDMsSpinDependent::scale(double factor) { g3abb_.scale(factor); g3bbb_.scale(factor); } + if (max_rdm_ > 3) { + g4aaaa_.scale(factor); + g4aaab_.scale(factor); + g4aabb_.scale(factor); + g4abbb_.scale(factor); + g4bbbb_.scale(factor); + } } void RDMsSpinDependent::axpy(std::shared_ptr rhs, double a) { @@ -732,6 +795,13 @@ void RDMsSpinDependent::dump_to_disk(const std::string& filename_prefix) const { ambit::save(g3abb_, prefix + "g3abb.bin"); ambit::save(g3bbb_, prefix + "g3bbb.bin"); } + if (max_rdm_ > 3) { + ambit::save(g4aaaa_, prefix + "g4aaaa.bin"); + ambit::save(g4aaab_, prefix + "g4aaab.bin"); + ambit::save(g4aabb_, prefix + "g4aabb.bin"); + ambit::save(g4abbb_, prefix + "g4abbb.bin"); + ambit::save(g4bbbb_, prefix + "g4bbbb.bin"); + } } RDMsSpinFree::RDMsSpinFree() { diff --git a/forte/base_classes/rdms.h b/forte/base_classes/rdms.h index c2f6b9bca..8a198e52f 100644 --- a/forte/base_classes/rdms.h +++ b/forte/base_classes/rdms.h @@ -201,6 +201,16 @@ class RDMs { virtual ambit::Tensor g3abb() const = 0; /// @return the beta-beta-beta 3-RDM virtual ambit::Tensor g3bbb() const = 0; + // /// @return the alpha-alpha-alpha-alpha 4-RDM + // virtual ambit::Tensor g4aaaa() const = 0; + // /// @return the alpha-alpha-alpha-beta 4-RDM + // virtual ambit::Tensor g4aaab() const = 0; + // /// @return the alpha-alpha-beta-beta 4-RDM + // virtual ambit::Tensor g4aabb() const = 0; + // /// @return the alpha-beta-beta-beta 4-RDM + // virtual ambit::Tensor g4abbb() const = 0; + // /// @return the beta-beta-beta-beta 4-RDM + // virtual ambit::Tensor g4bbbb() const = 0; // Spin-free RDMs @@ -306,6 +316,16 @@ class RDMsSpinDependent : public RDMs { ambit::Tensor g3abb() const override; /// @return the beta-beta-beta 3-RDM ambit::Tensor g3bbb() const override; + /// @return the alpha-alpha-alpha-alpha 4-RDM + ambit::Tensor g4aaaa() const; + /// @return the alpha-alpha-alpha-beta 4-RDM + ambit::Tensor g4aaab() const; + /// @return the alpha-alpha-beta-beta 4-RDM + ambit::Tensor g4aabb() const; + /// @return the alpha-beta-beta-beta 4-RDM + ambit::Tensor g4abbb() const; + /// @return the beta-beta-beta-beta 4-RDM + ambit::Tensor g4bbbb() const; // Spin-free RDMs @@ -372,6 +392,16 @@ class RDMsSpinDependent : public RDMs { ambit::Tensor g3abb_; /// The beta-beta-beta 3-RDM ambit::Tensor g3bbb_; + /// The alpha-alpha-alpha-alpha 4-RDM + ambit::Tensor g4aaaa_; + /// The alpha-alpha-alpha-beta 4-RDM + ambit::Tensor g4aaab_; + /// The alpha-alpha-beta-beta 4-RDM + ambit::Tensor g4aabb_; + /// The alpha-beta-beta-beta 4-RDM + ambit::Tensor g4abbb_; + /// The beta-beta-beta-beta 4-RDM + ambit::Tensor g4bbbb_; }; class RDMsSpinFree : public RDMs { From 226f826c84697dabc44acd92cabb686c7bd36ea7 Mon Sep 17 00:00:00 2001 From: Brian Zhao Date: Sun, 15 Sep 2024 13:22:31 -0400 Subject: [PATCH 25/55] test rdms --- forte/base_classes/rdms.h | 30 ++--- forte/genci/genci_vector_rdm.cc | 220 +++++++++++++++++++++++++++++++- 2 files changed, 233 insertions(+), 17 deletions(-) diff --git a/forte/base_classes/rdms.h b/forte/base_classes/rdms.h index 8a198e52f..72d01e56e 100644 --- a/forte/base_classes/rdms.h +++ b/forte/base_classes/rdms.h @@ -201,16 +201,16 @@ class RDMs { virtual ambit::Tensor g3abb() const = 0; /// @return the beta-beta-beta 3-RDM virtual ambit::Tensor g3bbb() const = 0; - // /// @return the alpha-alpha-alpha-alpha 4-RDM - // virtual ambit::Tensor g4aaaa() const = 0; - // /// @return the alpha-alpha-alpha-beta 4-RDM - // virtual ambit::Tensor g4aaab() const = 0; - // /// @return the alpha-alpha-beta-beta 4-RDM - // virtual ambit::Tensor g4aabb() const = 0; - // /// @return the alpha-beta-beta-beta 4-RDM - // virtual ambit::Tensor g4abbb() const = 0; - // /// @return the beta-beta-beta-beta 4-RDM - // virtual ambit::Tensor g4bbbb() const = 0; + /// @return the alpha-alpha-alpha-alpha 4-RDM + virtual ambit::Tensor g4aaaa() const; + /// @return the alpha-alpha-alpha-beta 4-RDM + virtual ambit::Tensor g4aaab() const; + /// @return the alpha-alpha-beta-beta 4-RDM + virtual ambit::Tensor g4aabb() const; + /// @return the alpha-beta-beta-beta 4-RDM + virtual ambit::Tensor g4abbb() const; + /// @return the beta-beta-beta-beta 4-RDM + virtual ambit::Tensor g4bbbb() const; // Spin-free RDMs @@ -317,15 +317,15 @@ class RDMsSpinDependent : public RDMs { /// @return the beta-beta-beta 3-RDM ambit::Tensor g3bbb() const override; /// @return the alpha-alpha-alpha-alpha 4-RDM - ambit::Tensor g4aaaa() const; + ambit::Tensor g4aaaa() const override; /// @return the alpha-alpha-alpha-beta 4-RDM - ambit::Tensor g4aaab() const; + ambit::Tensor g4aaab() const override; /// @return the alpha-alpha-beta-beta 4-RDM - ambit::Tensor g4aabb() const; + ambit::Tensor g4aabb() const override; /// @return the alpha-beta-beta-beta 4-RDM - ambit::Tensor g4abbb() const; + ambit::Tensor g4abbb() const override; /// @return the beta-beta-beta-beta 4-RDM - ambit::Tensor g4bbbb() const; + ambit::Tensor g4bbbb() const override; // Spin-free RDMs diff --git a/forte/genci/genci_vector_rdm.cc b/forte/genci/genci_vector_rdm.cc index 7b43e90f6..8ea56f827 100644 --- a/forte/genci/genci_vector_rdm.cc +++ b/forte/genci/genci_vector_rdm.cc @@ -1433,8 +1433,7 @@ void GenCIVector::test_rdms(GenCIVector& Cl, GenCIVector& Cr, int max_rdm_level, auto g3bbb = rdms->g3bbb(); double error_3rdm_bbb = 0.0; - for (size_t p = 0; p < 1; ++p) { - // for (size_t p = 0; p < no_; ++p){ + for (size_t p = 0; p < ncmo; ++p) { for (size_t q = p + 1; q < ncmo; ++q) { for (size_t r = q + 1; r < ncmo; ++r) { for (size_t s = 0; s < ncmo; ++s) { @@ -1469,6 +1468,223 @@ void GenCIVector::test_rdms(GenCIVector& Cl, GenCIVector& Cr, int max_rdm_level, psi::Process::environment.globals["BBBBBB 3-RDM ERROR"] = error_3rdm_bbb; psi::outfile->Printf("\n BBBBBB 3-RDM Error : %+e", error_3rdm_bbb); } + + if (max_rdm_level >= 4) { + auto g4aaaa = rdms->g4aaaa(); + double error_4rdm_aaaa = 0.0; + for (size_t p = 0; p < 1; ++p) { + for (size_t q = p + 1; q < 2; ++q) { + for (size_t r = q + 1; r < 3; ++r) { + for (size_t s = r + 1; s < ncmo; ++s) { + for (size_t t = 0; t < ncmo; ++t) { + for (size_t u = t + 1; u < ncmo; ++u) { + for (size_t v = u + 1; v < ncmo; ++v) { + for (size_t w = v + 1; w < ncmo; ++w) { + double rdm = 0.0; + for (const auto& [I, c_I] : state_vector_r) { + J = I; + double sign = 1.0; + sign *= J.destroy_alfa_bit(t); + sign *= J.destroy_alfa_bit(u); + sign *= J.destroy_alfa_bit(v); + sign *= J.destroy_alfa_bit(w); + sign *= J.create_alfa_bit(s); + sign *= J.create_alfa_bit(r); + sign *= J.create_alfa_bit(q); + sign *= J.create_alfa_bit(p); + if (sign != 0) { + if (state_vector_l.count(J) != 0) { + rdm += sign * state_vector_l[J] * c_I; + } + } + } + if (std::fabs(rdm) > 1.0e-12) { + double rdm_comp = g4aaaa.at({p, q, r, s, t, u, v, w}); + error_4rdm_aaaa += std::fabs(rdm - rdm_comp); + } + } + } + } + } + } + } + } + } + psi::Process::environment.globals["AAAAAAAA 4-RDM ERROR"] = error_4rdm_aaaa; + psi::outfile->Printf("\n AAAAAAAA 4-RDM Error : %+e", error_4rdm_aaaa); + + auto g4aaab = rdms->g4aaab(); + double error_4rdm_aaab = 0.0; + for (size_t p = 0; p < 1; ++p) { + for (size_t q = p + 1; q < 2; ++q) { + for (size_t r = q + 1; r < 3; ++r) { + for (size_t s = 0; s < ncmo; ++s) { + for (size_t t = 0; t < ncmo; ++t) { + for (size_t u = t + 1; u < ncmo; ++u) { + for (size_t v = u + 1; v < ncmo; ++v) { + for (size_t w = 0; w < ncmo; ++w) { + double rdm = 0.0; + for (const auto& [I, c_I] : state_vector_r) { + J = I; + double sign = 1.0; + sign *= J.destroy_alfa_bit(t); + sign *= J.destroy_alfa_bit(u); + sign *= J.destroy_alfa_bit(v); + sign *= J.destroy_beta_bit(w); + sign *= J.create_beta_bit(s); + sign *= J.create_alfa_bit(r); + sign *= J.create_alfa_bit(q); + sign *= J.create_alfa_bit(p); + if (sign != 0) { + if (state_vector_l.count(J) != 0) { + rdm += sign * state_vector_l[J] * c_I; + } + } + } + if (std::fabs(rdm) > 1.0e-12) { + double rdm_comp = g4aaab.at({p, q, r, s, t, u, v, w}); + error_4rdm_aaab += std::fabs(rdm - rdm_comp); + } + } + } + } + } + } + } + } + } + psi::Process::environment.globals["AAABAAAB 4-RDM ERROR"] = error_4rdm_aaab; + psi::outfile->Printf("\n AAABAAAB 4-RDM Error : %+e", error_4rdm_aaab); + + auto g4aabb = rdms->g4aabb(); + double error_4rdm_aabb = 0.0; + for (size_t p = 0; p < 1; ++p) { + for (size_t q = p + 1; q < 2; ++q) { + for (size_t r = 0; r < ncmo; ++r) { + for (size_t s = r + 1; s < ncmo; ++s) { + for (size_t t = 0; t < ncmo; ++t) { + for (size_t u = t + 1; u < ncmo; ++u) { + for (size_t v = 0; v < ncmo; ++v) { + for (size_t w = v + 1; w < ncmo; ++w) { + double rdm = 0.0; + for (const auto& [I, c_I] : state_vector_r) { + J = I; + double sign = 1.0; + sign *= J.destroy_alfa_bit(t); + sign *= J.destroy_alfa_bit(u); + sign *= J.destroy_beta_bit(v); + sign *= J.destroy_beta_bit(w); + sign *= J.create_beta_bit(s); + sign *= J.create_beta_bit(r); + sign *= J.create_alfa_bit(q); + sign *= J.create_alfa_bit(p); + if (sign != 0) { + if (state_vector_l.count(J) != 0) { + rdm += sign * state_vector_l[J] * c_I; + } + } + } + if (std::fabs(rdm) > 1.0e-12) { + double rdm_comp = g4aabb.at({p, q, r, s, t, u, v, w}); + error_4rdm_aabb += std::fabs(rdm - rdm_comp); + } + } + } + } + } + } + } + } + } + psi::Process::environment.globals["AABBAABB 4-RDM ERROR"] = error_4rdm_aabb; + psi::outfile->Printf("\n AABBAABB 4-RDM Error : %+e", error_4rdm_aabb); + + auto g4abbb = rdms->g4abbb(); + double error_4rdm_abbb = 0.0; + for (size_t p = 0; p < ncmo; ++p) { + for (size_t q = 0; q < ncmo; ++q) { + for (size_t r = q + 1; r < ncmo; ++r) { + for (size_t s = r + 1; s < ncmo; ++s) { + for (size_t t = 0; t < ncmo; ++t) { + for (size_t u = 0; u < ncmo; ++u) { + for (size_t v = u + 1; v < ncmo; ++v) { + for (size_t w = v + 1; w < ncmo; ++w) { + double rdm = 0.0; + for (const auto& [I, c_I] : state_vector_r) { + J = I; + double sign = 1.0; + sign *= J.destroy_alfa_bit(t); + sign *= J.destroy_beta_bit(u); + sign *= J.destroy_beta_bit(v); + sign *= J.destroy_beta_bit(w); + sign *= J.create_beta_bit(s); + sign *= J.create_beta_bit(r); + sign *= J.create_beta_bit(q); + sign *= J.create_alfa_bit(p); + if (sign != 0) { + if (state_vector_l.count(J) != 0) { + rdm += sign * state_vector_l[J] * c_I; + } + } + } + if (std::fabs(rdm) > 1.0e-12) { + double rdm_comp = g4abbb.at({p, q, r, s, t, u, v, w}); + error_4rdm_abbb += std::fabs(rdm - rdm_comp); + } + } + } + } + } + } + } + } + } + psi::Process::environment.globals["ABBBABBB 4-RDM ERROR"] = error_4rdm_abbb; + psi::outfile->Printf("\n ABBBABBB 4-RDM Error : %+e", error_4rdm_abbb); + + auto g4bbbb = rdms->g4bbbb(); + double error_4rdm_bbbb = 0.0; + for (size_t p = 0; p < ncmo; ++p) { + for (size_t q = p + 1; q < ncmo; ++q) { + for (size_t r = q + 1; r < ncmo; ++r) { + for (size_t s = r + 1; s < ncmo; ++s) { + for (size_t t = 0; t < ncmo; ++t) { + for (size_t u = t + 1; u < ncmo; ++u) { + for (size_t v = u + 1; v < ncmo; ++v) { + for (size_t w = v + 1; w < ncmo; ++w) { + double rdm = 0.0; + for (const auto& [I, c_I] : state_vector_r) { + J = I; + double sign = 1.0; + sign *= J.destroy_beta_bit(t); + sign *= J.destroy_beta_bit(u); + sign *= J.destroy_beta_bit(v); + sign *= J.destroy_beta_bit(w); + sign *= J.create_beta_bit(s); + sign *= J.create_beta_bit(r); + sign *= J.create_beta_bit(q); + sign *= J.create_beta_bit(p); + if (sign != 0) { + if (state_vector_l.count(J) != 0) { + rdm += sign * state_vector_l[J] * c_I; + } + } + } + if (std::fabs(rdm) > 1.0e-12) { + double rdm_comp = g4bbbb.at({p, q, r, s, t, u, v, w}); + error_4rdm_bbbb += std::fabs(rdm - rdm_comp); + } + } + } + } + } + } + } + } + } + psi::Process::environment.globals["BBBBBBBB 4-RDM ERROR"] = error_4rdm_bbbb; + psi::outfile->Printf("\n BBBBBBBB 4-RDM Error : %+e", error_4rdm_bbbb); + } } } // namespace forte From 7af699cd43d28d07d5b7c5f366dd6b2e157ed7fe Mon Sep 17 00:00:00 2001 From: Shuhang Li Date: Sun, 15 Sep 2024 15:54:50 -0400 Subject: [PATCH 26/55] save from local --- forte/api/forte_python_module.cc | 28 ++- forte/mrdsrg-spin-integrated/master_mrdsrg.h | 11 +- forte/mrdsrg-spin-integrated/mrdsrg.h | 3 + forte/mrdsrg-spin-integrated/mrdsrg_nonpt.cc | 169 +++++++++++++++++++ forte/proc/dsrg.py | 26 ++- 5 files changed, 227 insertions(+), 10 deletions(-) diff --git a/forte/api/forte_python_module.cc b/forte/api/forte_python_module.cc index ed5dd6fdb..3b11ea679 100644 --- a/forte/api/forte_python_module.cc +++ b/forte/api/forte_python_module.cc @@ -282,8 +282,26 @@ PYBIND11_MODULE(_forte, m) { return pyints; }, "Return the full Heff in a dictionary"); + // m.def( + // "Mbar_dict", + // [](std::vector Mbar) { + // std::vector pymbar; + // py::dict pyints; + // for (size_t i = 0; i < Mbar.size(); i++) { + // pyints = {}; + // for (const auto& int_ : Mbar[i]) { + // auto labels = int_.block_labels(); + // for (const auto& label : labels) { + // pyints[py::str(label)] = ambit_to_np(int_.block(label)); + // } + // } + // pymbar.push_back(pyints); + // } + // return pymbar; + // }, + // "Return the full Meff in a list of dictionary"); m.def( - "rdm_dict", + "blocktensor_to_dict", [](ambit::BlockedTensor rdm) { py::dict pyrdm; auto labels = rdm.block_labels(); @@ -292,7 +310,7 @@ PYBIND11_MODULE(_forte, m) { } return pyrdm; }, - "Return the RDM in a dictionary"); + "Return the BlockTensor in a dictionary"); m.def( "L3_dict", [](std::vector rdm) { @@ -384,6 +402,12 @@ PYBIND11_MODULE(_forte, m) { "Return the DSRG dressed ActiveSpaceIntegrals") .def("compute_Heff_full", &MASTER_DSRG::compute_Heff_full, "Return full transformed Hamiltonian") + .def("compute_Mbar0_full", &MASTER_DSRG::compute_Mbar0_full, + "Return full transformed zero-body dipole integrals") + .def("compute_Mbar1_full", &MASTER_DSRG::compute_Mbar1_full, + "Return full transformed one-body dipole integrals") + .def("compute_Mbar2_full", &MASTER_DSRG::compute_Mbar2_full, + "Return full transformed two-body dipole integrals") .def("get_gamma1", &MASTER_DSRG::get_gamma1, "Return the gamma1 tensor") .def("get_eta1", &MASTER_DSRG::get_eta1, "Return the eta1 tensor") .def("get_lambda2", &MASTER_DSRG::get_lambda2, "Return the lambda2 tensor") diff --git a/forte/mrdsrg-spin-integrated/master_mrdsrg.h b/forte/mrdsrg-spin-integrated/master_mrdsrg.h index 2fcac2594..bfc5f32e2 100644 --- a/forte/mrdsrg-spin-integrated/master_mrdsrg.h +++ b/forte/mrdsrg-spin-integrated/master_mrdsrg.h @@ -47,9 +47,14 @@ class MASTER_DSRG : public DynamicCorrelationSolver { /// Compute DSRG transformed Hamiltonian virtual std::shared_ptr compute_Heff_actv(); - /// compute DSRG full transformed Hamiltonian + /// Compute DSRG full transformed Hamiltonian std::vector compute_Heff_full(); + /// Compute DSRG transformed dipole integral + std::vector compute_Mbar0_full() { return Mbar0_full_; } + std::vector compute_Mbar1_full() { return Mbar1_full_; } + std::vector compute_Mbar2_full() { return Mbar2_full_; } + ambit::BlockedTensor get_gamma1() { return Gamma1_; } ambit::BlockedTensor get_eta1() { return Eta1_; } ambit::BlockedTensor get_lambda2() { return Lambda2_; } @@ -384,6 +389,10 @@ class MASTER_DSRG : public DynamicCorrelationSolver { /// DSRG transformed 3-body dipole integrals (active only) std::array Mbar3_; + std::vector Mbar0_full_; /// This is redundant. + std::vector Mbar1_full_; + std::vector Mbar2_full_; + // ==> commutators <== /** * H1, C1, G1: a rank 2 tensor of all MOs in general diff --git a/forte/mrdsrg-spin-integrated/mrdsrg.h b/forte/mrdsrg-spin-integrated/mrdsrg.h index 6e0e076a0..bd66c4b48 100644 --- a/forte/mrdsrg-spin-integrated/mrdsrg.h +++ b/forte/mrdsrg-spin-integrated/mrdsrg.h @@ -257,6 +257,9 @@ class MRDSRG : public MASTER_DSRG { /// commutator void compute_hbar_qc(); + void transform_one_body(const std::vector& oetens); + void compute_mbar_ldsrg2(const ambit::BlockedTensor& M, int ind); + /// Temporary one-body Hamiltonian ambit::BlockedTensor O1_; ambit::BlockedTensor C1_; diff --git a/forte/mrdsrg-spin-integrated/mrdsrg_nonpt.cc b/forte/mrdsrg-spin-integrated/mrdsrg_nonpt.cc index 4fa8299ee..98aeaaa75 100644 --- a/forte/mrdsrg-spin-integrated/mrdsrg_nonpt.cc +++ b/forte/mrdsrg-spin-integrated/mrdsrg_nonpt.cc @@ -40,6 +40,7 @@ #include "helpers/timer.h" #include "base_classes/mo_space_info.h" +#include "integrals/one_body_integrals.h" #include "mrdsrg.h" using namespace psi; @@ -827,6 +828,18 @@ double MRDSRG::compute_energy_ldsrg2() { if (foptions_->get_bool("FULL_HBAR")) { compute_hbar(); + auto mpints = std::make_shared(ints_, mo_space_info_); + // bare dipoles + std::vector M1; + std::vector dp_dirs{"X", "Y", "Z"}; + for (int z = 0; z < 3; ++z) { + std::string name = "DIPOLE " + dp_dirs[z]; + ambit::BlockedTensor m1 = BTF_->build(tensor_type_, name, spin_cases({"gg"})); + m1.iterate([&](const std::vector& i, const std::vector&, + double& value) { value = mpints->dp_ints_corr(z, i[0], i[1]); }); + M1.push_back(m1); + } + transform_one_body(M1); } final.stop(); @@ -835,6 +848,162 @@ double MRDSRG::compute_energy_ldsrg2() { return Ecorr; } +void MRDSRG::transform_one_body(const std::vector& oetens) { + int n_tensors = oetens.size(); + Mbar0_full_ = std::vector(n_tensors, 0.0); + Mbar1_full_.resize(n_tensors); + Mbar2_full_.resize(n_tensors); + for (int i = 0; i < n_tensors; ++i) { + Mbar1_full_[i] = BTF_->build(tensor_type_, oetens[i].name() + "1", spin_cases({"gg"})); + Mbar2_full_[i] = BTF_->build(tensor_type_, oetens[i].name() + "2", spin_cases({"gggg"})); + const auto& M = oetens[i]; + compute_mbar_ldsrg2(M, i); + } +} + +void MRDSRG::compute_mbar_ldsrg2(const ambit::BlockedTensor& M, int ind) { + // compute reference multipole + { + Mbar0_full_[ind] = M["uv"] * Gamma1_["vu"]; + Mbar0_full_[ind] += M["UV"] * Gamma1_["VU"]; + auto& M1c = M.block("cc").data(); + for (size_t m = 0, ncore = core_mos_.size(); m < ncore; ++m) { + Mbar0_full_[ind] += M1c[m * ncore + m]; + } + auto& M1C = M.block("CC").data(); + for (size_t m = 0, ncore = core_mos_.size(); m < ncore; ++m) { + Mbar0_full_[ind] += M1C[m * ncore + m]; + } + Mbar1_full_[ind]["pq"] = M["pq"]; + Mbar1_full_[ind]["PQ"] = M["PQ"]; + } + + O1_["pq"] = M["pq"]; + O1_["PQ"] = M["PQ"]; + + bool converged = false; + int maxn = foptions_->get_int("DSRG_RSC_NCOMM"); + double ct_threshold = foptions_->get_double("DSRG_RSC_THRESHOLD"); + std::string dsrg_op = foptions_->get_str("DSRG_TRANS_TYPE"); + + // compute Hbar recursively + for (int n = 1; n <= maxn; ++n) { + // prefactor before n-nested commutator + double factor = 1.0 / n; + + // Compute the commutator C = 1/n [O, T] + double C0 = 0.0; + C1_.zero(); + C2_.zero(); + + // zero-body + H1_T1_C0(O1_, T1_, factor, C0); + H1_T2_C0(O1_, T2_, factor, C0); + if (n != 1) { + H2_T1_C0(O2_, T1_, factor, C0); + H2_T2_C0(O2_, T2_, factor, C0); + } + // one-body + H1_T1_C1(O1_, T1_, factor, C1_); + H1_T2_C1(O1_, T2_, factor, C1_); + if (n != 1) { + H2_T1_C1(O2_, T1_, factor, C1_); + } + if (foptions_->get_str("SRG_COMM") == "STANDARD") { + if (n != 1) { + H2_T2_C1(O2_, T2_, factor, C1_); + } + } else if (foptions_->get_str("SRG_COMM") == "FO") { + BlockedTensor C1p = BTF_->build(tensor_type_, "C1p", spin_cases({"gg"})); + if (n != 1) { + H2_T2_C1(O2_, T2_, factor, C1p); + } + C1p.block("cc").scale(2.0); + C1p.block("aa").scale(2.0); + C1p.block("vv").scale(2.0); + C1p.block("CC").scale(2.0); + C1p.block("AA").scale(2.0); + C1p.block("VV").scale(2.0); + C1_["pq"] += C1p["pq"]; + C1_["PQ"] += C1p["PQ"]; + } + // two-body + if ((foptions_->get_str("SRG_COMM") == "STANDARD") or n < 2) { + H1_T2_C2(O1_, T2_, factor, C2_); + } else if (foptions_->get_str("SRG_COMM") == "FO2") { + O1_.block("cc").scale(2.0); + O1_.block("aa").scale(2.0); + O1_.block("vv").scale(2.0); + O1_.block("CC").scale(2.0); + O1_.block("AA").scale(2.0); + O1_.block("VV").scale(2.0); + H1_T2_C2(O1_, T2_, factor, C2_); + O1_.block("cc").scale(0.5); + O1_.block("aa").scale(0.5); + O1_.block("vv").scale(0.5); + O1_.block("CC").scale(0.5); + O1_.block("AA").scale(0.5); + O1_.block("VV").scale(0.5); + } + if (n != 1) { + H2_T1_C2(O2_, T1_, factor, C2_); + H2_T2_C2(O2_, T2_, factor, C2_); + } + + // printing level + if (print_ > 3) { + std::string dash(38, '-'); + outfile->Printf("\n %s\n", dash.c_str()); + } + + // [H, A] = [H, T] + [H, T]^dagger + if (dsrg_op == "UNITARY") { + C0 *= 2.0; + O1_["pq"] = C1_["pq"]; + O1_["PQ"] = C1_["PQ"]; + C1_["pq"] += O1_["qp"]; + C1_["PQ"] += O1_["QP"]; + O2_["pqrs"] = C2_["pqrs"]; + O2_["pQrS"] = C2_["pQrS"]; + O2_["PQRS"] = C2_["PQRS"]; + C2_["pqrs"] += O2_["rspq"]; + C2_["pQrS"] += O2_["rSpQ"]; + C2_["PQRS"] += O2_["RSPQ"]; + } + + // Hbar += C + Mbar0_full_[ind] += C0; + Mbar1_full_[ind]["pq"] += C1_["pq"]; + Mbar1_full_[ind]["PQ"] += C1_["PQ"]; + Mbar2_full_[ind]["pqrs"] += C2_["pqrs"]; + Mbar2_full_[ind]["pQrS"] += C2_["pQrS"]; + Mbar2_full_[ind]["PQRS"] += C2_["PQRS"]; + + // copy C to O for next level commutator + O1_["pq"] = C1_["pq"]; + O1_["PQ"] = C1_["PQ"]; + O2_["pqrs"] = C2_["pqrs"]; + O2_["pQrS"] = C2_["pQrS"]; + O2_["PQRS"] = C2_["PQRS"]; + + // test convergence of C + double norm_C1 = C1_.norm(); + double norm_C2 = C2_.norm(); + if (print_ > 3) { + outfile->Printf("\n n: %3d, C0: %20.15f, C1 max: %20.15f, C2 max: %20.15f", n, C0, + C1_.norm(0), C2_.norm(0)); + } + if (std::sqrt(norm_C2 * norm_C2 + norm_C1 * norm_C1) < ct_threshold) { + converged = true; + break; + } + } + if (!converged) { + outfile->Printf("\n Warning! Mbar is not converged in %3d-nested commutators!", maxn); + outfile->Printf("\n Please increase DSRG_RSC_NCOMM."); + } +} + void MRDSRG::compute_hbar_qc() { std::string dsrg_op = foptions_->get_str("DSRG_TRANS_TYPE"); diff --git a/forte/proc/dsrg.py b/forte/proc/dsrg.py index d59f8f406..72177fd35 100644 --- a/forte/proc/dsrg.py +++ b/forte/proc/dsrg.py @@ -413,6 +413,9 @@ def compute_energy(self): e_dsrg = self.dsrg_solver.compute_energy() ################ + if self.solver_type == 'SA-MRDSRG': + print("HERE") + asmpints = self.dsrg_solver.compute_mp_eff_actv() if self.options.get_bool('FULL_HBAR'): # Heff = self.dsrg_solver.compute_Heff_full() # Heff_dict = forte.Heff_dict(Heff) @@ -421,22 +424,31 @@ def compute_energy(self): eta1 = self.dsrg_solver.get_eta1() lambda2 = self.dsrg_solver.get_lambda2() lambda3 = self.dsrg_solver.get_lambda3() - gamma1_dict = forte.rdm_dict(gamma1) - eta_1_dict = forte.rdm_dict(eta1) - lambda2_dict = forte.rdm_dict(lambda2) + gamma1_dict = forte.blocktensor_to_dict(gamma1) + eta_1_dict = forte.blocktensor_to_dict(eta1) + lambda2_dict = forte.blocktensor_to_dict(lambda2) if self.solver_type in ["MRDSRG_SO", "MRDSRG-SO"]: - lambda3_dict = forte.rdm_dict(lambda3) + lambda3_dict = forte.blocktensor_to_dict(lambda3) else: lambda3_dict = forte.L3_dict(lambda3) + Mbar0 = self.dsrg_solver.compute_Mbar0_full() + print(Mbar0) + np.save('Mbar0', Mbar0) + Mbar1 = self.dsrg_solver.compute_Mbar1_full() + Mbar2 = self.dsrg_solver.compute_Mbar2_full() + + for i in range(3): + np.savez(f"Mbar1_{i}", **forte.blocktensor_to_dict(Mbar1[i])) + np.savez(f"Mbar2_{i}", **forte.blocktensor_to_dict(Mbar2[i])) + # Heff_dict = forte.Heff_dict(Heff) + # np.savez('save_Hbar', **Heff_dict) + np.savez('save_gamma1', **gamma1_dict) np.savez('save_eta1', **eta_1_dict) np.savez('save_lambda2', **lambda2_dict) np.savez('save_lambda3', **lambda3_dict) - dp1 = self.ints.mo_dipole_ints() - np.save('save_dp1', dp1) - # self.rdms = self.active_space_solver.compute_average_rdms( # self.state_weights_map, self.max_rdm_level, self.rdm_type # ) From e77cb251a51c34de50e7ba67518f8dd2fc4e8cd3 Mon Sep 17 00:00:00 2001 From: Brian Zhao Date: Tue, 17 Sep 2024 11:27:34 -0400 Subject: [PATCH 27/55] Fix compile issues --- forte/base_classes/rdms.cc | 30 ++++++++++++++++++++++++++++++ forte/base_classes/rdms.h | 20 +++++++++++++++----- 2 files changed, 45 insertions(+), 5 deletions(-) diff --git a/forte/base_classes/rdms.cc b/forte/base_classes/rdms.cc index 418423b1c..f1e5e58be 100644 --- a/forte/base_classes/rdms.cc +++ b/forte/base_classes/rdms.cc @@ -901,6 +901,36 @@ ambit::Tensor RDMsSpinFree::g3bbb() const { g3bbb.set_name("g3bbb"); return g3bbb; } +ambit::Tensor RDMsSpinFree::g4aaaa() const { + // TODO: Implement g4aaaa + _test_rdm_level(20, "g4aaaa"); + ambit::Tensor g4aaaa; + return g4aaaa; +} +ambit::Tensor RDMsSpinFree::g4aaab() const { + // TODO: Implement g4aaab + _test_rdm_level(20, "g4aaab"); + ambit::Tensor g4aaab; + return g4aaab; +} +ambit::Tensor RDMsSpinFree::g4aabb() const { + // TODO: Implement g4aabb + _test_rdm_level(20, "g4aabb"); + ambit::Tensor g4aabb; + return g4aabb; +} +ambit::Tensor RDMsSpinFree::g4abbb() const { + // TODO: Implement g4abbb + _test_rdm_level(20, "g4abbb"); + ambit::Tensor g4abbb; + return g4abbb; +} +ambit::Tensor RDMsSpinFree::g4bbbb() const { + // TODO: Implement g4bbbb + _test_rdm_level(20, "g4bbbb"); + ambit::Tensor g4bbbb; + return g4bbbb; +} ambit::Tensor RDMsSpinFree::L1a() const { _test_rdm_level(1, "L1a"); auto L1a = sf1_to_sd1(SF_G1_); diff --git a/forte/base_classes/rdms.h b/forte/base_classes/rdms.h index 72d01e56e..b51e0551a 100644 --- a/forte/base_classes/rdms.h +++ b/forte/base_classes/rdms.h @@ -202,15 +202,15 @@ class RDMs { /// @return the beta-beta-beta 3-RDM virtual ambit::Tensor g3bbb() const = 0; /// @return the alpha-alpha-alpha-alpha 4-RDM - virtual ambit::Tensor g4aaaa() const; + virtual ambit::Tensor g4aaaa() const = 0; /// @return the alpha-alpha-alpha-beta 4-RDM - virtual ambit::Tensor g4aaab() const; + virtual ambit::Tensor g4aaab() const = 0; /// @return the alpha-alpha-beta-beta 4-RDM - virtual ambit::Tensor g4aabb() const; + virtual ambit::Tensor g4aabb() const = 0; /// @return the alpha-beta-beta-beta 4-RDM - virtual ambit::Tensor g4abbb() const; + virtual ambit::Tensor g4abbb() const = 0; /// @return the beta-beta-beta-beta 4-RDM - virtual ambit::Tensor g4bbbb() const; + virtual ambit::Tensor g4bbbb() const = 0; // Spin-free RDMs @@ -433,6 +433,16 @@ class RDMsSpinFree : public RDMs { ambit::Tensor g3abb() const override; /// @return the beta-beta-beta 3-RDM ambit::Tensor g3bbb() const override; + /// @return the alpha-alpha-alpha-alpha 4-RDM + ambit::Tensor g4aaaa() const override; + /// @return the alpha-alpha-alpha-beta 4-RDM + ambit::Tensor g4aaab() const override; + /// @return the alpha-alpha-beta-beta 4-RDM + ambit::Tensor g4aabb() const override; + /// @return the alpha-beta-beta-beta 4-RDM + ambit::Tensor g4abbb() const override; + /// @return the beta-beta-beta-beta 4-RDM + ambit::Tensor g4bbbb() const override; // Spin-free RDMs From 7780d650991ab10ae6d07b378b3b5d9091592168 Mon Sep 17 00:00:00 2001 From: Brian Zhao Date: Tue, 17 Sep 2024 13:51:01 -0400 Subject: [PATCH 28/55] Add to_double's --- forte/genci/genci_vector_rdm.cc | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/forte/genci/genci_vector_rdm.cc b/forte/genci/genci_vector_rdm.cc index e8b74616b..6febcddfd 100644 --- a/forte/genci/genci_vector_rdm.cc +++ b/forte/genci/genci_vector_rdm.cc @@ -1494,7 +1494,7 @@ void GenCIVector::test_rdms(GenCIVector& Cl, GenCIVector& Cr, int max_rdm_level, sign *= J.create_alfa_bit(p); if (sign != 0) { if (state_vector_l.count(J) != 0) { - rdm += sign * state_vector_l[J] * c_I; + rdm += sign * to_double(state_vector_l[J] * c_I); } } } @@ -1537,7 +1537,7 @@ void GenCIVector::test_rdms(GenCIVector& Cl, GenCIVector& Cr, int max_rdm_level, sign *= J.create_alfa_bit(p); if (sign != 0) { if (state_vector_l.count(J) != 0) { - rdm += sign * state_vector_l[J] * c_I; + rdm += sign * to_double(state_vector_l[J] * c_I); } } } @@ -1580,7 +1580,7 @@ void GenCIVector::test_rdms(GenCIVector& Cl, GenCIVector& Cr, int max_rdm_level, sign *= J.create_alfa_bit(p); if (sign != 0) { if (state_vector_l.count(J) != 0) { - rdm += sign * state_vector_l[J] * c_I; + rdm += sign * to_double(state_vector_l[J] * c_I); } } } @@ -1623,7 +1623,7 @@ void GenCIVector::test_rdms(GenCIVector& Cl, GenCIVector& Cr, int max_rdm_level, sign *= J.create_alfa_bit(p); if (sign != 0) { if (state_vector_l.count(J) != 0) { - rdm += sign * state_vector_l[J] * c_I; + rdm += sign * to_double(state_vector_l[J] * c_I); } } } @@ -1666,7 +1666,7 @@ void GenCIVector::test_rdms(GenCIVector& Cl, GenCIVector& Cr, int max_rdm_level, sign *= J.create_beta_bit(p); if (sign != 0) { if (state_vector_l.count(J) != 0) { - rdm += sign * state_vector_l[J] * c_I; + rdm += sign * to_double(state_vector_l[J] * c_I); } } } From 4336ec617c5ca5871a697abb56b70fa00b94f230 Mon Sep 17 00:00:00 2001 From: Brian Zhao Date: Tue, 17 Sep 2024 15:27:29 -0400 Subject: [PATCH 29/55] Working 4rdm test --- forte/base_classes/rdms.cc | 17 +- forte/genci/genci_solver.cc | 2 +- forte/genci/genci_vector_rdm.cc | 19 +- tests/methods/fci-rdms-1/output.ref | 928 +++++++++++++++++++++++++++ tests/methods/fci-rdms-3/input.dat | 42 ++ tests/methods/fci-rdms-3/output.ref | 956 ++++++++++++++++++++++++++++ tests/methods/tests.yaml | 1 + 7 files changed, 1952 insertions(+), 13 deletions(-) create mode 100644 tests/methods/fci-rdms-1/output.ref create mode 100644 tests/methods/fci-rdms-3/input.dat create mode 100644 tests/methods/fci-rdms-3/output.ref diff --git a/forte/base_classes/rdms.cc b/forte/base_classes/rdms.cc index f1e5e58be..77aff92d3 100644 --- a/forte/base_classes/rdms.cc +++ b/forte/base_classes/rdms.cc @@ -42,11 +42,13 @@ std::shared_ptr RDMs::build(size_t max_rdm_level, size_t n_orbs, RDMsType std::vector dims1(2, n_orbs); std::vector dims2(4, n_orbs); std::vector dims3(6, n_orbs); + std::vector dims4(8, n_orbs); std::shared_ptr rdms; if (type == RDMsType::spin_dependent) { - ambit::Tensor g1a, g1b, g2aa, g2ab, g2bb, g3aaa, g3aab, g3abb, g3bbb; + ambit::Tensor g1a, g1b, g2aa, g2ab, g2bb, g3aaa, g3aab, g3abb, g3bbb, + g4aaaa, g4aaab, g4aabb, g4abbb, g4bbbb; if (max_rdm_level > 0) { g1a = ambit::Tensor::build(ambit::CoreTensor, "g1a", dims1); g1b = ambit::Tensor::build(ambit::CoreTensor, "g1b", dims1); @@ -62,6 +64,13 @@ std::shared_ptr RDMs::build(size_t max_rdm_level, size_t n_orbs, RDMsType g3abb = ambit::Tensor::build(ambit::CoreTensor, "g3abb", dims3); g3bbb = ambit::Tensor::build(ambit::CoreTensor, "g3bbb", dims3); } + if (max_rdm_level > 3) { + g4aaaa = ambit::Tensor::build(ambit::CoreTensor, "g4aaaa", dims4); + g4aaab = ambit::Tensor::build(ambit::CoreTensor, "g4aaab", dims4); + g4aabb = ambit::Tensor::build(ambit::CoreTensor, "g4aabb", dims4); + g4abbb = ambit::Tensor::build(ambit::CoreTensor, "g4abbb", dims4); + g4bbbb = ambit::Tensor::build(ambit::CoreTensor, "g4bbbb", dims4); + } if (max_rdm_level < 1) { rdms = std::make_shared(); @@ -69,9 +78,13 @@ std::shared_ptr RDMs::build(size_t max_rdm_level, size_t n_orbs, RDMsType rdms = std::make_shared(g1a, g1b); } else if (max_rdm_level == 2) { rdms = std::make_shared(g1a, g1b, g2aa, g2ab, g2bb); - } else { + } else if (max_rdm_level == 3) { rdms = std::make_shared(g1a, g1b, g2aa, g2ab, g2bb, g3aaa, g3aab, g3abb, g3bbb); + } else { + rdms = std::make_shared(g1a, g1b, g2aa, g2ab, g2bb, g3aaa, g3aab, + g3abb, g3bbb, g4aaaa, g4aaab, g4aabb, g4abbb, + g4bbbb); } } else { ambit::Tensor g1, g2, g3; diff --git a/forte/genci/genci_solver.cc b/forte/genci/genci_solver.cc index bf96e45ae..dc0f66cd3 100644 --- a/forte/genci/genci_solver.cc +++ b/forte/genci/genci_solver.cc @@ -375,7 +375,7 @@ void GenCISolver::test_rdms(std::shared_ptr b, std::shared_ptrcompute_rdms(*C_, *C_, max_rdm_level, RDMsType::spin_dependent); C_->test_rdms(*C_, *C_, max_rdm_level, RDMsType::spin_dependent, rdms); } diff --git a/forte/genci/genci_vector_rdm.cc b/forte/genci/genci_vector_rdm.cc index 6febcddfd..f3defd291 100644 --- a/forte/genci/genci_vector_rdm.cc +++ b/forte/genci/genci_vector_rdm.cc @@ -1321,8 +1321,7 @@ void GenCIVector::test_rdms(GenCIVector& Cl, GenCIVector& Cr, int max_rdm_level, if (max_rdm_level >= 3) { auto g3aaa = rdms->g3aaa(); double error_3rdm_aaa = 0.0; - // for (size_t p = 0; p < no_; ++p){ - for (size_t p = 0; p < 1; ++p) { + for (size_t p = 0; p < ncmo; ++p) { for (size_t q = p + 1; q < ncmo; ++q) { for (size_t r = q + 1; r < ncmo; ++r) { for (size_t s = 0; s < ncmo; ++s) { @@ -1472,9 +1471,9 @@ void GenCIVector::test_rdms(GenCIVector& Cl, GenCIVector& Cr, int max_rdm_level, if (max_rdm_level >= 4) { auto g4aaaa = rdms->g4aaaa(); double error_4rdm_aaaa = 0.0; - for (size_t p = 0; p < 1; ++p) { - for (size_t q = p + 1; q < 2; ++q) { - for (size_t r = q + 1; r < 3; ++r) { + for (size_t p = 0; p < ncmo; ++p) { + for (size_t q = p + 1; q < ncmo; ++q) { + for (size_t r = q + 1; r < ncmo; ++r) { for (size_t s = r + 1; s < ncmo; ++s) { for (size_t t = 0; t < ncmo; ++t) { for (size_t u = t + 1; u < ncmo; ++u) { @@ -1515,9 +1514,9 @@ void GenCIVector::test_rdms(GenCIVector& Cl, GenCIVector& Cr, int max_rdm_level, auto g4aaab = rdms->g4aaab(); double error_4rdm_aaab = 0.0; - for (size_t p = 0; p < 1; ++p) { - for (size_t q = p + 1; q < 2; ++q) { - for (size_t r = q + 1; r < 3; ++r) { + for (size_t p = 0; p < ncmo; ++p) { + for (size_t q = p + 1; q < ncmo; ++q) { + for (size_t r = q + 1; r < ncmo; ++r) { for (size_t s = 0; s < ncmo; ++s) { for (size_t t = 0; t < ncmo; ++t) { for (size_t u = t + 1; u < ncmo; ++u) { @@ -1558,8 +1557,8 @@ void GenCIVector::test_rdms(GenCIVector& Cl, GenCIVector& Cr, int max_rdm_level, auto g4aabb = rdms->g4aabb(); double error_4rdm_aabb = 0.0; - for (size_t p = 0; p < 1; ++p) { - for (size_t q = p + 1; q < 2; ++q) { + for (size_t p = 0; p < ncmo; ++p) { + for (size_t q = p + 1; q < ncmo; ++q) { for (size_t r = 0; r < ncmo; ++r) { for (size_t s = r + 1; s < ncmo; ++s) { for (size_t t = 0; t < ncmo; ++t) { diff --git a/tests/methods/fci-rdms-1/output.ref b/tests/methods/fci-rdms-1/output.ref new file mode 100644 index 000000000..7af108138 --- /dev/null +++ b/tests/methods/fci-rdms-1/output.ref @@ -0,0 +1,928 @@ + + ----------------------------------------------------------------------- + Psi4: An Open-Source Ab Initio Electronic Structure Package + Psi4 1.10a1.dev53 + + Git: Rev {master} 45660d8 dirty + + + D. G. A. Smith, L. A. Burns, A. C. Simmonett, R. M. Parrish, + M. C. Schieber, R. Galvelis, P. Kraus, H. Kruse, R. Di Remigio, + A. Alenaizan, A. M. James, S. Lehtola, J. P. Misiewicz, M. Scheurer, + R. A. Shaw, J. B. Schriber, Y. Xie, Z. L. Glick, D. A. Sirianni, + J. S. O'Brien, J. M. Waldrop, A. Kumar, E. G. Hohenstein, + B. P. Pritchard, B. R. Brooks, H. F. Schaefer III, A. Yu. Sokolov, + K. Patkowski, A. E. DePrince III, U. Bozkaya, R. A. King, + F. A. Evangelista, J. M. Turney, T. D. Crawford, C. D. Sherrill, + J. Chem. Phys. 152(18) 184108 (2020). https://doi.org/10.1063/5.0006002 + + Additional Code Authors + E. T. Seidl, C. L. Janssen, E. F. Valeev, M. L. Leininger, + J. F. Gonthier, R. M. Richard, H. R. McAlexander, M. Saitow, X. Wang, + P. Verma, M. H. Lechner, A. Jiang, S. Behnle, A. G. Heide, + M. F. Herbst, and D. L. Poole + + Previous Authors, Complete List of Code Contributors, + and Citations for Specific Modules + https://github.com/psi4/psi4/blob/master/codemeta.json + https://github.com/psi4/psi4/graphs/contributors + http://psicode.org/psi4manual/master/introduction.html#citing-psifour + + ----------------------------------------------------------------------- + + + Psi4 started on: Tuesday, 17 September 2024 03:25PM + + Process ID: 19158 + Host: Brian-Zs-MBA.local + PSIDATADIR: /Users/brianz98/local/psi4/objdir-Release/stage/share/psi4 + Memory: 500.0 MiB + Threads: 1 + + ==> Input File <== + +-------------------------------------------------------------------------- +#! Generated using commit GITCOMMIT + +import forte + +molecule { +0 1 +Li +H 1 R + +R = 3.0 +units bohr +} + +set { + basis sto-3g + reference rhf + scf_type pk + e_convergence 12 +} + +set forte { + active_space_solver fci + fci_test_rdms true +} + +energy('scf') +energy('forte') + +compare_values(0.0, variable("AA 1-RDM ERROR"),12, "AA 1-RDM") #TEST +compare_values(0.0, variable("BB 1-RDM ERROR"),12, "BB 1-RDM") #TEST +compare_values(0.0, variable("AAAA 2-RDM ERROR"),12, "AAAA 2-RDM") #TEST +compare_values(0.0, variable("BBBB 2-RDM ERROR"),12, "BBBB 2-RDM") #TEST +compare_values(0.0, variable("ABAB 2-RDM ERROR"),12, "ABAB 2-RDM") #TEST +compare_values(0.0, variable("AABAAB 3-RDM ERROR"),12, "AABAAB 3-RDM") #TEST +compare_values(0.0, variable("ABBABB 3-RDM ERROR"),12, "ABBABB 3-RDM") #TEST +compare_values(0.0, variable("AAAAAA 3-RDM ERROR"),12, "AAAAAA 3-RDM") #TEST +compare_values(0.0, variable("BBBBBB 3-RDM ERROR"),12, "BBBBBB 3-RDM") #TEST +-------------------------------------------------------------------------- + +Scratch directory: /tmp/ + => Libint2 <= + + Primary basis highest AM E, G, H: 6, 6, 3 + Auxiliary basis highest AM E, G, H: 7, 7, 4 + Onebody basis highest AM E, G, H: -, -, - + Solid Harmonics ordering: Gaussian + +*** tstart() called on Brian-Zs-MBA.local +*** at Tue Sep 17 15:25:11 2024 + + => Loading Basis Set <= + + Name: STO-3G + Role: ORBITAL + Keyword: BASIS + atoms 1 entry LI line 31 file /Users/brianz98/local/psi4/objdir-Release/stage/share/psi4/basis/sto-3g.gbs + atoms 2 entry H line 19 file /Users/brianz98/local/psi4/objdir-Release/stage/share/psi4/basis/sto-3g.gbs + + + --------------------------------------------------------- + SCF + by Justin Turney, Rob Parrish, Andy Simmonett + and Daniel G. A. Smith + RHF Reference + 1 Threads, 500 MiB Core + --------------------------------------------------------- + + ==> Geometry <== + + Molecular point group: c2v + Full point group: C_inf_v + + Geometry (in Bohr), charge = 0, multiplicity = 1: + + Center X Y Z Mass + ------------ ----------------- ----------------- ----------------- ----------------- + LI 0.000000000000 0.000000000000 -0.376812030371 7.016003436600 + H 0.000000000000 0.000000000000 2.623187969629 1.007825032230 + + Running in c2v symmetry. + + Rotational constants: A = ************ B = 7.59029 C = 7.59029 [cm^-1] + Rotational constants: A = ************ B = 227551.19787 C = 227551.19787 [MHz] + Nuclear repulsion = 1.000000000000000 + + Charge = 0 + Multiplicity = 1 + Electrons = 4 + Nalpha = 2 + Nbeta = 2 + + ==> Algorithm <== + + SCF Algorithm Type is PK. + DIIS enabled. + MOM disabled. + Fractional occupation disabled. + Guess Type is SAD. + Energy threshold = 1.00e-12 + Density threshold = 1.00e-06 + Integral threshold = 1.00e-12 + + ==> Primary Basis <== + + Basis Set: STO-3G + Blend: STO-3G + Number of shells: 4 + Number of basis functions: 6 + Number of Cartesian functions: 6 + Spherical Harmonics?: true + Max angular momentum: 1 + + ==> Integral Setup <== + + Using in-core PK algorithm. + Calculation information: + Number of atoms: 2 + Number of AO shells: 4 + Number of primitives: 12 + Number of atomic orbitals: 6 + Number of basis functions: 6 + + Integral cutoff 1.00e-12 + Number of threads: 1 + + Performing in-core PK + Using 462 doubles for integral storage. + We computed 55 shell quartets total. + Whereas there are 55 unique shell quartets. + + ==> DiskJK: Disk-Based J/K Matrices <== + + J tasked: Yes + K tasked: Yes + wK tasked: No + Memory [MiB]: 375 + Schwarz Cutoff: 1E-12 + + OpenMP threads: 1 + + Minimum eigenvalue in the overlap matrix is 3.4333995519E-01. + Reciprocal condition number of the overlap matrix is 2.0339047710E-01. + Using symmetric orthogonalization. + + ==> Pre-Iterations <== + + SCF Guess: Superposition of Atomic Densities via on-the-fly atomic UHF (no occupation information). + + ------------------------- + Irrep Nso Nmo + ------------------------- + A1 4 4 + A2 0 0 + B1 1 1 + B2 1 1 + ------------------------- + Total 6 6 + ------------------------- + + ==> Iterations <== + + Total Energy Delta E RMS |[F,P]| + + @RHF iter SAD: -6.75622365412217 -6.75622e+00 0.00000e+00 + @RHF iter 1: -7.86092861588784 -1.10470e+00 8.57305e-03 DIIS/ADIIS + @RHF iter 2: -7.86223475166447 -1.30614e-03 8.22758e-04 DIIS/ADIIS + @RHF iter 3: -7.86224589388798 -1.11422e-05 7.41119e-05 DIIS + @RHF iter 4: -7.86224624208850 -3.48201e-07 2.61264e-05 DIIS + @RHF iter 5: -7.86224631040868 -6.83202e-08 3.24230e-07 DIIS + @RHF iter 6: -7.86224631041032 -1.64135e-12 1.56779e-08 DIIS + @RHF iter 7: -7.86224631041034 -1.77636e-14 2.79325e-12 DIIS + Energy and wave function converged. + + + ==> Post-Iterations <== + + Orbital Energies [Eh] + --------------------- + + Doubly Occupied: + + 1A1 -2.348477 2A1 -0.286330 + + Virtual: + + 3A1 0.078326 1B1 0.163933 1B2 0.163933 + 4A1 0.551172 + + Final Occupation by Irrep: + A1 A2 B1 B2 + DOCC [ 2, 0, 0, 0 ] + NA [ 2, 0, 0, 0 ] + NB [ 2, 0, 0, 0 ] + + @RHF Final Energy: -7.86224631041034 + + => Energetics <= + + Nuclear Repulsion Energy = 1.0000000000000000 + One-Electron Energy = -12.4548780553254126 + Two-Electron Energy = 3.5926317449150740 + Total Energy = -7.8622463104103382 + +Computation Completed + + +Properties will be evaluated at 0.000000, 0.000000, 0.000000 [a0] + +Properties computed using the SCF density matrix + + + Multipole Moments: + + ------------------------------------------------------------------------------------ + Multipole Electronic (a.u.) Nuclear (a.u.) Total (a.u.) + ------------------------------------------------------------------------------------ + + L = 1. Multiply by 2.5417464519 to convert [e a0] to [Debye] + Dipole X : 0.0000000 0.0000000 0.0000000 + Dipole Y : 0.0000000 0.0000000 0.0000000 + Dipole Z : -3.4031201 1.4927519 -1.9103682 + Magnitude : 1.9103682 + + ------------------------------------------------------------------------------------ + +*** tstop() called on Brian-Zs-MBA.local at Tue Sep 17 15:25:11 2024 +Module time: + user time = 0.10 seconds = 0.00 minutes + system time = 0.01 seconds = 0.00 minutes + total time = 0 seconds = 0.00 minutes +Total time: + user time = 0.10 seconds = 0.00 minutes + system time = 0.01 seconds = 0.00 minutes + total time = 0 seconds = 0.00 minutes + +Scratch directory: /tmp/ + + Forte + ---------------------------------------------------------------------------- + A suite of quantum chemistry methods for strongly correlated electrons + + git branch: rdm4 - git commit: 7780d650 + + Developed by: + Francesco A. Evangelista, Chenyang Li, Kevin P. Hannon, + Jeffrey B. Schriber, Tianyuan Zhang, Chenxi Cai, + Nan He, Nicholas Stair, Shuhe Wang, Renke Huang + ---------------------------------------------------------------------------- + + + Preparing forte objects from a Psi4 Wavefunction object + No reference wave function provided for Forte. Computing SCF orbitals using Psi4 ... + => Libint2 <= + + Primary basis highest AM E, G, H: 6, 6, 3 + Auxiliary basis highest AM E, G, H: 7, 7, 4 + Onebody basis highest AM E, G, H: -, -, - + Solid Harmonics ordering: Gaussian + +*** tstart() called on Brian-Zs-MBA.local +*** at Tue Sep 17 15:25:11 2024 + + => Loading Basis Set <= + + Name: STO-3G + Role: ORBITAL + Keyword: BASIS + atoms 1 entry LI line 31 file /Users/brianz98/local/psi4/objdir-Release/stage/share/psi4/basis/sto-3g.gbs + atoms 2 entry H line 19 file /Users/brianz98/local/psi4/objdir-Release/stage/share/psi4/basis/sto-3g.gbs + + + --------------------------------------------------------- + SCF + by Justin Turney, Rob Parrish, Andy Simmonett + and Daniel G. A. Smith + RHF Reference + 1 Threads, 500 MiB Core + --------------------------------------------------------- + + ==> Geometry <== + + Molecular point group: c2v + Full point group: C_inf_v + + Geometry (in Bohr), charge = 0, multiplicity = 1: + + Center X Y Z Mass + ------------ ----------------- ----------------- ----------------- ----------------- + LI 0.000000000000 0.000000000000 -0.376812030371 7.016003436600 + H 0.000000000000 0.000000000000 2.623187969629 1.007825032230 + + Running in c2v symmetry. + + Rotational constants: A = ************ B = 7.59029 C = 7.59029 [cm^-1] + Rotational constants: A = ************ B = 227551.19787 C = 227551.19787 [MHz] + Nuclear repulsion = 1.000000000000000 + + Charge = 0 + Multiplicity = 1 + Electrons = 4 + Nalpha = 2 + Nbeta = 2 + + ==> Algorithm <== + + SCF Algorithm Type is PK. + DIIS enabled. + MOM disabled. + Fractional occupation disabled. + Guess Type is SAD. + Energy threshold = 1.00e-12 + Density threshold = 1.00e-08 + Integral threshold = 1.00e-12 + + ==> Primary Basis <== + + Basis Set: STO-3G + Blend: STO-3G + Number of shells: 4 + Number of basis functions: 6 + Number of Cartesian functions: 6 + Spherical Harmonics?: true + Max angular momentum: 1 + + ==> Integral Setup <== + + Using in-core PK algorithm. + Calculation information: + Number of atoms: 2 + Number of AO shells: 4 + Number of primitives: 12 + Number of atomic orbitals: 6 + Number of basis functions: 6 + + Integral cutoff 1.00e-12 + Number of threads: 1 + + Performing in-core PK + Using 462 doubles for integral storage. + We computed 55 shell quartets total. + Whereas there are 55 unique shell quartets. + + ==> DiskJK: Disk-Based J/K Matrices <== + + J tasked: Yes + K tasked: Yes + wK tasked: No + Memory [MiB]: 375 + Schwarz Cutoff: 1E-12 + + OpenMP threads: 1 + + Minimum eigenvalue in the overlap matrix is 3.4333995519E-01. + Reciprocal condition number of the overlap matrix is 2.0339047710E-01. + Using symmetric orthogonalization. + + ==> Pre-Iterations <== + + SCF Guess: Superposition of Atomic Densities via on-the-fly atomic UHF (no occupation information). + + ------------------------- + Irrep Nso Nmo + ------------------------- + A1 4 4 + A2 0 0 + B1 1 1 + B2 1 1 + ------------------------- + Total 6 6 + ------------------------- + + ==> Iterations <== + + Total Energy Delta E RMS |[F,P]| + + @RHF iter SAD: -6.75622365412217 -6.75622e+00 0.00000e+00 + @RHF iter 1: -7.86092861588784 -1.10470e+00 8.57305e-03 DIIS/ADIIS + @RHF iter 2: -7.86223475166447 -1.30614e-03 8.22758e-04 DIIS/ADIIS + @RHF iter 3: -7.86224589388798 -1.11422e-05 7.41119e-05 DIIS + @RHF iter 4: -7.86224624208850 -3.48201e-07 2.61264e-05 DIIS + @RHF iter 5: -7.86224631040868 -6.83202e-08 3.24230e-07 DIIS + @RHF iter 6: -7.86224631041032 -1.64135e-12 1.56779e-08 DIIS + @RHF iter 7: -7.86224631041034 -1.77636e-14 2.79325e-12 DIIS + Energy and wave function converged. + + + ==> Post-Iterations <== + + Orbital Energies [Eh] + --------------------- + + Doubly Occupied: + + 1A1 -2.348477 2A1 -0.286330 + + Virtual: + + 3A1 0.078326 1B1 0.163933 1B2 0.163933 + 4A1 0.551172 + + Final Occupation by Irrep: + A1 A2 B1 B2 + DOCC [ 2, 0, 0, 0 ] + NA [ 2, 0, 0, 0 ] + NB [ 2, 0, 0, 0 ] + + @RHF Final Energy: -7.86224631041034 + + => Energetics <= + + Nuclear Repulsion Energy = 1.0000000000000000 + One-Electron Energy = -12.4548780553254126 + Two-Electron Energy = 3.5926317449150740 + Total Energy = -7.8622463104103382 + +Computation Completed + + +Properties will be evaluated at 0.000000, 0.000000, 0.000000 [a0] + +Properties computed using the SCF density matrix + + + Multipole Moments: + + ------------------------------------------------------------------------------------ + Multipole Electronic (a.u.) Nuclear (a.u.) Total (a.u.) + ------------------------------------------------------------------------------------ + + L = 1. Multiply by 2.5417464519 to convert [e a0] to [Debye] + Dipole X : 0.0000000 0.0000000 0.0000000 + Dipole Y : 0.0000000 0.0000000 0.0000000 + Dipole Z : -3.4031201 1.4927519 -1.9103682 + Magnitude : 1.9103682 + + ------------------------------------------------------------------------------------ + +*** tstop() called on Brian-Zs-MBA.local at Tue Sep 17 15:25:11 2024 +Module time: + user time = 0.08 seconds = 0.00 minutes + system time = 0.00 seconds = 0.00 minutes + total time = 0 seconds = 0.00 minutes +Total time: + user time = 0.31 seconds = 0.01 minutes + system time = 0.01 seconds = 0.00 minutes + total time = 0 seconds = 0.00 minutes + + + ==> MO Space Information <== + + ------------------------------------------------- + A1 A2 B1 B2 Sum + ------------------------------------------------- + FROZEN_DOCC 0 0 0 0 0 + RESTRICTED_DOCC 0 0 0 0 0 + GAS1 4 0 1 1 6 + GAS2 0 0 0 0 0 + GAS3 0 0 0 0 0 + GAS4 0 0 0 0 0 + GAS5 0 0 0 0 0 + GAS6 0 0 0 0 0 + RESTRICTED_UOCC 0 0 0 0 0 + FROZEN_UOCC 0 0 0 0 0 + Total 4 0 1 1 6 + ------------------------------------------------- => Loading Basis Set <= + + Name: STO-3G + Role: ORBITAL + Keyword: MINAO_BASIS + atoms 1 entry LI line 31 file /Users/brianz98/local/psi4/objdir-Release/stage/share/psi4/basis/sto-3g.gbs + atoms 2 entry H line 19 file /Users/brianz98/local/psi4/objdir-Release/stage/share/psi4/basis/sto-3g.gbs + + + State Singlet (Ms = 0) A1 GAS min: 0 0 0 0 0 0 ; GAS max: 12 0 0 0 0 0 ; weights: + 1.000000000000 + Forte will use psi4 integrals + + ==> Primary Basis Set Summary <== + + Basis Set: STO-3G + Blend: STO-3G + Number of shells: 4 + Number of basis functions: 6 + Number of Cartesian functions: 6 + Spherical Harmonics?: true + Max angular momentum: 1 + + + JK created using conventional PK integrals + Using in-core PK algorithm. + Calculation information: + Number of atoms: 2 + Number of AO shells: 4 + Number of primitives: 12 + Number of atomic orbitals: 6 + Number of basis functions: 6 + + Integral cutoff 1.00e-12 + Number of threads: 1 + + Performing in-core PK + Using 462 doubles for integral storage. + We computed 55 shell quartets total. + Whereas there are 55 unique shell quartets. + + ==> DiskJK: Disk-Based J/K Matrices <== + + J tasked: Yes + K tasked: Yes + wK tasked: No + Memory [MiB]: 400 + Schwarz Cutoff: 1E-12 + + OpenMP threads: 1 + + + + ==> Integral Transformation <== + + Number of molecular orbitals: 6 + Number of correlated molecular orbitals: 6 + Number of frozen occupied orbitals: 0 + Number of frozen unoccupied orbitals: 0 + Two-electron integral type: Conventional + + + Computing Conventional Integrals Presorting SO-basis two-electron integrals. + Sorting File: SO Ints (nn|nn) nbuckets = 1 + Constructing frozen core operators + Starting first half-transformation. + Sorting half-transformed integrals. + First half integral transformation complete. + Starting second half-transformation. + Two-electron integral transformation complete. + + Integral transformation done. 0.00423067 s + Reading the two-electron integrals from disk + Size of two-electron integrals: 0.000029 GB + Timing for conventional integral transformation: 0.010 s. + Timing for freezing core and virtual orbitals: 0.000 s. + Timing for computing conventional integrals: 0.010 s. + + ----------------------------------------------------------- + Multi-Configurational Self Consistent Field + Two-Step Approximate Second-Order AO Algorithm + written by Chenyang Li, Kevin P. Hannon, and Shuhe Wang + ----------------------------------------------------------- + + + ==> MCSCF Calculation Information <== + + -------------------------------------------------------- + Print level Default + Integral type CONVENTIONAL + CI solver type FCI + Final orbital type CANONICAL + Derivative type NONE + Optimize orbitals TRUE + Include internal rotations FALSE + Debug printing FALSE + Energy convergence 1.000e-08 + Gradient convergence 1.000e-07 + Max value for rotation 2.000e-01 + Max number of macro iter. 100 + Max number of micro iter. for orbitals 6 + Max number of micro iter. for CI 12 + DIIS start 15 + Min DIIS vectors 3 + Max DIIS vectors 8 + Frequency of DIIS extrapolation 1 + -------------------------------------------------------- + + ==> Independent Orbital Rotations <== + + ORBITAL SPACES A1 A2 B1 B2 + ------------------------------------------------------------- + ACTIVE / RESTRICTED_DOCC 0 0 0 0 + RESTRICTED_UOCC / ACTIVE 0 0 0 0 + RESTRICTED_UOCC / RESTRICTED_DOCC 0 0 0 0 + ------------------------------------------------------------- + + ==> String Lists <== + + -------------------------------------------------------- + number of alpha electrons 2 + number of beta electrons 2 + number of alpha strings 15 + number of beta strings 15 + -------------------------------------------------------- + + ==> FCI Solver <== + + -------------------------------------------------------- + Spin adapt FALSE + Number of determinants 69 + Symmetry 0 + Multiplicity 1 + Number of roots 1 + Target root 0 + -------------------------------------------------------- + + ==> Initial Guess <== + + Initial guess determinants: 50 + + Classification of the initial guess solutions + + Number 2S+1 Selected + ------------------------ + 28 1 * + 21 3 + 1 5 + ------------------------ + + Spin Root Energy Status + ------------------------------------------------------- + singlet 0 -7.882494298809 -0.000000 added + ------------------------------------------------------- + + ==> Davidson-Liu Solver <== + + -------------------------------------------------------- + Print level Default + Energy convergence threshold 1.000e-08 + Residual convergence threshold 1.000e-06 + Schmidt orthogonality threshold 1.000e-12 + Schmidt discard threshold 1.000e-07 + Size of the space 69 + Number of roots 1 + Maximum number of iterations 100 + Collapse subspace size 2 + Maximum subspace size 10 + -------------------------------------------------------- + + Davidson-Liu solver: adding 1 guess vectors + Iteration Average Energy max(∆E) max(Residual) Vectors + --------------------------------------------------------------------------------- + 0 -7.882494298809 7.882494298809 0.008038987350 1 + 1 -7.882504307468 0.000010008659 0.000284247755 2 + 2 -7.882504329166 0.000000021698 0.000021027585 3 + 3 -7.882504329345 0.000000000179 0.000006599970 4 + 4 -7.882504329370 0.000000000025 0.000001340396 5 + 5 -7.882504329372 0.000000000002 0.000000531683 6 + --------------------------------------------------------------------------------- + + ==> Root No. 0 <== + + 2200 0 0 -0.98722460 + 2002 0 0 0.11303965 + 20ba 0 0 0.05889309 + 20ab 0 0 0.05889309 + 2ab0 0 0 -0.03825367 + 2ba0 0 0 -0.03825367 + 2020 0 0 0.03413984 + 2000 2 0 0.02725508 + 2000 0 2 0.02725508 + + Total Energy: -7.882504329372, : 0.000000 + +==> RDMs Test <== + + AA 1-RDM Error : +1.573946e-16 + BB 1-RDM Error : +1.080000e-17 + AAAA 2-RDM Error : +3.705896e-17 + BBBB 2-RDM Error : +6.919200e-19 + ABAB 2-RDM Error : +1.832531e-16 + AAAAAA 3-RDM Error : +0.000000e+00 + AABAAB 3-RDM Error : +0.000000e+00 + ABBABB 3-RDM Error : +0.000000e+00 + BBBBBB 3-RDM Error : +0.000000e+00 + Time for FCI: 0.027383458000 + + ==> Energy Summary <== + + Multi.(2ms) Irrep. No. Energy + -------------------------------------------------------- + 1 ( 0) A1 0 -7.882504329372 0.000000 + -------------------------------------------------------- + +==> RDMs Test <== + + SF 1-RDM Error : +5.214325e-18 + + ==> Natural Orbitals <== + + 1A1 1.999911 2A1 1.955085 3A1 0.041876 + 1B1 0.001534 1B2 0.001534 4A1 0.000059 + + + ==> Dipole Moments [e a0] (Nuclear + Electronic) for Singlet (Ms = 0) A1 <== + + State DM_X DM_Y DM_Z |DM| + -------------------------------------------------------------------- + 0A1 0.00000000 0.00000000 -1.81815571 1.81815571 + -------------------------------------------------------------------- + Nuclear 0.00000000 0.00000000 1.49275188 1.49275188 + -------------------------------------------------------------------- + +==> RDMs Test <== + + SF 1-RDM Error : +5.214325e-18 + + ==> Natural Orbitals <== + + 1A1 1.999911 2A1 1.955085 3A1 0.041876 + 1B1 0.001534 1B2 0.001534 4A1 0.000059 + + + ==> Quadrupole Moments [e a0^2] (Nuclear + Electronic) for Singlet (Ms = 0) A1 <== + + State QM_XX QM_XY QM_XZ QM_YY QM_YZ QM_ZZ + -------------------------------------------------------------------------------------------------- + 0A1 -4.08221296 0.00000000 0.00000000 -4.08221296 0.00000000 -4.94856087 + -------------------------------------------------------------------------------------------------- + Nuclear 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 7.30707704 + -------------------------------------------------------------------------------------------------- + +==> RDMs Test <== + + SF 1-RDM Error : +5.214325e-18 + AAAA 2-RDM Error : +5.248916e-08 + BBBB 2-RDM Error : +5.248916e-08 + ABAB 2-RDM Error : +5.248916e-08 + + ==> Natural Orbitals <== + + 1A1 1.999911 2A1 1.955085 3A1 0.041876 + 1B1 0.001534 1B2 0.001534 4A1 0.000059 + + + ==> String Lists <== + + -------------------------------------------------------- + number of alpha electrons 2 + number of beta electrons 2 + number of alpha strings 15 + number of beta strings 15 + -------------------------------------------------------- + + ==> FCI Solver <== + + -------------------------------------------------------- + Spin adapt FALSE + Number of determinants 69 + Symmetry 0 + Multiplicity 1 + Number of roots 1 + Target root 0 + -------------------------------------------------------- + + ==> Initial Guess <== + + Initial guess determinants: 50 + + Classification of the initial guess solutions + + Number 2S+1 Selected + ------------------------ + 28 1 * + 21 3 + 1 5 + ------------------------ + + Spin Root Energy Status + ------------------------------------------------------- + singlet 0 -7.882494298809 -0.000000 added + ------------------------------------------------------- + + ==> Davidson-Liu Solver <== + + -------------------------------------------------------- + Print level Default + Energy convergence threshold 1.000e-12 + Residual convergence threshold 1.000e-06 + Schmidt orthogonality threshold 1.000e-12 + Schmidt discard threshold 1.000e-07 + Size of the space 69 + Number of roots 1 + Maximum number of iterations 100 + Collapse subspace size 2 + Maximum subspace size 10 + -------------------------------------------------------- + + Davidson-Liu solver: adding 1 guess vectors + Iteration Average Energy max(∆E) max(Residual) Vectors + --------------------------------------------------------------------------------- + 0 -7.882494298809 7.882494298809 0.008038987350 1 + 1 -7.882504307468 0.000010008659 0.000284247755 2 + 2 -7.882504329166 0.000000021698 0.000021027585 3 + 3 -7.882504329345 0.000000000179 0.000006599970 4 + 4 -7.882504329370 0.000000000025 0.000001340396 5 + 5 -7.882504329372 0.000000000002 0.000000531683 6 + 6 -7.882504329372 0.000000000000 0.000000120716 7 + --------------------------------------------------------------------------------- + + ==> Root No. 0 <== + + 2200 0 0 0.98722452 + 2002 0 0 -0.11303969 + 20ba 0 0 -0.05889325 + 20ab 0 0 -0.05889325 + 2ab0 0 0 0.03825444 + 2ba0 0 0 0.03825444 + 2020 0 0 -0.03414006 + 2000 0 2 -0.02725499 + 2000 2 0 -0.02725499 + + Total Energy: -7.882504329372, : 0.000000 + +==> RDMs Test <== + + AA 1-RDM Error : +2.221717e-16 + BB 1-RDM Error : +1.115228e-16 + AAAA 2-RDM Error : +1.406016e-17 + BBBB 2-RDM Error : +5.650255e-17 + ABAB 2-RDM Error : +1.834372e-16 + AAAAAA 3-RDM Error : +0.000000e+00 + AABAAB 3-RDM Error : +0.000000e+00 + ABBABB 3-RDM Error : +0.000000e+00 + BBBBBB 3-RDM Error : +0.000000e+00 + Time for FCI: 0.023231209000 + + ==> Energy Summary <== + + Multi.(2ms) Irrep. No. Energy + -------------------------------------------------------- + 1 ( 0) A1 0 -7.882504329372 0.000000 + -------------------------------------------------------- + +==> RDMs Test <== + + SF 1-RDM Error : +2.221734e-16 + + ==> Natural Orbitals <== + + 1A1 1.999911 2A1 1.955085 3A1 0.041876 + 1B2 0.001534 1B1 0.001534 4A1 0.000059 + + + ==> Dipole Moments [e a0] (Nuclear + Electronic) for Singlet (Ms = 0) A1 <== + + State DM_X DM_Y DM_Z |DM| + -------------------------------------------------------------------- + 0A1 0.00000000 0.00000000 -1.81815375 1.81815375 + -------------------------------------------------------------------- + Nuclear 0.00000000 0.00000000 1.49275188 1.49275188 + -------------------------------------------------------------------- + +==> RDMs Test <== + + SF 1-RDM Error : +2.221734e-16 + + ==> Natural Orbitals <== + + 1A1 1.999911 2A1 1.955085 3A1 0.041876 + 1B2 0.001534 1B1 0.001534 4A1 0.000059 + + + ==> Quadrupole Moments [e a0^2] (Nuclear + Electronic) for Singlet (Ms = 0) A1 <== + + State QM_XX QM_XY QM_XZ QM_YY QM_YZ QM_ZZ + -------------------------------------------------------------------------------------------------- + 0A1 -4.08221616 0.00000000 0.00000000 -4.08221616 0.00000000 -4.94855691 + -------------------------------------------------------------------------------------------------- + Nuclear 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 7.30707704 + -------------------------------------------------------------------------------------------------- + + Time to prepare integrals: 0.122 seconds + Time to run job : 0.061 seconds + Total : 0.184 seconds + AA 1-RDM..............................................................................PASSED + BB 1-RDM..............................................................................PASSED + AAAA 2-RDM............................................................................PASSED + BBBB 2-RDM............................................................................PASSED + ABAB 2-RDM............................................................................PASSED + AABAAB 3-RDM..........................................................................PASSED + ABBABB 3-RDM..........................................................................PASSED + AAAAAA 3-RDM..........................................................................PASSED + BBBBBB 3-RDM..........................................................................PASSED + + Psi4 stopped on: Tuesday, 17 September 2024 03:25PM + Psi4 wall time for execution: 0:00:01.10 + +*** Psi4 exiting successfully. Buy a developer a beer! diff --git a/tests/methods/fci-rdms-3/input.dat b/tests/methods/fci-rdms-3/input.dat new file mode 100644 index 000000000..1da8aa246 --- /dev/null +++ b/tests/methods/fci-rdms-3/input.dat @@ -0,0 +1,42 @@ +#! Generated using commit GITCOMMIT + +import forte + +molecule { +0 1 +Li +H 1 R + +R = 3.0 +units bohr +} + +set { + basis sto-3g + reference rhf + scf_type pk + e_convergence 12 +} + +set forte { + active_space_solver genci + fci_test_rdms true +} + +energy('scf') +energy('forte') + +compare_values(0.0, variable("AA 1-RDM ERROR"),12, "AA 1-RDM") #TEST +compare_values(0.0, variable("BB 1-RDM ERROR"),12, "BB 1-RDM") #TEST +compare_values(0.0, variable("AAAA 2-RDM ERROR"),12, "AAAA 2-RDM") #TEST +compare_values(0.0, variable("BBBB 2-RDM ERROR"),12, "BBBB 2-RDM") #TEST +compare_values(0.0, variable("ABAB 2-RDM ERROR"),12, "ABAB 2-RDM") #TEST +compare_values(0.0, variable("AABAAB 3-RDM ERROR"),12, "AABAAB 3-RDM") #TEST +compare_values(0.0, variable("ABBABB 3-RDM ERROR"),12, "ABBABB 3-RDM") #TEST +compare_values(0.0, variable("AAAAAA 3-RDM ERROR"),12, "AAAAAA 3-RDM") #TEST +compare_values(0.0, variable("BBBBBB 3-RDM ERROR"),12, "BBBBBB 3-RDM") #TEST +compare_values(0.0, variable("AAAAAAAA 4-RDM ERROR"),12, "AAAAAAAA 4-RDM") #TEST +compare_values(0.0, variable("AAABAAAB 4-RDM ERROR"),12, "AAABAAAB 4-RDM") #TEST +compare_values(0.0, variable("AABBAABB 4-RDM ERROR"),12, "AABBAABB 4-RDM") #TEST +compare_values(0.0, variable("ABBBABBB 4-RDM ERROR"),12, "ABBBABBB 4-RDM") #TEST +compare_values(0.0, variable("BBBBBBBB 4-RDM ERROR"),12, "BBBBBBBB 4-RDM") #TEST diff --git a/tests/methods/fci-rdms-3/output.ref b/tests/methods/fci-rdms-3/output.ref new file mode 100644 index 000000000..4a27def6c --- /dev/null +++ b/tests/methods/fci-rdms-3/output.ref @@ -0,0 +1,956 @@ + + ----------------------------------------------------------------------- + Psi4: An Open-Source Ab Initio Electronic Structure Package + Psi4 1.10a1.dev53 + + Git: Rev {master} 45660d8 dirty + + + D. G. A. Smith, L. A. Burns, A. C. Simmonett, R. M. Parrish, + M. C. Schieber, R. Galvelis, P. Kraus, H. Kruse, R. Di Remigio, + A. Alenaizan, A. M. James, S. Lehtola, J. P. Misiewicz, M. Scheurer, + R. A. Shaw, J. B. Schriber, Y. Xie, Z. L. Glick, D. A. Sirianni, + J. S. O'Brien, J. M. Waldrop, A. Kumar, E. G. Hohenstein, + B. P. Pritchard, B. R. Brooks, H. F. Schaefer III, A. Yu. Sokolov, + K. Patkowski, A. E. DePrince III, U. Bozkaya, R. A. King, + F. A. Evangelista, J. M. Turney, T. D. Crawford, C. D. Sherrill, + J. Chem. Phys. 152(18) 184108 (2020). https://doi.org/10.1063/5.0006002 + + Additional Code Authors + E. T. Seidl, C. L. Janssen, E. F. Valeev, M. L. Leininger, + J. F. Gonthier, R. M. Richard, H. R. McAlexander, M. Saitow, X. Wang, + P. Verma, M. H. Lechner, A. Jiang, S. Behnle, A. G. Heide, + M. F. Herbst, and D. L. Poole + + Previous Authors, Complete List of Code Contributors, + and Citations for Specific Modules + https://github.com/psi4/psi4/blob/master/codemeta.json + https://github.com/psi4/psi4/graphs/contributors + http://psicode.org/psi4manual/master/introduction.html#citing-psifour + + ----------------------------------------------------------------------- + + + Psi4 started on: Tuesday, 17 September 2024 03:25PM + + Process ID: 19290 + Host: Brian-Zs-MBA.local + PSIDATADIR: /Users/brianz98/local/psi4/objdir-Release/stage/share/psi4 + Memory: 500.0 MiB + Threads: 1 + + ==> Input File <== + +-------------------------------------------------------------------------- +#! Generated using commit GITCOMMIT + +import forte + +molecule { +0 1 +Li +H 1 R + +R = 3.0 +units bohr +} + +set { + basis sto-3g + reference rhf + scf_type pk + e_convergence 12 +} + +set forte { + active_space_solver genci + fci_test_rdms true +} + +energy('scf') +energy('forte') + +compare_values(0.0, variable("AA 1-RDM ERROR"),12, "AA 1-RDM") #TEST +compare_values(0.0, variable("BB 1-RDM ERROR"),12, "BB 1-RDM") #TEST +compare_values(0.0, variable("AAAA 2-RDM ERROR"),12, "AAAA 2-RDM") #TEST +compare_values(0.0, variable("BBBB 2-RDM ERROR"),12, "BBBB 2-RDM") #TEST +compare_values(0.0, variable("ABAB 2-RDM ERROR"),12, "ABAB 2-RDM") #TEST +compare_values(0.0, variable("AABAAB 3-RDM ERROR"),12, "AABAAB 3-RDM") #TEST +compare_values(0.0, variable("ABBABB 3-RDM ERROR"),12, "ABBABB 3-RDM") #TEST +compare_values(0.0, variable("AAAAAA 3-RDM ERROR"),12, "AAAAAA 3-RDM") #TEST +compare_values(0.0, variable("BBBBBB 3-RDM ERROR"),12, "BBBBBB 3-RDM") #TEST +compare_values(0.0, variable("AAAAAAAA 4-RDM ERROR"),12, "AAAAAAAA 4-RDM") #TEST +compare_values(0.0, variable("AAABAAAB 4-RDM ERROR"),12, "AAABAAAB 4-RDM") #TEST +compare_values(0.0, variable("AABBAABB 4-RDM ERROR"),12, "AABBAABB 4-RDM") #TEST +compare_values(0.0, variable("ABBBABBB 4-RDM ERROR"),12, "ABBBABBB 4-RDM") #TEST +compare_values(0.0, variable("BBBBBBBB 4-RDM ERROR"),12, "BBBBBBBB 4-RDM") #TEST +-------------------------------------------------------------------------- + +Scratch directory: /tmp/ + => Libint2 <= + + Primary basis highest AM E, G, H: 6, 6, 3 + Auxiliary basis highest AM E, G, H: 7, 7, 4 + Onebody basis highest AM E, G, H: -, -, - + Solid Harmonics ordering: Gaussian + +*** tstart() called on Brian-Zs-MBA.local +*** at Tue Sep 17 15:25:33 2024 + + => Loading Basis Set <= + + Name: STO-3G + Role: ORBITAL + Keyword: BASIS + atoms 1 entry LI line 31 file /Users/brianz98/local/psi4/objdir-Release/stage/share/psi4/basis/sto-3g.gbs + atoms 2 entry H line 19 file /Users/brianz98/local/psi4/objdir-Release/stage/share/psi4/basis/sto-3g.gbs + + + --------------------------------------------------------- + SCF + by Justin Turney, Rob Parrish, Andy Simmonett + and Daniel G. A. Smith + RHF Reference + 1 Threads, 500 MiB Core + --------------------------------------------------------- + + ==> Geometry <== + + Molecular point group: c2v + Full point group: C_inf_v + + Geometry (in Bohr), charge = 0, multiplicity = 1: + + Center X Y Z Mass + ------------ ----------------- ----------------- ----------------- ----------------- + LI 0.000000000000 0.000000000000 -0.376812030371 7.016003436600 + H 0.000000000000 0.000000000000 2.623187969629 1.007825032230 + + Running in c2v symmetry. + + Rotational constants: A = ************ B = 7.59029 C = 7.59029 [cm^-1] + Rotational constants: A = ************ B = 227551.19787 C = 227551.19787 [MHz] + Nuclear repulsion = 1.000000000000000 + + Charge = 0 + Multiplicity = 1 + Electrons = 4 + Nalpha = 2 + Nbeta = 2 + + ==> Algorithm <== + + SCF Algorithm Type is PK. + DIIS enabled. + MOM disabled. + Fractional occupation disabled. + Guess Type is SAD. + Energy threshold = 1.00e-12 + Density threshold = 1.00e-06 + Integral threshold = 1.00e-12 + + ==> Primary Basis <== + + Basis Set: STO-3G + Blend: STO-3G + Number of shells: 4 + Number of basis functions: 6 + Number of Cartesian functions: 6 + Spherical Harmonics?: true + Max angular momentum: 1 + + ==> Integral Setup <== + + Using in-core PK algorithm. + Calculation information: + Number of atoms: 2 + Number of AO shells: 4 + Number of primitives: 12 + Number of atomic orbitals: 6 + Number of basis functions: 6 + + Integral cutoff 1.00e-12 + Number of threads: 1 + + Performing in-core PK + Using 462 doubles for integral storage. + We computed 55 shell quartets total. + Whereas there are 55 unique shell quartets. + + ==> DiskJK: Disk-Based J/K Matrices <== + + J tasked: Yes + K tasked: Yes + wK tasked: No + Memory [MiB]: 375 + Schwarz Cutoff: 1E-12 + + OpenMP threads: 1 + + Minimum eigenvalue in the overlap matrix is 3.4333995519E-01. + Reciprocal condition number of the overlap matrix is 2.0339047710E-01. + Using symmetric orthogonalization. + + ==> Pre-Iterations <== + + SCF Guess: Superposition of Atomic Densities via on-the-fly atomic UHF (no occupation information). + + ------------------------- + Irrep Nso Nmo + ------------------------- + A1 4 4 + A2 0 0 + B1 1 1 + B2 1 1 + ------------------------- + Total 6 6 + ------------------------- + + ==> Iterations <== + + Total Energy Delta E RMS |[F,P]| + + @RHF iter SAD: -6.75622365412217 -6.75622e+00 0.00000e+00 + @RHF iter 1: -7.86092861588784 -1.10470e+00 8.57305e-03 DIIS/ADIIS + @RHF iter 2: -7.86223475166447 -1.30614e-03 8.22758e-04 DIIS/ADIIS + @RHF iter 3: -7.86224589388798 -1.11422e-05 7.41119e-05 DIIS + @RHF iter 4: -7.86224624208850 -3.48201e-07 2.61264e-05 DIIS + @RHF iter 5: -7.86224631040868 -6.83202e-08 3.24230e-07 DIIS + @RHF iter 6: -7.86224631041032 -1.64135e-12 1.56779e-08 DIIS + @RHF iter 7: -7.86224631041034 -1.77636e-14 2.79325e-12 DIIS + Energy and wave function converged. + + + ==> Post-Iterations <== + + Orbital Energies [Eh] + --------------------- + + Doubly Occupied: + + 1A1 -2.348477 2A1 -0.286330 + + Virtual: + + 3A1 0.078326 1B1 0.163933 1B2 0.163933 + 4A1 0.551172 + + Final Occupation by Irrep: + A1 A2 B1 B2 + DOCC [ 2, 0, 0, 0 ] + NA [ 2, 0, 0, 0 ] + NB [ 2, 0, 0, 0 ] + + @RHF Final Energy: -7.86224631041034 + + => Energetics <= + + Nuclear Repulsion Energy = 1.0000000000000000 + One-Electron Energy = -12.4548780553254126 + Two-Electron Energy = 3.5926317449150740 + Total Energy = -7.8622463104103382 + +Computation Completed + + +Properties will be evaluated at 0.000000, 0.000000, 0.000000 [a0] + +Properties computed using the SCF density matrix + + + Multipole Moments: + + ------------------------------------------------------------------------------------ + Multipole Electronic (a.u.) Nuclear (a.u.) Total (a.u.) + ------------------------------------------------------------------------------------ + + L = 1. Multiply by 2.5417464519 to convert [e a0] to [Debye] + Dipole X : 0.0000000 0.0000000 0.0000000 + Dipole Y : 0.0000000 0.0000000 0.0000000 + Dipole Z : -3.4031201 1.4927519 -1.9103682 + Magnitude : 1.9103682 + + ------------------------------------------------------------------------------------ + +*** tstop() called on Brian-Zs-MBA.local at Tue Sep 17 15:25:33 2024 +Module time: + user time = 0.09 seconds = 0.00 minutes + system time = 0.01 seconds = 0.00 minutes + total time = 0 seconds = 0.00 minutes +Total time: + user time = 0.09 seconds = 0.00 minutes + system time = 0.01 seconds = 0.00 minutes + total time = 0 seconds = 0.00 minutes + +Scratch directory: /tmp/ + + Forte + ---------------------------------------------------------------------------- + A suite of quantum chemistry methods for strongly correlated electrons + + git branch: rdm4 - git commit: 7780d650 + + Developed by: + Francesco A. Evangelista, Chenyang Li, Kevin P. Hannon, + Jeffrey B. Schriber, Tianyuan Zhang, Chenxi Cai, + Nan He, Nicholas Stair, Shuhe Wang, Renke Huang + ---------------------------------------------------------------------------- + + + Preparing forte objects from a Psi4 Wavefunction object + No reference wave function provided for Forte. Computing SCF orbitals using Psi4 ... + => Libint2 <= + + Primary basis highest AM E, G, H: 6, 6, 3 + Auxiliary basis highest AM E, G, H: 7, 7, 4 + Onebody basis highest AM E, G, H: -, -, - + Solid Harmonics ordering: Gaussian + +*** tstart() called on Brian-Zs-MBA.local +*** at Tue Sep 17 15:25:33 2024 + + => Loading Basis Set <= + + Name: STO-3G + Role: ORBITAL + Keyword: BASIS + atoms 1 entry LI line 31 file /Users/brianz98/local/psi4/objdir-Release/stage/share/psi4/basis/sto-3g.gbs + atoms 2 entry H line 19 file /Users/brianz98/local/psi4/objdir-Release/stage/share/psi4/basis/sto-3g.gbs + + + --------------------------------------------------------- + SCF + by Justin Turney, Rob Parrish, Andy Simmonett + and Daniel G. A. Smith + RHF Reference + 1 Threads, 500 MiB Core + --------------------------------------------------------- + + ==> Geometry <== + + Molecular point group: c2v + Full point group: C_inf_v + + Geometry (in Bohr), charge = 0, multiplicity = 1: + + Center X Y Z Mass + ------------ ----------------- ----------------- ----------------- ----------------- + LI 0.000000000000 0.000000000000 -0.376812030371 7.016003436600 + H 0.000000000000 0.000000000000 2.623187969629 1.007825032230 + + Running in c2v symmetry. + + Rotational constants: A = ************ B = 7.59029 C = 7.59029 [cm^-1] + Rotational constants: A = ************ B = 227551.19787 C = 227551.19787 [MHz] + Nuclear repulsion = 1.000000000000000 + + Charge = 0 + Multiplicity = 1 + Electrons = 4 + Nalpha = 2 + Nbeta = 2 + + ==> Algorithm <== + + SCF Algorithm Type is PK. + DIIS enabled. + MOM disabled. + Fractional occupation disabled. + Guess Type is SAD. + Energy threshold = 1.00e-12 + Density threshold = 1.00e-08 + Integral threshold = 1.00e-12 + + ==> Primary Basis <== + + Basis Set: STO-3G + Blend: STO-3G + Number of shells: 4 + Number of basis functions: 6 + Number of Cartesian functions: 6 + Spherical Harmonics?: true + Max angular momentum: 1 + + ==> Integral Setup <== + + Using in-core PK algorithm. + Calculation information: + Number of atoms: 2 + Number of AO shells: 4 + Number of primitives: 12 + Number of atomic orbitals: 6 + Number of basis functions: 6 + + Integral cutoff 1.00e-12 + Number of threads: 1 + + Performing in-core PK + Using 462 doubles for integral storage. + We computed 55 shell quartets total. + Whereas there are 55 unique shell quartets. + + ==> DiskJK: Disk-Based J/K Matrices <== + + J tasked: Yes + K tasked: Yes + wK tasked: No + Memory [MiB]: 375 + Schwarz Cutoff: 1E-12 + + OpenMP threads: 1 + + Minimum eigenvalue in the overlap matrix is 3.4333995519E-01. + Reciprocal condition number of the overlap matrix is 2.0339047710E-01. + Using symmetric orthogonalization. + + ==> Pre-Iterations <== + + SCF Guess: Superposition of Atomic Densities via on-the-fly atomic UHF (no occupation information). + + ------------------------- + Irrep Nso Nmo + ------------------------- + A1 4 4 + A2 0 0 + B1 1 1 + B2 1 1 + ------------------------- + Total 6 6 + ------------------------- + + ==> Iterations <== + + Total Energy Delta E RMS |[F,P]| + + @RHF iter SAD: -6.75622365412217 -6.75622e+00 0.00000e+00 + @RHF iter 1: -7.86092861588784 -1.10470e+00 8.57305e-03 DIIS/ADIIS + @RHF iter 2: -7.86223475166447 -1.30614e-03 8.22758e-04 DIIS/ADIIS + @RHF iter 3: -7.86224589388798 -1.11422e-05 7.41119e-05 DIIS + @RHF iter 4: -7.86224624208850 -3.48201e-07 2.61264e-05 DIIS + @RHF iter 5: -7.86224631040868 -6.83202e-08 3.24230e-07 DIIS + @RHF iter 6: -7.86224631041032 -1.64135e-12 1.56779e-08 DIIS + @RHF iter 7: -7.86224631041034 -1.77636e-14 2.79325e-12 DIIS + Energy and wave function converged. + + + ==> Post-Iterations <== + + Orbital Energies [Eh] + --------------------- + + Doubly Occupied: + + 1A1 -2.348477 2A1 -0.286330 + + Virtual: + + 3A1 0.078326 1B1 0.163933 1B2 0.163933 + 4A1 0.551172 + + Final Occupation by Irrep: + A1 A2 B1 B2 + DOCC [ 2, 0, 0, 0 ] + NA [ 2, 0, 0, 0 ] + NB [ 2, 0, 0, 0 ] + + @RHF Final Energy: -7.86224631041034 + + => Energetics <= + + Nuclear Repulsion Energy = 1.0000000000000000 + One-Electron Energy = -12.4548780553254126 + Two-Electron Energy = 3.5926317449150740 + Total Energy = -7.8622463104103382 + +Computation Completed + + +Properties will be evaluated at 0.000000, 0.000000, 0.000000 [a0] + +Properties computed using the SCF density matrix + + + Multipole Moments: + + ------------------------------------------------------------------------------------ + Multipole Electronic (a.u.) Nuclear (a.u.) Total (a.u.) + ------------------------------------------------------------------------------------ + + L = 1. Multiply by 2.5417464519 to convert [e a0] to [Debye] + Dipole X : 0.0000000 0.0000000 0.0000000 + Dipole Y : 0.0000000 0.0000000 0.0000000 + Dipole Z : -3.4031201 1.4927519 -1.9103682 + Magnitude : 1.9103682 + + ------------------------------------------------------------------------------------ + +*** tstop() called on Brian-Zs-MBA.local at Tue Sep 17 15:25:33 2024 +Module time: + user time = 0.09 seconds = 0.00 minutes + system time = 0.00 seconds = 0.00 minutes + total time = 0 seconds = 0.00 minutes +Total time: + user time = 0.31 seconds = 0.01 minutes + system time = 0.01 seconds = 0.00 minutes + total time = 0 seconds = 0.00 minutes + + + ==> MO Space Information <== + + ------------------------------------------------- + A1 A2 B1 B2 Sum + ------------------------------------------------- + FROZEN_DOCC 0 0 0 0 0 + RESTRICTED_DOCC 0 0 0 0 0 + GAS1 4 0 1 1 6 + GAS2 0 0 0 0 0 + GAS3 0 0 0 0 0 + GAS4 0 0 0 0 0 + GAS5 0 0 0 0 0 + GAS6 0 0 0 0 0 + RESTRICTED_UOCC 0 0 0 0 0 + FROZEN_UOCC 0 0 0 0 0 + Total 4 0 1 1 6 + ------------------------------------------------- => Loading Basis Set <= + + Name: STO-3G + Role: ORBITAL + Keyword: MINAO_BASIS + atoms 1 entry LI line 31 file /Users/brianz98/local/psi4/objdir-Release/stage/share/psi4/basis/sto-3g.gbs + atoms 2 entry H line 19 file /Users/brianz98/local/psi4/objdir-Release/stage/share/psi4/basis/sto-3g.gbs + + + State Singlet (Ms = 0) A1 GAS min: 0 0 0 0 0 0 ; GAS max: 12 0 0 0 0 0 ; weights: + 1.000000000000 + Forte will use psi4 integrals + + ==> Primary Basis Set Summary <== + + Basis Set: STO-3G + Blend: STO-3G + Number of shells: 4 + Number of basis functions: 6 + Number of Cartesian functions: 6 + Spherical Harmonics?: true + Max angular momentum: 1 + + + JK created using conventional PK integrals + Using in-core PK algorithm. + Calculation information: + Number of atoms: 2 + Number of AO shells: 4 + Number of primitives: 12 + Number of atomic orbitals: 6 + Number of basis functions: 6 + + Integral cutoff 1.00e-12 + Number of threads: 1 + + Performing in-core PK + Using 462 doubles for integral storage. + We computed 55 shell quartets total. + Whereas there are 55 unique shell quartets. + + ==> DiskJK: Disk-Based J/K Matrices <== + + J tasked: Yes + K tasked: Yes + wK tasked: No + Memory [MiB]: 400 + Schwarz Cutoff: 1E-12 + + OpenMP threads: 1 + + + + ==> Integral Transformation <== + + Number of molecular orbitals: 6 + Number of correlated molecular orbitals: 6 + Number of frozen occupied orbitals: 0 + Number of frozen unoccupied orbitals: 0 + Two-electron integral type: Conventional + + + Computing Conventional Integrals Presorting SO-basis two-electron integrals. + Sorting File: SO Ints (nn|nn) nbuckets = 1 + Constructing frozen core operators + Starting first half-transformation. + Sorting half-transformed integrals. + First half integral transformation complete. + Starting second half-transformation. + Two-electron integral transformation complete. + + Integral transformation done. 0.00360425 s + Reading the two-electron integrals from disk + Size of two-electron integrals: 0.000029 GB + Timing for conventional integral transformation: 0.009 s. + Timing for freezing core and virtual orbitals: 0.000 s. + Timing for computing conventional integrals: 0.009 s. + + ----------------------------------------------------------- + Multi-Configurational Self Consistent Field + Two-Step Approximate Second-Order AO Algorithm + written by Chenyang Li, Kevin P. Hannon, and Shuhe Wang + ----------------------------------------------------------- + + + ==> MCSCF Calculation Information <== + + -------------------------------------------------------- + Print level Default + Integral type CONVENTIONAL + CI solver type GENCI + Final orbital type CANONICAL + Derivative type NONE + Optimize orbitals TRUE + Include internal rotations FALSE + Debug printing FALSE + Energy convergence 1.000e-08 + Gradient convergence 1.000e-07 + Max value for rotation 2.000e-01 + Max number of macro iter. 100 + Max number of micro iter. for orbitals 6 + Max number of micro iter. for CI 12 + DIIS start 15 + Min DIIS vectors 3 + Max DIIS vectors 8 + Frequency of DIIS extrapolation 1 + -------------------------------------------------------- + + ==> Independent Orbital Rotations <== + + ORBITAL SPACES A1 A2 B1 B2 + ------------------------------------------------------------- + ACTIVE / RESTRICTED_DOCC 0 0 0 0 + RESTRICTED_UOCC / ACTIVE 0 0 0 0 + RESTRICTED_UOCC / RESTRICTED_DOCC 0 0 0 0 + ------------------------------------------------------------- + + ==> Possible Electron Occupations <== + + Config. Space 1 + α β + ----------------- + 1 2 2 + + ==> String Lists <== + + -------------------------------------------------------- + number of alpha electrons 2 + number of beta electrons 2 + number of alpha strings 15 + number of beta strings 15 + -------------------------------------------------------- + + ==> String-based CI Solver <== + + -------------------------------------------------------- + Print level Default + Spin adapt FALSE + Number of determinants 69 + Symmetry 0 + Multiplicity 1 + Number of roots 1 + Target root 0 + -------------------------------------------------------- + + ==> Initial Guess <== + + Initial guess determinants: 50 + + Classification of the initial guess solutions + + Number 2S+1 Selected + ------------------------ + 28 1 * + 21 3 + 1 5 + ------------------------ + + Spin Root Energy Status + ------------------------------------------------------- + singlet 0 -7.882494298809 -0.000000 added + ------------------------------------------------------- + + ==> Davidson-Liu Solver <== + + -------------------------------------------------------- + Print level Default + Energy convergence threshold 1.000e-08 + Residual convergence threshold 1.000e-06 + Schmidt orthogonality threshold 1.000e-12 + Schmidt discard threshold 1.000e-07 + Size of the space 69 + Number of roots 1 + Maximum number of iterations 100 + Collapse subspace size 2 + Maximum subspace size 10 + -------------------------------------------------------- + + Davidson-Liu solver: adding 1 guess vectors + Iteration Average Energy max(∆E) max(Residual) Vectors + --------------------------------------------------------------------------------- + 0 -7.882494298809 7.882494298809 0.008038987350 1 + 1 -7.882504307468 0.000010008659 0.000284247755 2 + 2 -7.882504329166 0.000000021698 0.000021027585 3 + 3 -7.882504329345 0.000000000179 0.000006599970 4 + 4 -7.882504329370 0.000000000025 0.000001340396 5 + 5 -7.882504329372 0.000000000002 0.000000531683 6 + --------------------------------------------------------------------------------- + Timing for CI: 0.006 s. + + ==> Root No. 0 <== + + 2200 0 0 -0.98722460 + 2002 0 0 0.11303965 + + Total Energy: -7.882504329372, : 0.000000 + Timing for 3-RDM (aab): 0.000 s + Timing for 3-RDM (abb): 0.000 s + Timing for 4-RDM (aabb): 0.005 s + +==> RDMs Test (max level = 4)<== + + AA 1-RDM Error : +2.483883e-16 + BB 1-RDM Error : +1.573397e-16 + AAAA 2-RDM Error : +4.764858e-16 + BBBB 2-RDM Error : +4.767134e-16 + ABAB 2-RDM Error : +2.070125e-16 + AAAAAA 3-RDM Error : +0.000000e+00 + AABAAB 3-RDM Error : +3.585422e-17 + ABBABB 3-RDM Error : +1.834991e-18 + BBBBBB 3-RDM Error : +0.000000e+00 + AAAAAAAA 4-RDM Error : +0.000000e+00 + AAABAAAB 4-RDM Error : +0.000000e+00 + AABBAABB 4-RDM Error : +0.000000e+00 + ABBBABBB 4-RDM Error : +0.000000e+00 + BBBBBBBB 4-RDM Error : +0.000000e+00 + + ==> Energy Summary <== + + Multi.(2ms) Irrep. No. Energy + -------------------------------------------------------- + 1 ( 0) A1 0 -7.882504329372 0.000000 + -------------------------------------------------------- + +==> RDMs Test (max level = 1)<== + + SF 1-RDM Error : +4.975030e-16 + + ==> Natural Orbitals Occupation Numbers <== + + 1A1 1.999911 2A1 1.955085 3A1 0.041876 + 1B1 0.001534 1B2 0.001534 4A1 0.000059 + + + ==> Dipole Moments [e a0] (Nuclear + Electronic) for Singlet (Ms = 0) A1 <== + + State DM_X DM_Y DM_Z |DM| + -------------------------------------------------------------------- + 0A1 0.00000000 0.00000000 -1.81815571 1.81815571 + -------------------------------------------------------------------- + Nuclear 0.00000000 0.00000000 1.49275188 1.49275188 + -------------------------------------------------------------------- + +==> RDMs Test (max level = 1)<== + + SF 1-RDM Error : +4.975030e-16 + + ==> Natural Orbitals Occupation Numbers <== + + 1A1 1.999911 2A1 1.955085 3A1 0.041876 + 1B1 0.001534 1B2 0.001534 4A1 0.000059 + + + ==> Quadrupole Moments [e a0^2] (Nuclear + Electronic) for Singlet (Ms = 0) A1 <== + + State QM_XX QM_XY QM_XZ QM_YY QM_YZ QM_ZZ + -------------------------------------------------------------------------------------------------- + 0A1 -4.08221296 0.00000000 0.00000000 -4.08221296 0.00000000 -4.94856087 + -------------------------------------------------------------------------------------------------- + Nuclear 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 7.30707704 + -------------------------------------------------------------------------------------------------- + +==> RDMs Test (max level = 2)<== + + SF 1-RDM Error : +4.975030e-16 + AAAA 2-RDM Error : +5.248916e-08 + BBBB 2-RDM Error : +5.248916e-08 + ABAB 2-RDM Error : +5.248916e-08 + + ==> Natural Orbitals Occupation Numbers <== + + 1A1 1.999911 2A1 1.955085 3A1 0.041876 + 1B1 0.001534 1B2 0.001534 4A1 0.000059 + + + ==> Possible Electron Occupations <== + + Config. Space 1 + α β + ----------------- + 1 2 2 + + ==> String Lists <== + + -------------------------------------------------------- + number of alpha electrons 2 + number of beta electrons 2 + number of alpha strings 15 + number of beta strings 15 + -------------------------------------------------------- + + ==> String-based CI Solver <== + + -------------------------------------------------------- + Print level Default + Spin adapt FALSE + Number of determinants 69 + Symmetry 0 + Multiplicity 1 + Number of roots 1 + Target root 0 + -------------------------------------------------------- + + ==> Initial Guess <== + + Initial guess determinants: 50 + + Classification of the initial guess solutions + + Number 2S+1 Selected + ------------------------ + 28 1 * + 21 3 + 1 5 + ------------------------ + + Spin Root Energy Status + ------------------------------------------------------- + singlet 0 -7.882494298809 -0.000000 added + ------------------------------------------------------- + + ==> Davidson-Liu Solver <== + + -------------------------------------------------------- + Print level Default + Energy convergence threshold 1.000e-12 + Residual convergence threshold 1.000e-06 + Schmidt orthogonality threshold 1.000e-12 + Schmidt discard threshold 1.000e-07 + Size of the space 69 + Number of roots 1 + Maximum number of iterations 100 + Collapse subspace size 2 + Maximum subspace size 10 + -------------------------------------------------------- + + Davidson-Liu solver: adding 1 guess vectors + Iteration Average Energy max(∆E) max(Residual) Vectors + --------------------------------------------------------------------------------- + 0 -7.882494298809 7.882494298809 0.008038987350 1 + 1 -7.882504307468 0.000010008659 0.000284247755 2 + 2 -7.882504329166 0.000000021698 0.000021027585 3 + 3 -7.882504329345 0.000000000179 0.000006599970 4 + 4 -7.882504329370 0.000000000025 0.000001340396 5 + 5 -7.882504329372 0.000000000002 0.000000531683 6 + 6 -7.882504329372 0.000000000000 0.000000120716 7 + --------------------------------------------------------------------------------- + Timing for CI: 0.001 s. + + ==> Root No. 0 <== + + 2200 0 0 0.98722452 + 2002 0 0 -0.11303969 + + Total Energy: -7.882504329372, : 0.000000 + Timing for 3-RDM (aab): 0.000 s + Timing for 3-RDM (abb): 0.000 s + Timing for 4-RDM (aabb): 0.001 s + +==> RDMs Test (max level = 4)<== + + AA 1-RDM Error : +2.223021e-16 + BB 1-RDM Error : +1.140409e-16 + AAAA 2-RDM Error : +1.112128e-17 + BBBB 2-RDM Error : +6.716114e-17 + ABAB 2-RDM Error : +4.478902e-16 + AAAAAA 3-RDM Error : +0.000000e+00 + AABAAB 3-RDM Error : +7.676617e-18 + ABBABB 3-RDM Error : +7.248220e-19 + BBBBBB 3-RDM Error : +0.000000e+00 + AAAAAAAA 4-RDM Error : +0.000000e+00 + AAABAAAB 4-RDM Error : +0.000000e+00 + AABBAABB 4-RDM Error : +0.000000e+00 + ABBBABBB 4-RDM Error : +0.000000e+00 + BBBBBBBB 4-RDM Error : +0.000000e+00 + + ==> Energy Summary <== + + Multi.(2ms) Irrep. No. Energy + -------------------------------------------------------- + 1 ( 0) A1 0 -7.882504329372 0.000000 + -------------------------------------------------------- + +==> RDMs Test (max level = 1)<== + + SF 1-RDM Error : +2.247255e-16 + + ==> Natural Orbitals Occupation Numbers <== + + 1A1 1.999911 2A1 1.955085 3A1 0.041876 + 1B2 0.001534 1B1 0.001534 4A1 0.000059 + + + ==> Dipole Moments [e a0] (Nuclear + Electronic) for Singlet (Ms = 0) A1 <== + + State DM_X DM_Y DM_Z |DM| + -------------------------------------------------------------------- + 0A1 0.00000000 0.00000000 -1.81815375 1.81815375 + -------------------------------------------------------------------- + Nuclear 0.00000000 0.00000000 1.49275188 1.49275188 + -------------------------------------------------------------------- + +==> RDMs Test (max level = 1)<== + + SF 1-RDM Error : +2.247255e-16 + + ==> Natural Orbitals Occupation Numbers <== + + 1A1 1.999911 2A1 1.955085 3A1 0.041876 + 1B2 0.001534 1B1 0.001534 4A1 0.000059 + + + ==> Quadrupole Moments [e a0^2] (Nuclear + Electronic) for Singlet (Ms = 0) A1 <== + + State QM_XX QM_XY QM_XZ QM_YY QM_YZ QM_ZZ + -------------------------------------------------------------------------------------------------- + 0A1 -4.08221616 0.00000000 0.00000000 -4.08221616 0.00000000 -4.94855691 + -------------------------------------------------------------------------------------------------- + Nuclear 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 7.30707704 + -------------------------------------------------------------------------------------------------- + + Time to prepare integrals: 0.128 seconds + Time to run job : 0.416 seconds + Total : 0.544 seconds + AA 1-RDM..............................................................................PASSED + BB 1-RDM..............................................................................PASSED + AAAA 2-RDM............................................................................PASSED + BBBB 2-RDM............................................................................PASSED + ABAB 2-RDM............................................................................PASSED + AABAAB 3-RDM..........................................................................PASSED + ABBABB 3-RDM..........................................................................PASSED + AAAAAA 3-RDM..........................................................................PASSED + BBBBBB 3-RDM..........................................................................PASSED + AAAAAAAA 4-RDM........................................................................PASSED + AAABAAAB 4-RDM........................................................................PASSED + AABBAABB 4-RDM........................................................................PASSED + ABBBABBB 4-RDM........................................................................PASSED + BBBBBBBB 4-RDM........................................................................PASSED + + Psi4 stopped on: Tuesday, 17 September 2024 03:25PM + Psi4 wall time for execution: 0:00:01.46 + +*** Psi4 exiting successfully. Buy a developer a beer! diff --git a/tests/methods/tests.yaml b/tests/methods/tests.yaml index 981a3ffea..7afa31870 100644 --- a/tests/methods/tests.yaml +++ b/tests/methods/tests.yaml @@ -247,6 +247,7 @@ fci: - fci-ecp-1 - fci-ecp-2 - fci-rdms-2 + - fci-rdms-3 - fci-trdms-1 - fci-trdms-2 long: From f5ea32df14d57a5d59c02415eeda72fff205c104 Mon Sep 17 00:00:00 2001 From: Brian Zhao Date: Fri, 20 Sep 2024 14:36:45 -0400 Subject: [PATCH 30/55] Review response 1 --- forte/base_classes/rdms.cc | 30 ++++++++++++++---------------- forte/genci/genci_string_lists.cc | 2 -- forte/genci/genci_vector.h | 15 +++++++-------- 3 files changed, 21 insertions(+), 26 deletions(-) diff --git a/forte/base_classes/rdms.cc b/forte/base_classes/rdms.cc index 77aff92d3..f93d15e41 100644 --- a/forte/base_classes/rdms.cc +++ b/forte/base_classes/rdms.cc @@ -104,9 +104,12 @@ std::shared_ptr RDMs::build(size_t max_rdm_level, size_t n_orbs, RDMsType rdms = std::make_shared(g1); } else if (max_rdm_level == 2) { rdms = std::make_shared(g1, g2); - } else { + } else if (max_rdm_level == 3) { rdms = std::make_shared(g1, g2, g3); } + else { + throw std::runtime_error("RDMs::build: max_rdm_level > 3 not implemented for spin-free RDMs."); + } } return rdms; } @@ -657,11 +660,11 @@ std::shared_ptr RDMsSpinDependent::clone() { g3bbb = g3bbb_.clone(); } if (max_rdm_ > 3) { - g4aaaa_ = g4aaaa_.clone(); - g4aaab_ = g4aaab_.clone(); - g4aabb_ = g4aabb_.clone(); - g4abbb_ = g4abbb_.clone(); - g4bbbb_ = g4bbbb_.clone(); + g4aaaa = g4aaaa_.clone(); + g4aaab = g4aaab_.clone(); + g4aabb = g4aabb_.clone(); + g4abbb = g4abbb_.clone(); + g4bbbb = g4bbbb_.clone(); } std::shared_ptr rdms; @@ -915,32 +918,27 @@ ambit::Tensor RDMsSpinFree::g3bbb() const { return g3bbb; } ambit::Tensor RDMsSpinFree::g4aaaa() const { - // TODO: Implement g4aaaa - _test_rdm_level(20, "g4aaaa"); + throw std::runtime_error("RDMsSpinFree::g4aaaa not implemented."); ambit::Tensor g4aaaa; return g4aaaa; } ambit::Tensor RDMsSpinFree::g4aaab() const { - // TODO: Implement g4aaab - _test_rdm_level(20, "g4aaab"); + throw std::runtime_error("RDMsSpinFree::g4aaab not implemented."); ambit::Tensor g4aaab; return g4aaab; } ambit::Tensor RDMsSpinFree::g4aabb() const { - // TODO: Implement g4aabb - _test_rdm_level(20, "g4aabb"); + throw std::runtime_error("RDMsSpinFree::g4aabb not implemented."); ambit::Tensor g4aabb; return g4aabb; } ambit::Tensor RDMsSpinFree::g4abbb() const { - // TODO: Implement g4abbb - _test_rdm_level(20, "g4abbb"); + throw std::runtime_error("RDMsSpinFree::g4abbb not implemented."); ambit::Tensor g4abbb; return g4abbb; } ambit::Tensor RDMsSpinFree::g4bbbb() const { - // TODO: Implement g4bbbb - _test_rdm_level(20, "g4bbbb"); + throw std::runtime_error("RDMsSpinFree::g4bbbb not implemented."); ambit::Tensor g4bbbb; return g4bbbb; } diff --git a/forte/genci/genci_string_lists.cc b/forte/genci/genci_string_lists.cc index aabfb79b5..a5f5a5371 100644 --- a/forte/genci/genci_string_lists.cc +++ b/forte/genci/genci_string_lists.cc @@ -189,7 +189,6 @@ void GenCIStringLists::startup(std::shared_ptr mo_space_info) { ngas_spaces_, nirrep_, gas_size_, gas_mos_, gas_beta_3h_occupations_, string_class_); beta_address_3h_ = std::make_shared(gas_size_, nb_ - 3, beta_3h_strings); } - if (na_ >= 4) { auto alfa_4h_strings = make_strings_with_occupation( ngas_spaces_, nirrep_, gas_size_, gas_mos_, gas_alfa_4h_occupations_, string_class_); @@ -264,7 +263,6 @@ void GenCIStringLists::startup(std::shared_ptr mo_space_info) { beta_3h_list = make_3h_list(beta_strings_, beta_address_, beta_address_3h_); h3_list_timer += t.get(); } - { local_timer t; alfa_4h_list = make_4h_list(alfa_strings_, alfa_address_, alfa_address_4h_); diff --git a/forte/genci/genci_vector.h b/forte/genci/genci_vector.h index 9e15cc409..6044e53ef 100644 --- a/forte/genci/genci_vector.h +++ b/forte/genci/genci_vector.h @@ -287,14 +287,13 @@ class GenCIVector { } static size_t eight_index(size_t p, size_t q, size_t r, size_t s, size_t t, size_t u, size_t v, size_t w, size_t ncmo) { - return (ncmo * ncmo * ncmo * ncmo * ncmo * ncmo * ncmo * p + - ncmo * ncmo * ncmo * ncmo * ncmo * ncmo * q + - ncmo * ncmo * ncmo * ncmo * ncmo * r + - ncmo * ncmo * ncmo * ncmo * s + - ncmo * ncmo * ncmo * t + - ncmo * ncmo * u + - ncmo * v + - w); + size_t ncmo2 = ncmo * ncmo; + size_t ncmo4 = ncmo2 * ncmo2; + size_t ncmo6 = ncmo4 * ncmo2; + return (ncmo6 * ncmo * p + ncmo6 * q + + ncmo4 * ncmo * r + ncmo4 * s + + ncmo2 * ncmo * t + ncmo2 * u + + ncmo * v + w); } /// @brief Apply the scalar part of the Hamiltonian to this vector and add it to the result From 6b6a24dd7d2299437a844f5e801c5ef1ba448439 Mon Sep 17 00:00:00 2001 From: Brian Zhao Date: Fri, 20 Sep 2024 14:56:38 -0400 Subject: [PATCH 31/55] oops --- forte/base_classes/rdms.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/forte/base_classes/rdms.cc b/forte/base_classes/rdms.cc index f93d15e41..d248c729a 100644 --- a/forte/base_classes/rdms.cc +++ b/forte/base_classes/rdms.cc @@ -643,7 +643,8 @@ ambit::Tensor RDMsSpinDependent::L3bbb() const { } std::shared_ptr RDMsSpinDependent::clone() { - ambit::Tensor g1a, g1b, g2aa, g2ab, g2bb, g3aaa, g3aab, g3abb, g3bbb; + ambit::Tensor g1a, g1b, g2aa, g2ab, g2bb, g3aaa, g3aab, g3abb, g3bbb, g4aaaa, g4aaab, g4aabb, + g4abbb, g4bbbb; if (max_rdm_ > 0) { g1a = g1a_.clone(); g1b = g1b_.clone(); From d3a95c45672ca16b9fccc383a4288f6d2cd04775 Mon Sep 17 00:00:00 2001 From: Shuhang Li Date: Sat, 21 Sep 2024 13:52:39 -0400 Subject: [PATCH 32/55] 4-cumulant --- forte/base_classes/rdms.cc | 491 +++++++++++++++++++++++++++++++++++-- forte/base_classes/rdms.h | 51 ++++ 2 files changed, 523 insertions(+), 19 deletions(-) diff --git a/forte/base_classes/rdms.cc b/forte/base_classes/rdms.cc index d248c729a..24c75e52d 100644 --- a/forte/base_classes/rdms.cc +++ b/forte/base_classes/rdms.cc @@ -47,8 +47,8 @@ std::shared_ptr RDMs::build(size_t max_rdm_level, size_t n_orbs, RDMsType std::shared_ptr rdms; if (type == RDMsType::spin_dependent) { - ambit::Tensor g1a, g1b, g2aa, g2ab, g2bb, g3aaa, g3aab, g3abb, g3bbb, - g4aaaa, g4aaab, g4aabb, g4abbb, g4bbbb; + ambit::Tensor g1a, g1b, g2aa, g2ab, g2bb, g3aaa, g3aab, g3abb, g3bbb, g4aaaa, g4aaab, + g4aabb, g4abbb, g4bbbb; if (max_rdm_level > 0) { g1a = ambit::Tensor::build(ambit::CoreTensor, "g1a", dims1); g1b = ambit::Tensor::build(ambit::CoreTensor, "g1b", dims1); @@ -82,9 +82,9 @@ std::shared_ptr RDMs::build(size_t max_rdm_level, size_t n_orbs, RDMsType rdms = std::make_shared(g1a, g1b, g2aa, g2ab, g2bb, g3aaa, g3aab, g3abb, g3bbb); } else { - rdms = std::make_shared(g1a, g1b, g2aa, g2ab, g2bb, g3aaa, g3aab, - g3abb, g3bbb, g4aaaa, g4aaab, g4aabb, g4abbb, - g4bbbb); + rdms = + std::make_shared(g1a, g1b, g2aa, g2ab, g2bb, g3aaa, g3aab, g3abb, + g3bbb, g4aaaa, g4aaab, g4aabb, g4abbb, g4bbbb); } } else { ambit::Tensor g1, g2, g3; @@ -106,9 +106,9 @@ std::shared_ptr RDMs::build(size_t max_rdm_level, size_t n_orbs, RDMsType rdms = std::make_shared(g1, g2); } else if (max_rdm_level == 3) { rdms = std::make_shared(g1, g2, g3); - } - else { - throw std::runtime_error("RDMs::build: max_rdm_level > 3 not implemented for spin-free RDMs."); + } else { + throw std::runtime_error( + "RDMs::build: max_rdm_level > 3 not implemented for spin-free RDMs."); } } return rdms; @@ -329,6 +329,353 @@ ambit::Tensor RDMs::make_cumulant_L3abb(const ambit::Tensor& g1a, const ambit::T return L3abb; } +ambit::Tensor RDMs::make_cumulant_L4aaaa(const ambit::Tensor& L1a, const ambit::Tensor& L2aa, + const ambit::Tensor& L3aaa, const ambit::Tensor& g4aaaa) { + timer t("make_cumulant_L4aaaa"); + + auto L4aaaa = g4aaaa.clone(); + /// 1111 contributions (24 terms) + L4aaaa("pqrstuvw") -= L1a("pw") * L1a("qv") * L1a("ru") * L1a("st"); + L4aaaa("pqrstuvw") += L1a("pw") * L1a("qv") * L1a("rt") * L1a("su"); + L4aaaa("pqrstuvw") += L1a("pw") * L1a("qu") * L1a("rv") * L1a("st"); + L4aaaa("pqrstuvw") -= L1a("pw") * L1a("qu") * L1a("rt") * L1a("sv"); + L4aaaa("pqrstuvw") -= L1a("pw") * L1a("qt") * L1a("rv") * L1a("su"); + L4aaaa("pqrstuvw") += L1a("pw") * L1a("qt") * L1a("ru") * L1a("sv"); + L4aaaa("pqrstuvw") += L1a("pv") * L1a("qw") * L1a("ru") * L1a("st"); + L4aaaa("pqrstuvw") -= L1a("pv") * L1a("qw") * L1a("rt") * L1a("su"); + L4aaaa("pqrstuvw") -= L1a("pv") * L1a("qu") * L1a("rw") * L1a("st"); + L4aaaa("pqrstuvw") += L1a("pv") * L1a("qu") * L1a("rt") * L1a("sw"); + L4aaaa("pqrstuvw") += L1a("pv") * L1a("qt") * L1a("rw") * L1a("su"); + L4aaaa("pqrstuvw") -= L1a("pv") * L1a("qt") * L1a("ru") * L1a("sw"); + L4aaaa("pqrstuvw") -= L1a("pu") * L1a("qw") * L1a("rv") * L1a("st"); + L4aaaa("pqrstuvw") += L1a("pu") * L1a("qw") * L1a("rt") * L1a("sv"); + L4aaaa("pqrstuvw") += L1a("pu") * L1a("qv") * L1a("rw") * L1a("st"); + L4aaaa("pqrstuvw") -= L1a("pu") * L1a("qv") * L1a("rt") * L1a("sw"); + L4aaaa("pqrstuvw") -= L1a("pu") * L1a("qt") * L1a("rw") * L1a("sv"); + L4aaaa("pqrstuvw") += L1a("pu") * L1a("qt") * L1a("rv") * L1a("sw"); + L4aaaa("pqrstuvw") += L1a("pt") * L1a("qw") * L1a("rv") * L1a("su"); + L4aaaa("pqrstuvw") -= L1a("pt") * L1a("qw") * L1a("ru") * L1a("sv"); + L4aaaa("pqrstuvw") -= L1a("pt") * L1a("qv") * L1a("rw") * L1a("su"); + L4aaaa("pqrstuvw") += L1a("pt") * L1a("qv") * L1a("ru") * L1a("sw"); + L4aaaa("pqrstuvw") += L1a("pt") * L1a("qu") * L1a("rw") * L1a("sv"); + L4aaaa("pqrstuvw") -= L1a("pt") * L1a("qu") * L1a("rv") * L1a("sw"); + + /// 211 contributions (72 terms) + L4aaaa("pqrstuvw") += L2aa("pqvw") * L1a("ru") * L1a("st"); + L4aaaa("pqrstuvw") -= L2aa("pqvw") * L1a("rt") * L1a("su"); + L4aaaa("pqrstuvw") -= L2aa("pquw") * L1a("rv") * L1a("st"); + L4aaaa("pqrstuvw") += L2aa("pquw") * L1a("rt") * L1a("sv"); + L4aaaa("pqrstuvw") += L2aa("pqtw") * L1a("rv") * L1a("su"); + L4aaaa("pqrstuvw") -= L2aa("pqtw") * L1a("ru") * L1a("sv"); + L4aaaa("pqrstuvw") += L2aa("pquv") * L1a("rw") * L1a("st"); + L4aaaa("pqrstuvw") -= L2aa("pquv") * L1a("rt") * L1a("sw"); + L4aaaa("pqrstuvw") -= L2aa("pqtv") * L1a("rw") * L1a("su"); + L4aaaa("pqrstuvw") += L2aa("pqtv") * L1a("ru") * L1a("sw"); + L4aaaa("pqrstuvw") += L2aa("pqtu") * L1a("rw") * L1a("sv"); + L4aaaa("pqrstuvw") -= L2aa("pqtu") * L1a("rv") * L1a("sw"); + L4aaaa("pqrstuvw") -= L2aa("prvw") * L1a("qu") * L1a("st"); + L4aaaa("pqrstuvw") += L2aa("prvw") * L1a("qt") * L1a("su"); + L4aaaa("pqrstuvw") += L2aa("pruw") * L1a("qv") * L1a("st"); + L4aaaa("pqrstuvw") -= L2aa("pruw") * L1a("qt") * L1a("sv"); + L4aaaa("pqrstuvw") -= L2aa("prtw") * L1a("qv") * L1a("su"); + L4aaaa("pqrstuvw") += L2aa("prtw") * L1a("qu") * L1a("sv"); + L4aaaa("pqrstuvw") -= L2aa("pruv") * L1a("qw") * L1a("st"); + L4aaaa("pqrstuvw") += L2aa("pruv") * L1a("qt") * L1a("sw"); + L4aaaa("pqrstuvw") += L2aa("prtv") * L1a("qw") * L1a("su"); + L4aaaa("pqrstuvw") -= L2aa("prtv") * L1a("qu") * L1a("sw"); + L4aaaa("pqrstuvw") -= L2aa("prtu") * L1a("qw") * L1a("sv"); + L4aaaa("pqrstuvw") += L2aa("prtu") * L1a("qv") * L1a("sw"); + L4aaaa("pqrstuvw") += L2aa("psvw") * L1a("qu") * L1a("rt"); + L4aaaa("pqrstuvw") -= L2aa("psvw") * L1a("qt") * L1a("ru"); + L4aaaa("pqrstuvw") -= L2aa("psuw") * L1a("qv") * L1a("rt"); + L4aaaa("pqrstuvw") += L2aa("psuw") * L1a("qt") * L1a("rv"); + L4aaaa("pqrstuvw") += L2aa("pstw") * L1a("qv") * L1a("ru"); + L4aaaa("pqrstuvw") -= L2aa("pstw") * L1a("qu") * L1a("rv"); + L4aaaa("pqrstuvw") += L2aa("psuv") * L1a("qw") * L1a("rt"); + L4aaaa("pqrstuvw") -= L2aa("psuv") * L1a("qt") * L1a("rw"); + L4aaaa("pqrstuvw") -= L2aa("pstv") * L1a("qw") * L1a("ru"); + L4aaaa("pqrstuvw") += L2aa("pstv") * L1a("qu") * L1a("rw"); + L4aaaa("pqrstuvw") += L2aa("pstu") * L1a("qw") * L1a("rv"); + L4aaaa("pqrstuvw") -= L2aa("pstu") * L1a("qv") * L1a("rw"); + L4aaaa("pqrstuvw") += L2aa("qrvw") * L1a("pu") * L1a("st"); + L4aaaa("pqrstuvw") -= L2aa("qrvw") * L1a("pt") * L1a("su"); + L4aaaa("pqrstuvw") -= L2aa("qruw") * L1a("pv") * L1a("st"); + L4aaaa("pqrstuvw") += L2aa("qruw") * L1a("pt") * L1a("sv"); + L4aaaa("pqrstuvw") += L2aa("qrtw") * L1a("pv") * L1a("su"); + L4aaaa("pqrstuvw") -= L2aa("qrtw") * L1a("pu") * L1a("sv"); + L4aaaa("pqrstuvw") += L2aa("qruv") * L1a("pw") * L1a("st"); + L4aaaa("pqrstuvw") -= L2aa("qruv") * L1a("pt") * L1a("sw"); + L4aaaa("pqrstuvw") -= L2aa("qrtv") * L1a("pw") * L1a("su"); + L4aaaa("pqrstuvw") += L2aa("qrtv") * L1a("pu") * L1a("sw"); + L4aaaa("pqrstuvw") += L2aa("qrtu") * L1a("pw") * L1a("sv"); + L4aaaa("pqrstuvw") -= L2aa("qrtu") * L1a("pv") * L1a("sw"); + L4aaaa("pqrstuvw") -= L2aa("qsvw") * L1a("pu") * L1a("rt"); + L4aaaa("pqrstuvw") += L2aa("qsvw") * L1a("pt") * L1a("ru"); + L4aaaa("pqrstuvw") += L2aa("qsuw") * L1a("pv") * L1a("rt"); + L4aaaa("pqrstuvw") -= L2aa("qsuw") * L1a("pt") * L1a("rv"); + L4aaaa("pqrstuvw") -= L2aa("qstw") * L1a("pv") * L1a("ru"); + L4aaaa("pqrstuvw") += L2aa("qstw") * L1a("pu") * L1a("rv"); + L4aaaa("pqrstuvw") -= L2aa("qsuv") * L1a("pw") * L1a("rt"); + L4aaaa("pqrstuvw") += L2aa("qsuv") * L1a("pt") * L1a("rw"); + L4aaaa("pqrstuvw") += L2aa("qstv") * L1a("pw") * L1a("ru"); + L4aaaa("pqrstuvw") -= L2aa("qstv") * L1a("pu") * L1a("rw"); + L4aaaa("pqrstuvw") -= L2aa("qstu") * L1a("pw") * L1a("rv"); + L4aaaa("pqrstuvw") += L2aa("qstu") * L1a("pv") * L1a("rw"); + L4aaaa("pqrstuvw") += L2aa("rsvw") * L1a("pu") * L1a("qt"); + L4aaaa("pqrstuvw") -= L2aa("rsvw") * L1a("pt") * L1a("qu"); + L4aaaa("pqrstuvw") -= L2aa("rsuw") * L1a("pv") * L1a("qt"); + L4aaaa("pqrstuvw") += L2aa("rsuw") * L1a("pt") * L1a("qv"); + L4aaaa("pqrstuvw") += L2aa("rstw") * L1a("pv") * L1a("qu"); + L4aaaa("pqrstuvw") -= L2aa("rstw") * L1a("pu") * L1a("qv"); + L4aaaa("pqrstuvw") += L2aa("rsuv") * L1a("pw") * L1a("qt"); + L4aaaa("pqrstuvw") -= L2aa("rsuv") * L1a("pt") * L1a("qw"); + L4aaaa("pqrstuvw") -= L2aa("rstv") * L1a("pw") * L1a("qu"); + L4aaaa("pqrstuvw") += L2aa("rstv") * L1a("pu") * L1a("qw"); + L4aaaa("pqrstuvw") += L2aa("rstu") * L1a("pw") * L1a("qv"); + L4aaaa("pqrstuvw") -= L2aa("rstu") * L1a("pv") * L1a("qw"); + + /// 22 contributions (18 terms) + L4aaaa("pqrstuvw") -= L2aa("pqvw") * L2aa("rstu"); + L4aaaa("pqrstuvw") += L2aa("pquw") * L2aa("rstv"); + L4aaaa("pqrstuvw") -= L2aa("pqtw") * L2aa("rsuv"); + L4aaaa("pqrstuvw") -= L2aa("pquv") * L2aa("rstw"); + L4aaaa("pqrstuvw") += L2aa("pqtv") * L2aa("rsuw"); + L4aaaa("pqrstuvw") -= L2aa("pqtu") * L2aa("rsvw"); + L4aaaa("pqrstuvw") += L2aa("prvw") * L2aa("qstu"); + L4aaaa("pqrstuvw") -= L2aa("pruw") * L2aa("qstv"); + L4aaaa("pqrstuvw") += L2aa("prtw") * L2aa("qsuv"); + L4aaaa("pqrstuvw") += L2aa("pruv") * L2aa("qstw"); + L4aaaa("pqrstuvw") -= L2aa("prtv") * L2aa("qsuw"); + L4aaaa("pqrstuvw") += L2aa("prtu") * L2aa("qsvw"); + L4aaaa("pqrstuvw") -= L2aa("psvw") * L2aa("qrtu"); + L4aaaa("pqrstuvw") += L2aa("psuw") * L2aa("qrtv"); + L4aaaa("pqrstuvw") -= L2aa("pstw") * L2aa("qruv"); + L4aaaa("pqrstuvw") -= L2aa("psuv") * L2aa("qrtw"); + L4aaaa("pqrstuvw") += L2aa("pstv") * L2aa("qruw"); + L4aaaa("pqrstuvw") -= L2aa("pstu") * L2aa("qrvw"); + + /// 31 contributions (16 terms) + L4aaaa("pqrstuvw") += L3aaa("pqruvw") * L1a("st"); + L4aaaa("pqrstuvw") -= L3aaa("pqrtvw") * L1a("su"); + L4aaaa("pqrstuvw") += L3aaa("pqrtuw") * L1a("sv"); + L4aaaa("pqrstuvw") -= L3aaa("pqrtuv") * L1a("sw"); + L4aaaa("pqrstuvw") -= L3aaa("pqsuvw") * L1a("rt"); + L4aaaa("pqrstuvw") += L3aaa("pqstvw") * L1a("ru"); + L4aaaa("pqrstuvw") -= L3aaa("pqstuw") * L1a("rv"); + L4aaaa("pqrstuvw") += L3aaa("pqstuv") * L1a("rw"); + L4aaaa("pqrstuvw") += L3aaa("prsuvw") * L1a("qt"); + L4aaaa("pqrstuvw") -= L3aaa("prstvw") * L1a("qu"); + L4aaaa("pqrstuvw") += L3aaa("prstuw") * L1a("qv"); + L4aaaa("pqrstuvw") -= L3aaa("prstuv") * L1a("qw"); + L4aaaa("pqrstuvw") -= L3aaa("qrsuvw") * L1a("pt"); + L4aaaa("pqrstuvw") += L3aaa("qrstvw") * L1a("pu"); + L4aaaa("pqrstuvw") -= L3aaa("qrstuw") * L1a("pv"); + L4aaaa("pqrstuvw") += L3aaa("qrstuv") * L1a("pw"); + + return L4aaaa; +} + +ambit::Tensor RDMs::make_cumulant_L4aaab(const ambit::Tensor& L1a, const ambit::Tensor& L1b, + const ambit::Tensor& L2aa, const ambit::Tensor& L2ab, + const ambit::Tensor& L3aaa, const ambit::Tensor& L3aab, + const ambit::Tensor& g4aaab) { + timer t("make_cumulant_L4aaab"); + + auto L4aaab = g4aaab.clone(); + /// 1111 contributions + L4aaab("pqrStuvW") += L1a("pv") * L1a("qu") * L1a("rt") * L1b("SW"); + L4aaab("pqrStuvW") -= L1a("pv") * L1a("qt") * L1a("ru") * L1b("SW"); + L4aaab("pqrStuvW") -= L1a("pu") * L1a("qv") * L1a("rt") * L1b("SW"); + L4aaab("pqrStuvW") += L1a("pu") * L1a("qt") * L1a("rv") * L1b("SW"); + L4aaab("pqrStuvW") += L1a("pt") * L1a("qv") * L1a("ru") * L1b("SW"); + L4aaab("pqrStuvW") -= L1a("pt") * L1a("qu") * L1a("rv") * L1b("SW"); + + /// 211 contributions + L4aaab("pqrStuvW") -= L2aa("pquv") * L1a("rt") * L1b("SW"); + L4aaab("pqrStuvW") += L2aa("pqtv") * L1a("ru") * L1b("SW"); + L4aaab("pqrStuvW") -= L2aa("pqtu") * L1a("rv") * L1b("SW"); + L4aaab("pqrStuvW") += L2aa("pruv") * L1a("qt") * L1b("SW"); + L4aaab("pqrStuvW") -= L2aa("prtv") * L1a("qu") * L1b("SW"); + L4aaab("pqrStuvW") += L2aa("prtu") * L1a("qv") * L1b("SW"); + L4aaab("pqrStuvW") += L2ab("pSvW") * L1a("qu") * L1a("rt"); + L4aaab("pqrStuvW") -= L2ab("pSvW") * L1a("qt") * L1a("ru"); + L4aaab("pqrStuvW") -= L2ab("pSuW") * L1a("qv") * L1a("rt"); + L4aaab("pqrStuvW") += L2ab("pSuW") * L1a("qt") * L1a("rv"); + L4aaab("pqrStuvW") += L2ab("pStW") * L1a("qv") * L1a("ru"); + L4aaab("pqrStuvW") -= L2ab("pStW") * L1a("qu") * L1a("rv"); + L4aaab("pqrStuvW") -= L2aa("qruv") * L1a("pt") * L1b("SW"); + L4aaab("pqrStuvW") += L2aa("qrtv") * L1a("pu") * L1b("SW"); + L4aaab("pqrStuvW") -= L2aa("qrtu") * L1a("pv") * L1b("SW"); + L4aaab("pqrStuvW") -= L2ab("qSvW") * L1a("pu") * L1a("rt"); + L4aaab("pqrStuvW") += L2ab("qSvW") * L1a("pt") * L1a("ru"); + L4aaab("pqrStuvW") += L2ab("qSuW") * L1a("pv") * L1a("rt"); + L4aaab("pqrStuvW") -= L2ab("qSuW") * L1a("pt") * L1a("rv"); + L4aaab("pqrStuvW") -= L2ab("qStW") * L1a("pv") * L1a("ru"); + L4aaab("pqrStuvW") += L2ab("qStW") * L1a("pu") * L1a("rv"); + L4aaab("pqrStuvW") += L2ab("rSvW") * L1a("pu") * L1a("qt"); + L4aaab("pqrStuvW") -= L2ab("rSvW") * L1a("pt") * L1a("qu"); + L4aaab("pqrStuvW") -= L2ab("rSuW") * L1a("pv") * L1a("qt"); + L4aaab("pqrStuvW") += L2ab("rSuW") * L1a("pt") * L1a("qv"); + L4aaab("pqrStuvW") += L2ab("rStW") * L1a("pv") * L1a("qu"); + L4aaab("pqrStuvW") -= L2ab("rStW") * L1a("pu") * L1a("qv"); + + /// 22 contributions + L4aaab("pqrStuvW") -= L2aa("pquv") * L2ab("rStW"); + L4aaab("pqrStuvW") += L2aa("pqtv") * L2ab("rSuW"); + L4aaab("pqrStuvW") -= L2aa("pqtu") * L2ab("rSvW"); + L4aaab("pqrStuvW") += L2aa("pruv") * L2ab("qStW"); + L4aaab("pqrStuvW") -= L2aa("prtv") * L2ab("qSuW"); + L4aaab("pqrStuvW") += L2aa("prtu") * L2ab("qSvW"); + L4aaab("pqrStuvW") -= L2ab("pSvW") * L2aa("qrtu"); + L4aaab("pqrStuvW") += L2ab("pSuW") * L2aa("qrtv"); + L4aaab("pqrStuvW") -= L2ab("pStW") * L2aa("qruv"); + + /// 31 contributions (16 terms) + L4aaab("pqrStuvW") -= L3aaa("pqrtuv") * L1b("SW"); + L4aaab("pqrStuvW") -= L3aab("pqSuvW") * L1a("rt"); + L4aaab("pqrStuvW") += L3aab("pqStvW") * L1a("ru"); + L4aaab("pqrStuvW") -= L3aab("pqStuW") * L1a("rv"); + L4aaab("pqrStuvW") += L3aab("prSuvW") * L1a("qt"); + L4aaab("pqrStuvW") -= L3aab("prStvW") * L1a("qu"); + L4aaab("pqrStuvW") += L3aab("prStuW") * L1a("qv"); + L4aaab("pqrStuvW") -= L3aab("qrSuvW") * L1a("pt"); + L4aaab("pqrStuvW") += L3aab("qrStvW") * L1a("pu"); + L4aaab("pqrStuvW") -= L3aab("qrStuW") * L1a("pv"); + + return L4aaab; +} + +ambit::Tensor RDMs::make_cumulant_L4aabb(const ambit::Tensor& L1a, const ambit::Tensor& L1b, + const ambit::Tensor& L2aa, const ambit::Tensor& L2ab, + const ambit::Tensor& L2bb, const ambit::Tensor& L3aab, + const ambit::Tensor& L3abb, const ambit::Tensor& g4aabb) { + timer t("make_cumulant_L4aabb"); + + auto L4aabb = g4aabb.clone(); + /// 1111 contributions + L4aabb("pqRStuVW") -= L1a("pu") * L1a("qt") * L1b("RW") * L1b("SV"); + L4aabb("pqRStuVW") += L1a("pu") * L1a("qt") * L1b("RV") * L1b("SW"); + L4aabb("pqRStuVW") += L1a("pt") * L1a("qu") * L1b("RW") * L1b("SV"); + L4aabb("pqRStuVW") -= L1a("pt") * L1a("qu") * L1b("RV") * L1b("SW"); + + /// 211 contributions + L4aabb("pqRStuVW") += L2aa("pqtu") * L1b("RW") * L1b("SV"); + L4aabb("pqRStuVW") -= L2aa("pqtu") * L1b("RV") * L1b("SW"); + L4aabb("pqRStuVW") -= L2ab("pRuW") * L1a("qt") * L1b("SV"); + L4aabb("pqRStuVW") += L2ab("pRtW") * L1a("qu") * L1b("SV"); + L4aabb("pqRStuVW") += L2ab("pRuV") * L1a("qt") * L1b("SW"); + L4aabb("pqRStuVW") -= L2ab("pRtV") * L1a("qu") * L1b("SW"); + L4aabb("pqRStuVW") += L2ab("pSuW") * L1a("qt") * L1b("RV"); + L4aabb("pqRStuVW") -= L2ab("pStW") * L1a("qu") * L1b("RV"); + L4aabb("pqRStuVW") -= L2ab("pSuV") * L1a("qt") * L1b("RW"); + L4aabb("pqRStuVW") += L2ab("pStV") * L1a("qu") * L1b("RW"); + L4aabb("pqRStuVW") += L2ab("qRuW") * L1a("pt") * L1b("SV"); + L4aabb("pqRStuVW") -= L2ab("qRtW") * L1a("pu") * L1b("SV"); + L4aabb("pqRStuVW") -= L2ab("qRuV") * L1a("pt") * L1b("SW"); + L4aabb("pqRStuVW") += L2ab("qRtV") * L1a("pu") * L1b("SW"); + L4aabb("pqRStuVW") -= L2ab("qSuW") * L1a("pt") * L1b("RV"); + L4aabb("pqRStuVW") += L2ab("qStW") * L1a("pu") * L1b("RV"); + L4aabb("pqRStuVW") += L2ab("qSuV") * L1a("pt") * L1b("RW"); + L4aabb("pqRStuVW") -= L2ab("qStV") * L1a("pu") * L1b("RW"); + L4aabb("pqRStuVW") += L2bb("RSVW") * L1a("pu") * L1a("qt"); + L4aabb("pqRStuVW") -= L2bb("RSVW") * L1a("pt") * L1a("qu"); + + /// 22 contributions + L4aabb("pqRStuVW") -= L2aa("pqtu") * L2bb("RSVW"); + L4aabb("pqRStuVW") -= L2ab("pRuW") * L2ab("qStV"); + L4aabb("pqRStuVW") += L2ab("pRtW") * L2ab("qSuV"); + L4aabb("pqRStuVW") += L2ab("pRuV") * L2ab("qStW"); + L4aabb("pqRStuVW") -= L2ab("pRtV") * L2ab("qSuW"); + L4aabb("pqRStuVW") += L2ab("pSuW") * L2ab("qRtV"); + L4aabb("pqRStuVW") -= L2ab("pStW") * L2ab("qRuV"); + L4aabb("pqRStuVW") -= L2ab("pSuV") * L2ab("qRtW"); + L4aabb("pqRStuVW") += L2ab("pStV") * L2ab("qRuW"); + + /// 31 contributions + L4aabb("pqRStuVW") += L3aab("pqRtuW") * L1b("SV"); + L4aabb("pqRStuVW") -= L3aab("pqRtuV") * L1b("SW"); + L4aabb("pqRStuVW") -= L3aab("pqStuW") * L1b("RV"); + L4aabb("pqRStuVW") += L3aab("pqStuV") * L1b("RW"); + L4aabb("pqRStuVW") += L3abb("pRSuVW") * L1a("qt"); + L4aabb("pqRStuVW") -= L3abb("pRStVW") * L1a("qu"); + L4aabb("pqRStuVW") -= L3abb("qRSuVW") * L1a("pt"); + L4aabb("pqRStuVW") += L3abb("qRStVW") * L1a("pu"); + + return L4aabb; +} + +ambit::Tensor RDMs::make_cumulat_L4abbb(const ambit::Tensor& L1a, const ambit::Tensor& L1b, + const ambit::Tensor& L2ab, const ambit::Tensor& L2bb, + const ambit::Tensor& L3abb, const ambit::Tensor& L3bbb, + const ambit::Tensor& g4abbb) { + timer t("make_cumulant_L4abbb"); + + auto L4abbb = g4abbb.clone(); + /// 1111 contributions (24 terms) + L4abbb("pQRStUVW") += L1a("pt") * L1b("QW") * L1b("RV") * L1b("SU"); + L4abbb("pQRStUVW") -= L1a("pt") * L1b("QW") * L1b("RU") * L1b("SV"); + L4abbb("pQRStUVW") -= L1a("pt") * L1b("QV") * L1b("RW") * L1b("SU"); + L4abbb("pQRStUVW") += L1a("pt") * L1b("QV") * L1b("RU") * L1b("SW"); + L4abbb("pQRStUVW") += L1a("pt") * L1b("QU") * L1b("RW") * L1b("SV"); + L4abbb("pQRStUVW") -= L1a("pt") * L1b("QU") * L1b("RV") * L1b("SW"); + + /// 211 contributions (72 terms) + L4abbb("pQRStUVW") += L2ab("pQtW") * L1b("RV") * L1b("SU"); + L4abbb("pQRStUVW") -= L2ab("pQtW") * L1a("RU") * L1b("SV"); + L4abbb("pQRStUVW") -= L2ab("pQtV") * L1b("RW") * L1b("SU"); + L4abbb("pQRStUVW") += L2ab("pQtV") * L1b("RU") * L1b("SW"); + L4abbb("pQRStUVW") += L2ab("pQtU") * L1b("RW") * L1b("SV"); + L4abbb("pQRStUVW") -= L2ab("pQtU") * L1b("RV") * L1b("SW"); + L4abbb("pQRStUVW") -= L2ab("pRtW") * L1b("QV") * L1b("SU"); + L4abbb("pQRStUVW") += L2ab("pRtW") * L1b("QU") * L1b("SV"); + L4abbb("pQRStUVW") += L2ab("pRtV") * L1b("QW") * L1b("SU"); + L4abbb("pQRStUVW") -= L2ab("pRtV") * L1b("QU") * L1b("SW"); + L4abbb("pQRStUVW") -= L2ab("pRtU") * L1b("QW") * L1b("SV"); + L4abbb("pQRStUVW") += L2ab("pRtU") * L1b("QV") * L1b("SW"); + L4abbb("pQRStUVW") += L2ab("pStW") * L1b("QV") * L1b("RU"); + L4abbb("pQRStUVW") -= L2ab("pStW") * L1b("QU") * L1b("RV"); + L4abbb("pQRStUVW") -= L2ab("pStV") * L1b("QW") * L1b("RU"); + L4abbb("pQRStUVW") += L2ab("pStV") * L1b("QU") * L1b("RW"); + L4abbb("pQRStUVW") += L2ab("pStU") * L1b("QW") * L1b("RV"); + L4abbb("pQRStUVW") -= L2ab("pStU") * L1b("QV") * L1b("RW"); + + L4abbb("pQRStUVW") -= L2bb("QRVW") * L1a("pt") * L1b("SU"); + L4abbb("pQRStUVW") += L2bb("QRUW") * L1a("pt") * L1b("SV"); + L4abbb("pQRStUVW") -= L2bb("QRUV") * L1a("pt") * L1b("SW"); + L4abbb("pQRStUVW") += L2bb("QSVW") * L1a("pt") * L1b("RU"); + L4abbb("pQRStUVW") -= L2bb("QSUW") * L1a("pt") * L1b("RV"); + L4abbb("pQRStUVW") += L2bb("QSUV") * L1a("pt") * L1b("RW"); + L4abbb("pQRStUVW") -= L2bb("RSVW") * L1a("pt") * L1b("QU"); + L4abbb("pQRStUVW") += L2bb("RSUW") * L1a("pt") * L1b("QV"); + L4abbb("pQRStUVW") -= L2bb("RSUV") * L1a("pt") * L1b("QW"); + + /// 22 contributions (18 terms) + L4abbb("pQRStUVW") -= L2ab("pQtW") * L2bb("RSUV"); + L4abbb("pQRStUVW") += L2ab("pQtV") * L2bb("RSUW"); + L4abbb("pQRStUVW") -= L2ab("pQtU") * L2bb("RSVW"); + L4abbb("pQRStUVW") += L2ab("pRtW") * L2bb("QSUV"); + L4abbb("pQRStUVW") -= L2ab("pRtV") * L2bb("QSUW"); + L4abbb("pQRStUVW") += L2ab("pRtU") * L2bb("QSVW"); + L4abbb("pQRStUVW") -= L2ab("pStW") * L2bb("QRUV"); + L4abbb("pQRStUVW") += L2ab("pStV") * L2bb("QRUW"); + L4abbb("pQRStUVW") -= L2ab("pStU") * L2bb("QRVW"); + + /// 31 contributions (16 terms) + L4abbb("pQRStUVW") -= L3abb("pQRtVW") * L1b("SU"); + L4abbb("pQRStUVW") += L3abb("pQRtUW") * L1b("SV"); + L4abbb("pQRStUVW") -= L3abb("pQRtUV") * L1b("SW"); + L4abbb("pQRStUVW") += L3abb("pQStVW") * L1b("RU"); + L4abbb("pQRStUVW") -= L3abb("pQStUW") * L1b("RV"); + L4abbb("pQRStUVW") += L3abb("pQStUV") * L1b("RW"); + L4abbb("pQRStUVW") -= L3abb("pRStVW") * L1b("QU"); + L4abbb("pQRStUVW") += L3abb("pRStUW") * L1b("QV"); + L4abbb("pQRStUVW") -= L3abb("pRStUV") * L1b("QW"); + + L4abbb("pQRStUVW") -= L3bbb("QRSUVW") * L1a("pt"); + + return L4abbb; +} + ambit::Tensor RDMs::sf1_to_sd1(const ambit::Tensor& G1) { auto g1 = G1.clone(); g1.scale(0.5); @@ -472,16 +819,15 @@ RDMsSpinDependent::RDMsSpinDependent(ambit::Tensor g1a, ambit::Tensor g1b, ambit _test_rdm_dims(g3bbb, "g3bbb", 6); } -RDMsSpinDependent::RDMsSpinDependent(ambit::Tensor g1a, ambit::Tensor g1b, ambit::Tensor g2aa, ambit::Tensor g2ab, - ambit::Tensor g2bb, ambit::Tensor g3aaa, ambit::Tensor g3aab, - ambit::Tensor g3abb, ambit::Tensor g3bbb, ambit::Tensor g4aaaa, - ambit::Tensor g4aaab, ambit::Tensor g4aabb, ambit::Tensor g4abbb, - ambit::Tensor g4bbbb) - : g1a_(g1a), g1b_(g1b), g2aa_(g2aa), g2ab_(g2ab), - g2bb_(g2bb), g3aaa_(g3aaa), g3aab_(g3aab), - g3abb_(g3abb), g3bbb_(g3bbb), g4aaaa_(g4aaaa), - g4aaab_(g4aaab), g4aabb_(g4aabb), g4abbb_(g4abbb), - g4bbbb_(g4bbbb) { +RDMsSpinDependent::RDMsSpinDependent(ambit::Tensor g1a, ambit::Tensor g1b, ambit::Tensor g2aa, + ambit::Tensor g2ab, ambit::Tensor g2bb, ambit::Tensor g3aaa, + ambit::Tensor g3aab, ambit::Tensor g3abb, ambit::Tensor g3bbb, + ambit::Tensor g4aaaa, ambit::Tensor g4aaab, + ambit::Tensor g4aabb, ambit::Tensor g4abbb, + ambit::Tensor g4bbbb) + : g1a_(g1a), g1b_(g1b), g2aa_(g2aa), g2ab_(g2ab), g2bb_(g2bb), g3aaa_(g3aaa), g3aab_(g3aab), + g3abb_(g3abb), g3bbb_(g3bbb), g4aaaa_(g4aaaa), g4aaab_(g4aaab), g4aabb_(g4aabb), + g4abbb_(g4abbb), g4bbbb_(g4bbbb) { max_rdm_ = 4; type_ = RDMsType::spin_dependent; n_orbs_ = g1a.dim(0); @@ -642,6 +988,67 @@ ambit::Tensor RDMsSpinDependent::L3bbb() const { return L3bbb; } +ambit::Tensor RDMsSpinDependent::L4aaaa() const { + _test_rdm_level(4, "L4aaaa"); + auto _L1a = L1a(); + auto _L2aa = L2aa(); + auto _L3aaa = L3aaa(); + auto _L4aaaa = make_cumulant_L4aaaa(_L1a, _L2aa, _L3aaa, g4aaaa_); + L4aaaa.set_name("L4aaaa"); + return L4aaaa; +} + +ambit::Tensor RDMsSpinDependent::L4aaab() const { + _test_rdm_level(4, "L4aaab"); + auto _L1a = L1a(); + auto _L1b = L1b(); + auto _L2aa = L2aa(); + auto _L2ab = L2ab(); + auto _L3aaa = L3aaa(); + auto _L3aab = L3aab(); + auto L4aaab = make_cumulant_L4aaab(_L1a, _L1b, _L2aa, _L2ab, _L3aaa, _L3aab, g4aaab_); + L4aaab.set_name("L4aaab"); + return L4aaab; +} + +ambit::Tensor RDMsSpinDependent::L4aabb() const { + _test_rdm_level(4, "L4aabb"); + auto _L1a = L1a(); + auto _L1b = L1b(); + auto _L2aa = L2aa(); + auto _L2ab = L2ab(); + auto _L2bb = L2bb(); + auto _L3aab = L3aab(); + auto _L3abb = L3abb(); + auto L4aabb = make_cumulant_L4aabb(_L1a, _L1b, _L2aa, _L2ab, _L2bb, _L3aab, _L3abb, g4aabb_); + L4aabb.set_name("L4aabb"); + return L4aabb; +} + +ambit::Tensor RDMSpinDependent::L4abbb() const { + _test_rdm_level(4, "L4abbb"); + auto _L1a = L1a(); + auto _L1b = L1b(); + auto _L2ab = L2ab(); + auto _L2bb = L2bb(); + auto _L3abb = L3abb(); + auto _L3bbb = L3bbb(); + auto L4abbb = make_cumulant_L4abbb(_L1a, _L1b, _L2ab, _L2bb, _L3abb, _L3bbb, g4abbb_); + L4abbb.set_name("L4abbb"); + return L4abbb; +} + +ambit::Tensor RDMsSpinDependent::L4bbbb() const { + _test_rdm_level(4, "L4bbbb"); + auto L1b = L1b(); + auto L2bb = L2bb(); + auto L3bbb = L3bbb(); + auto g4bbbb = g4bbbb(); + auto L4bbbb = make_cumulant_L4aaaa(L1b, L2bb, L3bbb, g4bbbb); + L4bbbb.set_name("L4bbbb"); + return L4aaaa; +} + std::shared_ptr RDMsSpinDependent::clone() { ambit::Tensor g1a, g1b, g2aa, g2ab, g2bb, g3aaa, g3aab, g3abb, g3bbb, g4aaaa, g4aaab, g4aabb, g4abbb, g4bbbb; @@ -676,9 +1083,12 @@ std::shared_ptr RDMsSpinDependent::clone() { rdms = std::make_shared(g1a, g1b); else if (max_rdm_ == 2) rdms = std::make_shared(g1a, g1b, g2aa, g2ab, g2bb); - else + else if (max_rdm_ == 3) rdms = std::make_shared(g1a, g1b, g2aa, g2ab, g2bb, g3aaa, g3aab, g3abb, g3bbb); + else: + rdms = std::make_shared(g1a, g1b, g2aa, g2ab, g2bb, g3aaa, g3aab, g3abb, + g3bbb, g4aaaa, g4aaab, g4aabb, g4abbb, g4bbbb); return rdms; } @@ -731,6 +1141,13 @@ void RDMsSpinDependent::axpy(std::shared_ptr rhs, double a) { g3abb_("pqrstu") += a * rhs->g3abb()("pqrstu"); g3bbb_("pqrstu") += a * rhs->g3bbb()("pqrstu"); } + if (max_rdm_ > 3) { + g4aaaa_("pqrstuvw") += a * rhs->g4aaaa()("pqrstuvw"); + g4aaab_("pqrstuvw") += a * rhs->g4aaab()("pqrstuvw"); + g4aabb_("pqrstuvw") += a * rhs->g4aabb()("pqrstuvw"); + g4abbb_("pqrstuvw") += a * rhs->g4abbb()("pqrstuvw"); + g4bbbb_("pqrstuvw") += a * rhs->g4bbbb()("pqrstuvw"); + } } void RDMsSpinDependent::rotate(const ambit::Tensor& Ua, const ambit::Tensor& Ub) { @@ -792,6 +1209,12 @@ void RDMsSpinDependent::rotate(const ambit::Tensor& Ua, const ambit::Tensor& Ub) g3bbb_("pqrstu") = g3T("pqrstu"); psi::outfile->Printf("\n Transformed 3 RDMs."); + + if (max_rdm_ == 3) + return; + + if (max_rdm_ == 4) + throw std::runtime_error("RDMs rotation not implemented for 4-RDMs."); } void RDMsSpinDependent::dump_to_disk(const std::string& filename_prefix) const { @@ -998,6 +1421,36 @@ ambit::Tensor RDMsSpinFree::L3bbb() const { return L3bbb; } +ambit::Tensor RDMsSpinFree::L4aaaa() const { + throw std::runtime_error("RDMsSpinFree::L4aaaa not implemented."); + ambit::Tensor L4aaaa; + return L4aaaa; +} + +ambit::Tensor RDMsSpinFree::L4aaab() const { + throw std::runtime_error("RDMsSpinFree::L4aaab not implemented."); + ambit::Tensor L4aaab; + return L4aaab; +} + +ambit::Tensor RDMsSpinFree::L4aabb() const { + throw std::runtime_error("RDMsSpinFree::L4aabb not implemented."); + ambit::Tensor L4aabb; + return L4aabb; +} + +ambit::Tensor RDMsSpinFree::L4abbb() const { + throw std::runtime_error("RDMsSpinFree::L4abbb not implemented."); + ambit::Tensor L4abbb; + return L4abbb; +} + +ambit::Tensor RDMsSpinFree::L4bbbb() const { + throw std::runtime_error("RDMsSpinFree::L4bbbb not implemented."); + ambit::Tensor L4bbbb; + return L4bbbb; +} + std::shared_ptr RDMsSpinFree::clone() { ambit::Tensor g1, g2, g3; if (max_rdm_ > 0) diff --git a/forte/base_classes/rdms.h b/forte/base_classes/rdms.h index b51e0551a..4b37b8fce 100644 --- a/forte/base_classes/rdms.h +++ b/forte/base_classes/rdms.h @@ -170,6 +170,27 @@ class RDMs { static ambit::Tensor make_cumulant_L3abb(const ambit::Tensor& g1a, const ambit::Tensor& g1b, const ambit::Tensor& g2ab, const ambit::Tensor& g2bb, const ambit::Tensor& g3abb); + /// Make alpha-alpha-alpha-alpha or beta-beta-beta-beta 4-RDC from 4-RDMs + static ambit::Tensor make_cumulant_L4aaaa(const ambit::Tensor& L1a, const ambit::Tensor& L2aa, + const ambit::Tensor& L3aaa, + const ambit::Tensor& g4aaaa); + /// Make alpha-alpha-alpha-beta 4-RDC from 4-RDMs + static ambit::Tensor make_cumulant_L4aaab(const ambit::Tensor& L1a, const ambit::Tensor& L1b, + const ambit::Tensor& L2aa, const ambit::Tensor& L2ab, + const ambit::Tensor& L3aaa, + const ambit::Tensor& L3aab, + const ambit::Tensor& g4aaab); + /// Make alpha-alpha-beta-beta 4-RDC from 4-RDMs + static ambit::Tensor make_cumulant_L4aabb(const ambit::Tensor& L1a, const ambit::Tensor& L1b, + const ambit::Tensor& L2aa, const ambit::Tensor& L2ab, + const ambit::Tensor& L2bb, const ambit::Tensor& L3aab, + const ambit::Tensor& L3abb, + const ambit::Tensor& g4aabb); + /// Make alpha-beta-beta-beta 4-RDC from 4-RDMs + static ambit::Tensor make_cumulat_L4abbb(const ambit::Tensor& L1a, const ambit::Tensor& L1b, + const ambit::Tensor& L2ab, const ambit::Tensor& L2bb, + const ambit::Tensor& L3abb, const ambit::Tensor& L3bbb, + const ambit::Tensor& g4abbb); /// Spin-free 1-body to spin-dependent 1-body subject to Ms averaging static ambit::Tensor sf1_to_sd1(const ambit::Tensor& G1); @@ -246,6 +267,16 @@ class RDMs { virtual ambit::Tensor L3abb() const = 0; /// @return the beta-beta-beta 3-RDC virtual ambit::Tensor L3bbb() const = 0; + /// @return the alpha-alpha-alpha-alpha 4-RDC + virtual ambit::Tensor L4aaaa() const = 0; + /// @return the alpha-alpha-alpha-beta 4-RDC + virtual ambit::Tensor L4aaab() const = 0; + /// @return the alpha-alpha-beta-beta 4-RDC + virtual ambit::Tensor L4aabb() const = 0; + /// @return the alpha-beta-beta-beta 4-RDC + virtual ambit::Tensor L4abbb() const = 0; + /// @return the beta-beta-beta-beta 4-RDC + virtual ambit::Tensor L4bbbb() const = 0; // Spin-free density cumulants @@ -355,6 +386,16 @@ class RDMsSpinDependent : public RDMs { ambit::Tensor L3abb() const override; /// @return the beta-beta-beta 3-RDC ambit::Tensor L3bbb() const override; + /// @return the alpha-alpha-alpha-alpha 4-RDC + ambit::Tensor L4aaaa() const override; + /// @return the alpha-alpha-alpha-beta 4-RDC + ambit::Tensor L4aaab() const override; + /// @return the alpha-alpha-beta-beta 4-RDC + ambit::Tensor L4aabb() const override; + /// @return the alpha-beta-beta-beta 4-RDC + ambit::Tensor L4abbb() const override; + /// @return the beta-beta-beta-beta 4-RDC + ambit::Tensor L4bbbb() const override; // class methods @@ -472,6 +513,16 @@ class RDMsSpinFree : public RDMs { ambit::Tensor L3abb() const override; /// @return the beta-beta-beta 3-RDC ambit::Tensor L3bbb() const override; + /// @return the alpha-alpha-alpha-alpha 4-RDC + ambit::Tensor L4aaaa() const override; + /// @return the alpha-alpha-alpha-beta 4-RDC + ambit::Tensor L4aaab() const override; + /// @return the alpha-alpha-beta-beta 4-RDC + ambit::Tensor L4aabb() const override; + /// @return the alpha-beta-beta-beta 4-RDC + ambit::Tensor L4abbb() const override; + /// @return the beta-beta-beta-beta 4-RDC + ambit::Tensor L4bbbb() const override; // class methods From 7e08440215333fdf8040050ba5b2a2ca0c4dfd8a Mon Sep 17 00:00:00 2001 From: Shuhang Li Date: Sat, 21 Sep 2024 14:01:32 -0400 Subject: [PATCH 33/55] 4-cumulant --- forte/base_classes/rdms.cc | 25 ++++++++++++------------- forte/base_classes/rdms.h | 9 +++++---- 2 files changed, 17 insertions(+), 17 deletions(-) diff --git a/forte/base_classes/rdms.cc b/forte/base_classes/rdms.cc index 24c75e52d..aa5ec5dcd 100644 --- a/forte/base_classes/rdms.cc +++ b/forte/base_classes/rdms.cc @@ -604,10 +604,10 @@ ambit::Tensor RDMs::make_cumulant_L4aabb(const ambit::Tensor& L1a, const ambit:: return L4aabb; } -ambit::Tensor RDMs::make_cumulat_L4abbb(const ambit::Tensor& L1a, const ambit::Tensor& L1b, - const ambit::Tensor& L2ab, const ambit::Tensor& L2bb, - const ambit::Tensor& L3abb, const ambit::Tensor& L3bbb, - const ambit::Tensor& g4abbb) { +ambit::Tensor RDMs::make_cumulant_L4abbb(const ambit::Tensor& L1a, const ambit::Tensor& L1b, + const ambit::Tensor& L2ab, const ambit::Tensor& L2bb, + const ambit::Tensor& L3abb, const ambit::Tensor& L3bbb, + const ambit::Tensor& g4abbb) { timer t("make_cumulant_L4abbb"); auto L4abbb = g4abbb.clone(); @@ -993,7 +993,7 @@ ambit::Tensor RDMsSpinDependent::L4aaaa() const { auto _L1a = L1a(); auto _L2aa = L2aa(); auto _L3aaa = L3aaa(); - auto _L4aaaa = make_cumulant_L4aaaa(_L1a, _L2aa, _L3aaa, g4aaaa_); + auto L4aaaa = make_cumulant_L4aaaa(_L1a, _L2aa, _L3aaa, g4aaaa_); L4aaaa.set_name("L4aaaa"); return L4aaaa; } @@ -1025,7 +1025,7 @@ ambit::Tensor RDMsSpinDependent::L4aabb() const { return L4aabb; } -ambit::Tensor RDMSpinDependent::L4abbb() const { +ambit::Tensor RDMsSpinDependent::L4abbb() const { _test_rdm_level(4, "L4abbb"); auto _L1a = L1a(); auto _L1b = L1b(); @@ -1040,13 +1040,12 @@ ambit::Tensor RDMSpinDependent::L4abbb() const { ambit::Tensor RDMsSpinDependent::L4bbbb() const { _test_rdm_level(4, "L4bbbb"); - auto L1b = L1b(); - auto L2bb = L2bb(); - auto L3bbb = L3bbb(); - auto g4bbbb = g4bbbb(); - auto L4bbbb = make_cumulant_L4aaaa(L1b, L2bb, L3bbb, g4bbbb); + auto _L1b = L1b(); + auto _L2bb = L2bb(); + auto _L3bbb = L3bbb(); + auto L4bbbb = make_cumulant_L4aaaa(_L1b, _L2bb, _L3bbb, g4bbbb_); L4bbbb.set_name("L4bbbb"); - return L4aaaa; + return L4bbbb; } std::shared_ptr RDMsSpinDependent::clone() { @@ -1086,7 +1085,7 @@ std::shared_ptr RDMsSpinDependent::clone() { else if (max_rdm_ == 3) rdms = std::make_shared(g1a, g1b, g2aa, g2ab, g2bb, g3aaa, g3aab, g3abb, g3bbb); - else: + else rdms = std::make_shared(g1a, g1b, g2aa, g2ab, g2bb, g3aaa, g3aab, g3abb, g3bbb, g4aaaa, g4aaab, g4aabb, g4abbb, g4bbbb); diff --git a/forte/base_classes/rdms.h b/forte/base_classes/rdms.h index 4b37b8fce..942bb4d00 100644 --- a/forte/base_classes/rdms.h +++ b/forte/base_classes/rdms.h @@ -187,10 +187,11 @@ class RDMs { const ambit::Tensor& L3abb, const ambit::Tensor& g4aabb); /// Make alpha-beta-beta-beta 4-RDC from 4-RDMs - static ambit::Tensor make_cumulat_L4abbb(const ambit::Tensor& L1a, const ambit::Tensor& L1b, - const ambit::Tensor& L2ab, const ambit::Tensor& L2bb, - const ambit::Tensor& L3abb, const ambit::Tensor& L3bbb, - const ambit::Tensor& g4abbb); + static ambit::Tensor make_cumulant_L4abbb(const ambit::Tensor& L1a, const ambit::Tensor& L1b, + const ambit::Tensor& L2ab, const ambit::Tensor& L2bb, + const ambit::Tensor& L3abb, + const ambit::Tensor& L3bbb, + const ambit::Tensor& g4abbb); /// Spin-free 1-body to spin-dependent 1-body subject to Ms averaging static ambit::Tensor sf1_to_sd1(const ambit::Tensor& G1); From 40a5fdce95a0419ebf45b3c2b0193c902b135739 Mon Sep 17 00:00:00 2001 From: Brian Zhao Date: Sat, 21 Sep 2024 19:10:37 -0400 Subject: [PATCH 34/55] Various additions to rdm base class --- forte/base_classes/rdms.cc | 44 +++++++++++++++++++++++++++++++++++--- 1 file changed, 41 insertions(+), 3 deletions(-) diff --git a/forte/base_classes/rdms.cc b/forte/base_classes/rdms.cc index aa5ec5dcd..6a4904337 100644 --- a/forte/base_classes/rdms.cc +++ b/forte/base_classes/rdms.cc @@ -121,7 +121,8 @@ std::shared_ptr RDMs::build_from_disk(size_t max_rdm_level, RDMsType type, std::string prefix = (filename_prefix.empty() ? "" : filename_prefix + "."); if (type == RDMsType::spin_dependent) { - ambit::Tensor g1a, g1b, g2aa, g2ab, g2bb, g3aaa, g3aab, g3abb, g3bbb; + ambit::Tensor g1a, g1b, g2aa, g2ab, g2bb, g3aaa, g3aab, g3abb, g3bbb, g4aaaa, g4aaab, + g4aabb, g4abbb, g4bbbb; if (max_rdm_level > 0) { g1a = ambit::load_tensor(prefix + "g1a.bin"); g1b = ambit::load_tensor(prefix + "g1b.bin"); @@ -137,6 +138,13 @@ std::shared_ptr RDMs::build_from_disk(size_t max_rdm_level, RDMsType type, g3abb = ambit::load_tensor(prefix + "g3abb.bin"); g3bbb = ambit::load_tensor(prefix + "g3bbb.bin"); } + if (max_rdm_level > 3) { + g4aaaa = ambit::load_tensor(prefix + "g4aaaa.bin"); + g4aaab = ambit::load_tensor(prefix + "g4aaab.bin"); + g4aabb = ambit::load_tensor(prefix + "g4aabb.bin"); + g4abbb = ambit::load_tensor(prefix + "g4abbb.bin"); + g4bbbb = ambit::load_tensor(prefix + "g4bbbb.bin"); + } if (max_rdm_level < 1) { rdms = std::make_shared(); @@ -144,9 +152,13 @@ std::shared_ptr RDMs::build_from_disk(size_t max_rdm_level, RDMsType type, rdms = std::make_shared(g1a, g1b); } else if (max_rdm_level == 2) { rdms = std::make_shared(g1a, g1b, g2aa, g2ab, g2bb); - } else { + } else if (max_rdm_level == 3) { rdms = std::make_shared(g1a, g1b, g2aa, g2ab, g2bb, g3aaa, g3aab, g3abb, g3bbb); + } else { + rdms = std::make_shared(g1a, g1b, g2aa, g2ab, g2bb, g3aaa, g3aab, + g3abb, g3bbb, g4aaaa, g4aaab, g4aabb, g4abbb, + g4bbbb); } } else { ambit::Tensor g1, g2, g3; @@ -159,6 +171,10 @@ std::shared_ptr RDMs::build_from_disk(size_t max_rdm_level, RDMsType type, if (max_rdm_level > 2) { g3 = ambit::load_tensor(prefix + "g3.bin"); } + if (max_rdm_level > 3) { + throw std::runtime_error( + "RDMs::build_from_disk: max_rdm_level > 3 not implemented for spin-free RDMs."); + } if (max_rdm_level < 1) { rdms = std::make_shared(); @@ -1212,8 +1228,30 @@ void RDMsSpinDependent::rotate(const ambit::Tensor& Ua, const ambit::Tensor& Ub) if (max_rdm_ == 3) return; + // Transform the 4-rdms + auto g4T = ambit::Tensor::build(ambit::CoreTensor, "g4T", g4aaaa_.dims()); + g4T("pqrstuvw") = Ua("ap") * Ua("bq") * Ua("cr") * Ua("ds") * g4aaaa_("abcdijkl") * Ua("it") * + Ua("ju") * Ua("kv") * Ua("lw"); + g4aaaa_("pqrstuvw") = g4T("pqrstuvw"); + + g4T("pqrStuvW") = Ua("ap") * Ua("bq") * Ua("cr") * Ub("DS") * g4aaab_("abcDijkL") * Ua("it") * + Ua("ju") * Ua("kv") * Ub("LW"); + g4aaab_("pqrStuvW") = g4T("pqrStuvW"); + g4T("pqRStuVW") = Ua("ap") * Ua("bq") * Ub("CR") * Ub("DS") * g4aabb_("abCDijkL") * Ua("it") * + Ua("ju") * Ub("KV") * Ub("LW"); + g4aabb_("pqRStuVW") = g4T("pqRStuVW"); + g4T("pQRStUVW") = Ua("ap") * Ub("BQ") * Ub("CR") * Ub("DS") * g4abbb_("aBCDiJKL") * Ua("it") * + Ub("JU") * Ub("KV") * Ub("LW"); + g4abbb_("pQRStUVW") = g4T("pQRStUVW"); + + g4T("PQRSTUVW") = Ub("AP") * Ub("BQ") * Ub("CR") * Ub("DS") * g4bbbb_("ABCDIJKL") * Ub("IT") * + Ub("JU") * Ub("KV") * Ub("LW"); + g4bbbb_("PQRSTUVW") = g4T("PQRSTUVW"); + + psi::outfile->Printf("\n Transformed 4 RDMs."); + if (max_rdm_ == 4) - throw std::runtime_error("RDMs rotation not implemented for 4-RDMs."); + return; } void RDMsSpinDependent::dump_to_disk(const std::string& filename_prefix) const { From 24da5997db2437461bbab7c9c282686da001e391 Mon Sep 17 00:00:00 2001 From: Shuhang Li Date: Wed, 2 Oct 2024 22:08:08 -0400 Subject: [PATCH 35/55] merge rdm4 to eom-dsrg --- forte/mrdsrg-so/mrdsrg_so.cc | 32 +++++++------------------------- forte/mrdsrg-so/mrdsrg_so.h | 17 ----------------- forte/proc/dsrg.py | 8 +++++++- 3 files changed, 14 insertions(+), 43 deletions(-) diff --git a/forte/mrdsrg-so/mrdsrg_so.cc b/forte/mrdsrg-so/mrdsrg_so.cc index ee7109073..9931c51e1 100644 --- a/forte/mrdsrg-so/mrdsrg_so.cc +++ b/forte/mrdsrg-so/mrdsrg_so.cc @@ -108,14 +108,6 @@ void MRDSRG_SO::startup() { source_ = foptions_->get_str("SOURCE"); - dsrg_trans_type_ = foptions_->get_str("DSRG_TRANS_TYPE"); - if (dsrg_trans_type_ == "CC" && foptions_->get_str("CORR_LEVEL") == "QDSRG2") { - outfile->Printf( - "\n Warning: DSRG_TRANS_TYPE option CC is not supported with CORR_LEVEL QDSRG2."); - outfile->Printf("\n Changed DSRG_TRANS_TYPE option to UNITARY"); - dsrg_trans_type_ = "UNITARY"; - } - ntamp_ = foptions_->get_int("NTAMP"); intruder_tamp_ = foptions_->get_double("INTRUDER_TAMP"); @@ -775,8 +767,6 @@ void MRDSRG_SO::compute_hbar() { BlockedTensor C1 = ambit::BlockedTensor::build(tensor_type_, "C1", {"gg"}); BlockedTensor C2 = ambit::BlockedTensor::build(tensor_type_, "C2", {"gggg"}); - bool do_wicked = foptions_->get_bool("DO_WICKED"); - // compute Hbar recursively for (int n = 1; n <= maxn; ++n) { // prefactor before n-nested commutator @@ -786,6 +776,7 @@ void MRDSRG_SO::compute_hbar() { double C0 = 0.0; C1.zero(); C2.zero(); + // zero-body H1_T1_C0(O1, T1, factor, C0); H1_T2_C0(O1, T2, factor, C0); @@ -808,21 +799,12 @@ void MRDSRG_SO::compute_hbar() { // outfile->Printf("\n |H2| = %20.12f", C2.norm(1)); // outfile->Printf("\n --------------------------------"); - if (dsrg_trans_type_ == "UNITARY") { - // [H, A] = [H, T] + [H, T]^dagger - C0 *= 2.0; - O1["pq"] = C1["pq"]; - C1["pq"] += O1["qp"]; - O2["pqrs"] = C2["pqrs"]; - C2["pqrs"] += O2["rspq"]; - } - - if (do_wicked) { - O2["pqrs"] = C2["pqrs"]; - C2["pqrs"] -= O2["qprs"]; - C2["pqrs"] -= O2["pqsr"]; - C2["pqrs"] += O2["qpsr"]; - } + // [H, A] = [H, T] + [H, T]^dagger + C0 *= 2.0; + O1["pq"] = C1["pq"]; + C1["pq"] += O1["qp"]; + O2["pqrs"] = C2["pqrs"]; + C2["pqrs"] += O2["rspq"]; // Hbar += C Hbar0 += C0; diff --git a/forte/mrdsrg-so/mrdsrg_so.h b/forte/mrdsrg-so/mrdsrg_so.h index da6388a6b..927b126fe 100644 --- a/forte/mrdsrg-so/mrdsrg_so.h +++ b/forte/mrdsrg-so/mrdsrg_so.h @@ -120,9 +120,6 @@ class MRDSRG_SO : public DynamicCorrelationSolver { /// Order of the Taylor expansion of f(z) = (1-exp(-z^2))/z int taylor_order_; - /// DSRG transformation type - std::string dsrg_trans_type_; - std::shared_ptr BTF_; TensorType tensor_type_; @@ -213,11 +210,6 @@ class MRDSRG_SO : public DynamicCorrelationSolver { void H1_T2_C0(BlockedTensor& H1, BlockedTensor& T2, const double& alpha, double& C0); void H2_T2_C0(BlockedTensor& H2, BlockedTensor& T2, const double& alpha, double& C0); - void H1_T1_C0(BlockedTensor& H1, BlockedTensor& T1, const double& alpha, double& C0); - void H2_T1_C0(BlockedTensor& H2, BlockedTensor& T1, const double& alpha, double& C0); - void H1_T2_C0(BlockedTensor& H1, BlockedTensor& T2, const double& alpha, double& C0); - void H2_T2_C0(BlockedTensor& H2, BlockedTensor& T2, const double& alpha, double& C0); - /// Compute one-body term of commutator [H, T] void H1_T1_C1(BlockedTensor& H1, BlockedTensor& T1, const double& alpha, BlockedTensor& C1); void H1_T2_C1(BlockedTensor& H1, BlockedTensor& T2, const double& alpha, BlockedTensor& C1); @@ -226,11 +218,6 @@ class MRDSRG_SO : public DynamicCorrelationSolver { void H3_T1_C1(BlockedTensor& H3, BlockedTensor& T1, const double& alpha, BlockedTensor& C1); void H3_T2_C1(BlockedTensor& H3, BlockedTensor& T2, const double& alpha, BlockedTensor& C1); - void H1_T1_C1(BlockedTensor& H1, BlockedTensor& T1, const double& alpha, BlockedTensor& C1); - void H1_T2_C1(BlockedTensor& H1, BlockedTensor& T2, const double& alpha, BlockedTensor& C1); - void H2_T1_C1(BlockedTensor& H2, BlockedTensor& T1, const double& alpha, BlockedTensor& C1); - void H2_T2_C1(BlockedTensor& H2, BlockedTensor& T2, const double& alpha, BlockedTensor& C1); - /// Compute two-body term of commutator [H, T] void H2_T1_C2(BlockedTensor& H2, BlockedTensor& T1, const double& alpha, BlockedTensor& C2); void H1_T2_C2(BlockedTensor& H1, BlockedTensor& T2, const double& alpha, BlockedTensor& C2); @@ -238,10 +225,6 @@ class MRDSRG_SO : public DynamicCorrelationSolver { void H3_T1_C2(BlockedTensor& H3, BlockedTensor& T1, const double& alpha, BlockedTensor& C2); void H3_T2_C2(BlockedTensor& H3, BlockedTensor& T2, const double& alpha, BlockedTensor& C2); - void H2_T1_C2(BlockedTensor& H2, BlockedTensor& T1, const double& alpha, BlockedTensor& C2); - void H1_T2_C2(BlockedTensor& H1, BlockedTensor& T2, const double& alpha, BlockedTensor& C2); - void H2_T2_C2(BlockedTensor& H2, BlockedTensor& T2, const double& alpha, BlockedTensor& C2); - /// Compute three-body term of commutator [H, T] void H2_T2_C3(BlockedTensor& H2, BlockedTensor& T2, const double& alpha, BlockedTensor& C3); diff --git a/forte/proc/dsrg.py b/forte/proc/dsrg.py index 3fc96cb7d..b0517aa0a 100644 --- a/forte/proc/dsrg.py +++ b/forte/proc/dsrg.py @@ -72,7 +72,13 @@ def __init__(self, active_space_solver, state_weights_map, mo_space_info, ints, "\n DSRG relaxation only supports UNITARY transformation. Setting RELAX_REF to NONE.") self.relax_ref = "NONE" - self.max_rdm_level = 3 if options.get_str("THREEPDC") != "ZERO" else 2 + if options.get_str("FOURPDC") != "ZERO": + self.max_rdm_level = 4 + elif options.get_str("THREEPDC") != "ZERO": + self.max_rdm_level = 3 + else: + self.max_rdm_level = 2 + if options.get_str("DSRG_3RDM_ALGORITHM") == "DIRECT": as_type = options.get_str("ACTIVE_SPACE_SOLVER") if as_type == "BLOCK2" and self.solver_type in ["SA-MRDSRG", "SA_MRDSRG"]: From 7dddb8c11b6ec0a99b8e40cf11b92fb8d964757e Mon Sep 17 00:00:00 2001 From: Shuhang Li Date: Tue, 8 Oct 2024 08:30:28 -0400 Subject: [PATCH 36/55] print --- forte/proc/dsrg.py | 79 ++++++++++++++-------------------------------- 1 file changed, 23 insertions(+), 56 deletions(-) diff --git a/forte/proc/dsrg.py b/forte/proc/dsrg.py index b0517aa0a..3021c48ec 100644 --- a/forte/proc/dsrg.py +++ b/forte/proc/dsrg.py @@ -199,27 +199,6 @@ def __init__(self, active_space_solver, state_weights_map, mo_space_info, ints, self.semi = forte.SemiCanonical( self.mo_space_info, self.ints, options, inactive_mix, active_mix) - # if self.options.get_bool('FULL_HBAR'): - # L1a = self.rdms.L1a() - # L1b = self.rdms.L1b() - # L2aa = self.rdms.L2aa() - # L2ab = self.rdms.L2ab() - # L2bb = self.rdms.L2bb() - # L3aaa = self.rdms.L3aaa() - # L3aab = self.rdms.L3aab() - # L3abb = self.rdms.L3abb() - # L3bbb = self.rdms.L3bbb() - - # np.save("L1a", L1a) - # np.save("L1b", L1b) - # np.save("L2aa", L2aa) - # np.save("L2ab", L2ab) - # np.save("L2bb", L2bb) - # np.save("L3aaa", L3aaa) - # np.save("L3aab", L3aab) - # np.save("L3abb", L3abb) - # np.save("L3bbb", L3bbb) - def make_dsrg_solver(self): """Make a DSRG solver.""" args = (self.rdms, self.scf_info, self.options, @@ -294,9 +273,11 @@ def compute_energy(self): # self.relax_maxiter = 0 if self.options.get_bool('FULL_HBAR') and self.relax_maxiter == 0: + psi4.core.print_out("\n =>** Saving Full Hbar **<=\n") Heff = self.dsrg_solver.compute_Heff_full() Heff_dict = forte.Heff_dict(Heff) np.savez('save_Hbar', **Heff_dict) + del Heff # Reference relaxation procedure for n in range(self.relax_maxiter): @@ -404,6 +385,7 @@ def compute_energy(self): # Test convergence and break loop if self.test_relaxation_convergence(n): if self.options.get_bool('FULL_HBAR'): + psi4.core.print_out("\n =>** Saving Full Hbar **<=\n") Heff = self.dsrg_solver.compute_Heff_full() Heff_dict = forte.Heff_dict(Heff) np.savez('save_Hbar', **Heff_dict) @@ -454,23 +436,36 @@ def compute_energy(self): ################ if self.solver_type == 'SA-MRDSRG': - print("HERE") asmpints = self.dsrg_solver.compute_mp_eff_actv() if self.options.get_bool('FULL_HBAR'): - # Heff = self.dsrg_solver.compute_Heff_full() - # Heff_dict = forte.Heff_dict(Heff) - # np.savez('save_Hbar', **Heff_dict) + psi4.core.print_out("\n =>** Getting gamma1 **<=\n") gamma1 = self.dsrg_solver.get_gamma1() + psi4.core.print_out("\n =>** Getting eta1 **<=\n") eta1 = self.dsrg_solver.get_eta1() + psi4.core.print_out("\n =>** Getting lambda2 **<=\n") lambda2 = self.dsrg_solver.get_lambda2() + psi4.core.print_out("\n =>** Getting lambda3 **<=\n") lambda3 = self.dsrg_solver.get_lambda3() - lambda4 = self.dsrg_solver.get_lambda4() gamma1_dict = forte.blocktensor_to_dict(gamma1) eta_1_dict = forte.blocktensor_to_dict(eta1) lambda2_dict = forte.blocktensor_to_dict(lambda2) lambda3_dict = forte.L3_dict(lambda3) - lambda4_dict = forte.L4_dict(lambda4) + np.savez('save_gamma1', **gamma1_dict) + np.savez('save_eta1', **eta_1_dict) + np.savez('save_lambda2', **lambda2_dict) + np.savez('save_lambda3', **lambda3_dict) + + del gamma1, eta1, lambda2, lambda3, gamma1_dict, eta_1_dict, lambda2_dict, lambda3_dict + + if self.options.get_str('FOURPDC') != 'ZERO': + psi4.core.print_out("\n =>** Getting lambda4 **<=\n") + lambda4 = self.dsrg_solver.get_lambda4() + lambda4_dict = forte.L4_dict(lambda4) + np.savez('save_lambda4', **lambda4_dict) + del lambda4, lambda4_dict + + psi4.core.print_out("\n =>** Getting dipole integral **<=\n") Mbar0 = self.dsrg_solver.compute_Mbar0_full() print(Mbar0) np.save('Mbar0', Mbar0) @@ -483,35 +478,7 @@ def compute_energy(self): # Heff_dict = forte.Heff_dict(Heff) # np.savez('save_Hbar', **Heff_dict) - np.savez('save_gamma1', **gamma1_dict) - np.savez('save_eta1', **eta_1_dict) - np.savez('save_lambda2', **lambda2_dict) - np.savez('save_lambda3', **lambda3_dict) - np.savez('save_lambda4', **lambda4_dict) - - # self.rdms = self.active_space_solver.compute_average_rdms( - # self.state_weights_map, self.max_rdm_level, self.rdm_type - # ) - # self.rdms.rotate(self.Ua, self.Ub) - # self.semi.semicanonicalize(self.rdms) - # gamma1_aa = self.rdms.g1a() - # gamma1_bb = self.rdms.g1b() - # lambda2_aa = self.rdms.L2aa() - # lambda2_bb = self.rdms.L2bb() - # lambda2_ab = self.rdms.L2ab() - # lambda3_aaa = self.rdms.L3aaa() - # lambda3_aab = self.rdms.L3aab() - # lambda3_abb = self.rdms.L3abb() - # lambda3_bbb = self.rdms.L3bbb() - # np.save("gamma1_aa", gamma1_aa) - # np.save("gamma1_bb", gamma1_bb) - # np.save("lambda2_aa", lambda2_aa) - # np.save("lambda2_bb", lambda2_bb) - # np.save("lambda2_ab", lambda2_ab) - # np.save("lambda3_aaa", lambda3_aaa) - # np.save("lambda3_aab", lambda3_aab) - # np.save("lambda3_abb", lambda3_abb) - # np.save("lambda3_bbb", lambda3_bbb) + del Mbar0, Mbar1, Mbar2 ################ From 6fe621f92da6c5ec26116bbd50d1200430d1262f Mon Sep 17 00:00:00 2001 From: Shuhang Li Date: Wed, 9 Oct 2024 20:53:07 -0400 Subject: [PATCH 37/55] an inefficient way --- forte/proc/dsrg.py | 137 +++++++++++++++++++++++++++------------------ 1 file changed, 83 insertions(+), 54 deletions(-) diff --git a/forte/proc/dsrg.py b/forte/proc/dsrg.py index 3021c48ec..01c9b87ac 100644 --- a/forte/proc/dsrg.py +++ b/forte/proc/dsrg.py @@ -277,7 +277,45 @@ def compute_energy(self): Heff = self.dsrg_solver.compute_Heff_full() Heff_dict = forte.Heff_dict(Heff) np.savez('save_Hbar', **Heff_dict) - del Heff + psi4.core.print_out("\n =>** Getting gamma1 **<=\n") + gamma1 = self.dsrg_solver.get_gamma1() + psi4.core.print_out("\n =>** Getting eta1 **<=\n") + eta1 = self.dsrg_solver.get_eta1() + psi4.core.print_out("\n =>** Getting lambda2 **<=\n") + lambda2 = self.dsrg_solver.get_lambda2() + psi4.core.print_out("\n =>** Getting lambda3 **<=\n") + lambda3 = self.dsrg_solver.get_lambda3() + gamma1_dict = forte.blocktensor_to_dict(gamma1) + eta_1_dict = forte.blocktensor_to_dict(eta1) + lambda2_dict = forte.blocktensor_to_dict(lambda2) + lambda3_dict = forte.L3_dict(lambda3) + + np.savez('save_gamma1', **gamma1_dict) + np.savez('save_eta1', **eta_1_dict) + np.savez('save_lambda2', **lambda2_dict) + np.savez('save_lambda3', **lambda3_dict) + del gamma1, eta1, lambda2, lambda3, gamma1_dict, eta_1_dict, lambda2_dict, lambda3_dict + if self.options.get_str('FOURPDC') != 'ZERO': + psi4.core.print_out("\n =>** Getting lambda4 **<=\n") + lambda4 = self.dsrg_solver.get_lambda4() + lambda4_dict = forte.L4_dict(lambda4) + np.savez('save_lambda4', **lambda4_dict) + del lambda4, lambda4_dict + + psi4.core.print_out("\n =>** Getting dipole integral **<=\n") + Mbar0 = self.dsrg_solver.compute_Mbar0_full() + print(Mbar0) + np.save('Mbar0', Mbar0) + Mbar1 = self.dsrg_solver.compute_Mbar1_full() + Mbar2 = self.dsrg_solver.compute_Mbar2_full() + + for i in range(3): + np.savez(f"Mbar1_{i}", ** + forte.blocktensor_to_dict(Mbar1[i])) + np.savez(f"Mbar2_{i}", ** + forte.blocktensor_to_dict(Mbar2[i])) + + del Mbar0, Mbar1, Mbar2 # Reference relaxation procedure for n in range(self.relax_maxiter): @@ -384,11 +422,6 @@ def compute_energy(self): # Test convergence and break loop if self.test_relaxation_convergence(n): - if self.options.get_bool('FULL_HBAR'): - psi4.core.print_out("\n =>** Saving Full Hbar **<=\n") - Heff = self.dsrg_solver.compute_Heff_full() - Heff_dict = forte.Heff_dict(Heff) - np.savez('save_Hbar', **Heff_dict) break # Continue to solve DSRG equations @@ -433,54 +466,50 @@ def compute_energy(self): f"\n\n DSRG-MRPT2 FNO energy correction: {self.fno_pt2_energy_shift:20.15f}") psi4.core.print_out( f"\n DSRG-MRPT2 FNO corrected energy: {e_dsrg:20.15f}") - - ################ - if self.solver_type == 'SA-MRDSRG': - asmpints = self.dsrg_solver.compute_mp_eff_actv() - if self.options.get_bool('FULL_HBAR'): - psi4.core.print_out("\n =>** Getting gamma1 **<=\n") - gamma1 = self.dsrg_solver.get_gamma1() - psi4.core.print_out("\n =>** Getting eta1 **<=\n") - eta1 = self.dsrg_solver.get_eta1() - psi4.core.print_out("\n =>** Getting lambda2 **<=\n") - lambda2 = self.dsrg_solver.get_lambda2() - psi4.core.print_out("\n =>** Getting lambda3 **<=\n") - lambda3 = self.dsrg_solver.get_lambda3() - gamma1_dict = forte.blocktensor_to_dict(gamma1) - eta_1_dict = forte.blocktensor_to_dict(eta1) - lambda2_dict = forte.blocktensor_to_dict(lambda2) - lambda3_dict = forte.L3_dict(lambda3) - - np.savez('save_gamma1', **gamma1_dict) - np.savez('save_eta1', **eta_1_dict) - np.savez('save_lambda2', **lambda2_dict) - np.savez('save_lambda3', **lambda3_dict) - - del gamma1, eta1, lambda2, lambda3, gamma1_dict, eta_1_dict, lambda2_dict, lambda3_dict - - if self.options.get_str('FOURPDC') != 'ZERO': - psi4.core.print_out("\n =>** Getting lambda4 **<=\n") - lambda4 = self.dsrg_solver.get_lambda4() - lambda4_dict = forte.L4_dict(lambda4) - np.savez('save_lambda4', **lambda4_dict) - del lambda4, lambda4_dict - - psi4.core.print_out("\n =>** Getting dipole integral **<=\n") - Mbar0 = self.dsrg_solver.compute_Mbar0_full() - print(Mbar0) - np.save('Mbar0', Mbar0) - Mbar1 = self.dsrg_solver.compute_Mbar1_full() - Mbar2 = self.dsrg_solver.compute_Mbar2_full() - - for i in range(3): - np.savez(f"Mbar1_{i}", **forte.blocktensor_to_dict(Mbar1[i])) - np.savez(f"Mbar2_{i}", **forte.blocktensor_to_dict(Mbar2[i])) - # Heff_dict = forte.Heff_dict(Heff) - # np.savez('save_Hbar', **Heff_dict) - - del Mbar0, Mbar1, Mbar2 - - ################ + if self.options.get_bool('FULL_HBAR'): + psi4.core.print_out("\n =>** Saving Full Hbar **<=\n") + Heff = self.dsrg_solver.compute_Heff_full() + Heff_dict = forte.Heff_dict(Heff) + np.savez('save_Hbar', **Heff_dict) + psi4.core.print_out("\n =>** Getting gamma1 **<=\n") + gamma1 = self.dsrg_solver.get_gamma1() + psi4.core.print_out("\n =>** Getting eta1 **<=\n") + eta1 = self.dsrg_solver.get_eta1() + psi4.core.print_out("\n =>** Getting lambda2 **<=\n") + lambda2 = self.dsrg_solver.get_lambda2() + psi4.core.print_out("\n =>** Getting lambda3 **<=\n") + lambda3 = self.dsrg_solver.get_lambda3() + gamma1_dict = forte.blocktensor_to_dict(gamma1) + eta_1_dict = forte.blocktensor_to_dict(eta1) + lambda2_dict = forte.blocktensor_to_dict(lambda2) + lambda3_dict = forte.L3_dict(lambda3) + + np.savez('save_gamma1', **gamma1_dict) + np.savez('save_eta1', **eta_1_dict) + np.savez('save_lambda2', **lambda2_dict) + np.savez('save_lambda3', **lambda3_dict) + del gamma1, eta1, lambda2, lambda3, gamma1_dict, eta_1_dict, lambda2_dict, lambda3_dict + if self.options.get_str('FOURPDC') != 'ZERO': + psi4.core.print_out("\n =>** Getting lambda4 **<=\n") + lambda4 = self.dsrg_solver.get_lambda4() + lambda4_dict = forte.L4_dict(lambda4) + np.savez('save_lambda4', **lambda4_dict) + del lambda4, lambda4_dict + + psi4.core.print_out("\n =>** Getting dipole integral **<=\n") + Mbar0 = self.dsrg_solver.compute_Mbar0_full() + print(Mbar0) + np.save('Mbar0', Mbar0) + Mbar1 = self.dsrg_solver.compute_Mbar1_full() + Mbar2 = self.dsrg_solver.compute_Mbar2_full() + + for i in range(3): + np.savez(f"Mbar1_{i}", ** + forte.blocktensor_to_dict(Mbar1[i])) + np.savez(f"Mbar2_{i}", ** + forte.blocktensor_to_dict(Mbar2[i])) + + del Mbar0, Mbar1, Mbar2 self.dsrg_cleanup() From 718780b12d64c1bab35ce6f634708aa77f884ca8 Mon Sep 17 00:00:00 2001 From: Shuhang Li Date: Fri, 1 Nov 2024 15:49:41 -0400 Subject: [PATCH 38/55] save --- forte/proc/dsrg.py | 272 ++++++++++++++++++--------------------------- 1 file changed, 108 insertions(+), 164 deletions(-) diff --git a/forte/proc/dsrg.py b/forte/proc/dsrg.py index 01c9b87ac..1a0646708 100644 --- a/forte/proc/dsrg.py +++ b/forte/proc/dsrg.py @@ -55,21 +55,18 @@ def __init__(self, active_space_solver, state_weights_map, mo_space_info, ints, self.rdm_type = forte.RDMsType.spin_free else: self.rdm_type = ( - forte.RDMsType.spin_free if options.get_bool( - "DSRG_RDM_MS_AVG") else forte.RDMsType.spin_dependent + forte.RDMsType.spin_free if options.get_bool("DSRG_RDM_MS_AVG") else forte.RDMsType.spin_dependent ) self.do_semicanonical = options.get_bool("SEMI_CANONICAL") - self.do_multi_state = False if options.get_str( - "CALC_TYPE") == "SS" else True + self.do_multi_state = False if options.get_str("CALC_TYPE") == "SS" else True self.relax_ref = options.get_str("RELAX_REF") if self.relax_ref == "NONE" and self.do_multi_state: self.relax_ref = "ONCE" if self.relax_ref != "NONE" and options.get_str("DSRG_TRANS_TYPE") != "UNITARY": - psi4.core.print_out( - "\n DSRG relaxation only supports UNITARY transformation. Setting RELAX_REF to NONE.") + psi4.core.print_out("\n DSRG relaxation only supports UNITARY transformation. Setting RELAX_REF to NONE.") self.relax_ref = "NONE" if options.get_str("FOURPDC") != "ZERO": @@ -84,10 +81,8 @@ def __init__(self, active_space_solver, state_weights_map, mo_space_info, ints, if as_type == "BLOCK2" and self.solver_type in ["SA-MRDSRG", "SA_MRDSRG"]: self.max_rdm_level = 2 else: - psi4.core.print_out( - "\n DSRG 3RDM direct algorithm only available for BLOCK2/SA-MRDSRG") - psi4.core.print_out( - "\n Set DSRG_3RDM_ALGORITHM to 'EXPLICIT' (default)") + psi4.core.print_out("\n DSRG 3RDM direct algorithm only available for BLOCK2/SA-MRDSRG") + psi4.core.print_out("\n Set DSRG_3RDM_ALGORITHM to 'EXPLICIT' (default)") options.set_str("DSRG_3RDM_ALGORITHM", "EXPLICIT") self.relax_convergence = float("inf") @@ -105,45 +100,36 @@ def __init__(self, active_space_solver, state_weights_map, mo_space_info, ints, self.relax_maxiter = options.get_int("MAXITER_RELAX_REF") self.relax_convergence = options.get_double("RELAX_E_CONVERGENCE") - self.save_relax_energies = options.get_bool( - "DSRG_DUMP_RELAXED_ENERGIES") + self.save_relax_energies = options.get_bool("DSRG_DUMP_RELAXED_ENERGIES") # Filter out levels for analytic gradients if options.get_str("DERTYPE") != "NONE": if self.relax_ref != "NONE" or self.solver_type != "DSRG-MRPT2": - raise NotImplementedError( - "Analytic energy gradients are only implemented for unrelaxed DSRG-MRPT2!") + raise NotImplementedError("Analytic energy gradients are only implemented for unrelaxed DSRG-MRPT2!") # Filter out some ms-dsrg algorithms ms_dsrg_algorithm = options.get_str("DSRG_MULTI_STATE") if self.do_multi_state and ("SA" not in ms_dsrg_algorithm): - raise NotImplementedError( - "MS or XMS is disabled due to the reconstruction.") + raise NotImplementedError("MS or XMS is disabled due to the reconstruction.") if ms_dsrg_algorithm == "SA_SUB" and self.relax_ref != "ONCE": - raise NotImplementedError( - "SA_SUB only supports relax once at present. Relaxed SA density not implemented.") + raise NotImplementedError("SA_SUB only supports relax once at present. Relaxed SA density not implemented.") self.multi_state_type = ms_dsrg_algorithm # Filter out some methods for computing dipole moments do_dipole = options.get_bool("DSRG_DIPOLE") if do_dipole and (self.solver_type not in ["DSRG-MRPT2", "DSRG-MRPT3"]): do_dipole = False - psi4.core.print_out( - f"\n Skip computation for dipole moment (not implemented for {self.solver_type})!") - warnings.warn( - f"Dipole moment is not implemented for {self.solver_type}.", UserWarning) + psi4.core.print_out(f"\n Skip computation for dipole moment (not implemented for {self.solver_type})!") + warnings.warn(f"Dipole moment is not implemented for {self.solver_type}.", UserWarning) if do_dipole and self.do_multi_state: do_dipole = False - psi4.core.print_out( - "\n !DSRG transition dipoles are disabled temporarily.") - warnings.warn( - "DSRG transition dipoles are disabled temporarily.", UserWarning) + psi4.core.print_out("\n !DSRG transition dipoles are disabled temporarily.") + warnings.warn("DSRG transition dipoles are disabled temporarily.", UserWarning) self.do_dipole = do_dipole self.dipoles = [] self.max_dipole_level = options.get_int("DSRG_MAX_DIPOLE_LEVEL") - self.max_quadrupole_level = options.get_int( - "DSRG_MAX_QUADRUPOLE_LEVEL") + self.max_quadrupole_level = options.get_int("DSRG_MAX_QUADRUPOLE_LEVEL") # Set up Forte objects self.active_space_solver = active_space_solver @@ -167,8 +153,7 @@ def __init__(self, active_space_solver, state_weights_map, mo_space_info, ints, self.energies_environment = {} # energies pushed to Psi4 environment globals # Compute RDMs from initial ActiveSpaceSolver - self.rdms = active_space_solver.compute_average_rdms( - state_weights_map, self.max_rdm_level, self.rdm_type) + self.rdms = active_space_solver.compute_average_rdms(state_weights_map, self.max_rdm_level, self.rdm_type) # Save a copy CI vectors try: @@ -180,29 +165,26 @@ def __init__(self, active_space_solver, state_weights_map, mo_space_info, ints, inactive_mix = options.get_bool("SEMI_CANONICAL_MIX_INACTIVE") active_mix = options.get_bool("SEMI_CANONICAL_MIX_ACTIVE") # Semi-canonicalize orbitals and rotation matrices - self.semi = forte.SemiCanonical( - mo_space_info, ints, options, inactive_mix, active_mix) + self.semi = forte.SemiCanonical(mo_space_info, ints, options, inactive_mix, active_mix) if self.do_semicanonical: self.semi.semicanonicalize(self.rdms) self.Ua, self.Ub = self.semi.Ua_t(), self.semi.Ub_t() # Perform FNO-DSRG if options.get_bool("DSRG_FNO"): - fno_data = dsrg_fno_procrouting(state_weights_map, scf_info, options, ints, - mo_space_info, active_space_solver, self.rdms, - self.Ua) + fno_data = dsrg_fno_procrouting( + state_weights_map, scf_info, options, ints, mo_space_info, active_space_solver, self.rdms, self.Ua + ) self.mo_space_info, self.ints, dept2, dhpt2 = fno_data if options.get_bool("DSRG_FNO_PT2_CORRECTION"): self.fno_pt2_energy_shift = dept2 self.fno_pt2_Heff_shift = dhpt2 psi4.core.set_scalar_variable("FNO ENERGY CORRECTION", dept2) - self.semi = forte.SemiCanonical( - self.mo_space_info, self.ints, options, inactive_mix, active_mix) + self.semi = forte.SemiCanonical(self.mo_space_info, self.ints, options, inactive_mix, active_mix) def make_dsrg_solver(self): """Make a DSRG solver.""" - args = (self.rdms, self.scf_info, self.options, - self.ints, self.mo_space_info) + args = (self.rdms, self.scf_info, self.options, self.ints, self.mo_space_info) if self.solver_type in ["MRDSRG", "DSRG-MRPT2", "DSRG-MRPT3", "THREE-DSRG-MRPT2"]: self.dsrg_solver = forte.make_dsrg_method(*args) @@ -249,21 +231,16 @@ def compute_energy(self): # Perform the initial un-relaxed DSRG self.make_dsrg_solver() self.dsrg_setup() - psi4.core.print_out( - "\n =>** Before self.dsrg_solver.compute_energy() **<=\n") + psi4.core.print_out("\n =>** Before self.dsrg_solver.compute_energy() **<=\n") e_dsrg = self.dsrg_solver.compute_energy() + self.fno_pt2_energy_shift if self.fno_pt2_energy_shift != 0.0: - psi4.core.print_out( - f"\n\n DSRG-MRPT2 FNO energy correction: {self.fno_pt2_energy_shift:20.15f}") - psi4.core.print_out( - f"\n DSRG-MRPT2 FNO corrected energy: {e_dsrg:20.15f}") + psi4.core.print_out(f"\n\n DSRG-MRPT2 FNO energy correction: {self.fno_pt2_energy_shift:20.15f}") + psi4.core.print_out(f"\n DSRG-MRPT2 FNO corrected energy: {e_dsrg:20.15f}") psi4.core.set_scalar_variable("UNRELAXED ENERGY", e_dsrg) - psi4.core.print_out( - "\n =>** After self.dsrg_solver.compute_energy() **<=\n") + psi4.core.print_out("\n =>** After self.dsrg_solver.compute_energy() **<=\n") - self.energies_environment[0] = { - k: v for k, v in psi4.core.variables().items() if "ROOT" in k} + self.energies_environment[0] = {k: v for k, v in psi4.core.variables().items() if "ROOT" in k} # Spit out energy if reference relaxation not implemented if not self.Heff_implemented: @@ -272,11 +249,11 @@ def compute_energy(self): # if self.options.get_bool('FULL_HBAR'): # self.relax_maxiter = 0 - if self.options.get_bool('FULL_HBAR') and self.relax_maxiter == 0: + if self.options.get_bool("FULL_HBAR") and self.relax_maxiter == 0: psi4.core.print_out("\n =>** Saving Full Hbar **<=\n") Heff = self.dsrg_solver.compute_Heff_full() Heff_dict = forte.Heff_dict(Heff) - np.savez('save_Hbar', **Heff_dict) + np.savez("save_Hbar", **Heff_dict) psi4.core.print_out("\n =>** Getting gamma1 **<=\n") gamma1 = self.dsrg_solver.get_gamma1() psi4.core.print_out("\n =>** Getting eta1 **<=\n") @@ -288,34 +265,36 @@ def compute_energy(self): gamma1_dict = forte.blocktensor_to_dict(gamma1) eta_1_dict = forte.blocktensor_to_dict(eta1) lambda2_dict = forte.blocktensor_to_dict(lambda2) - lambda3_dict = forte.L3_dict(lambda3) + if self.solver_type in ["MRDSRG_SO", "MRDSRG-SO"]: + lambda3_dict = forte.blocktensor_to_dict(lambda3) + else: + lambda3_dict = forte.L3_dict(lambda3) - np.savez('save_gamma1', **gamma1_dict) - np.savez('save_eta1', **eta_1_dict) - np.savez('save_lambda2', **lambda2_dict) - np.savez('save_lambda3', **lambda3_dict) + np.savez("save_gamma1", **gamma1_dict) + np.savez("save_eta1", **eta_1_dict) + np.savez("save_lambda2", **lambda2_dict) + np.savez("save_lambda3", **lambda3_dict) del gamma1, eta1, lambda2, lambda3, gamma1_dict, eta_1_dict, lambda2_dict, lambda3_dict - if self.options.get_str('FOURPDC') != 'ZERO': + if self.options.get_str("FOURPDC") != "ZERO": psi4.core.print_out("\n =>** Getting lambda4 **<=\n") lambda4 = self.dsrg_solver.get_lambda4() lambda4_dict = forte.L4_dict(lambda4) - np.savez('save_lambda4', **lambda4_dict) + np.savez("save_lambda4", **lambda4_dict) del lambda4, lambda4_dict - psi4.core.print_out("\n =>** Getting dipole integral **<=\n") - Mbar0 = self.dsrg_solver.compute_Mbar0_full() - print(Mbar0) - np.save('Mbar0', Mbar0) - Mbar1 = self.dsrg_solver.compute_Mbar1_full() - Mbar2 = self.dsrg_solver.compute_Mbar2_full() + if self.solver_type not in ["MRDSRG_SO", "MRDSRG-SO"]: + psi4.core.print_out("\n =>** Getting dipole integral **<=\n") + Mbar0 = self.dsrg_solver.compute_Mbar0_full() + print(Mbar0) + np.save("Mbar0", Mbar0) + Mbar1 = self.dsrg_solver.compute_Mbar1_full() + Mbar2 = self.dsrg_solver.compute_Mbar2_full() - for i in range(3): - np.savez(f"Mbar1_{i}", ** - forte.blocktensor_to_dict(Mbar1[i])) - np.savez(f"Mbar2_{i}", ** - forte.blocktensor_to_dict(Mbar2[i])) + for i in range(3): + np.savez(f"Mbar1_{i}", **forte.blocktensor_to_dict(Mbar1[i])) + np.savez(f"Mbar2_{i}", **forte.blocktensor_to_dict(Mbar2[i])) - del Mbar0, Mbar1, Mbar2 + del Mbar0, Mbar1, Mbar2 # Reference relaxation procedure for n in range(self.relax_maxiter): @@ -329,15 +308,13 @@ def compute_energy(self): ints_dressed = self.dsrg_solver.compute_Heff_actv() if self.fno_pt2_Heff_shift is not None: ints_dressed.add(self.fno_pt2_Heff_shift, 1.0) - psi4.core.print_out( - "\n\n Applied DSRG-MRPT2 FNO corrections to dressed integrals.") + psi4.core.print_out("\n\n Applied DSRG-MRPT2 FNO corrections to dressed integrals.") if self.Meff_implemented and (self.max_dipole_level > 0 or self.max_quadrupole_level > 0): asmpints = self.dsrg_solver.compute_mp_eff_actv() if self.options.get_str("ACTIVE_SPACE_SOLVER") == "EXTERNAL": state_map = forte.to_state_nroots_map(self.state_weights_map) - write_external_active_space_file( - ints_dressed, state_map, self.mo_space_info, "dsrg_ints.json") + write_external_active_space_file(ints_dressed, state_map, self.mo_space_info, "dsrg_ints.json") msg = "External solver: save DSRG dressed integrals to dsrg_ints.json" print(msg) psi4.core.print_out(msg) @@ -352,15 +329,13 @@ def compute_energy(self): ints_dressed, ) active_space_solver_2.set_Uactv(self.Ua, self.Ub) - e_relax = list( - active_space_solver_2.compute_energy().values())[0][0] + e_relax = list(active_space_solver_2.compute_energy().values())[0][0] self.energies.append((e_dsrg, e_relax)) break if self.do_multi_state and self.options.get_bool("SAVE_SA_DSRG_INTS"): state_map = forte.to_state_nroots_map(self.state_weights_map) - write_external_active_space_file( - ints_dressed, state_map, self.mo_space_info, "dsrg_ints.json") + write_external_active_space_file(ints_dressed, state_map, self.mo_space_info, "dsrg_ints.json") msg = "\n\nSave SA-DSRG dressed integrals to dsrg_ints.json\n\n" print(msg) psi4.core.print_out(msg) @@ -368,10 +343,8 @@ def compute_energy(self): # Spit out contracted SA-DSRG energy if self.do_multi_state and self.multi_state_type == "SA_SUB": max_rdm_level = 3 if self.options.get_bool("FORM_HBAR3") else 2 - state_energies_list = self.active_space_solver.compute_contracted_energy( - ints_dressed, max_rdm_level) - e_relax = forte.compute_average_state_energy( - state_energies_list, self.state_weights_map) + state_energies_list = self.active_space_solver.compute_contracted_energy(ints_dressed, max_rdm_level) + e_relax = forte.compute_average_state_energy(state_energies_list, self.state_weights_map) self.energies.append((e_dsrg, e_relax)) break @@ -386,12 +359,10 @@ def compute_energy(self): if self.Meff_implemented: if self.max_quadrupole_level > 0: - self.active_space_solver.compute_multipole_moment( - asmpints, 2) + self.active_space_solver.compute_multipole_moment(asmpints, 2) else: if self.max_dipole_level > 0: - self.active_space_solver.compute_multipole_moment( - asmpints, 1) + self.active_space_solver.compute_multipole_moment(asmpints, 1) if self.max_dipole_level > 0 and self.options.get_list("TRANSITION_DIPOLES"): self.active_space_solver.compute_fosc_same_orbs(asmpints) @@ -401,8 +372,7 @@ def compute_energy(self): self.reorder_weights(state_ci_wfn_map) self.state_ci_wfn_map = state_ci_wfn_map - e_relax = forte.compute_average_state_energy( - state_energies_list, self.state_weights_map) + e_relax = forte.compute_average_state_energy(state_energies_list, self.state_weights_map) self.energies.append((e_dsrg, e_relax)) # Compute relaxed dipole @@ -415,8 +385,7 @@ def compute_energy(self): self.dipoles.append((dm_u, dm_r)) # Save energies that have been pushed to Psi4 environment - self.energies_environment[n + 1] = {k: v for k, - v in psi4.core.variables().items() if "ROOT" in k} + self.energies_environment[n + 1] = {k: v for k, v in psi4.core.variables().items() if "ROOT" in k} self.energies_environment[n + 1]["DSRG FIXED"] = e_dsrg self.energies_environment[n + 1]["DSRG RELAXED"] = e_relax @@ -462,15 +431,13 @@ def compute_energy(self): self.dsrg_solver.set_read_cwd_amps(not self.restart_amps) e_dsrg = self.dsrg_solver.compute_energy() + self.fno_pt2_energy_shift if self.fno_pt2_energy_shift != 0.0: - psi4.core.print_out( - f"\n\n DSRG-MRPT2 FNO energy correction: {self.fno_pt2_energy_shift:20.15f}") - psi4.core.print_out( - f"\n DSRG-MRPT2 FNO corrected energy: {e_dsrg:20.15f}") - if self.options.get_bool('FULL_HBAR'): + psi4.core.print_out(f"\n\n DSRG-MRPT2 FNO energy correction: {self.fno_pt2_energy_shift:20.15f}") + psi4.core.print_out(f"\n DSRG-MRPT2 FNO corrected energy: {e_dsrg:20.15f}") + if self.options.get_bool("FULL_HBAR"): psi4.core.print_out("\n =>** Saving Full Hbar **<=\n") Heff = self.dsrg_solver.compute_Heff_full() Heff_dict = forte.Heff_dict(Heff) - np.savez('save_Hbar', **Heff_dict) + np.savez("save_Hbar", **Heff_dict) psi4.core.print_out("\n =>** Getting gamma1 **<=\n") gamma1 = self.dsrg_solver.get_gamma1() psi4.core.print_out("\n =>** Getting eta1 **<=\n") @@ -482,42 +449,42 @@ def compute_energy(self): gamma1_dict = forte.blocktensor_to_dict(gamma1) eta_1_dict = forte.blocktensor_to_dict(eta1) lambda2_dict = forte.blocktensor_to_dict(lambda2) - lambda3_dict = forte.L3_dict(lambda3) + if self.solver_type in ["MRDSRG_SO", "MRDSRG-SO"]: + lambda3_dict = forte.blocktensor_to_dict(lambda3) + else: + lambda3_dict = forte.L3_dict(lambda3) - np.savez('save_gamma1', **gamma1_dict) - np.savez('save_eta1', **eta_1_dict) - np.savez('save_lambda2', **lambda2_dict) - np.savez('save_lambda3', **lambda3_dict) + np.savez("save_gamma1", **gamma1_dict) + np.savez("save_eta1", **eta_1_dict) + np.savez("save_lambda2", **lambda2_dict) + np.savez("save_lambda3", **lambda3_dict) del gamma1, eta1, lambda2, lambda3, gamma1_dict, eta_1_dict, lambda2_dict, lambda3_dict - if self.options.get_str('FOURPDC') != 'ZERO': + if self.options.get_str("FOURPDC") != "ZERO": psi4.core.print_out("\n =>** Getting lambda4 **<=\n") lambda4 = self.dsrg_solver.get_lambda4() lambda4_dict = forte.L4_dict(lambda4) - np.savez('save_lambda4', **lambda4_dict) + np.savez("save_lambda4", **lambda4_dict) del lambda4, lambda4_dict + if self.solver_type not in ["MRDSRG_SO", "MRDSRG-SO"]: + psi4.core.print_out("\n =>** Getting dipole integral **<=\n") + Mbar0 = self.dsrg_solver.compute_Mbar0_full() + print(Mbar0) + np.save("Mbar0", Mbar0) + Mbar1 = self.dsrg_solver.compute_Mbar1_full() + Mbar2 = self.dsrg_solver.compute_Mbar2_full() - psi4.core.print_out("\n =>** Getting dipole integral **<=\n") - Mbar0 = self.dsrg_solver.compute_Mbar0_full() - print(Mbar0) - np.save('Mbar0', Mbar0) - Mbar1 = self.dsrg_solver.compute_Mbar1_full() - Mbar2 = self.dsrg_solver.compute_Mbar2_full() - - for i in range(3): - np.savez(f"Mbar1_{i}", ** - forte.blocktensor_to_dict(Mbar1[i])) - np.savez(f"Mbar2_{i}", ** - forte.blocktensor_to_dict(Mbar2[i])) + for i in range(3): + np.savez(f"Mbar1_{i}", **forte.blocktensor_to_dict(Mbar1[i])) + np.savez(f"Mbar2_{i}", **forte.blocktensor_to_dict(Mbar2[i])) - del Mbar0, Mbar1, Mbar2 + del Mbar0, Mbar1, Mbar2 self.dsrg_cleanup() # dump reference relaxation energies to json file if self.save_relax_energies: with open("dsrg_relaxed_energies.json", "w") as w: - json.dump(self.energies_environment, - w, sort_keys=True, indent=4) + json.dump(self.energies_environment, w, sort_keys=True, indent=4) e_current = e_dsrg if len(self.energies) == 0 else e_relax psi4.core.set_scalar_variable("CURRENT ENERGY", e_current) @@ -534,8 +501,7 @@ def compute_gradient(self, ci_vectors): :param ci_vectors: the wave functions (vector of ambit::Tensor) from an ActiveSpaceSolver """ if self.dsrg_solver is None: - raise ValueError( - "Please compute energy before calling compute_gradient") + raise ValueError("Please compute energy before calling compute_gradient") self.dsrg_solver.set_ci_vectors(ci_vectors) self.dsrg_solver.compute_gradient() @@ -545,8 +511,7 @@ def compute_dipole_relaxed(self): dipole_moments = self.dsrg_solver.nuclear_dipole() dipole_dressed = self.dsrg_solver.deGNO_DMbar_actv() for i in range(3): - dipole_moments[i] += dipole_dressed[i].contract_with_rdms( - self.rdms) + dipole_moments[i] += dipole_dressed[i].contract_with_rdms(self.rdms) dm_total = math.sqrt(sum([i * i for i in dipole_moments])) dipole_moments.append(dm_total) return dipole_moments @@ -593,8 +558,7 @@ def reorder_weights(self, state_ci_wfn_map): continue # compute overlap between two sets of CI vectors - overlap = psi4.core.doublet( - state_ci_wfn_map[state], self.state_ci_wfn_map[state], True, False) + overlap = psi4.core.doublet(state_ci_wfn_map[state], self.state_ci_wfn_map[state], True, False) overlap.name = f"CI Overlap of {state}" # check overlap and determine if we need to permute states @@ -602,15 +566,13 @@ def reorder_weights(self, state_ci_wfn_map): max_values = np.max(overlap_np, axis=1) permutation = np.argmax(overlap_np, axis=1) psi4.core.print_out(f"\n\n Permutations: {permutation}") - check_pass = len(permutation) == len( - set(permutation)) and np.all(max_values > 0.5) + check_pass = len(permutation) == len(set(permutation)) and np.all(max_values > 0.5) if not check_pass: msg = "Relaxed states are likely wrong. Please increase the number of roots." warnings.warn(f"{msg}", UserWarning) psi4.core.print_out(f"\n\n Forte Warning: {msg}") - psi4.core.print_out( - "\n\n ==> Overlap of CI Vectors <==\n\n") + psi4.core.print_out("\n\n ==> Overlap of CI Vectors <==\n\n") overlap.print_out() else: if list(permutation) == list(range(len(permutation))): @@ -628,8 +590,7 @@ def reorder_weights(self, state_ci_wfn_map): psi4.core.print_out(f"\n {'-' * 24}") for i, w_old in enumerate(weights_old): w_new = weights_new[i] - psi4.core.print_out( - f"\n {i:4d} {w_old:9.3e} {w_new:9.3e}") + psi4.core.print_out(f"\n {i:4d} {w_old:9.3e} {w_new:9.3e}") psi4.core.print_out(f"\n {'-' * 24}\n") # try to fix ms < 0 @@ -653,8 +614,7 @@ def print_summary(self): return if (not self.do_multi_state) or self.relax_maxiter > 1: - psi4.core.print_out( - f"\n\n => {self.solver_type} Reference Relaxation Energy Summary <=\n") + psi4.core.print_out(f"\n\n => {self.solver_type} Reference Relaxation Energy Summary <=\n") indent = " " * 4 dash = "-" * 71 title = f"{indent}{' ':5} {'Fixed Ref. (a.u.)':>31} {'Relaxed Ref. (a.u.)':>31}\n" @@ -666,33 +626,27 @@ def print_summary(self): for n, pair in enumerate(self.energies, 1): e0, e1 = pair e0_diff, e1_diff = e0 - e0_old, e1 - e1_old - psi4.core.print_out( - f"\n{indent}{n:>5} {e0:>20.12f} {e0_diff:>10.3e} {e1:>20.12f} {e1_diff:>10.3e}") + psi4.core.print_out(f"\n{indent}{n:>5} {e0:>20.12f} {e0_diff:>10.3e} {e1:>20.12f} {e1_diff:>10.3e}") e0_old, e1_old = e0, e1 psi4.core.print_out(f"\n{indent}{dash}") def print_dipole(name, dipole_xyzt): out = f"\n {self.solver_type} {name.lower()} dipole moment:" - out += "\n X: {:10.6f} Y: {:10.6f} Z: {:10.6f} Total: {:10.6f}\n".format( - *dipole_xyzt) + out += "\n X: {:10.6f} Y: {:10.6f} Z: {:10.6f} Total: {:10.6f}\n".format(*dipole_xyzt) return out if self.do_dipole and (not self.do_multi_state): - psi4.core.print_out( - f"\n\n => {self.solver_type} Reference Relaxation Dipole Summary <=\n") + psi4.core.print_out(f"\n\n => {self.solver_type} Reference Relaxation Dipole Summary <=\n") psi4.core.print_out(print_dipole("unrelaxed", self.dipoles[0][0])) - psi4.core.print_out(print_dipole( - "partially relaxed", self.dipoles[0][1])) + psi4.core.print_out(print_dipole("partially relaxed", self.dipoles[0][1])) if self.relax_maxiter > 1: - psi4.core.print_out(print_dipole( - "relaxed", self.dipoles[1][0])) + psi4.core.print_out(print_dipole("relaxed", self.dipoles[1][0])) if self.relax_ref == "ITERATE" and self.converged: - psi4.core.print_out(print_dipole( - "fully relaxed", self.dipoles[-1][1])) + psi4.core.print_out(print_dipole("fully relaxed", self.dipoles[-1][1])) def push_to_psi4_environment(self): """Push results to Psi4 environment.""" @@ -700,34 +654,24 @@ def push_to_psi4_environment(self): return psi4.core.set_scalar_variable("UNRELAXED ENERGY", self.energies[0][0]) - psi4.core.set_scalar_variable( - "PARTIALLY RELAXED ENERGY", self.energies[0][1]) + psi4.core.set_scalar_variable("PARTIALLY RELAXED ENERGY", self.energies[0][1]) if self.do_dipole and (not self.do_multi_state): - psi4.core.set_scalar_variable( - "UNRELAXED DIPOLE", self.dipoles[0][0][-1]) - psi4.core.set_scalar_variable( - "PARTIALLY RELAXED DIPOLE", self.dipoles[0][1][-1]) + psi4.core.set_scalar_variable("UNRELAXED DIPOLE", self.dipoles[0][0][-1]) + psi4.core.set_scalar_variable("PARTIALLY RELAXED DIPOLE", self.dipoles[0][1][-1]) if self.relax_maxiter > 1: - psi4.core.set_scalar_variable( - "RELAXED ENERGY", self.energies[1][0]) + psi4.core.set_scalar_variable("RELAXED ENERGY", self.energies[1][0]) if self.do_dipole and (not self.do_multi_state): - psi4.core.set_scalar_variable( - "RELAXED DIPOLE", self.dipoles[1][0][-1]) + psi4.core.set_scalar_variable("RELAXED DIPOLE", self.dipoles[1][0][-1]) if self.relax_ref == "ITERATE": if not self.converged: - psi4.core.set_scalar_variable( - "CURRENT UNRELAXED ENERGY", self.energies[-1][0]) - psi4.core.set_scalar_variable( - "CURRENT RELAXED ENERGY", self.energies[-1][1]) - raise psi4.p4util.PsiException( - f"DSRG relaxation does not converge in {self.relax_maxiter} cycles") + psi4.core.set_scalar_variable("CURRENT UNRELAXED ENERGY", self.energies[-1][0]) + psi4.core.set_scalar_variable("CURRENT RELAXED ENERGY", self.energies[-1][1]) + raise psi4.p4util.PsiException(f"DSRG relaxation does not converge in {self.relax_maxiter} cycles") else: - psi4.core.set_scalar_variable( - "FULLY RELAXED ENERGY", self.energies[-1][1]) + psi4.core.set_scalar_variable("FULLY RELAXED ENERGY", self.energies[-1][1]) if self.do_dipole and (not self.do_multi_state): - psi4.core.set_scalar_variable( - "FULLY RELAXED DIPOLE", self.dipoles[-1][1][-1]) + psi4.core.set_scalar_variable("FULLY RELAXED DIPOLE", self.dipoles[-1][1][-1]) From 65e2b98b3df3cc935b180fb7ddcabf2229e0ab73 Mon Sep 17 00:00:00 2001 From: Shuhang Li Date: Wed, 6 Nov 2024 15:07:28 -0500 Subject: [PATCH 39/55] with ref_relax --- forte/base_classes/rdms.cc | 8 ++++---- forte/proc/dsrg.py | 2 ++ 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/forte/base_classes/rdms.cc b/forte/base_classes/rdms.cc index 6a4904337..30aa7b2ad 100644 --- a/forte/base_classes/rdms.cc +++ b/forte/base_classes/rdms.cc @@ -156,9 +156,9 @@ std::shared_ptr RDMs::build_from_disk(size_t max_rdm_level, RDMsType type, rdms = std::make_shared(g1a, g1b, g2aa, g2ab, g2bb, g3aaa, g3aab, g3abb, g3bbb); } else { - rdms = std::make_shared(g1a, g1b, g2aa, g2ab, g2bb, g3aaa, g3aab, - g3abb, g3bbb, g4aaaa, g4aaab, g4aabb, g4abbb, - g4bbbb); + rdms = + std::make_shared(g1a, g1b, g2aa, g2ab, g2bb, g3aaa, g3aab, g3abb, + g3bbb, g4aaaa, g4aaab, g4aabb, g4abbb, g4bbbb); } } else { ambit::Tensor g1, g2, g3; @@ -1237,7 +1237,7 @@ void RDMsSpinDependent::rotate(const ambit::Tensor& Ua, const ambit::Tensor& Ub) g4T("pqrStuvW") = Ua("ap") * Ua("bq") * Ua("cr") * Ub("DS") * g4aaab_("abcDijkL") * Ua("it") * Ua("ju") * Ua("kv") * Ub("LW"); g4aaab_("pqrStuvW") = g4T("pqrStuvW"); - g4T("pqRStuVW") = Ua("ap") * Ua("bq") * Ub("CR") * Ub("DS") * g4aabb_("abCDijkL") * Ua("it") * + g4T("pqRStuVW") = Ua("ap") * Ua("bq") * Ub("CR") * Ub("DS") * g4aabb_("abCDijKL") * Ua("it") * Ua("ju") * Ub("KV") * Ub("LW"); g4aabb_("pqRStuVW") = g4T("pqRStuVW"); g4T("pQRStUVW") = Ua("ap") * Ub("BQ") * Ub("CR") * Ub("DS") * g4abbb_("aBCDiJKL") * Ua("it") * diff --git a/forte/proc/dsrg.py b/forte/proc/dsrg.py index 1a0646708..4aae8191d 100644 --- a/forte/proc/dsrg.py +++ b/forte/proc/dsrg.py @@ -433,7 +433,9 @@ def compute_energy(self): if self.fno_pt2_energy_shift != 0.0: psi4.core.print_out(f"\n\n DSRG-MRPT2 FNO energy correction: {self.fno_pt2_energy_shift:20.15f}") psi4.core.print_out(f"\n DSRG-MRPT2 FNO corrected energy: {e_dsrg:20.15f}") + if self.options.get_bool("FULL_HBAR"): + self.rdms.rotate(self.Ua, self.Ub) psi4.core.print_out("\n =>** Saving Full Hbar **<=\n") Heff = self.dsrg_solver.compute_Heff_full() Heff_dict = forte.Heff_dict(Heff) From 11eb4ddbb62f4150a1458623cdd9fab08c831ed1 Mon Sep 17 00:00:00 2001 From: Shuhang Li Date: Tue, 12 Nov 2024 13:50:51 -0500 Subject: [PATCH 40/55] ref_relax --- forte/api/orbital_api.cc | 4 + forte/orbital-helpers/semi_canonicalize.cc | 74 ++++++++++++ forte/orbital-helpers/semi_canonicalize.h | 49 ++++++-- forte/proc/dsrg.py | 132 +++++++++------------ 4 files changed, 176 insertions(+), 83 deletions(-) diff --git a/forte/api/orbital_api.cc b/forte/api/orbital_api.cc index bfaeda282..15f3db4e9 100644 --- a/forte/api/orbital_api.cc +++ b/forte/api/orbital_api.cc @@ -78,8 +78,12 @@ void export_SemiCanonical(py::module& m) { "Semicanonicalize the orbitals and transform the integrals and reference") .def("Ua", &SemiCanonical::Ua, "Return the alpha rotation matrix") .def("Ub", &SemiCanonical::Ub, "Return the alpha rotation matrix") + .def("Ua_c", &SemiCanonical::Ua_c, "Return the alpha rotation matrix in the core space") + .def("Ub_c", &SemiCanonical::Ub_c, "Return the beta rotation matrix in the core space") .def("Ua_t", &SemiCanonical::Ua_t, "Return the alpha rotation matrix in the active space") .def("Ub_t", &SemiCanonical::Ub_t, "Return the beta rotation matrix in the active space") + .def("Ua_v", &SemiCanonical::Ua_v, "Return the alpha rotation matrix in the virtual space") + .def("Ub_v", &SemiCanonical::Ub_v, "Return the beta rotation matrix in the virtual space") .def("fix_orbital_success", &SemiCanonical::fix_orbital_success, "Return if the orbital ordering and phases are fixed successfully"); } diff --git a/forte/orbital-helpers/semi_canonicalize.cc b/forte/orbital-helpers/semi_canonicalize.cc index 462282982..fbb1a1159 100644 --- a/forte/orbital-helpers/semi_canonicalize.cc +++ b/forte/orbital-helpers/semi_canonicalize.cc @@ -74,16 +74,26 @@ void SemiCanonical::read_options(const std::shared_ptr& options) { void SemiCanonical::startup() { nirrep_ = mo_space_info_->nirrep(); nmopi_ = mo_space_info_->dimension("ALL"); + ncore_ = mo_space_info_->size("CORE"); nact_ = mo_space_info_->size("ACTIVE"); + nvirt_ = mo_space_info_->size("VIRTUAL"); // Prepare orbital rotation matrix, which transforms all MOs Ua_ = std::make_shared("Ua", nmopi_, nmopi_); Ub_ = std::make_shared("Ub", nmopi_, nmopi_); + // Prepare orbital rotation matrix, which transforms only core MOs + Ua_c_ = ambit::Tensor::build(ambit::CoreTensor, "Ua", {ncore_, ncore_}); + Ub_c_ = ambit::Tensor::build(ambit::CoreTensor, "Ub", {ncore_, ncore_}); + // Prepare orbital rotation matrix, which transforms only active MOs Ua_t_ = ambit::Tensor::build(ambit::CoreTensor, "Ua", {nact_, nact_}); Ub_t_ = ambit::Tensor::build(ambit::CoreTensor, "Ub", {nact_, nact_}); + // Prepare orbital rotation matrix, which transforms only virtual MOs + Ua_v_ = ambit::Tensor::build(ambit::CoreTensor, "Ua", {nvirt_, nvirt_}); + Ub_v_ = ambit::Tensor::build(ambit::CoreTensor, "Ub", {nvirt_, nvirt_}); + // Initialize U to identity set_U_to_identity(); @@ -120,11 +130,23 @@ void SemiCanonical::set_U_to_identity() { Ua_->identity(); Ub_->identity(); + Ua_c_.iterate( + [&](const std::vector& i, double& value) { value = (i[0] == i[1]) ? 1.0 : 0.0; }); + + Ub_c_.iterate( + [&](const std::vector& i, double& value) { value = (i[0] == i[1]) ? 1.0 : 0.0; }); + Ua_t_.iterate( [&](const std::vector& i, double& value) { value = (i[0] == i[1]) ? 1.0 : 0.0; }); Ub_t_.iterate( [&](const std::vector& i, double& value) { value = (i[0] == i[1]) ? 1.0 : 0.0; }); + + Ua_v_.iterate( + [&](const std::vector& i, double& value) { value = (i[0] == i[1]) ? 1.0 : 0.0; }); + + Ub_v_.iterate( + [&](const std::vector& i, double& value) { value = (i[0] == i[1]) ? 1.0 : 0.0; }); } void SemiCanonical::semicanonicalize(std::shared_ptr rdms, const bool& build_fock, @@ -274,12 +296,64 @@ void SemiCanonical::build_transformation_matrices(const bool& semi) { // keep phase and order unchanged fix_orbital_success_ = ints_->fix_orbital_phases(Ua_, true); + // fill in Ua_c_ + fill_Ucore(Ua_, Ua_c_); // fill in Ua_t_ fill_Uactv(Ua_, Ua_t_); + // fill in Ua_v_ + fill_Uvirt(Ua_, Ua_v_); // pass to Ub Ub_->copy(Ua_); + Ub_c_.copy(Ua_c_); Ub_t_.copy(Ua_t_); + Ub_v_.copy(Ua_v_); +} + +void SemiCanonical::fill_Ucore(const std::shared_ptr& U, ambit::Tensor& Ut) { + auto core_names = mo_space_info_->composite_space_names()["CORE"]; + auto& Ut_data = Ut.data(); + + for (const std::string& name : core_names) { + auto size = mo_space_info_->size(name); + if (size == 0) + continue; + + auto pos = mo_space_info_->pos_in_space(name, "CORE"); + auto relative_mos = mo_space_info_->relative_mo(name); + for (size_t p = 0; p < size; ++p) { + const auto& [hp, np] = relative_mos[p]; + for (size_t q = 0; q < size; ++q) { + const auto& [hq, nq] = relative_mos[q]; + if (hp != hq) + continue; + Ut_data[pos[p] * ncore_ + pos[q]] = U->get(hp, np, nq); + } + } + } +} + +void SemiCanonical::fill_Uvirt(const std::shared_ptr& U, ambit::Tensor& Ut) { + auto virtual_names = mo_space_info_->composite_space_names()["VIRTUAL"]; + auto& Ut_data = Ut.data(); + + for (const std::string& name : virtual_names) { + auto size = mo_space_info_->size(name); + if (size == 0) + continue; + + auto pos = mo_space_info_->pos_in_space(name, "VIRTUAL"); + auto relative_mos = mo_space_info_->relative_mo(name); + for (size_t p = 0; p < size; ++p) { + const auto& [hp, np] = relative_mos[p]; + for (size_t q = 0; q < size; ++q) { + const auto& [hq, nq] = relative_mos[q]; + if (hp != hq) + continue; + Ut_data[pos[p] * nvirt_ + pos[q]] = U->get(hp, np, nq); + } + } + } } void SemiCanonical::fill_Uactv(const std::shared_ptr& U, ambit::Tensor& Ut) { diff --git a/forte/orbital-helpers/semi_canonicalize.h b/forte/orbital-helpers/semi_canonicalize.h index 5fc779537..9e325b2f5 100644 --- a/forte/orbital-helpers/semi_canonicalize.h +++ b/forte/orbital-helpers/semi_canonicalize.h @@ -42,16 +42,16 @@ namespace forte { class ForteOptions; /// @brief The SemiCanonical class -/// This class computes semi-canonical orbitals from the 1RDM and optionally transforms the integrals and RDMs -/// Semi-canonical orbitals are obtained by diagonalizing the Fock matrix in each orbital space separately -/// The class can also produce natural orbitals. These differ by the semi-canonical orbital only in the active space -/// where they are defined to be eigenvectors of the 1RDM -/// -/// The final orbitals are ordered by increasing energy within each irrep and space. Natural orbitals are ordered -/// by decreasing occupation number +/// This class computes semi-canonical orbitals from the 1RDM and optionally transforms the +/// integrals and RDMs Semi-canonical orbitals are obtained by diagonalizing the Fock matrix in each +/// orbital space separately The class can also produce natural orbitals. These differ by the +/// semi-canonical orbital only in the active space where they are defined to be eigenvectors of the +/// 1RDM +/// +/// The final orbitals are ordered by increasing energy within each irrep and space. Natural +/// orbitals are ordered by decreasing occupation number class SemiCanonical { public: - /// @brief SemiCanonical Constructor /// @param mo_space_info The MOSpaceInfo object /// @param ints The ForteIntegrals object @@ -78,12 +78,22 @@ class SemiCanonical { /// @return the beta rotation matrix std::shared_ptr Ub() { return Ub_; } + /// @return the alpha rotation matrix in the core space + ambit::Tensor Ua_c() const { return Ua_c_.clone(); } + /// @return the beta rotation matrix in the core space + ambit::Tensor Ub_c() const { return Ub_c_.clone(); } + /// @return the alpha rotation matrix in the active space ambit::Tensor Ua_t() const { return Ua_t_.clone(); } /// @return the beta rotation matrix in the active space ambit::Tensor Ub_t() const { return Ub_t_.clone(); } + /// @return the alpha rotation matrix in the virtual space + ambit::Tensor Ua_v() const { return Ua_v_.clone(); } + /// @return the beta rotation matrix in the virtual space + ambit::Tensor Ub_v() const { return Ub_v_.clone(); } + /// @return if the orbital ordering and phases are fixed successfully bool fix_orbital_success() const { return fix_orbital_success_; } @@ -117,9 +127,15 @@ class SemiCanonical { /// Offset of GAS orbitals within ACTIVE std::map actv_offsets_; + /// Number of core MOs + size_t ncore_; + /// Number of active MOs size_t nact_; + /// Number of virtual MOs + size_t nvirt_; + /// Number of irreps size_t nirrep_; @@ -127,11 +143,22 @@ class SemiCanonical { std::shared_ptr Ua_; /// Unitary matrix for beta orbital rotation std::shared_ptr Ub_; + + /// Unitary matrix for alpha orbital rotation in the core space + ambit::Tensor Ua_c_; + /// Unitary matrix for beta orbital rotation in the core space + ambit::Tensor Ub_c_; + /// Unitary matrix for alpha orbital rotation in the active space ambit::Tensor Ua_t_; /// Unitary matrix for beta orbital rotation in the active space ambit::Tensor Ub_t_; + /// Unitary matrix for alpha orbital rotation in the virtual space + ambit::Tensor Ua_v_; + /// Unitary matrix for beta orbital rotation in the virtual space + ambit::Tensor Ub_v_; + /// Set Ua_, Ub_, Ua_t_, and Ub_t_ to identity void set_U_to_identity(); @@ -153,9 +180,15 @@ class SemiCanonical { /// Builds unitary matrices used to diagonalize diagonal blocks of Fock void build_transformation_matrices(const bool& semi); + /// Fill ambit::Tensor Ua_c_ (Ub_c_) using std::shared_ptr Ua_ (Ub_) + void fill_Ucore(const std::shared_ptr& U, ambit::Tensor& Ut); + /// Fill ambit::Tensor Ua_t_ (Ub_t_) using std::shared_ptr Ua_ (Ub_) void fill_Uactv(const std::shared_ptr& U, ambit::Tensor& Ut); + /// Fill ambit::Tensor Ua_v_ (Ub_v_) using std::shared_ptr Ua_ (Ub_) + void fill_Uvirt(const std::shared_ptr& U, ambit::Tensor& Ut); + /// Successfully fix the orbital ordering and phases bool fix_orbital_success_; }; diff --git a/forte/proc/dsrg.py b/forte/proc/dsrg.py index 4aae8191d..04088a644 100644 --- a/forte/proc/dsrg.py +++ b/forte/proc/dsrg.py @@ -246,41 +246,11 @@ def compute_energy(self): if not self.Heff_implemented: self.relax_maxiter = 0 - # if self.options.get_bool('FULL_HBAR'): - # self.relax_maxiter = 0 - if self.options.get_bool("FULL_HBAR") and self.relax_maxiter == 0: - psi4.core.print_out("\n =>** Saving Full Hbar **<=\n") + psi4.core.print_out("\n =>** Saving Full Hbar (unrelax) **<=\n") Heff = self.dsrg_solver.compute_Heff_full() Heff_dict = forte.Heff_dict(Heff) np.savez("save_Hbar", **Heff_dict) - psi4.core.print_out("\n =>** Getting gamma1 **<=\n") - gamma1 = self.dsrg_solver.get_gamma1() - psi4.core.print_out("\n =>** Getting eta1 **<=\n") - eta1 = self.dsrg_solver.get_eta1() - psi4.core.print_out("\n =>** Getting lambda2 **<=\n") - lambda2 = self.dsrg_solver.get_lambda2() - psi4.core.print_out("\n =>** Getting lambda3 **<=\n") - lambda3 = self.dsrg_solver.get_lambda3() - gamma1_dict = forte.blocktensor_to_dict(gamma1) - eta_1_dict = forte.blocktensor_to_dict(eta1) - lambda2_dict = forte.blocktensor_to_dict(lambda2) - if self.solver_type in ["MRDSRG_SO", "MRDSRG-SO"]: - lambda3_dict = forte.blocktensor_to_dict(lambda3) - else: - lambda3_dict = forte.L3_dict(lambda3) - - np.savez("save_gamma1", **gamma1_dict) - np.savez("save_eta1", **eta_1_dict) - np.savez("save_lambda2", **lambda2_dict) - np.savez("save_lambda3", **lambda3_dict) - del gamma1, eta1, lambda2, lambda3, gamma1_dict, eta_1_dict, lambda2_dict, lambda3_dict - if self.options.get_str("FOURPDC") != "ZERO": - psi4.core.print_out("\n =>** Getting lambda4 **<=\n") - lambda4 = self.dsrg_solver.get_lambda4() - lambda4_dict = forte.L4_dict(lambda4) - np.savez("save_lambda4", **lambda4_dict) - del lambda4, lambda4_dict if self.solver_type not in ["MRDSRG_SO", "MRDSRG-SO"]: psi4.core.print_out("\n =>** Getting dipole integral **<=\n") @@ -305,6 +275,27 @@ def compute_energy(self): # so that the CI vectors are comparable before and after DSRG dressing. # However, the ForteIntegrals object and the dipole integrals always refer to the current semi-canonical basis. # so to compute the dipole moment correctly, we need to make the RDMs and orbital basis consistent + + if self.options.get_bool("FULL_HBAR") and n == self.relax_maxiter - 1: + psi4.core.print_out("\n =>** Saving Full Hbar (relax) **<=\n") + Heff = self.dsrg_solver.compute_Heff_full() + Heff_dict = forte.Heff_dict(Heff) + np.savez("save_Hbar", **Heff_dict) + + if self.solver_type not in ["MRDSRG_SO", "MRDSRG-SO"]: + psi4.core.print_out("\n =>** Getting dipole integral **<=\n") + Mbar0 = self.dsrg_solver.compute_Mbar0_full() + print(Mbar0) + np.save("Mbar0", Mbar0) + Mbar1 = self.dsrg_solver.compute_Mbar1_full() + Mbar2 = self.dsrg_solver.compute_Mbar2_full() + + for i in range(3): + np.savez(f"Mbar1_{i}", **forte.blocktensor_to_dict(Mbar1[i])) + np.savez(f"Mbar2_{i}", **forte.blocktensor_to_dict(Mbar2[i])) + + del Mbar0, Mbar1, Mbar2 + ints_dressed = self.dsrg_solver.compute_Heff_actv() if self.fno_pt2_Heff_shift is not None: ints_dressed.add(self.fno_pt2_Heff_shift, 1.0) @@ -434,52 +425,43 @@ def compute_energy(self): psi4.core.print_out(f"\n\n DSRG-MRPT2 FNO energy correction: {self.fno_pt2_energy_shift:20.15f}") psi4.core.print_out(f"\n DSRG-MRPT2 FNO corrected energy: {e_dsrg:20.15f}") - if self.options.get_bool("FULL_HBAR"): - self.rdms.rotate(self.Ua, self.Ub) - psi4.core.print_out("\n =>** Saving Full Hbar **<=\n") - Heff = self.dsrg_solver.compute_Heff_full() - Heff_dict = forte.Heff_dict(Heff) - np.savez("save_Hbar", **Heff_dict) - psi4.core.print_out("\n =>** Getting gamma1 **<=\n") - gamma1 = self.dsrg_solver.get_gamma1() - psi4.core.print_out("\n =>** Getting eta1 **<=\n") - eta1 = self.dsrg_solver.get_eta1() - psi4.core.print_out("\n =>** Getting lambda2 **<=\n") - lambda2 = self.dsrg_solver.get_lambda2() - psi4.core.print_out("\n =>** Getting lambda3 **<=\n") - lambda3 = self.dsrg_solver.get_lambda3() - gamma1_dict = forte.blocktensor_to_dict(gamma1) - eta_1_dict = forte.blocktensor_to_dict(eta1) - lambda2_dict = forte.blocktensor_to_dict(lambda2) - if self.solver_type in ["MRDSRG_SO", "MRDSRG-SO"]: - lambda3_dict = forte.blocktensor_to_dict(lambda3) - else: - lambda3_dict = forte.L3_dict(lambda3) - - np.savez("save_gamma1", **gamma1_dict) - np.savez("save_eta1", **eta_1_dict) - np.savez("save_lambda2", **lambda2_dict) - np.savez("save_lambda3", **lambda3_dict) - del gamma1, eta1, lambda2, lambda3, gamma1_dict, eta_1_dict, lambda2_dict, lambda3_dict - if self.options.get_str("FOURPDC") != "ZERO": - psi4.core.print_out("\n =>** Getting lambda4 **<=\n") - lambda4 = self.dsrg_solver.get_lambda4() - lambda4_dict = forte.L4_dict(lambda4) - np.savez("save_lambda4", **lambda4_dict) - del lambda4, lambda4_dict - if self.solver_type not in ["MRDSRG_SO", "MRDSRG-SO"]: - psi4.core.print_out("\n =>** Getting dipole integral **<=\n") - Mbar0 = self.dsrg_solver.compute_Mbar0_full() - print(Mbar0) - np.save("Mbar0", Mbar0) - Mbar1 = self.dsrg_solver.compute_Mbar1_full() - Mbar2 = self.dsrg_solver.compute_Mbar2_full() + if self.options.get_bool("FULL_HBAR"): + if self.relax_maxiter != 0: + self.rdms = self.active_space_solver.compute_average_rdms( + self.state_weights_map, self.max_rdm_level, self.rdm_type + ) + self.rdms.rotate(self.Ua, self.Ub) # To previous semi-canonical basis - for i in range(3): - np.savez(f"Mbar1_{i}", **forte.blocktensor_to_dict(Mbar1[i])) - np.savez(f"Mbar2_{i}", **forte.blocktensor_to_dict(Mbar2[i])) + self.make_dsrg_solver() - del Mbar0, Mbar1, Mbar2 + psi4.core.print_out("\n =>** Getting gamma1 **<=\n") + gamma1 = self.dsrg_solver.get_gamma1() + psi4.core.print_out("\n =>** Getting eta1 **<=\n") + eta1 = self.dsrg_solver.get_eta1() + psi4.core.print_out("\n =>** Getting lambda2 **<=\n") + lambda2 = self.dsrg_solver.get_lambda2() + psi4.core.print_out("\n =>** Getting lambda3 **<=\n") + lambda3 = self.dsrg_solver.get_lambda3() + + gamma1_dict = forte.blocktensor_to_dict(gamma1) + eta1_dict = forte.blocktensor_to_dict(eta1) + lambda2_dict = forte.blocktensor_to_dict(lambda2) + if self.solver_type in ["MRDSRG_SO", "MRDSRG-SO"]: + lambda3_dict = forte.blocktensor_to_dict(lambda3) + else: + lambda3_dict = forte.L3_dict(lambda3) + + np.savez("save_gamma1", **gamma1_dict) + np.savez("save_eta1", **eta1_dict) + np.savez("save_lambda2", **lambda2_dict) + np.savez("save_lambda3", **lambda3_dict) + del gamma1, eta1, lambda2, lambda3, gamma1_dict, eta1_dict, lambda2_dict, lambda3_dict + if self.options.get_str("FOURPDC") != "ZERO": + psi4.core.print_out("\n =>** Getting lambda4 **<=\n") + lambda4 = self.dsrg_solver.get_lambda4() + lambda4_dict = forte.L4_dict(lambda4) + np.savez("save_lambda4", **lambda4_dict) + del lambda4, lambda4_dict self.dsrg_cleanup() From 426cc7b99f2a2e76190b10efd9ed625f65f065e8 Mon Sep 17 00:00:00 2001 From: Brian Zhao Date: Thu, 14 Nov 2024 22:23:27 -0500 Subject: [PATCH 41/55] Export SA-MRDSRG ints --- forte/api/forte_python_module.cc | 2 ++ forte/mrdsrg-spin-adapted/sadsrg.cc | 5 +++++ forte/mrdsrg-spin-adapted/sadsrg.h | 1 + forte/orbital-helpers/semi_canonicalize.cc | 4 ++-- forte/proc/dsrg.py | 6 +++--- 5 files changed, 13 insertions(+), 5 deletions(-) diff --git a/forte/api/forte_python_module.cc b/forte/api/forte_python_module.cc index 9ecac5b88..45d02a48f 100644 --- a/forte/api/forte_python_module.cc +++ b/forte/api/forte_python_module.cc @@ -352,6 +352,8 @@ PYBIND11_MODULE(_forte, m) { .def("compute_energy", &SADSRG::compute_energy, "Compute the DSRG energy") .def("compute_Heff_actv", &SADSRG::compute_Heff_actv, "Return the DSRG dressed ActiveSpaceIntegrals") + .def("compute_Heff_full", &SADSRG::compute_Heff_full, + "Return full transformed Hamiltonian") .def("compute_mp_eff_actv", &SADSRG::compute_mp_eff_actv, "Return the DSRG dressed ActiveMultipoleIntegrals") .def("set_Uactv", &SADSRG::set_Uactv, "Ua"_a, diff --git a/forte/mrdsrg-spin-adapted/sadsrg.cc b/forte/mrdsrg-spin-adapted/sadsrg.cc index fdcb3595f..2e2a5bca2 100644 --- a/forte/mrdsrg-spin-adapted/sadsrg.cc +++ b/forte/mrdsrg-spin-adapted/sadsrg.cc @@ -472,6 +472,11 @@ std::shared_ptr SADSRG::compute_Heff_actv() { return fci_ints; } +std::vector SADSRG::compute_Heff_full() { + std::vector Heff = {Hbar1_, Hbar2_}; + return Heff; +} + std::shared_ptr SADSRG::compute_mp_eff_actv() { /** * DSRG transform multipole integrals: Mbar = e^{-A} M e^{A} diff --git a/forte/mrdsrg-spin-adapted/sadsrg.h b/forte/mrdsrg-spin-adapted/sadsrg.h index 3516b491a..171948b7e 100644 --- a/forte/mrdsrg-spin-adapted/sadsrg.h +++ b/forte/mrdsrg-spin-adapted/sadsrg.h @@ -62,6 +62,7 @@ class SADSRG : public DynamicCorrelationSolver { /// Compute DSRG transformed Hamiltonian std::shared_ptr compute_Heff_actv() override; + std::vector compute_Heff_full(); /// Compute DSRG transformed multipole integrals std::shared_ptr compute_mp_eff_actv() override; diff --git a/forte/orbital-helpers/semi_canonicalize.cc b/forte/orbital-helpers/semi_canonicalize.cc index 4a615ee17..66b8efc32 100644 --- a/forte/orbital-helpers/semi_canonicalize.cc +++ b/forte/orbital-helpers/semi_canonicalize.cc @@ -314,7 +314,7 @@ void SemiCanonical::build_transformation_matrices(const bool& semi) { } void SemiCanonical::fill_Ucore(const std::shared_ptr& U, ambit::Tensor& Ut) { - auto core_names = mo_space_info_->composite_space_names()["CORE"]; + auto core_names = mo_space_info_->composite_spaces_def().at("CORE"); auto& Ut_data = Ut.data(); for (const std::string& name : core_names) { @@ -337,7 +337,7 @@ void SemiCanonical::fill_Ucore(const std::shared_ptr& U, ambit::Ten } void SemiCanonical::fill_Uvirt(const std::shared_ptr& U, ambit::Tensor& Ut) { - auto virtual_names = mo_space_info_->composite_space_names()["VIRTUAL"]; + auto virtual_names = mo_space_info_->composite_spaces_def().at("VIRTUAL"); auto& Ut_data = Ut.data(); for (const std::string& name : virtual_names) { diff --git a/forte/proc/dsrg.py b/forte/proc/dsrg.py index 19956b225..2606caaaa 100644 --- a/forte/proc/dsrg.py +++ b/forte/proc/dsrg.py @@ -249,13 +249,13 @@ def compute_energy(self): if not self.Heff_implemented: self.relax_maxiter = 0 - if self.options.get_bool("FULL_HBAR") and self.relax_maxiter == 0: + if self.options.get_bool("FULL_HBAR") and self.relax_maxiter == 0 and self.solver_type in ["MRDSRG","SA-MRDSRG","SA_MRDSRG"]: psi4.core.print_out("\n =>** Saving Full Hbar (unrelax) **<=\n") Heff = self.dsrg_solver.compute_Heff_full() Heff_dict = forte.Heff_dict(Heff) np.savez("save_Hbar", **Heff_dict) - if self.solver_type not in ["MRDSRG_SO", "MRDSRG-SO"]: + if self.solver_type in ["MRDSRG"]: psi4.core.print_out("\n =>** Getting dipole integral **<=\n") Mbar0 = self.dsrg_solver.compute_Mbar0_full() print(Mbar0) @@ -428,7 +428,7 @@ def compute_energy(self): psi4.core.print_out(f"\n\n DSRG-MRPT2 FNO energy correction: {self.fno_pt2_energy_shift:20.15f}") psi4.core.print_out(f"\n DSRG-MRPT2 FNO corrected energy: {e_dsrg:20.15f}") - if self.options.get_bool("FULL_HBAR"): + if self.options.get_bool("FULL_HBAR") and self.solver_type in ["MRDSRG"]: if self.relax_maxiter != 0: self.rdms = self.active_space_solver.compute_average_rdms( self.state_weights_map, self.max_rdm_level, self.rdm_type From bb89c72076c7a41f00d07281e24cc5a6856649c7 Mon Sep 17 00:00:00 2001 From: Brian Zhao Date: Fri, 15 Nov 2024 15:26:20 -0500 Subject: [PATCH 42/55] Degno full for SI --- forte/CMakeLists.txt | 1 - forte/api/forte_python_module.cc | 135 ++++++++---------- forte/helpers/helpers.cc | 9 ++ forte/helpers/helpers.h | 8 ++ forte/mrdsrg-so/mrdsrg_so.cc | 111 +++----------- forte/mrdsrg-so/mrdsrg_so.h | 3 + forte/mrdsrg-spin-adapted/eom_dsrg.cc | 71 --------- forte/mrdsrg-spin-adapted/sa_ldsrg2.cc | 10 +- forte/mrdsrg-spin-adapted/sa_mrdsrg.cc | 2 + forte/mrdsrg-spin-adapted/sa_mrdsrg.h | 2 + forte/mrdsrg-spin-adapted/sadsrg.cc | 51 +++++++ forte/mrdsrg-spin-adapted/sadsrg.h | 13 +- forte/mrdsrg-spin-integrated/master_mrdsrg.cc | 59 ++++++++ forte/mrdsrg-spin-integrated/master_mrdsrg.h | 9 ++ forte/mrdsrg-spin-integrated/mrdsrg_nonpt.cc | 32 ++--- forte/options.yaml | 6 +- forte/proc/dsrg.py | 51 ++++--- 17 files changed, 278 insertions(+), 295 deletions(-) delete mode 100644 forte/mrdsrg-spin-adapted/eom_dsrg.cc diff --git a/forte/CMakeLists.txt b/forte/CMakeLists.txt index 2eb826b03..084c74619 100644 --- a/forte/CMakeLists.txt +++ b/forte/CMakeLists.txt @@ -217,7 +217,6 @@ mrdsrg-spin-adapted/sadsrg.cc mrdsrg-spin-adapted/sadsrg_amps_analysis.cc mrdsrg-spin-adapted/sadsrg_block_labels.cc mrdsrg-spin-adapted/sadsrg_comm.cc -mrdsrg-spin-adapted/eom_dsrg.cc mrdsrg-spin-integrated/dsrg_mrpt2.cc mrdsrg-spin-integrated/dsrg_mrpt2_grad/dsrg_mrpt2_deriv_multipliers.cc mrdsrg-spin-integrated/dsrg_mrpt2_grad/dsrg_mrpt2_deriv_setb.cc diff --git a/forte/api/forte_python_module.cc b/forte/api/forte_python_module.cc index 45d02a48f..ce3bfc314 100644 --- a/forte/api/forte_python_module.cc +++ b/forte/api/forte_python_module.cc @@ -181,71 +181,6 @@ PYBIND11_MODULE(_forte, m) { }, "Return the cumulants of the RDMs in a spinorbital basis. Spinorbitals follow the ordering " "abab..."); - m.def( - "Heff_dict", - [](std::vector Heff) { - py::dict pyints; - for (const auto& int_ : Heff) { - auto labels = int_.block_labels(); - for (const auto& label : labels) { - pyints[py::str(label)] = ambit_to_np(int_.block(label)); - } - } - return pyints; - }, - "Return the full Heff in a dictionary"); - // m.def( - // "Mbar_dict", - // [](std::vector Mbar) { - // std::vector pymbar; - // py::dict pyints; - // for (size_t i = 0; i < Mbar.size(); i++) { - // pyints = {}; - // for (const auto& int_ : Mbar[i]) { - // auto labels = int_.block_labels(); - // for (const auto& label : labels) { - // pyints[py::str(label)] = ambit_to_np(int_.block(label)); - // } - // } - // pymbar.push_back(pyints); - // } - // return pymbar; - // }, - // "Return the full Meff in a list of dictionary"); - m.def( - "blocktensor_to_dict", - [](ambit::BlockedTensor rdm) { - py::dict pyrdm; - auto labels = rdm.block_labels(); - for (const auto& label : labels) { - pyrdm[py::str(label)] = ambit_to_np(rdm.block(label)); - } - return pyrdm; - }, - "Return the BlockTensor in a dictionary"); - m.def( - "L3_dict", - [](std::vector rdm) { - py::dict pyrdm; - pyrdm[py::str("aaaaaa")] = ambit_to_np(rdm[0]); - pyrdm[py::str("aaAaaA")] = ambit_to_np(rdm[1]); - pyrdm[py::str("aAAaAA")] = ambit_to_np(rdm[2]); - pyrdm[py::str("AAAAAA")] = ambit_to_np(rdm[3]); - return pyrdm; - }, - "Return the L3 in a dictionary"); - m.def( - "L4_dict", // L4aaaa_, L4aaab_, L4aabb_, L4abbb_, L4bbbb_ - [](std::vector rdm) { - py::dict pyrdm; - pyrdm[py::str("aaaaaaaa")] = ambit_to_np(rdm[0]); - pyrdm[py::str("aaaAaaaA")] = ambit_to_np(rdm[1]); - pyrdm[py::str("aaAAaaAA")] = ambit_to_np(rdm[2]); - pyrdm[py::str("aAAAaAAA")] = ambit_to_np(rdm[3]); - pyrdm[py::str("AAAAAAAA")] = ambit_to_np(rdm[4]); - return pyrdm; - }, - "Return the L3 in a dictionary"); m.def("get_gas_occupation", &get_gas_occupation); m.def("get_ci_occupation_patterns", &get_ci_occupation_patterns); @@ -314,19 +249,57 @@ PYBIND11_MODULE(_forte, m) { .def("compute_gradient", &MASTER_DSRG::compute_gradient, "Compute the DSRG gradient") .def("compute_Heff_actv", &MASTER_DSRG::compute_Heff_actv, "Return the DSRG dressed ActiveSpaceIntegrals") - .def("compute_Heff_full", &MASTER_DSRG::compute_Heff_full, - "Return full transformed Hamiltonian") + .def("compute_Heff_full", [](MASTER_DSRG& self) { + const auto Heff = self.compute_Heff_full(); + return py::make_tuple(blockedtensor_to_np(Heff.at(0)), blockedtensor_to_np(Heff.at(1))); + }) + .def("compute_Heff_full_degno", [](MASTER_DSRG& self) { + const auto Heff = self.compute_Heff_full_degno(); + return py::make_tuple(blockedtensor_to_np(Heff.at(0)), blockedtensor_to_np(Heff.at(1))); + }) .def("compute_Mbar0_full", &MASTER_DSRG::compute_Mbar0_full, "Return full transformed zero-body dipole integrals") - .def("compute_Mbar1_full", &MASTER_DSRG::compute_Mbar1_full, - "Return full transformed one-body dipole integrals") - .def("compute_Mbar2_full", &MASTER_DSRG::compute_Mbar2_full, - "Return full transformed two-body dipole integrals") - .def("get_gamma1", &MASTER_DSRG::get_gamma1, "Return the gamma1 tensor") - .def("get_eta1", &MASTER_DSRG::get_eta1, "Return the eta1 tensor") - .def("get_lambda2", &MASTER_DSRG::get_lambda2, "Return the lambda2 tensor") - .def("get_lambda3", &MASTER_DSRG::get_lambda3, "Return the lambda3 tensor") - .def("get_lambda4", &MASTER_DSRG::get_lambda4, "Return the lambda4 tensor") + .def("compute_Mbar1_full", [](MASTER_DSRG& self) { + const auto Mbar1 = self.compute_Mbar1_full(); + return py::make_tuple(blockedtensor_to_np(Mbar1.at(0)), blockedtensor_to_np(Mbar1.at(1)), + blockedtensor_to_np(Mbar1.at(2))); + }) + .def("compute_Mbar2_full", [](MASTER_DSRG& self) { + const auto Mbar2 = self.compute_Mbar2_full(); + return py::make_tuple(blockedtensor_to_np(Mbar2.at(0)), blockedtensor_to_np(Mbar2.at(1)), + blockedtensor_to_np(Mbar2.at(2))); + }) + .def("get_gamma1", [](MASTER_DSRG& self) { + const auto gamma1 = self.get_gamma1(); + return blockedtensor_to_np(gamma1); + }) + .def("get_eta1", [](MASTER_DSRG& self) { + const auto eta1 = self.get_eta1(); + return blockedtensor_to_np(eta1); + }) + .def("get_lambda2", [](MASTER_DSRG& self) { + const auto lambda2 = self.get_lambda2(); + return blockedtensor_to_np(lambda2); + }) + .def("get_lambda3", [](MASTER_DSRG& self) { + const auto lambda3 = self.get_lambda3(); + py::dict pyrdm; + pyrdm[py::str("aaaaaa")] = ambit_to_np(lambda3.at(0)); + pyrdm[py::str("aaAaaA")] = ambit_to_np(lambda3.at(1)); + pyrdm[py::str("aAAaAA")] = ambit_to_np(lambda3.at(2)); + pyrdm[py::str("AAAAAA")] = ambit_to_np(lambda3.at(3)); + return pyrdm; + }) + .def("get_lambda4", [](MASTER_DSRG& self) { + const auto lambda4 = self.get_lambda4(); + py::dict pyrdm; + pyrdm[py::str("aaaaaaaa")] = ambit_to_np(lambda4.at(0)); + pyrdm[py::str("aaaAaaaA")] = ambit_to_np(lambda4.at(1)); + pyrdm[py::str("aaAAaaAA")] = ambit_to_np(lambda4.at(2)); + pyrdm[py::str("aAAAaAAA")] = ambit_to_np(lambda4.at(3)); + pyrdm[py::str("AAAAAAAA")] = ambit_to_np(lambda4.at(4)); + return pyrdm; + }) .def("deGNO_DMbar_actv", &MASTER_DSRG::deGNO_DMbar_actv, "Return the DSRG dressed dipole integrals") .def("nuclear_dipole", &MASTER_DSRG::nuclear_dipole, @@ -352,8 +325,14 @@ PYBIND11_MODULE(_forte, m) { .def("compute_energy", &SADSRG::compute_energy, "Compute the DSRG energy") .def("compute_Heff_actv", &SADSRG::compute_Heff_actv, "Return the DSRG dressed ActiveSpaceIntegrals") - .def("compute_Heff_full", &SADSRG::compute_Heff_full, - "Return full transformed Hamiltonian") + .def("compute_Heff_full", [](SADSRG& self) { + const auto Heff = self.compute_Heff_full(); + return py::make_tuple(blockedtensor_to_np(Heff.at(0)), blockedtensor_to_np(Heff.at(1))); + }) + .def("compute_Heff_full_degno", [](SADSRG& self) { + const auto Heff = self.compute_Heff_full_degno(); + return py::make_tuple(blockedtensor_to_np(Heff.at(0)), blockedtensor_to_np(Heff.at(1))); + }) .def("compute_mp_eff_actv", &SADSRG::compute_mp_eff_actv, "Return the DSRG dressed ActiveMultipoleIntegrals") .def("set_Uactv", &SADSRG::set_Uactv, "Ua"_a, diff --git a/forte/helpers/helpers.cc b/forte/helpers/helpers.cc index dec29ba58..e093ad2fc 100644 --- a/forte/helpers/helpers.cc +++ b/forte/helpers/helpers.cc @@ -74,6 +74,15 @@ py::array_t vector_to_np(const std::vector& v, const std::vector return py::array_t(dims, &(v.data()[0])); } +py::dict blockedtensor_to_np(ambit::BlockedTensor bt) { + py::dict pybt; + auto labels = bt.block_labels(); + for (const auto& label : labels) { + pybt[py::str(label)] = ambit_to_np(bt.block(label)); + } + return pybt; +} + std::shared_ptr tensor_to_matrix(ambit::Tensor t) { size_t size1 = t.dim(0); size_t size2 = t.dim(1); diff --git a/forte/helpers/helpers.h b/forte/helpers/helpers.h index 3905e4dca..2a7f99a80 100644 --- a/forte/helpers/helpers.h +++ b/forte/helpers/helpers.h @@ -66,6 +66,14 @@ enum class Spin3 { aaa, aab, abb, bbb }; */ py::array_t ambit_to_np(ambit::Tensor t); +/** + * @brief Convert an ambit BlockedTensor to a dictionary of numpy ndarray's. + * The returned tensor is stored according to the C storage convention. + * @param t The input BlockedTensor + * @return A dictionary of numpy arrays + */ +py::dict blockedtensor_to_np(ambit::BlockedTensor bt); + /** * @brief Convert a std::vector to a numpy ndarray. * The returned tensor is stored according to the C storage convention. diff --git a/forte/mrdsrg-so/mrdsrg_so.cc b/forte/mrdsrg-so/mrdsrg_so.cc index 9931c51e1..e93edbe72 100644 --- a/forte/mrdsrg-so/mrdsrg_so.cc +++ b/forte/mrdsrg-so/mrdsrg_so.cc @@ -108,6 +108,13 @@ void MRDSRG_SO::startup() { source_ = foptions_->get_str("SOURCE"); + dsrg_trans_type_ = foptions_->get_str("DSRG_TRANS_TYPE"); + if (dsrg_trans_type_ == "CC" && foptions_->get_str("CORR_LEVEL") == "QDSRG2"){ + outfile->Printf("\n Warning: DSRG_TRANS_TYPE option CC is not supported with CORR_LEVEL QDSRG2."); + outfile->Printf("\n Changed DSRG_TRANS_TYPE option to UNITARY"); + dsrg_trans_type_ = "UNITARY"; + } + ntamp_ = foptions_->get_int("NTAMP"); intruder_tamp_ = foptions_->get_double("INTRUDER_TAMP"); @@ -645,99 +652,11 @@ double MRDSRG_SO::compute_energy() { outfile->Printf("\n\n\n MR-DSRG(2) correlation energy = %25.15f", Etotal - Eref); outfile->Printf("\n * MR-DSRG(2) total energy = %25.15f\n", Etotal); - // compute_eom(); - psi::Process::environment.globals["CURRENT ENERGY"] = Etotal; return Etotal; } -// double MRDSRG_SO::compute_eom() { -// // IP singles -// size_t ncore = nc_ / 2; -// size_t nactv = na_ / 2; -// size_t nmo = nso_ / 2; -// size_t nhole = ncore + nactv; - -// auto EOM_Hbar = BTF_->build(tensor_type_, "EOM-Hbar", {"hh"}); -// std::shared_ptr EOM_Hbar_mat_ = -// std::make_shared("EOM-Hbar-Matrx", nh_, nh_); - -// EOM_Hbar["nm"] = -Hbar1["nm"]; -// EOM_Hbar["mv"] = -Hbar1["mu"] * Gamma1["uv"]; -// EOM_Hbar["mv"] += 0.5 * Hbar2["mwux"] * Lambda2["uxwv"]; -// EOM_Hbar["vm"] = EOM_Hbar["mv"]; -// EOM_Hbar["wx"] = -Hbar1["vu"] * Gamma1["ux"] * Gamma1["wv"]; -// EOM_Hbar["wx"] += Hbar1["vu"] * Lambda2["uwvx"]; -// EOM_Hbar["wx"] += 0.5 * Hbar2["yzuv"] * Gamma1["wy"] * Lambda2["uvzx"]; -// EOM_Hbar["wx"] -= 0.5 * Hbar2["yzuv"] * Gamma1["vx"] * Lambda2["uwyz"]; -// EOM_Hbar["wx"] += 0.25 * Hbar2["yzuv"] * Lambda3["uvwyzx"]; - -// EOM_Hbar.iterate( -// [&](const std::vector& i, const std::vector&, double& value) { -// if (i[0] < nmo && i[1] < nmo) { -// EOM_Hbar_mat_->set(i[0], i[1], value); -// } -// if (i[0] >= nmo && i[1] >= nmo) { -// EOM_Hbar_mat_->set(i[0] - nmo + nhole, i[1] - nmo + nhole, value); -// } -// }); - -// EOM_Hbar_mat_->print(); - -// /// Overlap matrix -// std::shared_ptr S = std::make_shared("EOM-S-sub", nh_, nh_); -// std::shared_ptr Sevec = std::make_shared("S-evec", nh_, nh_); -// std::shared_ptr Seval = std::make_shared("S-eval", nh_); -// // std::shared_ptr Eevec = std::make_shared("E-evec", nh_, nh_); -// // std::shared_ptr Eeval = std::make_shared("E-eval", nh_); -// S->identity(); -// (rdms_->g1a()).citerate([&](const std::vector& i, const double& value) { -// S->set(i[0] + ncore, i[1] + ncore, value); -// }); -// (rdms_->g1b()).citerate([&](const std::vector& i, const double& value) { -// std::cout << value << std::endl; -// S->set(i[0] + 2 * ncore + nactv, i[1] + 2 * ncore + nactv, value); -// }); -// S->print(); -// S->diagonalize(Sevec, Seval); -// // auto Sevec = S->partial_cholesky_factorize(1e-10); -// // auto Seval = std::make_shared("S-eval", Sevec->rowdim()); - -// std::vector s_list; -// for (size_t i = 0; i < Sevec->coldim(); i++) { -// double value = abs(Seval->get(i)); -// if (value > 1e-8) { -// s_list.push_back(i); -// } -// } - -// size_t num_s_list = s_list.size(); - -// std::shared_ptr S_new = std::make_shared("S-new", nh_, num_s_list); -// for (size_t i = 0; i < num_s_list; i++) { -// psi::SharedVector temp = Sevec->get_column(0, s_list[i]); -// temp->scale(1.0 / Seval->get(s_list[i])); -// S_new->set_column(0, i, temp); -// } -// std::shared_ptr Eevec = std::make_shared("E-evec", nh_, -// num_s_list); std::shared_ptr Eeval = std::make_shared("E-eval", -// num_s_list); - -// EOM_Hbar_mat_ = psi::linalg::triplet(S_new, EOM_Hbar_mat_, S_new, true, false, false); - -// EOM_Hbar_mat_->diagonalize(Eevec, Eeval); - -// outfile->Printf("\n " -// "----------------------------------------------------------" -// "----------------------------------------"); -// outfile->Printf("\n\n\n EOM-DSRG "); - -// Eeval->print(); - -// return Eeval->get(0); -// } - void MRDSRG_SO::compute_hbar() { // outfile->Printf("\n\n Computing the similarity-transformed @@ -799,13 +718,15 @@ void MRDSRG_SO::compute_hbar() { // outfile->Printf("\n |H2| = %20.12f", C2.norm(1)); // outfile->Printf("\n --------------------------------"); - // [H, A] = [H, T] + [H, T]^dagger - C0 *= 2.0; - O1["pq"] = C1["pq"]; - C1["pq"] += O1["qp"]; - O2["pqrs"] = C2["pqrs"]; - C2["pqrs"] += O2["rspq"]; - + if (dsrg_trans_type_ == "UNITARY"){ + // [H, A] = [H, T] + [H, T]^dagger + C0 *= 2.0; + O1["pq"] = C1["pq"]; + C1["pq"] += O1["qp"]; + O2["pqrs"] = C2["pqrs"]; + C2["pqrs"] += O2["rspq"]; + } + // Hbar += C Hbar0 += C0; Hbar1["pq"] += C1["pq"]; diff --git a/forte/mrdsrg-so/mrdsrg_so.h b/forte/mrdsrg-so/mrdsrg_so.h index 927b126fe..042745999 100644 --- a/forte/mrdsrg-so/mrdsrg_so.h +++ b/forte/mrdsrg-so/mrdsrg_so.h @@ -120,6 +120,9 @@ class MRDSRG_SO : public DynamicCorrelationSolver { /// Order of the Taylor expansion of f(z) = (1-exp(-z^2))/z int taylor_order_; + /// DSRG transformation type + std::string dsrg_trans_type_; + std::shared_ptr BTF_; TensorType tensor_type_; diff --git a/forte/mrdsrg-spin-adapted/eom_dsrg.cc b/forte/mrdsrg-spin-adapted/eom_dsrg.cc deleted file mode 100644 index b879ef3ed..000000000 --- a/forte/mrdsrg-spin-adapted/eom_dsrg.cc +++ /dev/null @@ -1,71 +0,0 @@ -/* - * @BEGIN LICENSE - * - * Forte: an open-source plugin to Psi4 (https://github.com/psi4/psi4) - * that implements a variety of quantum chemistry methods for strongly - * correlated electrons. - * - * Copyright (c) 2012-2023 by its authors (see COPYING, COPYING.LESSER, - * AUTHORS). - * - * The copyrights for code used from other parties are included in - * the corresponding files. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program. If not, see http://www.gnu.org/licenses/. - * - * @END LICENSE - */ - -// #include "helpers/timer.h" -// #include "sa_mrdsrg.h" -// using namespace psi; -// namespace forte { -// double SA_MRDSRG::compute_eom() { -// // IP singles. Should add foptions. -// size_t nhole = mo_space_info_->dimension("GENERALIZED HOLE").sum(); -// size_t nocc = mo_space_info_->dimension("RESTRICTED_DOCC").sum(); -// size_t nact = mo_space_info_->dimension("ACTIVE").sum(); -// auto EOM_Hbar = BTF_->build(tensor_type_, "EOM-Hbar", {"hh"}, true); -// EOM_Hbar_mat_ = std::make_shared("EOM-Hbar-Matrx", nhole, nhole); - -// /// Should do spin adaptation. -// EOM_Hbar["nm"] -= Hbar1_["nm"]; -// // EOM_Hbar["mv"] = -Hbar1_["mu"] * L1_["uv"] + Hbar2_["mwux"] * L2_["uxwv"]; -// // EOM_Hbar["wx"] = -Hbar1_["vu"] * L1_["ux"] * L1_["wv"] + Hbar1_["vu"] * L2_["uwvx"] + -// // 0.5 * Hbar2_["yzuv"] * L1_["wy"] * L2_["uvzx"] - -// // 0.5 * Hbar2_["yzuv"] * L1_["vx"] * L2_["uwyz"] + -// // 0.25 * Hbar2_["yzuv"] * L3_["uvwyzx"]; - -// EOM_Hbar.iterate([&](const std::vector& i, const std::vector&, -// double& value) { EOM_Hbar_mat_->set(i[0], i[1], value); }); - -// /// Overlap matrix -// std::shared_ptr S = std::make_shared("EOM-S-sub", nhole, nhole); -// std::shared_ptr Sevec = std::make_shared("S-evec", nhole, nhole); -// std::shared_ptr Seval = std::make_shared("S-eval", nhole); -// S->identity(); -// L1_.iterate([&](const std::vector& i, const std::vector&, double& value) { -// S->set(i[0] + nocc, i[1] + nocc, value); -// }); -// S->diagonalize(Sevec, Seval); - -// EOM_Hbar_mat_ = psi::linalg::triplet(Sevec, EOM_Hbar_mat_, Sevec, true, false, false); - -// EOM_Hbar_mat_->diagonalize(Sevec, Seval); - -// Seval->print(); - -// return Seval->get(0); -// } -// } // namespace forte \ No newline at end of file diff --git a/forte/mrdsrg-spin-adapted/sa_ldsrg2.cc b/forte/mrdsrg-spin-adapted/sa_ldsrg2.cc index e7d04d822..e3e460ab4 100644 --- a/forte/mrdsrg-spin-adapted/sa_ldsrg2.cc +++ b/forte/mrdsrg-spin-adapted/sa_ldsrg2.cc @@ -192,16 +192,14 @@ double SA_MRDSRG::compute_energy_ldsrg2() { // dump amplitudes to disk dump_amps_to_disk(); + if (full_hbar_) { + int ncomm = compute_hbar(rsc_conv_); + } + final.stop(); Hbar0_ = Ecorr; - // bool do_eom = false; - // do_eom = foptions_->get_bool("DO_EOM"); - // if (do_eom) { - // Ecorr = compute_eom(); - // } - return Ecorr; } diff --git a/forte/mrdsrg-spin-adapted/sa_mrdsrg.cc b/forte/mrdsrg-spin-adapted/sa_mrdsrg.cc index 46196f5f4..735fe5076 100644 --- a/forte/mrdsrg-spin-adapted/sa_mrdsrg.cc +++ b/forte/mrdsrg-spin-adapted/sa_mrdsrg.cc @@ -95,6 +95,8 @@ void SA_MRDSRG::read_options() { outfile->Printf("\n Changed DSRG_TRANS_TYPE option to UNITARY"); dsrg_trans_type_ = "UNITARY"; } + + full_hbar_ = foptions_->get_bool("FULL_HBAR") || foptions_->get_bool("FULL_HBAR_DEGNO"); } void SA_MRDSRG::startup() { diff --git a/forte/mrdsrg-spin-adapted/sa_mrdsrg.h b/forte/mrdsrg-spin-adapted/sa_mrdsrg.h index bcbd7e232..690fca8e4 100644 --- a/forte/mrdsrg-spin-adapted/sa_mrdsrg.h +++ b/forte/mrdsrg-spin-adapted/sa_mrdsrg.h @@ -107,6 +107,8 @@ class SA_MRDSRG : public SADSRG { double rsc_conv_adapt_threshold_; double rsc_conv_adapt_delta_e_; + bool full_hbar_; + /// DSRG transformation type std::string dsrg_trans_type_; diff --git a/forte/mrdsrg-spin-adapted/sadsrg.cc b/forte/mrdsrg-spin-adapted/sadsrg.cc index 2e2a5bca2..7c09c75c1 100644 --- a/forte/mrdsrg-spin-adapted/sadsrg.cc +++ b/forte/mrdsrg-spin-adapted/sadsrg.cc @@ -232,7 +232,9 @@ void SADSRG::read_MOSpaceInfo() { core_mos_ = mo_space_info_->corr_absolute_mo("RESTRICTED_DOCC"); actv_mos_ = mo_space_info_->corr_absolute_mo("ACTIVE"); virt_mos_ = mo_space_info_->corr_absolute_mo("RESTRICTED_UOCC"); + gen_mos_ = mo_space_info_->corr_absolute_mo("CORRELATED"); actv_mos_sym_ = mo_space_info_->symmetry("ACTIVE"); + gen_mos_sym_ = mo_space_info_->symmetry("CORRELATED"); if (eri_df_) { aux_mos_ = std::vector(ints_->nthree()); @@ -477,6 +479,17 @@ std::vector SADSRG::compute_Heff_full() { return Heff; } +std::vector SADSRG::compute_Heff_full_degno() { + double Edsrg = Eref_ + Hbar0_; + if (foptions_->get_bool("FORM_HBAR3")) { + throw psi::PSIEXCEPTION("FORM_HBAR3 is not implemented for full Hamiltonian."); + } else { + deGNO_ints_full("Hamiltonian", Edsrg, Hbar1_, Hbar2_); + } + std::vector Heff = {Hbar1_, Hbar2_}; + return Heff; +} + std::shared_ptr SADSRG::compute_mp_eff_actv() { /** * DSRG transform multipole integrals: Mbar = e^{-A} M e^{A} @@ -712,6 +725,44 @@ void SADSRG::deGNO_ints(const std::string& name, double& H0, BlockedTensor& H1, print_done(t2.get()); } +void SADSRG::deGNO_ints_full(const std::string& name, double& H0, BlockedTensor& H1, BlockedTensor& H2) { + print_h2("De-Normal-Order Full 2-Body DSRG Transformed " + name); + + // compute scalar + local_timer t0; + print_contents("Computing the scalar term"); + + // build a temp["pqrs"] = 2 * H2["pqrs"] - H2["pqsr"] + auto temp = H2.clone(); + temp.scale(2.0); + temp["pqrs"] -= H2["pqsr"]; + + auto L1h = BTF_->build(tensor_type_, "L1h", spin_cases({"hh"})); + L1h.block("aa")("uv") = L1_.block("aa")("uv"); + L1h.block("cc").iterate( + [&](const std::vector& i, double& value) { value = i[0] == i[1] ? 2.0 : 0.0; }); + + // scalar from H1 + double scalar1 = 0.0; + scalar1 -= H1["ji"] * L1h["ij"]; + + // scalar from H2 + double scalar2 = 0.0; + scalar2 += 0.25 * L1h["ij"] * temp["jlik"] * L1h["kl"]; + + scalar2 -= 0.5 * H2["xyuv"] * L2_["uvxy"]; + + H0 += scalar1 + scalar2; + print_done(t0.get()); + + // compute 1-body term + local_timer t1; + print_contents("Computing the 1-body term"); + + H1["pq"] -= 0.5 * temp["piqj"] * L1h["ji"]; + print_done(t1.get()); +} + ambit::BlockedTensor SADSRG::deGNO_Tamp(BlockedTensor& T1, BlockedTensor& T2, BlockedTensor& D1) { BlockedTensor T1eff = BTF_->build(tensor_type_, "T1eff from de-GNO", {"hp"}); diff --git a/forte/mrdsrg-spin-adapted/sadsrg.h b/forte/mrdsrg-spin-adapted/sadsrg.h index 171948b7e..86bf68f8c 100644 --- a/forte/mrdsrg-spin-adapted/sadsrg.h +++ b/forte/mrdsrg-spin-adapted/sadsrg.h @@ -63,6 +63,7 @@ class SADSRG : public DynamicCorrelationSolver { /// Compute DSRG transformed Hamiltonian std::shared_ptr compute_Heff_actv() override; std::vector compute_Heff_full(); + std::vector compute_Heff_full_degno(); /// Compute DSRG transformed multipole integrals std::shared_ptr compute_mp_eff_actv() override; @@ -182,9 +183,13 @@ class SADSRG : public DynamicCorrelationSolver { std::vector actv_mos_; /// List of virtual MOs std::vector virt_mos_; + /// List of genereal MOs + std::vector gen_mos_; /// List of the symmetry of the active MOs std::vector actv_mos_sym_; - + /// List of the symmetry of the general MOs + std::vector gen_mos_sym_; + /// List of active active occupied MOs (relative to active) std::vector actv_occ_mos_; /// List of active active unoccupied MOs (relative to active) @@ -356,6 +361,12 @@ class SADSRG : public DynamicCorrelationSolver { void deGNO_ints(const std::string& name, double& H0, BlockedTensor& H1, BlockedTensor& H2, BlockedTensor& H3); + /** + * De-normal-order a 2-body DSRG transformed integrals (full Hbar!) + * This will change H0 and H1 !!! + */ + void deGNO_ints_full(const std::string& name, double& H0, BlockedTensor& H1, BlockedTensor& H2); + /** * De-normal-order the T1 and T2 amplitudes and return the effective T1 * T1eff = T1 - T2["ivau"] * D1["uv"] diff --git a/forte/mrdsrg-spin-integrated/master_mrdsrg.cc b/forte/mrdsrg-spin-integrated/master_mrdsrg.cc index b08b29411..9d8c0c229 100644 --- a/forte/mrdsrg-spin-integrated/master_mrdsrg.cc +++ b/forte/mrdsrg-spin-integrated/master_mrdsrg.cc @@ -691,6 +691,53 @@ void MASTER_DSRG::deGNO_ints(const std::string& name, double& H0, BlockedTensor& outfile->Printf("Done. Timing %8.3f s", t2.get()); } +void MASTER_DSRG::deGNO_ints_full(const std::string& name, double& H0, BlockedTensor& H1, + BlockedTensor& H2) { + print_h2("De-Normal-Order Full DSRG Transformed " + name); + + // compute scalar + local_timer t0; + outfile->Printf("\n %-40s ... ", "Computing the scalar term"); + + auto L1h = BTF_->build(tensor_type_, "L1h", spin_cases({"hh"})); + L1h["uv"] = Gamma1_["uv"]; + L1h["UV"] = Gamma1_["UV"]; + L1h.block("cc").iterate( + [&](const std::vector& i, double& value) { value = i[0] == i[1] ? 1.0 : 0.0; }); + L1h.block("CC").iterate( + [&](const std::vector& i, double& value) { value = i[0] == i[1] ? 1.0 : 0.0; }); + + + // scalar from H1 + double scalar1 = 0.0; + scalar1 -= H1["ji"] * L1h["ij"]; + scalar1 -= H1["JI"] * L1h["IJ"]; + + // scalar from H2 + double scalar2 = 0.0; + scalar2 += 0.5 * L1h["ij"] * H2["jlik"] * L1h["kl"]; + scalar2 += 0.5 * L1h["IJ"] * H2["JLIK"] * L1h["KL"]; + scalar2 += L1h["ij"] * H2["jLiK"] * L1h["KL"]; + + scalar2 -= 0.25 * H2["xyuv"] * Lambda2_["uvxy"]; + scalar2 -= 0.25 * H2["XYUV"] * Lambda2_["UVXY"]; + scalar2 -= H2["xYuV"] * Lambda2_["uVxY"]; + + H0 += scalar1 + scalar2; + outfile->Printf("Done. Timing %8.3f s", t0.get()); + + // compute 1-body term + local_timer t1; + outfile->Printf("\n %-40s ... ", "Computing the 1-body term"); + + H1["pq"] -= H2["piqj"] * L1h["ji"]; + H1["pq"] -= H2["pIqJ"] * L1h["JI"]; + H1["PQ"] -= H2["iPjQ"] * L1h["ji"]; + H1["PQ"] -= H2["PIQJ"] * L1h["JI"]; + outfile->Printf("Done. Timing %8.3f s", t1.get()); +} + + void MASTER_DSRG::fill_three_index_ints(ambit::BlockedTensor T) { const auto& block_labels = T.block_labels(); for (const std::string& string_block : block_labels) { @@ -2301,4 +2348,16 @@ std::vector MASTER_DSRG::compute_Heff_full() { std::vector Heff = {Hbar1_, Hbar2_}; return Heff; } + +std::vector MASTER_DSRG::compute_Heff_full_degno() { + double Edsrg = Eref_ + Hbar0_; + if (foptions_->get_bool("FORM_HBAR3")) { + throw psi::PSIEXCEPTION("FORM_HBAR3 is not implemented for full Hamiltonian."); + } else { + deGNO_ints_full("Hamiltonian", Edsrg, Hbar1_, Hbar2_); + } + std::vector Heff = {Hbar1_, Hbar2_}; + return Heff; +} + } // namespace forte diff --git a/forte/mrdsrg-spin-integrated/master_mrdsrg.h b/forte/mrdsrg-spin-integrated/master_mrdsrg.h index e54526f1b..ac2f2d062 100644 --- a/forte/mrdsrg-spin-integrated/master_mrdsrg.h +++ b/forte/mrdsrg-spin-integrated/master_mrdsrg.h @@ -50,6 +50,9 @@ class MASTER_DSRG : public DynamicCorrelationSolver { /// Compute DSRG full transformed Hamiltonian std::vector compute_Heff_full(); + /// Compute DSRG full transformed Hamiltonian in the de-normal-ordered basis + std::vector compute_Heff_full_degno(); + /// Compute DSRG transformed dipole integral std::vector compute_Mbar0_full() { return Mbar0_full_; } std::vector compute_Mbar1_full() { return Mbar1_full_; } @@ -350,6 +353,12 @@ class MASTER_DSRG : public DynamicCorrelationSolver { void deGNO_ints(const std::string& name, double& H0, BlockedTensor& H1, BlockedTensor& H2, BlockedTensor& H3); + /** + * De-normal-order the full DSRG transformed Hamiltonian + * This will change H0, H1 and H2!!! + */ + void deGNO_ints_full(const std::string& name, double& H0, BlockedTensor& H1, BlockedTensor& H2); + /** * De-normal-order the T1 and T2 amplitudes and return the effective T1 * T1eff = T1 - T2["ivau"] * D1["uv"] diff --git a/forte/mrdsrg-spin-integrated/mrdsrg_nonpt.cc b/forte/mrdsrg-spin-integrated/mrdsrg_nonpt.cc index f6010c7e6..052bfeccd 100644 --- a/forte/mrdsrg-spin-integrated/mrdsrg_nonpt.cc +++ b/forte/mrdsrg-spin-integrated/mrdsrg_nonpt.cc @@ -832,23 +832,23 @@ double MRDSRG::compute_energy_ldsrg2() { // dump amplitudes to file dump_amps_to_disk(); - if (foptions_->get_bool("FULL_HBAR")) { - double rsc_conv = rsc_adapt ? get_adaptive_rsc_conv(1, Edelta, rsc_thres, rsc_adapt_thres, - rsc_adapt_delta_e, e_conv) - : rsc_thres; + if (foptions_->get_bool("FULL_HBAR") || foptions_->get_bool("FULL_HBAR_DEGNO")) { + double rsc_conv = rsc_thres; compute_hbar(rsc_conv); - auto mpints = std::make_shared(ints_, mo_space_info_); - // bare dipoles - std::vector M1; - std::vector dp_dirs{"X", "Y", "Z"}; - for (int z = 0; z < 3; ++z) { - std::string name = "DIPOLE " + dp_dirs[z]; - ambit::BlockedTensor m1 = BTF_->build(tensor_type_, name, spin_cases({"gg"})); - m1.iterate([&](const std::vector& i, const std::vector&, - double& value) { value = mpints->dp_ints_corr(z, i[0], i[1]); }); - M1.push_back(m1); - } - transform_one_body(M1); + if (foptions_->get_bool("FULL_HBAR")){ + auto mpints = std::make_shared(ints_, mo_space_info_); + // bare dipoles + std::vector M1; + std::vector dp_dirs{"X", "Y", "Z"}; + for (int z = 0; z < 3; ++z) { + std::string name = "DIPOLE " + dp_dirs[z]; + ambit::BlockedTensor m1 = BTF_->build(tensor_type_, name, spin_cases({"gg"})); + m1.iterate([&](const std::vector& i, const std::vector&, + double& value) { value = mpints->dp_ints_corr(z, i[0], i[1]); }); + M1.push_back(m1); + } + transform_one_body(M1); + } } final.stop(); diff --git a/forte/options.yaml b/forte/options.yaml index 046d6d4d3..e388b618a 100644 --- a/forte/options.yaml +++ b/forte/options.yaml @@ -1117,7 +1117,11 @@ DSRG: FULL_HBAR: type: bool default: False - help: "Form full Hbar." + help: "Form the full DSRG effective Hamiltonian." + FULL_HBAR_DEGNO: + type: bool + default: False + help: "Form the full DSRG effective Hamiltonian normal ordered w.r.t. the true vacuum." DO_WICKED: type: bool default: False diff --git a/forte/proc/dsrg.py b/forte/proc/dsrg.py index 2606caaaa..43ac44bb6 100644 --- a/forte/proc/dsrg.py +++ b/forte/proc/dsrg.py @@ -249,25 +249,29 @@ def compute_energy(self): if not self.Heff_implemented: self.relax_maxiter = 0 - if self.options.get_bool("FULL_HBAR") and self.relax_maxiter == 0 and self.solver_type in ["MRDSRG","SA-MRDSRG","SA_MRDSRG"]: - psi4.core.print_out("\n =>** Saving Full Hbar (unrelax) **<=\n") - Heff = self.dsrg_solver.compute_Heff_full() - Heff_dict = forte.Heff_dict(Heff) - np.savez("save_Hbar", **Heff_dict) + if self.options.get_bool("FULL_HBAR") and self.solver_type in ["MRDSRG","SA-MRDSRG","SA_MRDSRG"]: + psi4.core.print_out("\n =>** Saving Full Hbar (unrelaxed) **<=\n") + Hbar1, Hbar2 = self.dsrg_solver.compute_Heff_full() + np.savez("save_Hbar", **Hbar1, **Hbar2) if self.solver_type in ["MRDSRG"]: psi4.core.print_out("\n =>** Getting dipole integral **<=\n") Mbar0 = self.dsrg_solver.compute_Mbar0_full() - print(Mbar0) np.save("Mbar0", Mbar0) Mbar1 = self.dsrg_solver.compute_Mbar1_full() Mbar2 = self.dsrg_solver.compute_Mbar2_full() for i in range(3): - np.savez(f"Mbar1_{i}", **forte.blocktensor_to_dict(Mbar1[i])) - np.savez(f"Mbar2_{i}", **forte.blocktensor_to_dict(Mbar2[i])) + np.savez(f"Mbar1_{i}", **Mbar1[i]) + np.savez(f"Mbar2_{i}", **Mbar2[i]) del Mbar0, Mbar1, Mbar2 + + if self.options.get_bool("FULL_HBAR_DEGNO") and self.solver_type in ["SA-MRDSRG","SA_MRDSRG","MRDSRG"]: + psi4.core.print_out("\n =>** Saving Full Hbar in de-normal-ordered basis (unrelaxed) **<=\n") + Hbar1, Hbar2 = self.dsrg_solver.compute_Heff_full_degno() + np.savez("save_Hbar_degno", **Hbar1, **Hbar2) + # Reference relaxation procedure for n in range(self.relax_maxiter): @@ -294,8 +298,8 @@ def compute_energy(self): Mbar2 = self.dsrg_solver.compute_Mbar2_full() for i in range(3): - np.savez(f"Mbar1_{i}", **forte.blocktensor_to_dict(Mbar1[i])) - np.savez(f"Mbar2_{i}", **forte.blocktensor_to_dict(Mbar2[i])) + np.savez(f"Mbar1_{i}", **Mbar1[i]) + np.savez(f"Mbar2_{i}", **Mbar2[i]) del Mbar0, Mbar1, Mbar2 @@ -439,32 +443,27 @@ def compute_energy(self): psi4.core.print_out("\n =>** Getting gamma1 **<=\n") gamma1 = self.dsrg_solver.get_gamma1() + np.savez("save_gamma1", **gamma1) + psi4.core.print_out("\n =>** Getting eta1 **<=\n") eta1 = self.dsrg_solver.get_eta1() + np.savez("save_eta1", **eta1) + psi4.core.print_out("\n =>** Getting lambda2 **<=\n") lambda2 = self.dsrg_solver.get_lambda2() + np.savez("save_lambda2", **lambda2) + psi4.core.print_out("\n =>** Getting lambda3 **<=\n") lambda3 = self.dsrg_solver.get_lambda3() + np.savez("save_lambda3", **lambda3) - gamma1_dict = forte.blocktensor_to_dict(gamma1) - eta1_dict = forte.blocktensor_to_dict(eta1) - lambda2_dict = forte.blocktensor_to_dict(lambda2) - if self.solver_type in ["MRDSRG_SO", "MRDSRG-SO"]: - lambda3_dict = forte.blocktensor_to_dict(lambda3) - else: - lambda3_dict = forte.L3_dict(lambda3) - - np.savez("save_gamma1", **gamma1_dict) - np.savez("save_eta1", **eta1_dict) - np.savez("save_lambda2", **lambda2_dict) - np.savez("save_lambda3", **lambda3_dict) - del gamma1, eta1, lambda2, lambda3, gamma1_dict, eta1_dict, lambda2_dict, lambda3_dict + del gamma1, eta1, lambda2, lambda3 + if self.options.get_str("FOURPDC") != "ZERO": psi4.core.print_out("\n =>** Getting lambda4 **<=\n") lambda4 = self.dsrg_solver.get_lambda4() - lambda4_dict = forte.L4_dict(lambda4) - np.savez("save_lambda4", **lambda4_dict) - del lambda4, lambda4_dict + np.savez("save_lambda4", **lambda4) + del lambda4 self.dsrg_cleanup() From d878f0dc812eccde2e65212306fa436266127204 Mon Sep 17 00:00:00 2001 From: Brian Zhao Date: Fri, 15 Nov 2024 16:00:37 -0500 Subject: [PATCH 43/55] Roll back changes made to semicanonicalize --- forte/api/orbital_api.cc | 4 - forte/mrdsrg-spin-integrated/master_mrdsrg.cc | 1 - forte/orbital-helpers/semi_canonicalize.cc | 74 ------------------- forte/orbital-helpers/semi_canonicalize.h | 32 -------- forte/proc/dsrg.py | 19 +++-- 5 files changed, 11 insertions(+), 119 deletions(-) diff --git a/forte/api/orbital_api.cc b/forte/api/orbital_api.cc index 9856917c7..8e614541e 100644 --- a/forte/api/orbital_api.cc +++ b/forte/api/orbital_api.cc @@ -88,12 +88,8 @@ void export_SemiCanonical(py::module& m) { "Semicanonicalize the orbitals and transform the integrals and reference") .def("Ua", &SemiCanonical::Ua, "Return the alpha rotation matrix") .def("Ub", &SemiCanonical::Ub, "Return the alpha rotation matrix") - .def("Ua_c", &SemiCanonical::Ua_c, "Return the alpha rotation matrix in the core space") - .def("Ub_c", &SemiCanonical::Ub_c, "Return the beta rotation matrix in the core space") .def("Ua_t", &SemiCanonical::Ua_t, "Return the alpha rotation matrix in the active space") .def("Ub_t", &SemiCanonical::Ub_t, "Return the beta rotation matrix in the active space") - .def("Ua_v", &SemiCanonical::Ua_v, "Return the alpha rotation matrix in the virtual space") - .def("Ub_v", &SemiCanonical::Ub_v, "Return the beta rotation matrix in the virtual space") .def("fix_orbital_success", &SemiCanonical::fix_orbital_success, "Return if the orbital ordering and phases are fixed successfully"); } diff --git a/forte/mrdsrg-spin-integrated/master_mrdsrg.cc b/forte/mrdsrg-spin-integrated/master_mrdsrg.cc index 9d8c0c229..b3be3ac7f 100644 --- a/forte/mrdsrg-spin-integrated/master_mrdsrg.cc +++ b/forte/mrdsrg-spin-integrated/master_mrdsrg.cc @@ -707,7 +707,6 @@ void MASTER_DSRG::deGNO_ints_full(const std::string& name, double& H0, BlockedTe L1h.block("CC").iterate( [&](const std::vector& i, double& value) { value = i[0] == i[1] ? 1.0 : 0.0; }); - // scalar from H1 double scalar1 = 0.0; scalar1 -= H1["ji"] * L1h["ij"]; diff --git a/forte/orbital-helpers/semi_canonicalize.cc b/forte/orbital-helpers/semi_canonicalize.cc index 66b8efc32..b8224c693 100644 --- a/forte/orbital-helpers/semi_canonicalize.cc +++ b/forte/orbital-helpers/semi_canonicalize.cc @@ -64,26 +64,16 @@ SemiCanonical::SemiCanonical(std::shared_ptr mo_space_info, void SemiCanonical::startup() { nirrep_ = mo_space_info_->nirrep(); nmopi_ = mo_space_info_->dimension("ALL"); - ncore_ = mo_space_info_->size("CORE"); nact_ = mo_space_info_->size("ACTIVE"); - nvirt_ = mo_space_info_->size("VIRTUAL"); // Prepare orbital rotation matrix, which transforms all MOs Ua_ = std::make_shared("Ua", nmopi_, nmopi_); Ub_ = std::make_shared("Ub", nmopi_, nmopi_); - // Prepare orbital rotation matrix, which transforms only core MOs - Ua_c_ = ambit::Tensor::build(ambit::CoreTensor, "Ua", {ncore_, ncore_}); - Ub_c_ = ambit::Tensor::build(ambit::CoreTensor, "Ub", {ncore_, ncore_}); - // Prepare orbital rotation matrix, which transforms only active MOs Ua_t_ = ambit::Tensor::build(ambit::CoreTensor, "Ua", {nact_, nact_}); Ub_t_ = ambit::Tensor::build(ambit::CoreTensor, "Ub", {nact_, nact_}); - // Prepare orbital rotation matrix, which transforms only virtual MOs - Ua_v_ = ambit::Tensor::build(ambit::CoreTensor, "Ua", {nvirt_, nvirt_}); - Ub_v_ = ambit::Tensor::build(ambit::CoreTensor, "Ub", {nvirt_, nvirt_}); - // Initialize U to identity set_U_to_identity(); @@ -122,23 +112,11 @@ void SemiCanonical::set_U_to_identity() { Ua_->identity(); Ub_->identity(); - Ua_c_.iterate( - [&](const std::vector& i, double& value) { value = (i[0] == i[1]) ? 1.0 : 0.0; }); - - Ub_c_.iterate( - [&](const std::vector& i, double& value) { value = (i[0] == i[1]) ? 1.0 : 0.0; }); - Ua_t_.iterate( [&](const std::vector& i, double& value) { value = (i[0] == i[1]) ? 1.0 : 0.0; }); Ub_t_.iterate( [&](const std::vector& i, double& value) { value = (i[0] == i[1]) ? 1.0 : 0.0; }); - - Ua_v_.iterate( - [&](const std::vector& i, double& value) { value = (i[0] == i[1]) ? 1.0 : 0.0; }); - - Ub_v_.iterate( - [&](const std::vector& i, double& value) { value = (i[0] == i[1]) ? 1.0 : 0.0; }); } void SemiCanonical::semicanonicalize(std::shared_ptr rdms, bool build_fock, @@ -299,64 +277,12 @@ void SemiCanonical::build_transformation_matrices(const bool& semi) { if (!inactive_mix_) fix_orbital_success_ = ints_->fix_orbital_phases(Ua_, true); - // fill in Ua_c_ - fill_Ucore(Ua_, Ua_c_); // fill in Ua_t_ fill_Uactv(Ua_, Ua_t_); - // fill in Ua_v_ - fill_Uvirt(Ua_, Ua_v_); // pass to Ub Ub_->copy(Ua_); - Ub_c_.copy(Ua_c_); Ub_t_.copy(Ua_t_); - Ub_v_.copy(Ua_v_); -} - -void SemiCanonical::fill_Ucore(const std::shared_ptr& U, ambit::Tensor& Ut) { - auto core_names = mo_space_info_->composite_spaces_def().at("CORE"); - auto& Ut_data = Ut.data(); - - for (const std::string& name : core_names) { - auto size = mo_space_info_->size(name); - if (size == 0) - continue; - - auto pos = mo_space_info_->pos_in_space(name, "CORE"); - auto relative_mos = mo_space_info_->relative_mo(name); - for (size_t p = 0; p < size; ++p) { - const auto& [hp, np] = relative_mos[p]; - for (size_t q = 0; q < size; ++q) { - const auto& [hq, nq] = relative_mos[q]; - if (hp != hq) - continue; - Ut_data[pos[p] * ncore_ + pos[q]] = U->get(hp, np, nq); - } - } - } -} - -void SemiCanonical::fill_Uvirt(const std::shared_ptr& U, ambit::Tensor& Ut) { - auto virtual_names = mo_space_info_->composite_spaces_def().at("VIRTUAL"); - auto& Ut_data = Ut.data(); - - for (const std::string& name : virtual_names) { - auto size = mo_space_info_->size(name); - if (size == 0) - continue; - - auto pos = mo_space_info_->pos_in_space(name, "VIRTUAL"); - auto relative_mos = mo_space_info_->relative_mo(name); - for (size_t p = 0; p < size; ++p) { - const auto& [hp, np] = relative_mos[p]; - for (size_t q = 0; q < size; ++q) { - const auto& [hq, nq] = relative_mos[q]; - if (hp != hq) - continue; - Ut_data[pos[p] * nvirt_ + pos[q]] = U->get(hp, np, nq); - } - } - } } void SemiCanonical::fill_Uactv(const std::shared_ptr& U, ambit::Tensor& Ut) { diff --git a/forte/orbital-helpers/semi_canonicalize.h b/forte/orbital-helpers/semi_canonicalize.h index 76bf9a84c..90b58c6d9 100644 --- a/forte/orbital-helpers/semi_canonicalize.h +++ b/forte/orbital-helpers/semi_canonicalize.h @@ -109,22 +109,12 @@ class SemiCanonical { /// @return the beta rotation matrix std::shared_ptr Ub() { return Ub_; } - /// @return the alpha rotation matrix in the core space - ambit::Tensor Ua_c() const { return Ua_c_.clone(); } - /// @return the beta rotation matrix in the core space - ambit::Tensor Ub_c() const { return Ub_c_.clone(); } - /// @return the alpha rotation matrix in the active space ambit::Tensor Ua_t() const { return Ua_t_.clone(); } /// @return the beta rotation matrix in the active space ambit::Tensor Ub_t() const { return Ub_t_.clone(); } - /// @return the alpha rotation matrix in the virtual space - ambit::Tensor Ua_v() const { return Ua_v_.clone(); } - /// @return the beta rotation matrix in the virtual space - ambit::Tensor Ub_v() const { return Ub_v_.clone(); } - /// @return if the orbital ordering and phases are fixed successfully bool fix_orbital_success() const { return fix_orbital_success_; } @@ -158,15 +148,9 @@ class SemiCanonical { /// Offset of GAS orbitals within ACTIVE std::map actv_offsets_; - /// Number of core MOs - size_t ncore_; - /// Number of active MOs size_t nact_; - /// Number of virtual MOs - size_t nvirt_; - /// Number of irreps size_t nirrep_; @@ -175,21 +159,11 @@ class SemiCanonical { /// Unitary matrix for beta orbital rotation std::shared_ptr Ub_; - /// Unitary matrix for alpha orbital rotation in the core space - ambit::Tensor Ua_c_; - /// Unitary matrix for beta orbital rotation in the core space - ambit::Tensor Ub_c_; - /// Unitary matrix for alpha orbital rotation in the active space ambit::Tensor Ua_t_; /// Unitary matrix for beta orbital rotation in the active space ambit::Tensor Ub_t_; - /// Unitary matrix for alpha orbital rotation in the virtual space - ambit::Tensor Ua_v_; - /// Unitary matrix for beta orbital rotation in the virtual space - ambit::Tensor Ub_v_; - /// Set Ua_, Ub_, Ua_t_, and Ub_t_ to identity void set_U_to_identity(); @@ -211,15 +185,9 @@ class SemiCanonical { /// Builds unitary matrices used to diagonalize diagonal blocks of Fock void build_transformation_matrices(const bool& semi); - /// Fill ambit::Tensor Ua_c_ (Ub_c_) using std::shared_ptr Ua_ (Ub_) - void fill_Ucore(const std::shared_ptr& U, ambit::Tensor& Ut); - /// Fill ambit::Tensor Ua_t_ (Ub_t_) using std::shared_ptr Ua_ (Ub_) void fill_Uactv(const std::shared_ptr& U, ambit::Tensor& Ut); - /// Fill ambit::Tensor Ua_v_ (Ub_v_) using std::shared_ptr Ua_ (Ub_) - void fill_Uvirt(const std::shared_ptr& U, ambit::Tensor& Ut); - /// Successfully fix the orbital ordering and phases bool fix_orbital_success_; }; diff --git a/forte/proc/dsrg.py b/forte/proc/dsrg.py index 43ac44bb6..1cb6c3e67 100644 --- a/forte/proc/dsrg.py +++ b/forte/proc/dsrg.py @@ -249,7 +249,7 @@ def compute_energy(self): if not self.Heff_implemented: self.relax_maxiter = 0 - if self.options.get_bool("FULL_HBAR") and self.solver_type in ["MRDSRG","SA-MRDSRG","SA_MRDSRG"]: + if self.options.get_bool("FULL_HBAR") and self.solver_type in ["MRDSRG","SA-MRDSRG","SA_MRDSRG"] and self.relax_maxiter == 0: psi4.core.print_out("\n =>** Saving Full Hbar (unrelaxed) **<=\n") Hbar1, Hbar2 = self.dsrg_solver.compute_Heff_full() np.savez("save_Hbar", **Hbar1, **Hbar2) @@ -267,7 +267,7 @@ def compute_energy(self): del Mbar0, Mbar1, Mbar2 - if self.options.get_bool("FULL_HBAR_DEGNO") and self.solver_type in ["SA-MRDSRG","SA_MRDSRG","MRDSRG"]: + if self.options.get_bool("FULL_HBAR_DEGNO") and self.solver_type in ["MRDSRG","SA-MRDSRG","SA_MRDSRG"] and self.relax_maxiter == 0: psi4.core.print_out("\n =>** Saving Full Hbar in de-normal-ordered basis (unrelaxed) **<=\n") Hbar1, Hbar2 = self.dsrg_solver.compute_Heff_full_degno() np.savez("save_Hbar_degno", **Hbar1, **Hbar2) @@ -283,16 +283,14 @@ def compute_energy(self): # However, the ForteIntegrals object and the dipole integrals always refer to the current semi-canonical basis. # so to compute the dipole moment correctly, we need to make the RDMs and orbital basis consistent - if self.options.get_bool("FULL_HBAR") and n == self.relax_maxiter - 1: - psi4.core.print_out("\n =>** Saving Full Hbar (relax) **<=\n") - Heff = self.dsrg_solver.compute_Heff_full() - Heff_dict = forte.Heff_dict(Heff) - np.savez("save_Hbar", **Heff_dict) + if self.options.get_bool("FULL_HBAR") and self.solver_type in ["MRDSRG","SA-MRDSRG","SA_MRDSRG"] and n == self.relax_maxiter - 1: + psi4.core.print_out("\n =>** Saving Full Hbar (relaxed) **<=\n") + Hbar1, Hbar2 = self.dsrg_solver.compute_Heff_full() + np.savez("save_Hbar", **Hbar1, **Hbar2) if self.solver_type not in ["MRDSRG_SO", "MRDSRG-SO"]: psi4.core.print_out("\n =>** Getting dipole integral **<=\n") Mbar0 = self.dsrg_solver.compute_Mbar0_full() - print(Mbar0) np.save("Mbar0", Mbar0) Mbar1 = self.dsrg_solver.compute_Mbar1_full() Mbar2 = self.dsrg_solver.compute_Mbar2_full() @@ -302,6 +300,11 @@ def compute_energy(self): np.savez(f"Mbar2_{i}", **Mbar2[i]) del Mbar0, Mbar1, Mbar2 + + if self.options.get_bool("FULL_HBAR_DEGNO") and self.solver_type in ["MRDSRG","SA-MRDSRG","SA_MRDSRG"] and n == self.relax_maxiter - 1: + psi4.core.print_out("\n =>** Saving Full Hbar in de-normal-ordered basis (relaxed) **<=\n") + Hbar1, Hbar2 = self.dsrg_solver.compute_Heff_full_degno() + np.savez("save_Hbar_degno", **Hbar1, **Hbar2) ints_dressed = self.dsrg_solver.compute_Heff_actv() if self.fno_pt2_Heff_shift is not None: From 39d5c52566b196884ce5ad048c24f51c18669353 Mon Sep 17 00:00:00 2001 From: Brian Zhao Date: Mon, 2 Dec 2024 21:22:54 -0500 Subject: [PATCH 44/55] Re enable spinorbital --- forte/api/forte_python_module.cc | 6 ++++-- forte/proc/dsrg.py | 8 +++++--- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/forte/api/forte_python_module.cc b/forte/api/forte_python_module.cc index ce3bfc314..7be3dc838 100644 --- a/forte/api/forte_python_module.cc +++ b/forte/api/forte_python_module.cc @@ -358,8 +358,10 @@ PYBIND11_MODULE(_forte, m) { .def("compute_energy", &MRDSRG_SO::compute_energy, "Compute DSRG energy") .def("compute_Heff_actv", &MRDSRG_SO::compute_Heff_actv, "Return the DSRG dressed ActiveSpaceIntegrals") - .def("compute_Heff_full", &MRDSRG_SO::compute_Heff_full, - "Return full transformed Hamiltonian") + .def("compute_Heff_full", [](MRDSRG_SO& self) { + const auto Heff = self.compute_Heff_full(); + return py::make_tuple(blockedtensor_to_np(Heff.at(0)), blockedtensor_to_np(Heff.at(1))); + }) .def("get_gamma1", &MRDSRG_SO::get_gamma1, "Return the gamma1 tensor") .def("get_eta1", &MRDSRG_SO::get_eta1, "Return the eta1 tensor") .def("get_lambda2", &MRDSRG_SO::get_lambda2, "Return the lambda2 tensor") diff --git a/forte/proc/dsrg.py b/forte/proc/dsrg.py index 1cb6c3e67..a3dfd1f37 100644 --- a/forte/proc/dsrg.py +++ b/forte/proc/dsrg.py @@ -249,7 +249,8 @@ def compute_energy(self): if not self.Heff_implemented: self.relax_maxiter = 0 - if self.options.get_bool("FULL_HBAR") and self.solver_type in ["MRDSRG","SA-MRDSRG","SA_MRDSRG"] and self.relax_maxiter == 0: + if self.options.get_bool("FULL_HBAR") and self.solver_type in ["MRDSRG","SA-MRDSRG","SA_MRDSRG","MRDSRG_SO", "MRDSRG-SO"] \ + and self.relax_maxiter == 0: psi4.core.print_out("\n =>** Saving Full Hbar (unrelaxed) **<=\n") Hbar1, Hbar2 = self.dsrg_solver.compute_Heff_full() np.savez("save_Hbar", **Hbar1, **Hbar2) @@ -283,12 +284,13 @@ def compute_energy(self): # However, the ForteIntegrals object and the dipole integrals always refer to the current semi-canonical basis. # so to compute the dipole moment correctly, we need to make the RDMs and orbital basis consistent - if self.options.get_bool("FULL_HBAR") and self.solver_type in ["MRDSRG","SA-MRDSRG","SA_MRDSRG"] and n == self.relax_maxiter - 1: + if self.options.get_bool("FULL_HBAR") and self.solver_type in ["MRDSRG","SA-MRDSRG","SA_MRDSRG","MRDSRG_SO","MRDSRG-SO"] \ + and n == self.relax_maxiter - 1: psi4.core.print_out("\n =>** Saving Full Hbar (relaxed) **<=\n") Hbar1, Hbar2 = self.dsrg_solver.compute_Heff_full() np.savez("save_Hbar", **Hbar1, **Hbar2) - if self.solver_type not in ["MRDSRG_SO", "MRDSRG-SO"]: + if self.solver_type in ["MRDSRG"]: psi4.core.print_out("\n =>** Getting dipole integral **<=\n") Mbar0 = self.dsrg_solver.compute_Mbar0_full() np.save("Mbar0", Mbar0) From bfc5ff55ae7bdf5f678d501161f0dbfcdcdbe40f Mon Sep 17 00:00:00 2001 From: Brian Zhao Date: Mon, 2 Dec 2024 21:27:08 -0500 Subject: [PATCH 45/55] Re-enable SO cumulants --- forte/api/forte_python_module.cc | 20 ++++++++++++++++---- forte/proc/dsrg.py | 4 ++-- 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/forte/api/forte_python_module.cc b/forte/api/forte_python_module.cc index 7be3dc838..bf3bb24d4 100644 --- a/forte/api/forte_python_module.cc +++ b/forte/api/forte_python_module.cc @@ -362,10 +362,22 @@ PYBIND11_MODULE(_forte, m) { const auto Heff = self.compute_Heff_full(); return py::make_tuple(blockedtensor_to_np(Heff.at(0)), blockedtensor_to_np(Heff.at(1))); }) - .def("get_gamma1", &MRDSRG_SO::get_gamma1, "Return the gamma1 tensor") - .def("get_eta1", &MRDSRG_SO::get_eta1, "Return the eta1 tensor") - .def("get_lambda2", &MRDSRG_SO::get_lambda2, "Return the lambda2 tensor") - .def("get_lambda3", &MRDSRG_SO::get_lambda3, "Return the lambda3 tensor"); + .def("get_gamma1", [](MRDSRG_SO& self) { + const auto gamma1 = self.get_gamma1(); + return blockedtensor_to_np(gamma1); + }) + .def("get_eta1", [](MRDSRG_SO& self) { + const auto eta1 = self.get_eta1(); + return blockedtensor_to_np(eta1); + }) + .def("get_lambda2", [](MRDSRG_SO& self) { + const auto lambda2 = self.get_lambda2(); + return blockedtensor_to_np(lambda2); + }) + .def("get_lambda3", [](MRDSRG_SO& self) { + const auto lambda3 = self.get_lambda3(); + return blockedtensor_to_np(lambda3); + }); // export DSRG_MRPT spin-adapted code py::class_(m, "DSRG_MRPT") diff --git a/forte/proc/dsrg.py b/forte/proc/dsrg.py index a3dfd1f37..8453bdb51 100644 --- a/forte/proc/dsrg.py +++ b/forte/proc/dsrg.py @@ -437,7 +437,7 @@ def compute_energy(self): psi4.core.print_out(f"\n\n DSRG-MRPT2 FNO energy correction: {self.fno_pt2_energy_shift:20.15f}") psi4.core.print_out(f"\n DSRG-MRPT2 FNO corrected energy: {e_dsrg:20.15f}") - if self.options.get_bool("FULL_HBAR") and self.solver_type in ["MRDSRG"]: + if self.options.get_bool("FULL_HBAR") and self.solver_type in ["MRDSRG","MRDSRG_SO","MRDSRG-SO"]: if self.relax_maxiter != 0: self.rdms = self.active_space_solver.compute_average_rdms( self.state_weights_map, self.max_rdm_level, self.rdm_type @@ -464,7 +464,7 @@ def compute_energy(self): del gamma1, eta1, lambda2, lambda3 - if self.options.get_str("FOURPDC") != "ZERO": + if self.options.get_str("FOURPDC") != "ZERO" and self.solver_type in ["MRDSRG"]: psi4.core.print_out("\n =>** Getting lambda4 **<=\n") lambda4 = self.dsrg_solver.get_lambda4() np.savez("save_lambda4", **lambda4) From eb2c3f8762f86390572f601a6e313746bb6d7396 Mon Sep 17 00:00:00 2001 From: Brian Zhao Date: Tue, 3 Dec 2024 14:31:20 -0500 Subject: [PATCH 46/55] Export scalar energy for de gno --- forte/api/forte_python_module.cc | 4 ++-- forte/mrdsrg-spin-adapted/sadsrg.cc | 4 ++-- forte/mrdsrg-spin-adapted/sadsrg.h | 2 +- forte/mrdsrg-spin-integrated/master_mrdsrg.cc | 4 ++-- forte/mrdsrg-spin-integrated/master_mrdsrg.h | 2 +- forte/proc/dsrg.py | 8 ++++---- 6 files changed, 12 insertions(+), 12 deletions(-) diff --git a/forte/api/forte_python_module.cc b/forte/api/forte_python_module.cc index bf3bb24d4..a6013654d 100644 --- a/forte/api/forte_python_module.cc +++ b/forte/api/forte_python_module.cc @@ -255,7 +255,7 @@ PYBIND11_MODULE(_forte, m) { }) .def("compute_Heff_full_degno", [](MASTER_DSRG& self) { const auto Heff = self.compute_Heff_full_degno(); - return py::make_tuple(blockedtensor_to_np(Heff.at(0)), blockedtensor_to_np(Heff.at(1))); + return py::make_tuple(Heff.first, blockedtensor_to_np(Heff.second.at(0)), blockedtensor_to_np(Heff.second.at(1))); }) .def("compute_Mbar0_full", &MASTER_DSRG::compute_Mbar0_full, "Return full transformed zero-body dipole integrals") @@ -331,7 +331,7 @@ PYBIND11_MODULE(_forte, m) { }) .def("compute_Heff_full_degno", [](SADSRG& self) { const auto Heff = self.compute_Heff_full_degno(); - return py::make_tuple(blockedtensor_to_np(Heff.at(0)), blockedtensor_to_np(Heff.at(1))); + return py::make_tuple(Heff.first, blockedtensor_to_np(Heff.second.at(0)), blockedtensor_to_np(Heff.second.at(1))); }) .def("compute_mp_eff_actv", &SADSRG::compute_mp_eff_actv, "Return the DSRG dressed ActiveMultipoleIntegrals") diff --git a/forte/mrdsrg-spin-adapted/sadsrg.cc b/forte/mrdsrg-spin-adapted/sadsrg.cc index 7c09c75c1..3683e0243 100644 --- a/forte/mrdsrg-spin-adapted/sadsrg.cc +++ b/forte/mrdsrg-spin-adapted/sadsrg.cc @@ -479,7 +479,7 @@ std::vector SADSRG::compute_Heff_full() { return Heff; } -std::vector SADSRG::compute_Heff_full_degno() { +std::pair> SADSRG::compute_Heff_full_degno() { double Edsrg = Eref_ + Hbar0_; if (foptions_->get_bool("FORM_HBAR3")) { throw psi::PSIEXCEPTION("FORM_HBAR3 is not implemented for full Hamiltonian."); @@ -487,7 +487,7 @@ std::vector SADSRG::compute_Heff_full_degno() { deGNO_ints_full("Hamiltonian", Edsrg, Hbar1_, Hbar2_); } std::vector Heff = {Hbar1_, Hbar2_}; - return Heff; + return std::make_pair(Edsrg, Heff); } std::shared_ptr SADSRG::compute_mp_eff_actv() { diff --git a/forte/mrdsrg-spin-adapted/sadsrg.h b/forte/mrdsrg-spin-adapted/sadsrg.h index 86bf68f8c..51b389fb7 100644 --- a/forte/mrdsrg-spin-adapted/sadsrg.h +++ b/forte/mrdsrg-spin-adapted/sadsrg.h @@ -63,7 +63,7 @@ class SADSRG : public DynamicCorrelationSolver { /// Compute DSRG transformed Hamiltonian std::shared_ptr compute_Heff_actv() override; std::vector compute_Heff_full(); - std::vector compute_Heff_full_degno(); + std::pair> compute_Heff_full_degno(); /// Compute DSRG transformed multipole integrals std::shared_ptr compute_mp_eff_actv() override; diff --git a/forte/mrdsrg-spin-integrated/master_mrdsrg.cc b/forte/mrdsrg-spin-integrated/master_mrdsrg.cc index b3be3ac7f..2e0c66c36 100644 --- a/forte/mrdsrg-spin-integrated/master_mrdsrg.cc +++ b/forte/mrdsrg-spin-integrated/master_mrdsrg.cc @@ -2348,7 +2348,7 @@ std::vector MASTER_DSRG::compute_Heff_full() { return Heff; } -std::vector MASTER_DSRG::compute_Heff_full_degno() { +std::pair> MASTER_DSRG::compute_Heff_full_degno() { double Edsrg = Eref_ + Hbar0_; if (foptions_->get_bool("FORM_HBAR3")) { throw psi::PSIEXCEPTION("FORM_HBAR3 is not implemented for full Hamiltonian."); @@ -2356,7 +2356,7 @@ std::vector MASTER_DSRG::compute_Heff_full_degno() { deGNO_ints_full("Hamiltonian", Edsrg, Hbar1_, Hbar2_); } std::vector Heff = {Hbar1_, Hbar2_}; - return Heff; + return std::make_pair(Edsrg, Heff); } } // namespace forte diff --git a/forte/mrdsrg-spin-integrated/master_mrdsrg.h b/forte/mrdsrg-spin-integrated/master_mrdsrg.h index ac2f2d062..c45bfe11d 100644 --- a/forte/mrdsrg-spin-integrated/master_mrdsrg.h +++ b/forte/mrdsrg-spin-integrated/master_mrdsrg.h @@ -51,7 +51,7 @@ class MASTER_DSRG : public DynamicCorrelationSolver { std::vector compute_Heff_full(); /// Compute DSRG full transformed Hamiltonian in the de-normal-ordered basis - std::vector compute_Heff_full_degno(); + std::pair> compute_Heff_full_degno(); /// Compute DSRG transformed dipole integral std::vector compute_Mbar0_full() { return Mbar0_full_; } diff --git a/forte/proc/dsrg.py b/forte/proc/dsrg.py index 8453bdb51..e30b7f71f 100644 --- a/forte/proc/dsrg.py +++ b/forte/proc/dsrg.py @@ -270,8 +270,8 @@ def compute_energy(self): if self.options.get_bool("FULL_HBAR_DEGNO") and self.solver_type in ["MRDSRG","SA-MRDSRG","SA_MRDSRG"] and self.relax_maxiter == 0: psi4.core.print_out("\n =>** Saving Full Hbar in de-normal-ordered basis (unrelaxed) **<=\n") - Hbar1, Hbar2 = self.dsrg_solver.compute_Heff_full_degno() - np.savez("save_Hbar_degno", **Hbar1, **Hbar2) + scalar, Hbar1, Hbar2 = self.dsrg_solver.compute_Heff_full_degno() + np.savez("save_Hbar_degno", scalar=scalar, **Hbar1, **Hbar2) # Reference relaxation procedure @@ -305,8 +305,8 @@ def compute_energy(self): if self.options.get_bool("FULL_HBAR_DEGNO") and self.solver_type in ["MRDSRG","SA-MRDSRG","SA_MRDSRG"] and n == self.relax_maxiter - 1: psi4.core.print_out("\n =>** Saving Full Hbar in de-normal-ordered basis (relaxed) **<=\n") - Hbar1, Hbar2 = self.dsrg_solver.compute_Heff_full_degno() - np.savez("save_Hbar_degno", **Hbar1, **Hbar2) + scalar, Hbar1, Hbar2 = self.dsrg_solver.compute_Heff_full_degno() + np.savez("save_Hbar_degno", scalar=scalar, **Hbar1, **Hbar2) ints_dressed = self.dsrg_solver.compute_Heff_actv() if self.fno_pt2_Heff_shift is not None: From 50ba4347f010f16b49e5e5ae46fc26920cc4c7c3 Mon Sep 17 00:00:00 2001 From: Brian Zhao Date: Thu, 5 Dec 2024 16:28:45 -0500 Subject: [PATCH 47/55] Mbar option --- forte/mrdsrg-spin-integrated/mrdsrg_nonpt.cc | 29 ++++++------- forte/options.yaml | 8 +++- forte/proc/dsrg.py | 44 ++++++++++---------- 3 files changed, 43 insertions(+), 38 deletions(-) diff --git a/forte/mrdsrg-spin-integrated/mrdsrg_nonpt.cc b/forte/mrdsrg-spin-integrated/mrdsrg_nonpt.cc index 052bfeccd..dc43f2c66 100644 --- a/forte/mrdsrg-spin-integrated/mrdsrg_nonpt.cc +++ b/forte/mrdsrg-spin-integrated/mrdsrg_nonpt.cc @@ -835,20 +835,21 @@ double MRDSRG::compute_energy_ldsrg2() { if (foptions_->get_bool("FULL_HBAR") || foptions_->get_bool("FULL_HBAR_DEGNO")) { double rsc_conv = rsc_thres; compute_hbar(rsc_conv); - if (foptions_->get_bool("FULL_HBAR")){ - auto mpints = std::make_shared(ints_, mo_space_info_); - // bare dipoles - std::vector M1; - std::vector dp_dirs{"X", "Y", "Z"}; - for (int z = 0; z < 3; ++z) { - std::string name = "DIPOLE " + dp_dirs[z]; - ambit::BlockedTensor m1 = BTF_->build(tensor_type_, name, spin_cases({"gg"})); - m1.iterate([&](const std::vector& i, const std::vector&, - double& value) { value = mpints->dp_ints_corr(z, i[0], i[1]); }); - M1.push_back(m1); - } - transform_one_body(M1); - } + } + + if (foptions_->get_bool("FULL_MBAR")){ + auto mpints = std::make_shared(ints_, mo_space_info_); + // bare dipoles + std::vector M1; + std::vector dp_dirs{"X", "Y", "Z"}; + for (int z = 0; z < 3; ++z) { + std::string name = "DIPOLE " + dp_dirs[z]; + ambit::BlockedTensor m1 = BTF_->build(tensor_type_, name, spin_cases({"gg"})); + m1.iterate([&](const std::vector& i, const std::vector&, + double& value) { value = mpints->dp_ints_corr(z, i[0], i[1]); }); + M1.push_back(m1); + } + transform_one_body(M1); } final.stop(); diff --git a/forte/options.yaml b/forte/options.yaml index e388b618a..48f47c83b 100644 --- a/forte/options.yaml +++ b/forte/options.yaml @@ -1117,11 +1117,15 @@ DSRG: FULL_HBAR: type: bool default: False - help: "Form the full DSRG effective Hamiltonian." + help: "Save the full DSRG effective Hamiltonian to disk." + FULL_MBAR: + type: bool + default: False + help: "Save the full DSRG effective dipole integrals to disk." FULL_HBAR_DEGNO: type: bool default: False - help: "Form the full DSRG effective Hamiltonian normal ordered w.r.t. the true vacuum." + help: "Save the full DSRG effective Hamiltonian normal ordered w.r.t. the true vacuum to disk." DO_WICKED: type: bool default: False diff --git a/forte/proc/dsrg.py b/forte/proc/dsrg.py index e30b7f71f..c52871ee9 100644 --- a/forte/proc/dsrg.py +++ b/forte/proc/dsrg.py @@ -255,18 +255,18 @@ def compute_energy(self): Hbar1, Hbar2 = self.dsrg_solver.compute_Heff_full() np.savez("save_Hbar", **Hbar1, **Hbar2) - if self.solver_type in ["MRDSRG"]: - psi4.core.print_out("\n =>** Getting dipole integral **<=\n") - Mbar0 = self.dsrg_solver.compute_Mbar0_full() - np.save("Mbar0", Mbar0) - Mbar1 = self.dsrg_solver.compute_Mbar1_full() - Mbar2 = self.dsrg_solver.compute_Mbar2_full() - - for i in range(3): - np.savez(f"Mbar1_{i}", **Mbar1[i]) - np.savez(f"Mbar2_{i}", **Mbar2[i]) - - del Mbar0, Mbar1, Mbar2 + if self.options.get_bool("FULL_MBAR") and self.solver_type in ["MRDSRG"]: + psi4.core.print_out("\n =>** Getting dipole integral (unrelaxed) **<=\n") + Mbar0 = self.dsrg_solver.compute_Mbar0_full() + np.save("Mbar0", Mbar0) + Mbar1 = self.dsrg_solver.compute_Mbar1_full() + Mbar2 = self.dsrg_solver.compute_Mbar2_full() + + for i in range(3): + np.savez(f"Mbar1_{i}", **Mbar1[i]) + np.savez(f"Mbar2_{i}", **Mbar2[i]) + + del Mbar0, Mbar1, Mbar2 if self.options.get_bool("FULL_HBAR_DEGNO") and self.solver_type in ["MRDSRG","SA-MRDSRG","SA_MRDSRG"] and self.relax_maxiter == 0: psi4.core.print_out("\n =>** Saving Full Hbar in de-normal-ordered basis (unrelaxed) **<=\n") @@ -290,18 +290,18 @@ def compute_energy(self): Hbar1, Hbar2 = self.dsrg_solver.compute_Heff_full() np.savez("save_Hbar", **Hbar1, **Hbar2) - if self.solver_type in ["MRDSRG"]: - psi4.core.print_out("\n =>** Getting dipole integral **<=\n") - Mbar0 = self.dsrg_solver.compute_Mbar0_full() - np.save("Mbar0", Mbar0) - Mbar1 = self.dsrg_solver.compute_Mbar1_full() - Mbar2 = self.dsrg_solver.compute_Mbar2_full() + if self.options.get_bool("FULL_MBAR") and self.solver_type in ["MRDSRG"]: + psi4.core.print_out("\n =>** Getting dipole integral (relaxed) **<=\n") + Mbar0 = self.dsrg_solver.compute_Mbar0_full() + np.save("Mbar0", Mbar0) + Mbar1 = self.dsrg_solver.compute_Mbar1_full() + Mbar2 = self.dsrg_solver.compute_Mbar2_full() - for i in range(3): - np.savez(f"Mbar1_{i}", **Mbar1[i]) - np.savez(f"Mbar2_{i}", **Mbar2[i]) + for i in range(3): + np.savez(f"Mbar1_{i}", **Mbar1[i]) + np.savez(f"Mbar2_{i}", **Mbar2[i]) - del Mbar0, Mbar1, Mbar2 + del Mbar0, Mbar1, Mbar2 if self.options.get_bool("FULL_HBAR_DEGNO") and self.solver_type in ["MRDSRG","SA-MRDSRG","SA_MRDSRG"] and n == self.relax_maxiter - 1: psi4.core.print_out("\n =>** Saving Full Hbar in de-normal-ordered basis (relaxed) **<=\n") From 8d6de79e617303064b1d9e56a2cca1435f9b762c Mon Sep 17 00:00:00 2001 From: Shuhang Li Date: Mon, 9 Dec 2024 14:51:17 -0500 Subject: [PATCH 48/55] override compute_Heff_full --- forte/mrdsrg-spin-integrated/master_mrdsrg.cc | 5 ----- forte/mrdsrg-spin-integrated/master_mrdsrg.h | 4 +++- forte/mrdsrg-spin-integrated/mrdsrg.h | 3 +-- forte/mrdsrg-spin-integrated/mrdsrg_nonpt.cc | 12 +++++++----- 4 files changed, 11 insertions(+), 13 deletions(-) diff --git a/forte/mrdsrg-spin-integrated/master_mrdsrg.cc b/forte/mrdsrg-spin-integrated/master_mrdsrg.cc index 2e0c66c36..a450eed55 100644 --- a/forte/mrdsrg-spin-integrated/master_mrdsrg.cc +++ b/forte/mrdsrg-spin-integrated/master_mrdsrg.cc @@ -2343,11 +2343,6 @@ std::vector MASTER_DSRG::re_two_labels() { return labels; } -std::vector MASTER_DSRG::compute_Heff_full() { - std::vector Heff = {Hbar1_, Hbar2_}; - return Heff; -} - std::pair> MASTER_DSRG::compute_Heff_full_degno() { double Edsrg = Eref_ + Hbar0_; if (foptions_->get_bool("FORM_HBAR3")) { diff --git a/forte/mrdsrg-spin-integrated/master_mrdsrg.h b/forte/mrdsrg-spin-integrated/master_mrdsrg.h index c45bfe11d..aa85c720c 100644 --- a/forte/mrdsrg-spin-integrated/master_mrdsrg.h +++ b/forte/mrdsrg-spin-integrated/master_mrdsrg.h @@ -48,7 +48,9 @@ class MASTER_DSRG : public DynamicCorrelationSolver { virtual std::shared_ptr compute_Heff_actv(); /// Compute DSRG full transformed Hamiltonian - std::vector compute_Heff_full(); + virtual std::vector compute_Heff_full() { + throw std::runtime_error("Child class should override this function"); + }; /// Compute DSRG full transformed Hamiltonian in the de-normal-ordered basis std::pair> compute_Heff_full_degno(); diff --git a/forte/mrdsrg-spin-integrated/mrdsrg.h b/forte/mrdsrg-spin-integrated/mrdsrg.h index 9bcaa767c..680f45c69 100644 --- a/forte/mrdsrg-spin-integrated/mrdsrg.h +++ b/forte/mrdsrg-spin-integrated/mrdsrg.h @@ -353,8 +353,7 @@ class MRDSRG : public MASTER_DSRG { /// Compute MR-LDSRG(2) double compute_energy_ldsrg2(); - /// Compute EOM-LDSRG(2) - // void compute_eom(); + std::vector compute_Heff_full() override; /// Zeroth-order Hamiltonian ambit::BlockedTensor H0th_; diff --git a/forte/mrdsrg-spin-integrated/mrdsrg_nonpt.cc b/forte/mrdsrg-spin-integrated/mrdsrg_nonpt.cc index dc43f2c66..c9c681dba 100644 --- a/forte/mrdsrg-spin-integrated/mrdsrg_nonpt.cc +++ b/forte/mrdsrg-spin-integrated/mrdsrg_nonpt.cc @@ -831,11 +831,6 @@ double MRDSRG::compute_energy_ldsrg2() { // dump amplitudes to file dump_amps_to_disk(); - - if (foptions_->get_bool("FULL_HBAR") || foptions_->get_bool("FULL_HBAR_DEGNO")) { - double rsc_conv = rsc_thres; - compute_hbar(rsc_conv); - } if (foptions_->get_bool("FULL_MBAR")){ auto mpints = std::make_shared(ints_, mo_space_info_); @@ -858,6 +853,13 @@ double MRDSRG::compute_energy_ldsrg2() { return Ecorr; } +std::vector MRDSRG::compute_Heff_full() { + double rsc_thres = foptions_->get_double("DSRG_RSC_THRESHOLD"); + compute_hbar(rsc_thres); + std::vector Heff = {Hbar1_, Hbar2_}; + return Heff; +} + void MRDSRG::transform_one_body(const std::vector& oetens) { int n_tensors = oetens.size(); Mbar0_full_ = std::vector(n_tensors, 0.0); From e35bf569d4affd9eaf2231749caedfeeeb79e885 Mon Sep 17 00:00:00 2001 From: Shuhang Li Date: Tue, 10 Dec 2024 12:00:05 -0500 Subject: [PATCH 49/55] update_Hbar WIP --- forte/api/forte_python_module.cc | 13 ++-- forte/mrdsrg-spin-integrated/master_mrdsrg.cc | 65 +++++++++++++++++++ forte/mrdsrg-spin-integrated/master_mrdsrg.h | 17 ++++- forte/mrdsrg-spin-integrated/mrdsrg.h | 3 +- forte/mrdsrg-spin-integrated/mrdsrg_nonpt.cc | 28 ++++++-- forte/proc/dsrg.py | 46 ++++++++----- 6 files changed, 143 insertions(+), 29 deletions(-) diff --git a/forte/api/forte_python_module.cc b/forte/api/forte_python_module.cc index a6013654d..165fa2c77 100644 --- a/forte/api/forte_python_module.cc +++ b/forte/api/forte_python_module.cc @@ -249,9 +249,13 @@ PYBIND11_MODULE(_forte, m) { .def("compute_gradient", &MASTER_DSRG::compute_gradient, "Compute the DSRG gradient") .def("compute_Heff_actv", &MASTER_DSRG::compute_Heff_actv, "Return the DSRG dressed ActiveSpaceIntegrals") - .def("compute_Heff_full", [](MASTER_DSRG& self) { - const auto Heff = self.compute_Heff_full(); - return py::make_tuple(blockedtensor_to_np(Heff.at(0)), blockedtensor_to_np(Heff.at(1))); + .def("save_Heff_full", [](MASTER_DSRG& self) { + const auto Heff = self.save_Heff_full(); + return py::make_tuple(Heff.first, Heff.second.at(0), Heff.second.at(1)); + }) + .def("update_Heff_full", [](MASTER_DSRG& self, double H0, BlockedTensor H1, BlockedTensor H2, std::shared_ptr rdms) { + const auto Heff = self.update_Heff_full(H0, H1, H2, rdms); + return py::make_tuple(Heff.first, blockedtensor_to_np(Heff.second.at(0)), blockedtensor_to_np(Heff.second.at(1))); }) .def("compute_Heff_full_degno", [](MASTER_DSRG& self) { const auto Heff = self.compute_Heff_full_degno(); @@ -318,7 +322,8 @@ PYBIND11_MODULE(_forte, m) { .def("set_ci_vectors", &MASTER_DSRG::set_ci_vectors, "Set the CI eigenvector for DSRG-MRPT2 analytic gradients") .def("set_active_space_solver", &MASTER_DSRG::set_active_space_solver, - "Set the shared pointer for ActiveSpaceSolver"); + "Set the shared pointer for ActiveSpaceSolver") + .def("set_rdms", &MASTER_DSRG::set_rdms, "Set external RDMs (dangerous, use with caution)"); // export SADSRG py::class_(m, "SADSRG") diff --git a/forte/mrdsrg-spin-integrated/master_mrdsrg.cc b/forte/mrdsrg-spin-integrated/master_mrdsrg.cc index a450eed55..b92886f27 100644 --- a/forte/mrdsrg-spin-integrated/master_mrdsrg.cc +++ b/forte/mrdsrg-spin-integrated/master_mrdsrg.cc @@ -736,6 +736,57 @@ void MASTER_DSRG::deGNO_ints_full(const std::string& name, double& H0, BlockedTe outfile->Printf("Done. Timing %8.3f s", t1.get()); } +void MASTER_DSRG::GNO_ints_full(const std::string& name, double& H0, BlockedTensor& H1, + BlockedTensor& H2, const std::shared_ptr rdms) { + print_h2("Normal-Order Full DSRG Transformed " + name); + + // compute scalar + local_timer t0; + outfile->Printf("\n %-40s ... ", "Computing the scalar term"); + + auto L1h = BTF_->build(tensor_type_, "L1h", spin_cases({"hh"})); + L1h.block("aa")("pq") = rdms->g1a()("pq"); + L1h.block("AA")("pq") = rdms->g1b()("pq"); + L1h.block("cc").iterate( + [&](const std::vector& i, double& value) { value = i[0] == i[1] ? 1.0 : 0.0; }); + L1h.block("CC").iterate( + [&](const std::vector& i, double& value) { value = i[0] == i[1] ? 1.0 : 0.0; }); + + // compute 1-body term + local_timer t1; + outfile->Printf("\n %-40s ... ", "Computing the 1-body term"); + + H1["pq"] += H2["piqj"] * L1h["ji"]; + H1["pq"] += H2["pIqJ"] * L1h["JI"]; + H1["PQ"] += H2["iPjQ"] * L1h["ji"]; + H1["PQ"] += H2["PIQJ"] * L1h["JI"]; + outfile->Printf("Done. Timing %8.3f s", t1.get()); + + // scalar from H1 + double scalar1 = 0.0; + scalar1 += H1["ji"] * L1h["ij"]; + scalar1 += H1["JI"] * L1h["IJ"]; + + // scalar from H2 + double scalar2 = 0.0; + scalar2 -= 0.5 * L1h["ij"] * H2["jlik"] * L1h["kl"]; + scalar2 -= 0.5 * L1h["IJ"] * H2["JLIK"] * L1h["KL"]; + scalar2 -= L1h["ij"] * H2["jLiK"] * L1h["KL"]; + + auto Lambda2 = BTF_->build(tensor_type_, "Lambda2", spin_cases({"aaaa"})); + + Lambda2.block("aaaa")("pqrs") = rdms->L2aa()("pqrs"); + Lambda2.block("aAaA")("pqrs") = rdms->L2ab()("pqrs"); + Lambda2.block("AAAA")("pqrs") = rdms->L2bb()("pqrs"); + + scalar2 += 0.25 * H2["xyuv"] * Lambda2["uvxy"]; + scalar2 += 0.25 * H2["XYUV"] * Lambda2["UVXY"]; + scalar2 += H2["xYuV"] * Lambda2["uVxY"]; + + H0 += scalar1 + scalar2; + outfile->Printf("Done. Timing %8.3f s", t0.get()); +} + void MASTER_DSRG::fill_three_index_ints(ambit::BlockedTensor T) { const auto& block_labels = T.block_labels(); @@ -2354,4 +2405,18 @@ std::pair> MASTER_DSRG::compute_Heff_full_deg return std::make_pair(Edsrg, Heff); } +std::pair> MASTER_DSRG::save_Heff_full() { + double Edsrg = Eref_ + Hbar0_; + std::vector Heff = {Hbar1_, Hbar2_}; + return std::make_pair(Edsrg, Heff); +} + +std::pair> MASTER_DSRG::update_Heff_full(double& H0, BlockedTensor& H1, + BlockedTensor& H2, std::shared_ptr rdms) { + deGNO_ints_full("Hamiltonian", H0, H1, H2); // De-normal ordering based on original RDMs. + GNO_ints_full("Hamiltonian", H0, H1, H2, rdms); // Re-normal ordering based on new RDMs. + std::vector Heff = {H1, H2}; + return std::make_pair(H0, Heff); +} + } // namespace forte diff --git a/forte/mrdsrg-spin-integrated/master_mrdsrg.h b/forte/mrdsrg-spin-integrated/master_mrdsrg.h index aa85c720c..3fb073abd 100644 --- a/forte/mrdsrg-spin-integrated/master_mrdsrg.h +++ b/forte/mrdsrg-spin-integrated/master_mrdsrg.h @@ -47,11 +47,18 @@ class MASTER_DSRG : public DynamicCorrelationSolver { /// Compute DSRG transformed Hamiltonian virtual std::shared_ptr compute_Heff_actv(); - /// Compute DSRG full transformed Hamiltonian - virtual std::vector compute_Heff_full() { + /// Modify the rdms_ member of the parent (base) class. Only used in EOM-DSRG. + virtual void set_rdms(std::shared_ptr rdms) { throw std::runtime_error("Child class should override this function"); }; + /// Save DSRG full transformed Hamiltonian + std::pair> save_Heff_full(); + + /// Update DSRG full transformed Hamiltonian + std::pair> update_Heff_full(double& H0, BlockedTensor& H1, + BlockedTensor& H2, std::shared_ptr rdms); + /// Compute DSRG full transformed Hamiltonian in the de-normal-ordered basis std::pair> compute_Heff_full_degno(); @@ -361,6 +368,12 @@ class MASTER_DSRG : public DynamicCorrelationSolver { */ void deGNO_ints_full(const std::string& name, double& H0, BlockedTensor& H1, BlockedTensor& H2); + /** + * Re-Normal-order the full DSRG transformed Hamiltonian + * This will change H0, H1 and H2!!! + */ + void GNO_ints_full(const std::string& name, double& H0, BlockedTensor& H1, BlockedTensor& H2, const std::shared_ptr rdms); + /** * De-normal-order the T1 and T2 amplitudes and return the effective T1 * T1eff = T1 - T2["ivau"] * D1["uv"] diff --git a/forte/mrdsrg-spin-integrated/mrdsrg.h b/forte/mrdsrg-spin-integrated/mrdsrg.h index 680f45c69..1997ff99e 100644 --- a/forte/mrdsrg-spin-integrated/mrdsrg.h +++ b/forte/mrdsrg-spin-integrated/mrdsrg.h @@ -353,7 +353,8 @@ class MRDSRG : public MASTER_DSRG { /// Compute MR-LDSRG(2) double compute_energy_ldsrg2(); - std::vector compute_Heff_full() override; + /// Modify the rdms_ member of the parent (base) class. Only used in EOM-DSRG. + void set_rdms(std::shared_ptr rdms) override; /// Zeroth-order Hamiltonian ambit::BlockedTensor H0th_; diff --git a/forte/mrdsrg-spin-integrated/mrdsrg_nonpt.cc b/forte/mrdsrg-spin-integrated/mrdsrg_nonpt.cc index c9c681dba..2daa065b7 100644 --- a/forte/mrdsrg-spin-integrated/mrdsrg_nonpt.cc +++ b/forte/mrdsrg-spin-integrated/mrdsrg_nonpt.cc @@ -832,6 +832,11 @@ double MRDSRG::compute_energy_ldsrg2() { // dump amplitudes to file dump_amps_to_disk(); + if (foptions_->get_bool("FULL_HBAR") || foptions_->get_bool("FULL_HBAR_DEGNO")) { + double rsc_conv = rsc_thres; + compute_hbar(rsc_conv); + } + if (foptions_->get_bool("FULL_MBAR")){ auto mpints = std::make_shared(ints_, mo_space_info_); // bare dipoles @@ -853,12 +858,15 @@ double MRDSRG::compute_energy_ldsrg2() { return Ecorr; } -std::vector MRDSRG::compute_Heff_full() { - double rsc_thres = foptions_->get_double("DSRG_RSC_THRESHOLD"); - compute_hbar(rsc_thres); - std::vector Heff = {Hbar1_, Hbar2_}; - return Heff; -} +// std::vector MRDSRG::compute_Heff_full() { +// double rsc_thres = foptions_->get_double("DSRG_RSC_THRESHOLD"); +// double Eref = compute_reference_energy_from_ints(ints_); +// compute_hbar(rsc_thres); +// outfile->Printf("\n\n %-30s = %22.15f", "Hbar0 (MR-LDSRG(2) energy) ", Eref + Hbar0_); +// outfile->Printf("\n\n ==> Computing MR-LDSRG(2) Effective Hamiltonian <==\n"); +// std::vector Heff = {Hbar1_, Hbar2_}; +// return Heff; +// } void MRDSRG::transform_one_body(const std::vector& oetens) { int n_tensors = oetens.size(); @@ -1450,4 +1458,12 @@ double MRDSRG::get_adaptive_rsc_conv(const int& iter, const double& deltaE, cons return threshold; } +void MRDSRG::set_rdms(std::shared_ptr rdms) { + // set up RDMS + rdms_ = rdms; + build_density(); + // build_ints(); + // build_fock(H_, V_); +} + } // namespace forte diff --git a/forte/proc/dsrg.py b/forte/proc/dsrg.py index c52871ee9..8fc202c2a 100644 --- a/forte/proc/dsrg.py +++ b/forte/proc/dsrg.py @@ -248,13 +248,14 @@ def compute_energy(self): # Spit out energy if reference relaxation not implemented if not self.Heff_implemented: self.relax_maxiter = 0 - + if self.options.get_bool("FULL_HBAR") and self.solver_type in ["MRDSRG","SA-MRDSRG","SA_MRDSRG","MRDSRG_SO", "MRDSRG-SO"] \ and self.relax_maxiter == 0: psi4.core.print_out("\n =>** Saving Full Hbar (unrelaxed) **<=\n") - Hbar1, Hbar2 = self.dsrg_solver.compute_Heff_full() + Hbar0, Hbar1, Hbar2 = self.dsrg_solver.save_Heff_full() + psi4.core.print_out(f"\n The Hbar0 term is: {Hbar0}\n") np.savez("save_Hbar", **Hbar1, **Hbar2) - + if self.options.get_bool("FULL_MBAR") and self.solver_type in ["MRDSRG"]: psi4.core.print_out("\n =>** Getting dipole integral (unrelaxed) **<=\n") Mbar0 = self.dsrg_solver.compute_Mbar0_full() @@ -283,13 +284,12 @@ def compute_energy(self): # so that the CI vectors are comparable before and after DSRG dressing. # However, the ForteIntegrals object and the dipole integrals always refer to the current semi-canonical basis. # so to compute the dipole moment correctly, we need to make the RDMs and orbital basis consistent - if self.options.get_bool("FULL_HBAR") and self.solver_type in ["MRDSRG","SA-MRDSRG","SA_MRDSRG","MRDSRG_SO","MRDSRG-SO"] \ and n == self.relax_maxiter - 1: - psi4.core.print_out("\n =>** Saving Full Hbar (relaxed) **<=\n") - Hbar1, Hbar2 = self.dsrg_solver.compute_Heff_full() - np.savez("save_Hbar", **Hbar1, **Hbar2) - + psi4.core.print_out("\n =>** Temporarily saving the Full Hbar (relaxed) **<=\n") + Hbar0, Hbar1, Hbar2 = self.dsrg_solver.save_Heff_full() + psi4.core.print_out(f"\n The Hbar0 term is: {Hbar0}\n") + if self.options.get_bool("FULL_MBAR") and self.solver_type in ["MRDSRG"]: psi4.core.print_out("\n =>** Getting dipole integral (relaxed) **<=\n") Mbar0 = self.dsrg_solver.compute_Mbar0_full() @@ -302,7 +302,7 @@ def compute_energy(self): np.savez(f"Mbar2_{i}", **Mbar2[i]) del Mbar0, Mbar1, Mbar2 - + if self.options.get_bool("FULL_HBAR_DEGNO") and self.solver_type in ["MRDSRG","SA-MRDSRG","SA_MRDSRG"] and n == self.relax_maxiter - 1: psi4.core.print_out("\n =>** Saving Full Hbar in de-normal-ordered basis (relaxed) **<=\n") scalar, Hbar1, Hbar2 = self.dsrg_solver.compute_Heff_full_degno() @@ -438,13 +438,13 @@ def compute_energy(self): psi4.core.print_out(f"\n DSRG-MRPT2 FNO corrected energy: {e_dsrg:20.15f}") if self.options.get_bool("FULL_HBAR") and self.solver_type in ["MRDSRG","MRDSRG_SO","MRDSRG-SO"]: - if self.relax_maxiter != 0: - self.rdms = self.active_space_solver.compute_average_rdms( - self.state_weights_map, self.max_rdm_level, self.rdm_type - ) - self.rdms.rotate(self.Ua, self.Ub) # To previous semi-canonical basis - - self.make_dsrg_solver() + self.rdms = self.active_space_solver.compute_average_rdms(self.state_weights_map, self.max_rdm_level, self.rdm_type) + self.rdms.rotate(self.Ua, self.Ub) # To previous semi-canonical basis + + psi4.core.print_out("\n =>** Saving Full Hbar **<=\n") + Hbar0, Hbar1, Hbar2 = self.dsrg_solver.update_Heff_full(Hbar0, Hbar1, Hbar2, self.rdms) + psi4.core.print_out(f"\n The Hbar0 term is: {Hbar0}\n") + np.savez("save_Hbar", **Hbar1, **Hbar2) psi4.core.print_out("\n =>** Getting gamma1 **<=\n") gamma1 = self.dsrg_solver.get_gamma1() @@ -469,6 +469,20 @@ def compute_energy(self): lambda4 = self.dsrg_solver.get_lambda4() np.savez("save_lambda4", **lambda4) del lambda4 + + # This part might be wrong. Should change rdms_ + if self.options.get_bool("FULL_MBAR") and self.solver_type in ["MRDSRG"]: + psi4.core.print_out("\n =>** Getting dipole integral **<=\n") + Mbar0 = self.dsrg_solver.compute_Mbar0_full() + np.save("Mbar0", Mbar0) + Mbar1 = self.dsrg_solver.compute_Mbar1_full() + Mbar2 = self.dsrg_solver.compute_Mbar2_full() + + for i in range(3): + np.savez(f"Mbar1_{i}", **Mbar1[i]) + np.savez(f"Mbar2_{i}", **Mbar2[i]) + + del Mbar0, Mbar1, Mbar2 self.dsrg_cleanup() From 6647a5a320addea2249299f0e78f25cd92d36413 Mon Sep 17 00:00:00 2001 From: Shuhang Li Date: Tue, 10 Dec 2024 23:57:16 -0500 Subject: [PATCH 50/55] Correct relaxed GNO Hbar --- forte/api/forte_python_module.cc | 10 ++- forte/mrdsrg-spin-integrated/master_mrdsrg.cc | 11 +++- forte/mrdsrg-spin-integrated/master_mrdsrg.h | 7 +- forte/mrdsrg-spin-integrated/mrdsrg.h | 1 + forte/mrdsrg-spin-integrated/mrdsrg_nonpt.cc | 23 ++++--- forte/proc/dsrg.py | 65 ++++++++----------- 6 files changed, 65 insertions(+), 52 deletions(-) diff --git a/forte/api/forte_python_module.cc b/forte/api/forte_python_module.cc index 165fa2c77..044df685d 100644 --- a/forte/api/forte_python_module.cc +++ b/forte/api/forte_python_module.cc @@ -249,10 +249,14 @@ PYBIND11_MODULE(_forte, m) { .def("compute_gradient", &MASTER_DSRG::compute_gradient, "Compute the DSRG gradient") .def("compute_Heff_actv", &MASTER_DSRG::compute_Heff_actv, "Return the DSRG dressed ActiveSpaceIntegrals") - .def("save_Heff_full", [](MASTER_DSRG& self) { + .def("save_Heff_full_ambit", [](MASTER_DSRG& self) { const auto Heff = self.save_Heff_full(); return py::make_tuple(Heff.first, Heff.second.at(0), Heff.second.at(1)); }) + .def("save_Heff_full", [](MASTER_DSRG& self) { + const auto Heff = self.save_Heff_full(); + return py::make_tuple(Heff.first, blockedtensor_to_np(Heff.second.at(0)), blockedtensor_to_np(Heff.second.at(1))); + }) .def("update_Heff_full", [](MASTER_DSRG& self, double H0, BlockedTensor H1, BlockedTensor H2, std::shared_ptr rdms) { const auto Heff = self.update_Heff_full(H0, H1, H2, rdms); return py::make_tuple(Heff.first, blockedtensor_to_np(Heff.second.at(0)), blockedtensor_to_np(Heff.second.at(1))); @@ -261,8 +265,8 @@ PYBIND11_MODULE(_forte, m) { const auto Heff = self.compute_Heff_full_degno(); return py::make_tuple(Heff.first, blockedtensor_to_np(Heff.second.at(0)), blockedtensor_to_np(Heff.second.at(1))); }) - .def("compute_Mbar0_full", &MASTER_DSRG::compute_Mbar0_full, - "Return full transformed zero-body dipole integrals") + .def("compute_mbar", &MASTER_DSRG::compute_mbar, "compute full transformed dipole integrals") + .def("compute_Mbar0_full", &MASTER_DSRG::compute_Mbar0_full, "Return full transformed zero-body dipole integrals") .def("compute_Mbar1_full", [](MASTER_DSRG& self) { const auto Mbar1 = self.compute_Mbar1_full(); return py::make_tuple(blockedtensor_to_np(Mbar1.at(0)), blockedtensor_to_np(Mbar1.at(1)), diff --git a/forte/mrdsrg-spin-integrated/master_mrdsrg.cc b/forte/mrdsrg-spin-integrated/master_mrdsrg.cc index b92886f27..024f3ef2c 100644 --- a/forte/mrdsrg-spin-integrated/master_mrdsrg.cc +++ b/forte/mrdsrg-spin-integrated/master_mrdsrg.cc @@ -2407,14 +2407,23 @@ std::pair> MASTER_DSRG::compute_Heff_full_deg std::pair> MASTER_DSRG::save_Heff_full() { double Edsrg = Eref_ + Hbar0_; - std::vector Heff = {Hbar1_, Hbar2_}; + ambit::BlockedTensor Hbar1_copy = BTF_->build(tensor_type_, "Hbar1_copy", spin_cases({"gg"})); + ambit::BlockedTensor Hbar2_copy = BTF_->build(tensor_type_, "Hbar2_copy", spin_cases({"gggg"})); + Hbar1_copy["pq"] = Hbar1_["pq"]; + Hbar1_copy["PQ"] = Hbar1_["PQ"]; + Hbar2_copy["pqrs"] = Hbar2_["pqrs"]; + Hbar2_copy["pQrS"] = Hbar2_["pQrS"]; + Hbar2_copy["PQRS"] = Hbar2_["PQRS"]; + std::vector Heff = {Hbar1_copy, Hbar2_copy}; return std::make_pair(Edsrg, Heff); } std::pair> MASTER_DSRG::update_Heff_full(double& H0, BlockedTensor& H1, BlockedTensor& H2, std::shared_ptr rdms) { deGNO_ints_full("Hamiltonian", H0, H1, H2); // De-normal ordering based on original RDMs. + outfile->Printf("\n H0 after deGNO: %20.12f", H0); GNO_ints_full("Hamiltonian", H0, H1, H2, rdms); // Re-normal ordering based on new RDMs. + outfile->Printf("\n H0 after GNO: %20.12f", H0); std::vector Heff = {H1, H2}; return std::make_pair(H0, Heff); } diff --git a/forte/mrdsrg-spin-integrated/master_mrdsrg.h b/forte/mrdsrg-spin-integrated/master_mrdsrg.h index 3fb073abd..3af9406a1 100644 --- a/forte/mrdsrg-spin-integrated/master_mrdsrg.h +++ b/forte/mrdsrg-spin-integrated/master_mrdsrg.h @@ -56,13 +56,16 @@ class MASTER_DSRG : public DynamicCorrelationSolver { std::pair> save_Heff_full(); /// Update DSRG full transformed Hamiltonian - std::pair> update_Heff_full(double& H0, BlockedTensor& H1, - BlockedTensor& H2, std::shared_ptr rdms); + std::pair> update_Heff_full(double& H0, BlockedTensor& H1, \ + BlockedTensor& H2, std::shared_ptr rdms); /// Compute DSRG full transformed Hamiltonian in the de-normal-ordered basis std::pair> compute_Heff_full_degno(); /// Compute DSRG transformed dipole integral + virtual void compute_mbar() { + throw std::runtime_error("Child class should override this function"); + } std::vector compute_Mbar0_full() { return Mbar0_full_; } std::vector compute_Mbar1_full() { return Mbar1_full_; } std::vector compute_Mbar2_full() { return Mbar2_full_; } diff --git a/forte/mrdsrg-spin-integrated/mrdsrg.h b/forte/mrdsrg-spin-integrated/mrdsrg.h index 1997ff99e..96400ec99 100644 --- a/forte/mrdsrg-spin-integrated/mrdsrg.h +++ b/forte/mrdsrg-spin-integrated/mrdsrg.h @@ -260,6 +260,7 @@ class MRDSRG : public MASTER_DSRG { double get_adaptive_rsc_conv(const int& iter, const double& deltaE, const double& rsc_conv, const double& rsc_conv_adapt, const double& rsc_conv_adapt_delta_e, const double& e_conv); + void compute_mbar() override; void transform_one_body(const std::vector& oetens); void compute_mbar_ldsrg2(const ambit::BlockedTensor& M, int ind); diff --git a/forte/mrdsrg-spin-integrated/mrdsrg_nonpt.cc b/forte/mrdsrg-spin-integrated/mrdsrg_nonpt.cc index 2daa065b7..0fc393269 100644 --- a/forte/mrdsrg-spin-integrated/mrdsrg_nonpt.cc +++ b/forte/mrdsrg-spin-integrated/mrdsrg_nonpt.cc @@ -858,15 +858,20 @@ double MRDSRG::compute_energy_ldsrg2() { return Ecorr; } -// std::vector MRDSRG::compute_Heff_full() { -// double rsc_thres = foptions_->get_double("DSRG_RSC_THRESHOLD"); -// double Eref = compute_reference_energy_from_ints(ints_); -// compute_hbar(rsc_thres); -// outfile->Printf("\n\n %-30s = %22.15f", "Hbar0 (MR-LDSRG(2) energy) ", Eref + Hbar0_); -// outfile->Printf("\n\n ==> Computing MR-LDSRG(2) Effective Hamiltonian <==\n"); -// std::vector Heff = {Hbar1_, Hbar2_}; -// return Heff; -// } +void MRDSRG::compute_mbar() { + auto mpints = std::make_shared(ints_, mo_space_info_); + // bare dipoles + std::vector M1; + std::vector dp_dirs{"X", "Y", "Z"}; + for (int z = 0; z < 3; ++z) { + std::string name = "DIPOLE " + dp_dirs[z]; + ambit::BlockedTensor m1 = BTF_->build(tensor_type_, name, spin_cases({"gg"})); + m1.iterate([&](const std::vector& i, const std::vector&, + double& value) { value = mpints->dp_ints_corr(z, i[0], i[1]); }); + M1.push_back(m1); + } + transform_one_body(M1); +} void MRDSRG::transform_one_body(const std::vector& oetens) { int n_tensors = oetens.size(); diff --git a/forte/proc/dsrg.py b/forte/proc/dsrg.py index 8fc202c2a..87059567d 100644 --- a/forte/proc/dsrg.py +++ b/forte/proc/dsrg.py @@ -258,6 +258,7 @@ def compute_energy(self): if self.options.get_bool("FULL_MBAR") and self.solver_type in ["MRDSRG"]: psi4.core.print_out("\n =>** Getting dipole integral (unrelaxed) **<=\n") + self.dsrg_solver.compute_mbar() Mbar0 = self.dsrg_solver.compute_Mbar0_full() np.save("Mbar0", Mbar0) Mbar1 = self.dsrg_solver.compute_Mbar1_full() @@ -286,23 +287,10 @@ def compute_energy(self): # so to compute the dipole moment correctly, we need to make the RDMs and orbital basis consistent if self.options.get_bool("FULL_HBAR") and self.solver_type in ["MRDSRG","SA-MRDSRG","SA_MRDSRG","MRDSRG_SO","MRDSRG-SO"] \ and n == self.relax_maxiter - 1: - psi4.core.print_out("\n =>** Temporarily saving the Full Hbar (relaxed) **<=\n") - Hbar0, Hbar1, Hbar2 = self.dsrg_solver.save_Heff_full() + psi4.core.print_out("\n =>** Temporarily saving Full Hbar in de-normal-ordered basis (relaxed) **<=\n") + Hbar0, Hbar1, Hbar2 = self.dsrg_solver.save_Heff_full_ambit() psi4.core.print_out(f"\n The Hbar0 term is: {Hbar0}\n") - if self.options.get_bool("FULL_MBAR") and self.solver_type in ["MRDSRG"]: - psi4.core.print_out("\n =>** Getting dipole integral (relaxed) **<=\n") - Mbar0 = self.dsrg_solver.compute_Mbar0_full() - np.save("Mbar0", Mbar0) - Mbar1 = self.dsrg_solver.compute_Mbar1_full() - Mbar2 = self.dsrg_solver.compute_Mbar2_full() - - for i in range(3): - np.savez(f"Mbar1_{i}", **Mbar1[i]) - np.savez(f"Mbar2_{i}", **Mbar2[i]) - - del Mbar0, Mbar1, Mbar2 - if self.options.get_bool("FULL_HBAR_DEGNO") and self.solver_type in ["MRDSRG","SA-MRDSRG","SA_MRDSRG"] and n == self.relax_maxiter - 1: psi4.core.print_out("\n =>** Saving Full Hbar in de-normal-ordered basis (relaxed) **<=\n") scalar, Hbar1, Hbar2 = self.dsrg_solver.compute_Heff_full_degno() @@ -437,15 +425,32 @@ def compute_energy(self): psi4.core.print_out(f"\n\n DSRG-MRPT2 FNO energy correction: {self.fno_pt2_energy_shift:20.15f}") psi4.core.print_out(f"\n DSRG-MRPT2 FNO corrected energy: {e_dsrg:20.15f}") - if self.options.get_bool("FULL_HBAR") and self.solver_type in ["MRDSRG","MRDSRG_SO","MRDSRG-SO"]: - self.rdms = self.active_space_solver.compute_average_rdms(self.state_weights_map, self.max_rdm_level, self.rdm_type) - self.rdms.rotate(self.Ua, self.Ub) # To previous semi-canonical basis + if self.options.get_bool("FULL_HBAR") and self.solver_type in ["MRDSRG","MRDSRG_SO","MRDSRG-SO"]: + if self.relax_maxiter != 0: + self.rdms = self.active_space_solver.compute_average_rdms(self.state_weights_map, self.max_rdm_level, self.rdm_type) + self.rdms.rotate(self.Ua, self.Ub) # To previous semi-canonical basis + + psi4.core.print_out("\n =>** Saving Full Hbar **<=\n") + Hbar0, Hbar1, Hbar2 = self.dsrg_solver.update_Heff_full(Hbar0, Hbar1, Hbar2, self.rdms) + psi4.core.print_out(f"\n The Hbar0 term is: {Hbar0}\n") + np.savez("save_Hbar", **Hbar1, **Hbar2) - psi4.core.print_out("\n =>** Saving Full Hbar **<=\n") - Hbar0, Hbar1, Hbar2 = self.dsrg_solver.update_Heff_full(Hbar0, Hbar1, Hbar2, self.rdms) - psi4.core.print_out(f"\n The Hbar0 term is: {Hbar0}\n") - np.savez("save_Hbar", **Hbar1, **Hbar2) - + self.dsrg_solver.set_rdms(self.rdms) # Important to update the rdms in the solver + + if self.options.get_bool("FULL_MBAR") and self.solver_type in ["MRDSRG"]: + psi4.core.print_out("\n =>** Getting dipole integral **<=\n") + self.dsrg_solver.compute_mbar() + Mbar0 = self.dsrg_solver.compute_Mbar0_full() + np.save("Mbar0", Mbar0) + Mbar1 = self.dsrg_solver.compute_Mbar1_full() + Mbar2 = self.dsrg_solver.compute_Mbar2_full() + + for i in range(3): + np.savez(f"Mbar1_{i}", **Mbar1[i]) + np.savez(f"Mbar2_{i}", **Mbar2[i]) + + del Mbar0, Mbar1, Mbar2 + psi4.core.print_out("\n =>** Getting gamma1 **<=\n") gamma1 = self.dsrg_solver.get_gamma1() np.savez("save_gamma1", **gamma1) @@ -469,20 +474,6 @@ def compute_energy(self): lambda4 = self.dsrg_solver.get_lambda4() np.savez("save_lambda4", **lambda4) del lambda4 - - # This part might be wrong. Should change rdms_ - if self.options.get_bool("FULL_MBAR") and self.solver_type in ["MRDSRG"]: - psi4.core.print_out("\n =>** Getting dipole integral **<=\n") - Mbar0 = self.dsrg_solver.compute_Mbar0_full() - np.save("Mbar0", Mbar0) - Mbar1 = self.dsrg_solver.compute_Mbar1_full() - Mbar2 = self.dsrg_solver.compute_Mbar2_full() - - for i in range(3): - np.savez(f"Mbar1_{i}", **Mbar1[i]) - np.savez(f"Mbar2_{i}", **Mbar2[i]) - - del Mbar0, Mbar1, Mbar2 self.dsrg_cleanup() From 01c9a53ca9e5e72cad7858b9bf57b80258646a0d Mon Sep 17 00:00:00 2001 From: Shuhang Li Date: Wed, 11 Dec 2024 12:07:13 -0500 Subject: [PATCH 51/55] skip unrelaxed dipole calculation --- forte/proc/dsrg.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/forte/proc/dsrg.py b/forte/proc/dsrg.py index 87059567d..7963a2e39 100644 --- a/forte/proc/dsrg.py +++ b/forte/proc/dsrg.py @@ -256,7 +256,7 @@ def compute_energy(self): psi4.core.print_out(f"\n The Hbar0 term is: {Hbar0}\n") np.savez("save_Hbar", **Hbar1, **Hbar2) - if self.options.get_bool("FULL_MBAR") and self.solver_type in ["MRDSRG"]: + if self.options.get_bool("FULL_MBAR") and self.solver_type in ["MRDSRG"] and self.relax_maxiter == 0: psi4.core.print_out("\n =>** Getting dipole integral (unrelaxed) **<=\n") self.dsrg_solver.compute_mbar() Mbar0 = self.dsrg_solver.compute_Mbar0_full() From 788d5943c898950787025e0860b7cd6ec10b5fa7 Mon Sep 17 00:00:00 2001 From: Shuhang Li Date: Tue, 17 Dec 2024 15:07:41 -0500 Subject: [PATCH 52/55] fix spin-orbital rdms and prepare_forte_object --- forte/api/forte_python_module.cc | 6 +++--- forte/mrdsrg-so/mrdsrg_so.cc | 16 ++++++++++++---- forte/mrdsrg-so/mrdsrg_so.h | 2 +- forte/proc/dsrg.py | 6 ++++-- forte/utils/helpers.py | 15 +++++++++------ 5 files changed, 29 insertions(+), 16 deletions(-) diff --git a/forte/api/forte_python_module.cc b/forte/api/forte_python_module.cc index 044df685d..faea2fd32 100644 --- a/forte/api/forte_python_module.cc +++ b/forte/api/forte_python_module.cc @@ -367,9 +367,9 @@ PYBIND11_MODULE(_forte, m) { .def("compute_energy", &MRDSRG_SO::compute_energy, "Compute DSRG energy") .def("compute_Heff_actv", &MRDSRG_SO::compute_Heff_actv, "Return the DSRG dressed ActiveSpaceIntegrals") - .def("compute_Heff_full", [](MRDSRG_SO& self) { - const auto Heff = self.compute_Heff_full(); - return py::make_tuple(blockedtensor_to_np(Heff.at(0)), blockedtensor_to_np(Heff.at(1))); + .def("save_Heff_full", [](MRDSRG_SO& self) { + const auto Heff = self.save_Heff_full(); + return py::make_tuple(Heff.first, blockedtensor_to_np(Heff.second.at(0)), blockedtensor_to_np(Heff.second.at(1))); }) .def("get_gamma1", [](MRDSRG_SO& self) { const auto gamma1 = self.get_gamma1(); diff --git a/forte/mrdsrg-so/mrdsrg_so.cc b/forte/mrdsrg-so/mrdsrg_so.cc index e93edbe72..184c93d80 100644 --- a/forte/mrdsrg-so/mrdsrg_so.cc +++ b/forte/mrdsrg-so/mrdsrg_so.cc @@ -646,6 +646,10 @@ double MRDSRG_SO::compute_energy() { ++cycle; } while (!converged); + if (foptions_->get_bool("FULL_HBAR")) { + compute_hbar(); + } + outfile->Printf("\n " "----------------------------------------------------------" "----------------------------------------"); @@ -1372,9 +1376,13 @@ void MRDSRG_SO::H3_T2_C2(BlockedTensor& H3, BlockedTensor& T2, const double& alp temp["mx"] += 0.5 * T2["myuv"] * Lambda2["uvxy"]; C2["toqr"] -= alpha * temp["mx"] * H3["xtomqr"]; } -std::vector MRDSRG_SO::compute_Heff_full() { - compute_hbar(); - std::vector Heff = {Hbar1, Hbar2}; - return Heff; +std::pair> MRDSRG_SO::save_Heff_full() { + double Edsrg = Eref + Hbar0; + ambit::BlockedTensor Hbar1_copy = BTF_->build(tensor_type_, "Hbar1_copy", {"gg"}); + ambit::BlockedTensor Hbar2_copy = BTF_->build(tensor_type_, "Hbar2_copy", {"gggg"}); + Hbar1_copy["pq"] = Hbar1["pq"]; + Hbar2_copy["pqrs"] = Hbar2["pqrs"]; + std::vector Heff = {Hbar1_copy, Hbar2_copy}; + return std::make_pair(Edsrg, Heff); } } // namespace forte diff --git a/forte/mrdsrg-so/mrdsrg_so.h b/forte/mrdsrg-so/mrdsrg_so.h index 042745999..4885fa11f 100644 --- a/forte/mrdsrg-so/mrdsrg_so.h +++ b/forte/mrdsrg-so/mrdsrg_so.h @@ -283,7 +283,7 @@ class MRDSRG_SO : public DynamicCorrelationSolver { // double compute_eom(); - std::vector compute_Heff_full(); + std::pair> save_Heff_full(); ambit::BlockedTensor get_gamma1() { return Gamma1; } ambit::BlockedTensor get_eta1() { return Eta1; } ambit::BlockedTensor get_lambda2() { return Lambda2; } diff --git a/forte/proc/dsrg.py b/forte/proc/dsrg.py index 7963a2e39..3025bcfa3 100644 --- a/forte/proc/dsrg.py +++ b/forte/proc/dsrg.py @@ -285,8 +285,10 @@ def compute_energy(self): # so that the CI vectors are comparable before and after DSRG dressing. # However, the ForteIntegrals object and the dipole integrals always refer to the current semi-canonical basis. # so to compute the dipole moment correctly, we need to make the RDMs and orbital basis consistent - if self.options.get_bool("FULL_HBAR") and self.solver_type in ["MRDSRG","SA-MRDSRG","SA_MRDSRG","MRDSRG_SO","MRDSRG-SO"] \ - and n == self.relax_maxiter - 1: + if self.options.get_bool("FULL_HBAR") and self.solver_type in ["SA-MRDSRG","SA_MRDSRG","MRDSRG_SO","MRDSRG-SO"]: + raise NotImplementedError("Relaxed full Hbar not implemented for SO/SA-DSRG") + + if self.options.get_bool("FULL_HBAR") and self.solver_type in ["MRDSRG"] and n == self.relax_maxiter - 1: psi4.core.print_out("\n =>** Temporarily saving Full Hbar in de-normal-ordered basis (relaxed) **<=\n") Hbar0, Hbar1, Hbar2 = self.dsrg_solver.save_Heff_full_ambit() psi4.core.print_out(f"\n The Hbar0 term is: {Hbar0}\n") diff --git a/forte/utils/helpers.py b/forte/utils/helpers.py index c88d642f3..e19753b0d 100644 --- a/forte/utils/helpers.py +++ b/forte/utils/helpers.py @@ -184,7 +184,7 @@ def psi4_cubeprop(wfn, path=".", orbs=[], nocc=0, nvir=0, density=False, frontie def prepare_forte_objects( - wfn, mo_spaces=None, active_space="ACTIVE", core_spaces=["RESTRICTED_DOCC"], localize=False, localize_spaces=[] + wfn, mo_spaces, active_space="ACTIVE", core_spaces=["RESTRICTED_DOCC"], localize=False, localize_spaces=[] ): """Take a psi4 wavefunction object and prepare the ForteIntegrals, SCFInfo, and MOSpaceInfo objects @@ -235,15 +235,18 @@ def prepare_forte_objects( point_group = wfn.molecule().point_group().symbol() # create a MOSpaceInfo object - if mo_spaces is None: - mo_space_info = forte.make_mo_space_info(nmopi, point_group, options) - else: - mo_space_info = forte.make_mo_space_info_from_map(nmopi, point_group, mo_spaces) + mo_space_info = forte.make_mo_space_info_from_map(nmopi, point_group, mo_spaces) + + # These variables are needed in make_state_weights_map + nel = wfn.nalpha() + wfn.nbeta() + multiplicity = 1 + options.set_int("NEL", nel) + options.set_int("MULTIPLICITY", multiplicity) state_weights_map = forte.make_state_weights_map(options, mo_space_info) # make a ForteIntegral object - ints = forte.make_ints_from_psi4(wfn, options, mo_space_info) + ints = forte.make_ints_from_psi4(wfn, options, scf_info, mo_space_info) if localize: localizer = forte.Localize(forte.forte_options, ints, mo_space_info) From 92bd751fee91dc3e8e79d2d62b5a106d2355b585 Mon Sep 17 00:00:00 2001 From: Brian Zhao Date: Thu, 23 Jan 2025 22:10:43 -0500 Subject: [PATCH 53/55] Export hbar0 in the npz file too, shouldn't break existing niupy code --- forte/proc/dsrg.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/forte/proc/dsrg.py b/forte/proc/dsrg.py index 3025bcfa3..9e46b38f3 100644 --- a/forte/proc/dsrg.py +++ b/forte/proc/dsrg.py @@ -254,7 +254,7 @@ def compute_energy(self): psi4.core.print_out("\n =>** Saving Full Hbar (unrelaxed) **<=\n") Hbar0, Hbar1, Hbar2 = self.dsrg_solver.save_Heff_full() psi4.core.print_out(f"\n The Hbar0 term is: {Hbar0}\n") - np.savez("save_Hbar", **Hbar1, **Hbar2) + np.savez("save_Hbar", Hbar0=Hbar0, **Hbar1, **Hbar2) if self.options.get_bool("FULL_MBAR") and self.solver_type in ["MRDSRG"] and self.relax_maxiter == 0: psi4.core.print_out("\n =>** Getting dipole integral (unrelaxed) **<=\n") @@ -435,7 +435,7 @@ def compute_energy(self): psi4.core.print_out("\n =>** Saving Full Hbar **<=\n") Hbar0, Hbar1, Hbar2 = self.dsrg_solver.update_Heff_full(Hbar0, Hbar1, Hbar2, self.rdms) psi4.core.print_out(f"\n The Hbar0 term is: {Hbar0}\n") - np.savez("save_Hbar", **Hbar1, **Hbar2) + np.savez("save_Hbar", Hbar0=Hbar0, **Hbar1, **Hbar2) self.dsrg_solver.set_rdms(self.rdms) # Important to update the rdms in the solver From 44a5812b2a72a847bf39c13ce05614517f2833bd Mon Sep 17 00:00:00 2001 From: Brian Zhao Date: Thu, 23 Jan 2025 22:23:11 -0500 Subject: [PATCH 54/55] Disable degno full hbar's python api - it complicates the dsrg.py file and is full hbar has all the necessary info to get the de-gno integrals in a simple python function --- forte/api/forte_python_module.cc | 8 -------- forte/options.yaml | 8 -------- forte/proc/dsrg.py | 11 ----------- 3 files changed, 27 deletions(-) diff --git a/forte/api/forte_python_module.cc b/forte/api/forte_python_module.cc index faea2fd32..fc0419ea3 100644 --- a/forte/api/forte_python_module.cc +++ b/forte/api/forte_python_module.cc @@ -261,10 +261,6 @@ PYBIND11_MODULE(_forte, m) { const auto Heff = self.update_Heff_full(H0, H1, H2, rdms); return py::make_tuple(Heff.first, blockedtensor_to_np(Heff.second.at(0)), blockedtensor_to_np(Heff.second.at(1))); }) - .def("compute_Heff_full_degno", [](MASTER_DSRG& self) { - const auto Heff = self.compute_Heff_full_degno(); - return py::make_tuple(Heff.first, blockedtensor_to_np(Heff.second.at(0)), blockedtensor_to_np(Heff.second.at(1))); - }) .def("compute_mbar", &MASTER_DSRG::compute_mbar, "compute full transformed dipole integrals") .def("compute_Mbar0_full", &MASTER_DSRG::compute_Mbar0_full, "Return full transformed zero-body dipole integrals") .def("compute_Mbar1_full", [](MASTER_DSRG& self) { @@ -338,10 +334,6 @@ PYBIND11_MODULE(_forte, m) { const auto Heff = self.compute_Heff_full(); return py::make_tuple(blockedtensor_to_np(Heff.at(0)), blockedtensor_to_np(Heff.at(1))); }) - .def("compute_Heff_full_degno", [](SADSRG& self) { - const auto Heff = self.compute_Heff_full_degno(); - return py::make_tuple(Heff.first, blockedtensor_to_np(Heff.second.at(0)), blockedtensor_to_np(Heff.second.at(1))); - }) .def("compute_mp_eff_actv", &SADSRG::compute_mp_eff_actv, "Return the DSRG dressed ActiveMultipoleIntegrals") .def("set_Uactv", &SADSRG::set_Uactv, "Ua"_a, diff --git a/forte/options.yaml b/forte/options.yaml index 48f47c83b..47cb1c05d 100644 --- a/forte/options.yaml +++ b/forte/options.yaml @@ -1122,14 +1122,6 @@ DSRG: type: bool default: False help: "Save the full DSRG effective dipole integrals to disk." - FULL_HBAR_DEGNO: - type: bool - default: False - help: "Save the full DSRG effective Hamiltonian normal ordered w.r.t. the true vacuum to disk." - DO_WICKED: - type: bool - default: False - help: "Compute hbar with Wicked. (only for spin orbital ldsrg2)." FORM_HBAR3: type: bool default: False diff --git a/forte/proc/dsrg.py b/forte/proc/dsrg.py index 9e46b38f3..efa386ad3 100644 --- a/forte/proc/dsrg.py +++ b/forte/proc/dsrg.py @@ -269,12 +269,6 @@ def compute_energy(self): np.savez(f"Mbar2_{i}", **Mbar2[i]) del Mbar0, Mbar1, Mbar2 - - if self.options.get_bool("FULL_HBAR_DEGNO") and self.solver_type in ["MRDSRG","SA-MRDSRG","SA_MRDSRG"] and self.relax_maxiter == 0: - psi4.core.print_out("\n =>** Saving Full Hbar in de-normal-ordered basis (unrelaxed) **<=\n") - scalar, Hbar1, Hbar2 = self.dsrg_solver.compute_Heff_full_degno() - np.savez("save_Hbar_degno", scalar=scalar, **Hbar1, **Hbar2) - # Reference relaxation procedure for n in range(self.relax_maxiter): @@ -293,11 +287,6 @@ def compute_energy(self): Hbar0, Hbar1, Hbar2 = self.dsrg_solver.save_Heff_full_ambit() psi4.core.print_out(f"\n The Hbar0 term is: {Hbar0}\n") - if self.options.get_bool("FULL_HBAR_DEGNO") and self.solver_type in ["MRDSRG","SA-MRDSRG","SA_MRDSRG"] and n == self.relax_maxiter - 1: - psi4.core.print_out("\n =>** Saving Full Hbar in de-normal-ordered basis (relaxed) **<=\n") - scalar, Hbar1, Hbar2 = self.dsrg_solver.compute_Heff_full_degno() - np.savez("save_Hbar_degno", scalar=scalar, **Hbar1, **Hbar2) - ints_dressed = self.dsrg_solver.compute_Heff_actv() if self.fno_pt2_Heff_shift is not None: ints_dressed.add(self.fno_pt2_Heff_shift, 1.0) From e19d8864caaf0dfeeb90bb839c5b3be4936b1e8f Mon Sep 17 00:00:00 2001 From: Brian Zhao Date: Thu, 23 Jan 2025 23:02:20 -0500 Subject: [PATCH 55/55] fix c++ side option checking --- forte/mrdsrg-spin-adapted/sa_mrdsrg.cc | 2 +- forte/mrdsrg-spin-integrated/mrdsrg_nonpt.cc | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/forte/mrdsrg-spin-adapted/sa_mrdsrg.cc b/forte/mrdsrg-spin-adapted/sa_mrdsrg.cc index 735fe5076..e67c03fd0 100644 --- a/forte/mrdsrg-spin-adapted/sa_mrdsrg.cc +++ b/forte/mrdsrg-spin-adapted/sa_mrdsrg.cc @@ -96,7 +96,7 @@ void SA_MRDSRG::read_options() { dsrg_trans_type_ = "UNITARY"; } - full_hbar_ = foptions_->get_bool("FULL_HBAR") || foptions_->get_bool("FULL_HBAR_DEGNO"); + full_hbar_ = foptions_->get_bool("FULL_HBAR"); } void SA_MRDSRG::startup() { diff --git a/forte/mrdsrg-spin-integrated/mrdsrg_nonpt.cc b/forte/mrdsrg-spin-integrated/mrdsrg_nonpt.cc index 0fc393269..44fd676c8 100644 --- a/forte/mrdsrg-spin-integrated/mrdsrg_nonpt.cc +++ b/forte/mrdsrg-spin-integrated/mrdsrg_nonpt.cc @@ -832,7 +832,7 @@ double MRDSRG::compute_energy_ldsrg2() { // dump amplitudes to file dump_amps_to_disk(); - if (foptions_->get_bool("FULL_HBAR") || foptions_->get_bool("FULL_HBAR_DEGNO")) { + if (foptions_->get_bool("FULL_HBAR")) { double rsc_conv = rsc_thres; compute_hbar(rsc_conv); }