1 | //
|
---|
2 | // intv3.cc
|
---|
3 | //
|
---|
4 | // Copyright (C) 1996 Limit Point Systems, Inc.
|
---|
5 | //
|
---|
6 | // Author: Curtis Janssen <cljanss@limitpt.com>
|
---|
7 | // Maintainer: LPS
|
---|
8 | //
|
---|
9 | // This file is part of the SC Toolkit.
|
---|
10 | //
|
---|
11 | // The SC Toolkit is free software; you can redistribute it and/or modify
|
---|
12 | // it under the terms of the GNU Library General Public License as published by
|
---|
13 | // the Free Software Foundation; either version 2, or (at your option)
|
---|
14 | // any later version.
|
---|
15 | //
|
---|
16 | // The SC Toolkit is distributed in the hope that it will be useful,
|
---|
17 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
18 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
19 | // GNU Library General Public License for more details.
|
---|
20 | //
|
---|
21 | // You should have received a copy of the GNU Library General Public License
|
---|
22 | // along with the SC Toolkit; see the file COPYING.LIB. If not, write to
|
---|
23 | // the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
|
---|
24 | //
|
---|
25 | // The U.S. Government is granted a limited license as per AL 91-7.
|
---|
26 | //
|
---|
27 |
|
---|
28 | #include <stdexcept>
|
---|
29 |
|
---|
30 | #include <util/state/stateio.h>
|
---|
31 | #include <chemistry/qc/basis/integral.h>
|
---|
32 | #include <chemistry/qc/intv3/intv3.h>
|
---|
33 | #include <chemistry/qc/intv3/cartitv3.h>
|
---|
34 | #include <chemistry/qc/intv3/tformv3.h>
|
---|
35 | #include <chemistry/qc/intv3/obintv3.h>
|
---|
36 | #include <chemistry/qc/intv3/tbintv3.h>
|
---|
37 |
|
---|
38 | using namespace std;
|
---|
39 | using namespace sc;
|
---|
40 |
|
---|
41 | static ClassDesc IntegralV3_cd(
|
---|
42 | typeid(IntegralV3),"IntegralV3",1,"public Integral",
|
---|
43 | 0, create<IntegralV3>, create<IntegralV3>);
|
---|
44 |
|
---|
45 | extern Ref<Integral> default_integral;
|
---|
46 |
|
---|
47 | Integral*
|
---|
48 | Integral::get_default_integral()
|
---|
49 | {
|
---|
50 | if (default_integral.null())
|
---|
51 | default_integral = new IntegralV3;
|
---|
52 |
|
---|
53 | return default_integral;
|
---|
54 | }
|
---|
55 |
|
---|
56 | IntegralV3::IntegralV3(const Ref<GaussianBasisSet> &b1,
|
---|
57 | const Ref<GaussianBasisSet> &b2,
|
---|
58 | const Ref<GaussianBasisSet> &b3,
|
---|
59 | const Ref<GaussianBasisSet> &b4):
|
---|
60 | Integral(b1,b2,b3,b4)
|
---|
61 | {
|
---|
62 | initialize_transforms();
|
---|
63 | }
|
---|
64 |
|
---|
65 | IntegralV3::IntegralV3(StateIn& s) :
|
---|
66 | Integral(s)
|
---|
67 | {
|
---|
68 | initialize_transforms();
|
---|
69 | }
|
---|
70 |
|
---|
71 | IntegralV3::IntegralV3(const Ref<KeyVal>& k) :
|
---|
72 | Integral(k)
|
---|
73 | {
|
---|
74 | initialize_transforms();
|
---|
75 | }
|
---|
76 |
|
---|
77 | void
|
---|
78 | IntegralV3::save_data_state(StateOut& s)
|
---|
79 | {
|
---|
80 | Integral::save_data_state(s);
|
---|
81 | }
|
---|
82 |
|
---|
83 | IntegralV3::~IntegralV3()
|
---|
84 | {
|
---|
85 | free_transforms();
|
---|
86 | }
|
---|
87 |
|
---|
88 | Integral*
|
---|
89 | IntegralV3::clone()
|
---|
90 | {
|
---|
91 | return new IntegralV3;
|
---|
92 | }
|
---|
93 |
|
---|
94 | CartesianIter *
|
---|
95 | IntegralV3::new_cartesian_iter(int l)
|
---|
96 | {
|
---|
97 | return new CartesianIterV3(l);
|
---|
98 | }
|
---|
99 |
|
---|
100 | RedundantCartesianIter *
|
---|
101 | IntegralV3::new_redundant_cartesian_iter(int l)
|
---|
102 | {
|
---|
103 | return new RedundantCartesianIterV3(l);
|
---|
104 | }
|
---|
105 |
|
---|
106 | RedundantCartesianSubIter *
|
---|
107 | IntegralV3::new_redundant_cartesian_sub_iter(int l)
|
---|
108 | {
|
---|
109 | return new RedundantCartesianSubIterV3(l);
|
---|
110 | }
|
---|
111 |
|
---|
112 | SphericalTransformIter *
|
---|
113 | IntegralV3::new_spherical_transform_iter(int l, int inv, int subl)
|
---|
114 | {
|
---|
115 | if (l>maxl_ || l<0) {
|
---|
116 | ExEnv::errn() << "IntegralV3::new_spherical_transform_iter: bad l" << endl;
|
---|
117 | abort();
|
---|
118 | }
|
---|
119 | if (subl == -1) subl = l;
|
---|
120 | if (subl < 0 || subl > l || (l-subl)%2 != 0) {
|
---|
121 | ExEnv::errn() << "IntegralV3::new_spherical_transform_iter: bad subl" << endl;
|
---|
122 | abort();
|
---|
123 | }
|
---|
124 | if (inv) {
|
---|
125 | return new SphericalTransformIter(ist_[l][(l-subl)/2]);
|
---|
126 | }
|
---|
127 | return new SphericalTransformIter(st_[l][(l-subl)/2]);
|
---|
128 | }
|
---|
129 |
|
---|
130 | const SphericalTransform *
|
---|
131 | IntegralV3::spherical_transform(int l, int inv, int subl)
|
---|
132 | {
|
---|
133 | if (l>maxl_ || l<0) {
|
---|
134 | ExEnv::errn() << "IntegralV3::spherical_transform_iter: bad l" << endl;
|
---|
135 | abort();
|
---|
136 | }
|
---|
137 | if (subl == -1) subl = l;
|
---|
138 | if (subl < 0 || subl > l || (l-subl)%2 != 0) {
|
---|
139 | ExEnv::errn() << "IntegralV3::spherical_transform_iter: bad subl" << endl;
|
---|
140 | abort();
|
---|
141 | }
|
---|
142 | if (inv) {
|
---|
143 | return ist_[l][(l-subl)/2];
|
---|
144 | }
|
---|
145 | return st_[l][(l-subl)/2];
|
---|
146 | }
|
---|
147 |
|
---|
148 | Ref<OneBodyInt>
|
---|
149 | IntegralV3::overlap()
|
---|
150 | {
|
---|
151 | return new OneBodyIntV3(this, bs1_, bs2_, &Int1eV3::overlap);
|
---|
152 | }
|
---|
153 |
|
---|
154 | Ref<OneBodyInt>
|
---|
155 | IntegralV3::kinetic()
|
---|
156 | {
|
---|
157 | return new OneBodyIntV3(this, bs1_, bs2_, &Int1eV3::kinetic);
|
---|
158 | }
|
---|
159 |
|
---|
160 | Ref<OneBodyInt>
|
---|
161 | IntegralV3::nuclear()
|
---|
162 | {
|
---|
163 | return new OneBodyIntV3(this, bs1_, bs2_, &Int1eV3::nuclear);
|
---|
164 | }
|
---|
165 |
|
---|
166 | Ref<OneBodyInt>
|
---|
167 | IntegralV3::hcore()
|
---|
168 | {
|
---|
169 | return new OneBodyIntV3(this, bs1_, bs2_, &Int1eV3::hcore);
|
---|
170 | }
|
---|
171 |
|
---|
172 | Ref<OneBodyOneCenterInt>
|
---|
173 | IntegralV3::point_charge1(const Ref<PointChargeData>& dat)
|
---|
174 | {
|
---|
175 | Ref<GaussianBasisSet> unit(new GaussianBasisSet(GaussianBasisSet::Unit));
|
---|
176 | return new OneBodyOneCenterWrapper(new PointChargeIntV3(this, bs1_, unit ,dat));
|
---|
177 | }
|
---|
178 |
|
---|
179 | Ref<OneBodyInt>
|
---|
180 | IntegralV3::point_charge(const Ref<PointChargeData>& dat)
|
---|
181 | {
|
---|
182 | return new PointChargeIntV3(this, bs1_, bs2_, dat);
|
---|
183 | }
|
---|
184 |
|
---|
185 | Ref<OneBodyInt>
|
---|
186 | IntegralV3::efield_dot_vector(const Ref<EfieldDotVectorData>&dat)
|
---|
187 | {
|
---|
188 | return new EfieldDotVectorIntV3(this, bs1_, bs2_, dat);
|
---|
189 | }
|
---|
190 |
|
---|
191 | Ref<OneBodyInt>
|
---|
192 | IntegralV3::dipole(const Ref<DipoleData>& dat)
|
---|
193 | {
|
---|
194 | return new DipoleIntV3(this, bs1_, bs2_, dat);
|
---|
195 | }
|
---|
196 |
|
---|
197 | Ref<OneBodyInt>
|
---|
198 | IntegralV3::quadrupole(const Ref<DipoleData>& dat)
|
---|
199 | {
|
---|
200 | throw std::runtime_error("IntegralV3 cannot compute quadrupole moment integrals yet. Try IntegralCints instead.");
|
---|
201 | }
|
---|
202 |
|
---|
203 | Ref<OneBodyDerivInt>
|
---|
204 | IntegralV3::overlap_deriv()
|
---|
205 | {
|
---|
206 | return new OneBodyDerivIntV3(this, bs1_, bs2_, &Int1eV3::overlap_1der);
|
---|
207 | }
|
---|
208 |
|
---|
209 | Ref<OneBodyDerivInt>
|
---|
210 | IntegralV3::kinetic_deriv()
|
---|
211 | {
|
---|
212 | return new OneBodyDerivIntV3(this, bs1_, bs2_, &Int1eV3::kinetic_1der);
|
---|
213 | }
|
---|
214 |
|
---|
215 | Ref<OneBodyDerivInt>
|
---|
216 | IntegralV3::nuclear_deriv()
|
---|
217 | {
|
---|
218 | return new OneBodyDerivIntV3(this, bs1_, bs2_, &Int1eV3::nuclear_1der);
|
---|
219 | }
|
---|
220 |
|
---|
221 | Ref<OneBodyDerivInt>
|
---|
222 | IntegralV3::hcore_deriv()
|
---|
223 | {
|
---|
224 | return new OneBodyDerivIntV3(this, bs1_, bs2_, &Int1eV3::hcore_1der);
|
---|
225 | }
|
---|
226 |
|
---|
227 | Ref<TwoBodyInt>
|
---|
228 | IntegralV3::electron_repulsion()
|
---|
229 | {
|
---|
230 | return new TwoBodyIntV3(this, bs1_, bs2_, bs3_, bs4_, storage_);
|
---|
231 | }
|
---|
232 |
|
---|
233 | Ref<TwoBodyThreeCenterInt>
|
---|
234 | IntegralV3::electron_repulsion3()
|
---|
235 | {
|
---|
236 | return new TwoBodyThreeCenterIntV3(this, bs1_, bs2_, bs3_, storage_);
|
---|
237 | }
|
---|
238 |
|
---|
239 | Ref<TwoBodyTwoCenterInt>
|
---|
240 | IntegralV3::electron_repulsion2()
|
---|
241 | {
|
---|
242 | return new TwoBodyTwoCenterIntV3(this, bs1_, bs2_, storage_);
|
---|
243 | }
|
---|
244 |
|
---|
245 | Ref<TwoBodyDerivInt>
|
---|
246 | IntegralV3::electron_repulsion_deriv()
|
---|
247 | {
|
---|
248 | return new TwoBodyDerivIntV3(this, bs1_, bs2_, bs3_, bs4_, storage_);
|
---|
249 | }
|
---|
250 |
|
---|
251 | void
|
---|
252 | IntegralV3::set_basis(const Ref<GaussianBasisSet> &b1,
|
---|
253 | const Ref<GaussianBasisSet> &b2,
|
---|
254 | const Ref<GaussianBasisSet> &b3,
|
---|
255 | const Ref<GaussianBasisSet> &b4)
|
---|
256 | {
|
---|
257 | free_transforms();
|
---|
258 | Integral::set_basis(b1,b2,b3,b4);
|
---|
259 | initialize_transforms();
|
---|
260 | }
|
---|
261 |
|
---|
262 | void
|
---|
263 | IntegralV3::free_transforms()
|
---|
264 | {
|
---|
265 | int i,j;
|
---|
266 | for (i=0; i<=maxl_; i++) {
|
---|
267 | for (j=0; j<=i/2; j++) {
|
---|
268 | delete st_[i][j];
|
---|
269 | delete ist_[i][j];
|
---|
270 | }
|
---|
271 | delete[] st_[i];
|
---|
272 | delete[] ist_[i];
|
---|
273 | }
|
---|
274 | delete[] st_;
|
---|
275 | delete[] ist_;
|
---|
276 | st_ = 0;
|
---|
277 | ist_ = 0;
|
---|
278 | }
|
---|
279 |
|
---|
280 | void
|
---|
281 | IntegralV3::initialize_transforms()
|
---|
282 | {
|
---|
283 | maxl_ = -1;
|
---|
284 | int maxam;
|
---|
285 | maxam = bs1_.nonnull()?bs1_->max_angular_momentum():-1;
|
---|
286 | if (maxl_ < maxam) maxl_ = maxam;
|
---|
287 | maxam = bs2_.nonnull()?bs2_->max_angular_momentum():-1;
|
---|
288 | if (maxl_ < maxam) maxl_ = maxam;
|
---|
289 | maxam = bs3_.nonnull()?bs3_->max_angular_momentum():-1;
|
---|
290 | if (maxl_ < maxam) maxl_ = maxam;
|
---|
291 | maxam = bs4_.nonnull()?bs4_->max_angular_momentum():-1;
|
---|
292 | if (maxl_ < maxam) maxl_ = maxam;
|
---|
293 |
|
---|
294 | st_ = new SphericalTransformV3**[maxl_+1];
|
---|
295 | ist_ = new ISphericalTransformV3**[maxl_+1];;
|
---|
296 | int i,j;
|
---|
297 | for (i=0; i<=maxl_; i++) {
|
---|
298 | st_[i] = new SphericalTransformV3*[i/2+1];
|
---|
299 | ist_[i] = new ISphericalTransformV3*[i/2+1];
|
---|
300 | for (j=0; j<=i/2; j++) {
|
---|
301 | st_[i][j] = new SphericalTransformV3(i,i-2*j);
|
---|
302 | ist_[i][j] = new ISphericalTransformV3(i,i-2*j);
|
---|
303 | }
|
---|
304 | }
|
---|
305 | }
|
---|
306 |
|
---|
307 | /////////////////////////////////////////////////////////////////////////////
|
---|
308 |
|
---|
309 | // Local Variables:
|
---|
310 | // mode: c++
|
---|
311 | // c-file-style: "CLJ"
|
---|
312 | // End:
|
---|