LIBINT 2.9.0
gaussoper.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 _libint2_src_bin_libint_gaussoper_h_
22#define _libint2_src_bin_libint_gaussoper_h_
23
24#include <braket.h>
25#include <global_macros.h>
26#include <prefactors.h>
27
28#include <boost/type_traits/is_same.hpp>
29
30namespace libint2 {
31
33template <class F, BraketType BKType>
34LinearCombination<std::shared_ptr<DGVertex>, BraketPair<F, BKType> >
36 if (BKType == CBra || BKType == CKet)
37 throw std::logic_error(
38 "R12vec_dot_Nabla1 can only be applied to physicists brakets");
39
40 const char* zeta = (BKType == PBra) ? "zeta_A" : "zeta_B";
41 const char* XY = (BKType == PBra) ? "AC" : "BD";
42
43 const auto& f = bkt[0];
44 const auto& g = bkt[1];
46 ResultType;
47 ResultType result;
48
49 using namespace libint2::prefactor;
50 if (f.norm())
51 result += make_pair(Scalar((double)f.norm()), BraketPair<F, BKType>(f, g));
52
53 const unsigned int nxyz = boost::is_same<F, CGF>::value ? 3 : 1;
54 for (unsigned int xyz = 0; xyz < nxyz; ++xyz) {
55 using namespace libint2::algebra;
56 F _1 = unit<F>(xyz);
57 const F& fm1 = f - _1;
58 const F& gp1 = g + _1;
59 if (exists(fm1)) {
60 const double f_xyz = (double)(f.qn(xyz));
61 result +=
62 make_pair(Scalar(-1.0 * f_xyz), BraketPair<F, BKType>(fm1, gp1));
63 result += make_pair(Scalar(f_xyz) * Vector(XY)[xyz],
64 BraketPair<F, BKType>(fm1, g));
65 }
66 const F& fp1 = f + _1;
67 const F& fp2 = fp1 + _1;
68 result +=
69 make_pair(Scalar(-2.0) * Scalar(zeta), BraketPair<F, BKType>(fp2, g));
70 result +=
71 make_pair(Scalar(2.0) * Scalar(zeta), BraketPair<F, BKType>(fp1, gp1));
72 result += make_pair(Scalar(-2.0) * Scalar(zeta) * Vector(XY)[xyz],
73 BraketPair<F, BKType>(fp1, g));
74 }
75
76 return result;
77}
78
80template <class F, BraketType BKType>
83 if (BKType == CBra || BKType == CKet)
84 throw std::logic_error(
85 "R12vec_dot_Nabla2 can only be applied to physicists brakets");
86
87 const char* zeta = (BKType == PBra) ? "zeta_C" : "zeta_D";
88 const char* XY = (BKType == PBra) ? "AC" : "BD";
89
90 const F& f = bkt[0];
91 const F& g = bkt[1];
93 ResultType;
94 ResultType result;
95
96 using namespace libint2::prefactor;
97 if (g.norm())
98 result += make_pair(Scalar(-1.0 * g.norm()), BraketPair<F, BKType>(f, g));
99
100 const unsigned int nxyz = boost::is_same<F, CGF>::value ? 3 : 1;
101 for (unsigned int xyz = 0; xyz < nxyz; ++xyz) {
102 using namespace libint2::algebra;
103 F _1 = unit<F>(xyz);
104 const F& fp1 = f + _1;
105 const F& gm1 = g - _1;
106 if (exists(gm1)) {
107 const double g_xyz = (double)(g.qn(xyz));
108 result += make_pair(Scalar(g_xyz), BraketPair<F, BKType>(fp1, gm1));
109 result += make_pair(Scalar(g_xyz) * Vector(XY)[xyz],
110 BraketPair<F, BKType>(f, gm1));
111 }
112 const F& gp1 = g + _1;
113 const F& gp2 = gp1 + _1;
114 result +=
115 make_pair(Scalar(-2.0) * Scalar(zeta), BraketPair<F, BKType>(fp1, gp1));
116 result +=
117 make_pair(Scalar(2.0) * Scalar(zeta), BraketPair<F, BKType>(f, gp2));
118 result += make_pair(Scalar(-2.0) * Scalar(zeta) * Vector(XY)[xyz],
119 BraketPair<F, BKType>(f, gp1));
120 }
121
122 return result;
123}
124
126template <class F, BraketType BKType>
128 const BraketPair<F, BKType>& bkt, int xyz) {
129 if (BKType == CBra || BKType == CKet)
130 throw std::logic_error("Nabla1 can only be applied to physicists brakets");
131
132 const char* zeta = (BKType == PBra) ? "zeta_A" : "zeta_B";
133
134 const F& f = bkt[0];
135 const F& g = bkt[1];
137 ResultType;
138 ResultType result;
139
140 using namespace libint2::prefactor;
141 using namespace libint2::algebra;
142 // if applying to shell pair, change angular momentum along 0
143 const unsigned int dir = boost::is_same<F, CGF>::value ? xyz : 0;
144 F _1 = unit<F>(dir);
145 const F& fm1 = f - _1;
146 if (exists(fm1)) {
147 const double f_xyz = (double)(f.qn(dir));
148 result += make_pair(Scalar(f_xyz), BraketPair<F, BKType>(fm1, g));
149 }
150 const F& fp1 = f + _1;
151 result +=
152 make_pair(Scalar(-2.0) * Scalar(zeta), BraketPair<F, BKType>(fp1, g));
153 return result;
154}
155
157template <class F, BraketType BKType>
159 const BraketPair<F, BKType>& bkt, int xyz) {
160 if (BKType == CBra || BKType == CKet)
161 throw std::logic_error("Nabla2 can only be applied to physicists brakets");
162
163 const char* zeta = (BKType == PBra) ? "zeta_C" : "zeta_D";
164
165 const F& f = bkt[0];
166 const F& g = bkt[1];
168 ResultType;
169 ResultType result;
170
171 using namespace libint2::prefactor;
172 using namespace libint2::algebra;
173 // if applying to shell pair, change angular momentum along 0
174 const unsigned int dir = boost::is_same<F, CGF>::value ? xyz : 0;
175 F _1 = unit<F>(dir);
176 const F& gm1 = g - _1;
177 if (exists(gm1)) {
178 const double g_xyz = (double)(g.qn(dir));
179 result += make_pair(Scalar(g_xyz), BraketPair<F, BKType>(f, gm1));
180 }
181 const F& gp1 = g + _1;
182 result +=
183 make_pair(Scalar(-2.0) * Scalar(zeta), BraketPair<F, BKType>(f, gp1));
184 return result;
185}
186
188template <class F, BraketType BKType>
190 const BraketPair<F, BKType>& bkt, unsigned int xyz) {
191 if (BKType == CBra || BKType == CKet)
192 throw std::logic_error("R12v can only be applied to physicists brakets");
193
194 const char* XY = (BKType == PBra) ? "AC" : "BD";
195
196 const F& f = bkt[0];
197 const F& g = bkt[1];
199 ResultType;
200 ResultType result;
201
202 using namespace libint2::prefactor;
203 using namespace libint2::algebra;
204 // if applying to shell pair, change angular momentum along 0
205 const unsigned int dir = boost::is_same<F, CGF>::value ? xyz : 0;
206 F _1 = unit<F>(dir);
207 const F& fp1 = f + _1;
208 const F& gp1 = g + _1;
209 result += make_pair(Scalar(1.0), BraketPair<F, BKType>(fp1, g));
210 result += make_pair(Scalar(-1.0), BraketPair<F, BKType>(f, gp1));
211 result += make_pair(Vector(XY)[xyz], BraketPair<F, BKType>(f, g));
212 return result;
213}
214
215}; // namespace libint2
216
217#endif // header guard
BraketPair is a trimmed down version of ArrayBraket specialized for same-particle or different-partic...
Definition src/bin/libint/braket.h:247
represents linear combination of objects of type T with coefficients of type C
Definition algebra.h:222
Defaults definitions for various parameters assumed by Libint.
Definition algebra.cc:24
bool exists(const IncableBFSet &A)
Return true if A is valid.
Definition bfset.h:96
LinearCombination< std::shared_ptr< DGVertex >, BraketPair< F, BKType > > R12vec_dot_Nabla1(const BraketPair< F, BKType > &bkt)
Applies R12vec_dot_Nabla1 to a physicists' braket.
Definition gaussoper.h:35
LinearCombination< std::shared_ptr< DGVertex >, BraketPair< F, BKType > > Nabla1(const BraketPair< F, BKType > &bkt, int xyz)
Applies Nabla1 to a physicists' braket.
Definition gaussoper.h:127
LinearCombination< std::shared_ptr< DGVertex >, BraketPair< F, BKType > > Nabla2(const BraketPair< F, BKType > &bkt, int xyz)
Applies Nabla2 to a physicists' braket.
Definition gaussoper.h:158
LinearCombination< std::shared_ptr< DGVertex >, BraketPair< F, BKType > > R12vec_dot_Nabla2(const BraketPair< F, BKType > &bkt)
Applies R12vec_dot_Nabla2 to a physicists' braket.
Definition gaussoper.h:82
LinearCombination< std::shared_ptr< DGVertex >, BraketPair< F, BKType > > R12v(const BraketPair< F, BKType > &bkt, unsigned int xyz)
Applies R12v to a physicists' braket.
Definition gaussoper.h:189