|
| 1 | +/* |
| 2 | + * @BEGIN LICENSE |
| 3 | + * |
| 4 | + * Forte: an open-source plugin to Psi4 (https://github.com/psi4/psi4) |
| 5 | + * that implements a variety of quantum chemistry methods for strongly |
| 6 | + * correlated electrons. |
| 7 | + * |
| 8 | + * Copyright (c) 2012-2024 by its authors (see COPYING, COPYING.LESSER, AUTHORS). |
| 9 | + * |
| 10 | + * The copyrights for code used from other parties are included in |
| 11 | + * the corresponding files. |
| 12 | + * |
| 13 | + * This program is free software: you can redistribute it and/or modify |
| 14 | + * it under the terms of the GNU Lesser General Public License as published by |
| 15 | + * the Free Software Foundation, either version 3 of the License, or |
| 16 | + * (at your option) any later version. |
| 17 | + * |
| 18 | + * This program is distributed in the hope that it will be useful, |
| 19 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 20 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 21 | + * GNU Lesser General Public License for more details. |
| 22 | + * |
| 23 | + * You should have received a copy of the GNU Lesser General Public License |
| 24 | + * along with this program. If not, see http://www.gnu.org/licenses/. |
| 25 | + * |
| 26 | + * @END LICENSE |
| 27 | + */ |
| 28 | + |
| 29 | +#include <format> |
| 30 | + |
| 31 | +#include "sparse_ci/sparse_operator_hamiltonian.h" |
| 32 | + |
| 33 | +#include "integrals/active_space_integrals.h" |
| 34 | + |
| 35 | +namespace forte { |
| 36 | + |
| 37 | +SparseOperator sparse_operator_hamiltonian(std::shared_ptr<ActiveSpaceIntegrals> as_ints) { |
| 38 | + SparseOperator H; |
| 39 | + size_t nmo = as_ints->nmo(); |
| 40 | + |
| 41 | + H.add_term_from_str("[]", as_ints->nuclear_repulsion_energy() + as_ints->scalar_energy() + |
| 42 | + as_ints->frozen_core_energy()); |
| 43 | + |
| 44 | + for (size_t p = 0; p < nmo; p++) { |
| 45 | + for (size_t q = 0; q < nmo; q++) { |
| 46 | + H.add_term_from_str(std::format("{}a+ {}a-", p, q), as_ints->oei_a(p, q)); |
| 47 | + H.add_term_from_str(std::format("{}b+ {}b-", p, q), as_ints->oei_b(p, q)); |
| 48 | + } |
| 49 | + } |
| 50 | + |
| 51 | + for (size_t p = 0; p < nmo; p++) { |
| 52 | + for (size_t q = p + 1; q < nmo; q++) { |
| 53 | + for (size_t r = 0; r < nmo; r++) { |
| 54 | + for (size_t s = r + 1; s < nmo; s++) { |
| 55 | + H.add_term_from_str(std::format("{}a+ {}a+ {}a- {}a-", p, q, s, r), |
| 56 | + as_ints->tei_aa(p, q, r, s)); |
| 57 | + H.add_term_from_str(std::format("{}b+ {}b+ {}b- {}b-", p, q, s, r), |
| 58 | + as_ints->tei_bb(p, q, r, s)); |
| 59 | + } |
| 60 | + } |
| 61 | + } |
| 62 | + } |
| 63 | + |
| 64 | + for (size_t p = 0; p < nmo; p++) { |
| 65 | + for (size_t q = 0; q < nmo; q++) { |
| 66 | + for (size_t r = 0; r < nmo; r++) { |
| 67 | + for (size_t s = 0; s < nmo; s++) { |
| 68 | + H.add_term_from_str(std::format("{}a+ {}b+ {}b- {}a-", p, q, s, r), |
| 69 | + as_ints->tei_ab(p, q, r, s)); |
| 70 | + } |
| 71 | + } |
| 72 | + } |
| 73 | + } |
| 74 | + |
| 75 | + return H; |
| 76 | +} |
| 77 | + |
| 78 | +} // namespace forte |
0 commit comments