LIBINT 2.9.0
comp_1_σpVσp_1.h
1/*
2 * Copyright (C) 2004-2024 Edward F. Valeev
3 *
4 * This file is part of Libint compiler.
5 *
6 * Libint compiler is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation, either version 3 of the License, or
9 * (at your option) any later version.
10 *
11 * Libint compiler is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with Libint compiler. If not, see <http://www.gnu.org/licenses/>.
18 *
19 */
20
21#ifndef LIBINT_COMP_1_ΣPVΣP_1_H
22#define LIBINT_COMP_1_ΣPVΣP_1_H
23
24#include <generic_rr.h>
25
26namespace libint2 {
27
35template <typename F>
38 CR_1_σpVσp_1<F>, F, GenIntegralSet_1_1<F, σpVσpOper, EmptySet>> {
39 public:
41 typedef F BasisFunctionType;
42 typedef σpVσpOper OperType;
46 friend class GenericRecurrenceRelation<ThisType, BasisFunctionType,
48 static const unsigned int max_nchildren = 100; // TODO figure out
49
51
52 static bool directional() { return false; }
53
54 private:
56 using ParentType::target_;
57 using ParentType::RecurrenceRelation::expr_;
58 using ParentType::RecurrenceRelation::nflops_;
59
62 CR_1_σpVσp_1(const std::shared_ptr<TargetType> &, unsigned int = 0);
63
64 static std::string descr() { return "CR"; }
65};
66
67template <typename F>
68CR_1_σpVσp_1<F>::CR_1_σpVσp_1(const std::shared_ptr<TargetType> &Tint,
69 unsigned int)
70 : ParentType(Tint, 0) {
71 assert(Tint->num_func_bra(/* particle */ 0) == 1);
72 assert(Tint->num_func_ket(/* particle */ 0) == 1);
73 const auto &a = Tint->bra(0, 0);
74 const auto &b = Tint->ket(0, 0);
75 const auto &oper = Tint->oper();
76
77 // can express integrals of σpVσp in terms of derivative integrals of V for
78 // primitive Gaussians only
79 if (a.contracted() || b.contracted()) return;
80
81 using namespace libint2::algebra;
82 using namespace libint2::prefactor;
83 using libint2::algebra::operator*;
84
85 const mType zero_m(0u);
86
87 ChildFactory<ThisType,
89 factory(this);
90
91 constexpr auto x = 0;
92 constexpr auto y = 1;
93 constexpr auto z = 2;
94
95 F Dx_a{a};
96 Dx_a.deriv().inc(x);
97 F Dx_b{b};
98 Dx_b.deriv().inc(x);
99 F Dy_a{a};
100 Dy_a.deriv().inc(y);
101 F Dy_b{b};
102 Dy_b.deriv().inc(y);
103 F Dz_a{a};
104 Dz_a.deriv().inc(z);
105 F Dz_b{b};
106 Dz_b.deriv().inc(z);
107
108 // (a|W0|b) = (d a/dAx | V | d b/dBx) + (d a/dAy | V | d b/dBy) + (d a/dAz | V
109 // | d b/dBz)
110 switch (oper->descr().pauli_index()) {
111 case 0: {
112 auto Dx_a_V_Dx_b = factory.make_child(Dx_a, Dx_b, zero_m);
113 auto Dy_a_V_Dy_b = factory.make_child(Dy_a, Dy_b, zero_m);
114 auto Dz_a_V_Dz_b = factory.make_child(Dz_a, Dz_b, zero_m);
115 if (is_simple()) {
116 expr_ = Dx_a_V_Dx_b + Dy_a_V_Dy_b + Dz_a_V_Dz_b;
117 nflops_ += 2;
118 }
119 } break;
120 // (a|Wx|b) = (d a/dAy | V | d b/dBz) - (d a/dAz | V | d b/dBy)
121 case 1: {
122 auto Dy_a_V_Dz_b = factory.make_child(Dy_a, Dz_b, zero_m);
123 auto Dz_a_V_Dy_b = factory.make_child(Dz_a, Dy_b, zero_m);
124 if (is_simple()) {
125 expr_ = Dy_a_V_Dz_b - Dz_a_V_Dy_b;
126 nflops_ += 1;
127 }
128 } break;
129 // (a|Wy|b) = (d a/dAz | V | d b/dBx) - (d a/dAx | V | d b/dBz)
130 case 2: {
131 auto Dz_a_V_Dx_b = factory.make_child(Dz_a, Dx_b, zero_m);
132 auto Dx_a_V_Dz_b = factory.make_child(Dx_a, Dz_b, zero_m);
133 if (is_simple()) {
134 expr_ = Dz_a_V_Dx_b - Dx_a_V_Dz_b;
135 nflops_ += 1;
136 }
137 } break;
138 // (a|Wz|b) = (d a/dAx | V | d b/dBy) - (d a/dAy | V | d
139 // b/dBx)
140 case 3: {
141 auto Dx_a_V_Dy_b = factory.make_child(Dx_a, Dy_b, zero_m);
142 auto Dy_a_V_Dx_b = factory.make_child(Dy_a, Dx_b, zero_m);
143 if (is_simple()) {
144 expr_ = Dx_a_V_Dy_b - Dy_a_V_Dx_b;
145 nflops_ += 1;
146 }
147 } break;
148 default:
149 throw std::runtime_error("CR_1_σpVσp_1: invalid Pauli index");
150 }
151
152} // CR_1_σpVσp_1<F>::CR_1_σpVσp_1
153
154}; // namespace libint2
155
156#endif // LIBINT_COMP_1_ΣPVΣP_1_H
this computes integral of over CGShell/CGF by rewriting it as a linear combination of integrals over...
Definition comp_1_σpVσp_1.h:38
Helps GenericRecurrenceRelation to work around the compiler problem with make_child.
Definition generic_rr.h:150
Generic integral over a one-body operator with one bfs for each particle in bra and ket.
Definition integral_1_1.h:36
RRImpl must inherit GenericRecurrenceRelation<RRImpl>
Definition generic_rr.h:47
bool is_simple() const override
Implementation of RecurrenceRelation::is_simple()
Definition generic_rr.h:81
static std::shared_ptr< RRImpl > Instance(const std::shared_ptr< TargetType > &Tint, unsigned int dir)
Return an instance if applicable, or a null pointer otherwise.
Definition generic_rr.h:55
QuantumNumbersA<T,N> is a set of N quantum numbers of type T implemented in terms of a C-style array.
Definition quanta.h:193
Defaults definitions for various parameters assumed by Libint.
Definition algebra.cc:24