LIBINT 2.7.2
r1dotr2g12_11_11.h
1/*
2 * Copyright (C) 2004-2021 Edward F. Valeev
3 *
4 * This file is part of Libint.
5 *
6 * Libint 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 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. If not, see <http://www.gnu.org/licenses/>.
18 *
19 */
20
21#ifndef _libint2_src_bin_libint_r1dotr2g121111_h_
22#define _libint2_src_bin_libint_r1dotr2g121111_h_
23
24#include <integral.h>
25#include <integral_11_11.h>
26
27namespace libint2 {
28
33 typedef GenIntegralSet_11_11<CGShell,R1dotR1_G12,EmptySet> R1dotR1G12_11_11_sq;
34 typedef GenIntegralSet_11_11<CGF,R1dotR1_G12,EmptySet> R1dotR1G12_11_11_int;
39
40#if 0
41 template <class BFS> class R1dotR2G12_11_11 :
42 public GenIntegralSet< R1dotR2_G12, IncableBFSet, typename DefaultTwoPBraket<BFS>::Result, typename DefaultTwoPBraket<BFS>::Result, EmptySet >
43 {
44 public:
45 typedef BFS BasisFunctionType;
46 typedef R1dotR2_G12 OperType;
49 typedef EmptySet AuxIndexType;
51
58
59 typedef typename parent_type::key_type key_type;
62
63 /* This "constructor" takes basis function sets, in Mulliken ordering.
64 Returns a pointer to a unique instance, a la Singleton
65 */
66 static const SafePtr<R1dotR2G12_11_11> Instance(const BFS& bra0, const BFS& ket0, const BFS& bra1, const BFS& ket1);
68 static const SafePtr<R1dotR2G12_11_11> Instance(const BraType& bra, const KetType& ket, const AuxIndexType& aux);
70
72 bool operator==(const this_type&) const;
73#if OVERLOAD_GENINTEGRALSET_LABEL
75 const std::string& label() const;
76#endif
77
78 private:
79 // This constructor is also private and not implemented since all Integral's are Singletons. Use Instance instead.
80 R1dotR2G12_11_11(const BraType& bra, const KetType& ket, const AuxIndexType& aux);
81
82 // This is used to manage GenIntegralSet objects as singletons
83 static SingletonManagerType singl_manager_;
84
86 bool this_precomputed() const;
87#if OVERLOAD_GENINTEGRALSET_LABEL
88 mutable std::string label_;
89#endif
90
91 };
92
93#if USE_INT_KEY_TO_HASH
94 template <class BFS>
97#else
98# error "USE_INT_KEY_TO_HASH must be set"
99#endif
100
101 template <class BFS>
102 R1dotR2G12_11_11<BFS>::R1dotR2G12_11_11(const BraType& bra, const KetType& ket, const AuxIndexType& aux) :
103 parent_type(R1dotR2_G12(),bra, ket, aux)
104 {
105 if (bra.num_members(0) != 1)
106 throw std::runtime_error("R1dotR2G12_11_11<BFS>::R1dotR2G12_11_11(bra,ket) -- number of BFSs in bra for particle 0 must be 1");
107 if (bra.num_members(1) != 1)
108 throw std::runtime_error("R1dotR2G12_11_11<BFS>::R1dotR2G12_11_11(bra,ket) -- number of BFSs in bra for particle 1 must be 1");
109 if (ket.num_members(0) != 1)
110 throw std::runtime_error("R1dotR2G12_11_11<BFS>::R1dotR2G12_11_11(bra,ket) -- number of BFSs in ket for particle 0 must be 1");
111 if (ket.num_members(1) != 1)
112 throw std::runtime_error("R1dotR2G12_11_11<BFS>::R1dotR2G12_11_11(bra,ket) -- number of BFSs in ket for particle 1 must be 1");
113#if DEBUG
114 std::cout << "R1dotR2G12_11_11: constructed " << this->label() << std::endl;
115#endif
116 }
117
118 template <class BFS>
119 R1dotR2G12_11_11<BFS>::~R1dotR2G12_11_11()
120 {
121#if DEBUG
122 std::cout << "R1dotR2G12_11_11: destructed " << this->label() << std::endl;
123#endif
124 }
125
126 template <class BFS>
127 const SafePtr< R1dotR2G12_11_11<BFS> >
129 {
130 typedef typename SingletonManagerType::value_type map_value_type;
131 key_type key = compute_key(OperType(),bra,ket,aux);
132 const map_value_type& val = singl_manager_.find(key);
133 if (!val.second) {
134 SafePtr<R1dotR2G12_11_11> this_int(new R1dotR2G12_11_11<BFS>(bra,ket,aux));
135 // Use singl_manager_ to make sure this is a new object of this type
136 const typename SingletonManagerType::value_type& val = singl_manager_.find(this_int);
137 val.second->instid_ = val.first;
138 return val.second;
139 }
140 return val.second;
141 }
142
143 template <class BFS>
144 const SafePtr< R1dotR2G12_11_11<BFS> >
145 R1dotR2G12_11_11<BFS>::Instance(const BFS& bra0, const BFS& ket0, const BFS& bra1, const BFS& ket1)
146 {
147#if USE_BRAKET_H
148 typedef BFS BFSRef;
149 BFSRef bra0_ref(bra0);
150 BFSRef bra1_ref(bra1);
151 BFSRef ket0_ref(ket0);
152 BFSRef ket1_ref(ket1);
153#else
154 typedef SafePtr<BFS> BFSRef;
155 BFSRef bra0_ref(new BFS(bra0));
156 BFSRef bra1_ref(new BFS(bra1));
157 BFSRef ket0_ref(new BFS(ket0));
158 BFSRef ket1_ref(new BFS(ket1));
159#endif
160 std::vector<BFSRef> vbra0; vbra0.push_back(bra0_ref);
161 std::vector<BFSRef> vbra1; vbra1.push_back(bra1_ref);
162 std::vector<BFSRef> vket0; vket0.push_back(ket0_ref);
163 std::vector<BFSRef> vket1; vket1.push_back(ket1_ref);
164 std::vector< std::vector<BFSRef> > vvbra; vvbra.push_back(vbra0); vvbra.push_back(vbra1);
165 std::vector< std::vector<BFSRef> > vvket; vvket.push_back(vket0); vvket.push_back(vket1);
166 BraType bra(vvbra);
167 KetType ket(vvket);
168 AuxIndexType aux(std::vector<int>(0));
169 return Instance(bra,ket,aux);
170 }
171
172 template <class BFS>
173 bool
175 {
176 return parent_type::PtrComp::equiv(static_cast<const parent_type*>(this),a);
177 }
178
179#if OVERLOAD_GENINTEGRALSET_LABEL
180 template <class BFS>
181 const std::string&
183 {
184 if (label_.empty()) {
185 ostringstream os;
186 os << "(" << parent_type::bra_.member(0,0)->label() << " "
187 << parent_type::ket_.member(0,0)->label()
188 << " | r_1.r_2 * G12 | "
189 << parent_type::bra_.member(1,0)->label() << " "
190 << parent_type::ket_.member(1,0)->label() << ")";
191 label_ = os.str();
192 }
193 return label_;
194 };
195#endif
196
197 template <class BFS>
198 bool
200 {
201 return false;
202 }
203
205 typedef R1dotR2G12_11_11<CGShell> R1dotR2G12_11_11_sq;
206 typedef R1dotR2G12_11_11<CGF> R1dotR2G12_11_11_int;
207#endif
208
209};
210
211#endif
212
ArrayBraket is a lightweight implementation of Braket concept.
Definition: src/bin/libint/braket.h:38
unsigned int num_members(unsigned int p) const
Returns the number of BFS for particle p.
Definition: src/bin/libint/braket.h:75
Generic integral over a two-body operator with one bfs for each particle in bra and ket.
Definition: integral_11_11.h:33
GenIntegralSet is a set of integrals over functions derived from BFS.
Definition: integral.h:92
const SafePtr< EmptySet > aux() const
Obtain the auxiliary quanta.
Definition: integral.h:365
PtrEquiv<T> provides a set of comparison functions named 'equiv' which take as arguments a mix of ref...
Definition: equiv.h:36
QuantumNumbersA<T,N> is a set of N quantum numbers of type T implemented in terms of a C-style array.
Definition: quanta.h:197
Definition: r1dotr2g12_11_11.h:43
bool operator==(const this_type &) const
Comparison operator.
Definition: r1dotr2g12_11_11.h:174
const std::string & label() const
Specialization of GenIntegralSet::label()
Definition: r1dotr2g12_11_11.h:182
PtrEquiv< this_type > PtrComp
This class provides comparison operations on pointers.
Definition: r1dotr2g12_11_11.h:57
SingletonStack< R1dotR2G12_11_11, key_type > SingletonManagerType
This the type of the object that manages GenIntegralSet's as Singletons.
Definition: r1dotr2g12_11_11.h:61
R1dotR2G12_11_11< typename BFS::iter_type > iter_type
R1dotR2G12_11_11 is a set of these subobjects.
Definition: r1dotr2g12_11_11.h:53
GenIntegralSet< OperType, IncableBFSet, BraType, KetType, AuxIndexType > parent_type
This is the immediate parent.
Definition: r1dotr2g12_11_11.h:55
SingletonStack<T,KeyType> helps to implement Singleton-like objects of type T.
Definition: singl_stack.h:44
Defaults definitions for various parameters assumed by Libint.
Definition: algebra.cc:24
GenIntegralSet_11_11< CGShell, R1dotR2_G12, EmptySet > R1dotR2G12_11_11_sq
the following typedefs are useful
Definition: r1dotr2g12_11_11.h:37
R1dotR1G12_11_11< CGShell > R1dotR1G12_11_11_sq
the following typedefs are useful
Definition: r1dotr1g12_11_11.h:197
GenIntegralSet_11_11< CGShell, R2dotR2_G12, EmptySet > R2dotR2G12_11_11_sq
the following typedefs are useful
Definition: r1dotr2g12_11_11.h:35