1 | //
|
---|
2 | // intcca.cc
|
---|
3 | //
|
---|
4 | // Copyright (C) 2004 Sandia National Laboratories
|
---|
5 | //
|
---|
6 | // Author: Joe Kenny <jpkenny@sandia.gov>
|
---|
7 | // Maintainer: Joe Kenny
|
---|
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 <util/state/stateio.h>
|
---|
29 | #include <util/misc/ccaenv.h>
|
---|
30 | #include <chemistry/qc/basis/integral.h>
|
---|
31 | #include <chemistry/qc/intcca/intcca.h>
|
---|
32 | #include <chemistry/qc/intcca/obintcca.h>
|
---|
33 | #include <chemistry/qc/intcca/tbintcca.h>
|
---|
34 | #include <util/class/scexception.h>
|
---|
35 | #ifdef INTV3_ORDER
|
---|
36 | #include <chemistry/qc/intv3/cartitv3.h>
|
---|
37 | #include <chemistry/qc/intv3/tformv3.h>
|
---|
38 | #else
|
---|
39 | #include <chemistry/qc/intcca/cartit.h>
|
---|
40 | #include <chemistry/qc/intcca/tform.h>
|
---|
41 | #endif
|
---|
42 |
|
---|
43 | using namespace std;
|
---|
44 | using namespace sc;
|
---|
45 | using namespace Chemistry::QC::GaussianBasis;
|
---|
46 |
|
---|
47 | static ClassDesc IntegralCCA_cd(
|
---|
48 | typeid(IntegralCCA),"IntegralCCA",1,"public Integral",
|
---|
49 | 0, create<IntegralCCA>, create<IntegralCCA>);
|
---|
50 |
|
---|
51 | extern Ref<Integral> default_integral;
|
---|
52 |
|
---|
53 | /* may need to add optional "eval_factory" argument to this method in
|
---|
54 | integral class to get this capability
|
---|
55 | Integral*
|
---|
56 | Integral::get_default_integral()
|
---|
57 | {
|
---|
58 | if (default_integral.null())
|
---|
59 | default_integral = new IntegralCCA();
|
---|
60 |
|
---|
61 | return default_integral;
|
---|
62 | }
|
---|
63 | */
|
---|
64 |
|
---|
65 | IntegralCCA::IntegralCCA(IntegralEvaluatorFactory eval_factory, bool use_opaque,
|
---|
66 | const Ref<GaussianBasisSet> &b1,
|
---|
67 | const Ref<GaussianBasisSet> &b2,
|
---|
68 | const Ref<GaussianBasisSet> &b3,
|
---|
69 | const Ref<GaussianBasisSet> &b4):
|
---|
70 | Integral(b1,b2,b3,b4), eval_factory_(eval_factory)
|
---|
71 | {
|
---|
72 | use_opaque_ = use_opaque;
|
---|
73 | initialize_transforms();
|
---|
74 | }
|
---|
75 |
|
---|
76 | IntegralCCA::IntegralCCA(const Ref<KeyVal> &keyval):
|
---|
77 | Integral(keyval)
|
---|
78 | {
|
---|
79 |
|
---|
80 | initialize_transforms();
|
---|
81 |
|
---|
82 | string buffer = keyval->stringvalue("integral_buffer");
|
---|
83 | if ( keyval->error() != KeyVal::OK ) buffer = "opaque";
|
---|
84 | if ( buffer == "opaque" ) use_opaque_ = 1;
|
---|
85 | else if ( buffer == "array" ) use_opaque_ = 0;
|
---|
86 | else {
|
---|
87 | InputError ex("integral_buffer must be either opaque or array",__FILE__, __LINE__,
|
---|
88 | "integral_buffer",buffer.c_str(),class_desc());
|
---|
89 | throw ex;
|
---|
90 | }
|
---|
91 |
|
---|
92 | factory_type_ = keyval->stringvalue("evaluator_factory");
|
---|
93 | if ( keyval->error() != KeyVal::OK ) {
|
---|
94 | factory_type_ = string("MPQC.IntegralEvaluatorFactory");
|
---|
95 | }
|
---|
96 | package_ = keyval->stringvalue("integral_package");
|
---|
97 | if ( keyval->error() != KeyVal::OK ) {
|
---|
98 | package_ = string("intv3");
|
---|
99 | }
|
---|
100 | #ifdef INTV3_ORDER
|
---|
101 | if(package_ == "cints") {
|
---|
102 | InputError ex("using intv3 ordering, can't use cints",__FILE__, __LINE__);
|
---|
103 | try { ex.elaborate() << "INTV3_ORDER=yes in LocalMakefile,"
|
---|
104 | << " this option is for development use only";
|
---|
105 | }
|
---|
106 | catch (...) {}
|
---|
107 | throw ex;
|
---|
108 | }
|
---|
109 | #endif
|
---|
110 |
|
---|
111 | sc_molecule_ << keyval->describedclassvalue("molecule");
|
---|
112 | if (sc_molecule_.null())
|
---|
113 | throw InputError("molecule is required",__FILE__,__LINE__);
|
---|
114 |
|
---|
115 | gov::cca::Services &services = *CCAEnv::get_services();
|
---|
116 | gov::cca::ports::BuilderService &bs = *CCAEnv::get_builder_service();
|
---|
117 | gov::cca::TypeMap &type_map = *CCAEnv::get_type_map();
|
---|
118 | gov::cca::ComponentID &my_id = *CCAEnv::get_component_id();
|
---|
119 |
|
---|
120 | // get eval factory
|
---|
121 | fac_id_ = bs.createInstance("evaluator_factory",factory_type_,type_map);
|
---|
122 | services.registerUsesPort("IntegralEvaluatorFactory",
|
---|
123 | "Chemistry.QC.GaussianBasis.IntegralEvaluatorFactory",
|
---|
124 | type_map);
|
---|
125 | fac_con_ = bs.connect(my_id,"IntegralEvaluatorFactory",
|
---|
126 | fac_id_,"IntegralEvaluatorFactory");
|
---|
127 | eval_factory_ = services.getPort("IntegralEvaluatorFactory");
|
---|
128 |
|
---|
129 | // set molecule on factory
|
---|
130 | molecule_ = Chemistry::Chemistry_Molecule::_create();
|
---|
131 | molecule_.initialize(sc_molecule_->natom(),"bohr");
|
---|
132 | for( int i=0; i<sc_molecule_->natom(); ++i ) {
|
---|
133 | molecule_.set_atomic_number( i, sc_molecule_->Z(i) );
|
---|
134 | for( int j=0; j<3; ++j )
|
---|
135 | molecule_.set_cart_coor( i, j, sc_molecule_->r(i,j) );
|
---|
136 | }
|
---|
137 | eval_factory_.set_molecule(molecule_);
|
---|
138 |
|
---|
139 | // set package
|
---|
140 | eval_factory_.set_integral_package(package_);
|
---|
141 |
|
---|
142 | }
|
---|
143 |
|
---|
144 | IntegralCCA::IntegralCCA(StateIn& s) :
|
---|
145 | Integral(s)
|
---|
146 | {
|
---|
147 | initialize_transforms();
|
---|
148 | }
|
---|
149 |
|
---|
150 | void
|
---|
151 | IntegralCCA::save_data_state(StateOut& s)
|
---|
152 | {
|
---|
153 | Integral::save_data_state(s);
|
---|
154 | }
|
---|
155 |
|
---|
156 | IntegralCCA::~IntegralCCA()
|
---|
157 | {
|
---|
158 | free_transforms();
|
---|
159 | }
|
---|
160 |
|
---|
161 | Integral*
|
---|
162 | IntegralCCA::clone()
|
---|
163 | {
|
---|
164 | // ???
|
---|
165 | return new IntegralCCA(eval_factory_,use_opaque_);
|
---|
166 | // this wouldn't take much work
|
---|
167 | //throw FeatureNotImplemented("clone not implemented",
|
---|
168 | // __FILE__,__LINE__);
|
---|
169 | }
|
---|
170 |
|
---|
171 | CartesianIter *
|
---|
172 | IntegralCCA::new_cartesian_iter(int l)
|
---|
173 | {
|
---|
174 | #ifdef INTV3_ORDER
|
---|
175 | return new CartesianIterV3(l);
|
---|
176 | #else
|
---|
177 | return new CartesianIterCCA(l);
|
---|
178 | #endif
|
---|
179 | }
|
---|
180 |
|
---|
181 | RedundantCartesianIter *
|
---|
182 | IntegralCCA::new_redundant_cartesian_iter(int l)
|
---|
183 | {
|
---|
184 | #ifdef INTV3_ORDER
|
---|
185 | return new RedundantCartesianIterV3(l);
|
---|
186 | #else
|
---|
187 | return new RedundantCartesianIterCCA(l);
|
---|
188 | #endif
|
---|
189 | }
|
---|
190 |
|
---|
191 | RedundantCartesianSubIter *
|
---|
192 | IntegralCCA::new_redundant_cartesian_sub_iter(int l)
|
---|
193 | {
|
---|
194 | #ifdef INTV3_ORDER
|
---|
195 | return new RedundantCartesianSubIterV3(l);
|
---|
196 | #else
|
---|
197 | return new RedundantCartesianSubIterCCA(l);
|
---|
198 | #endif
|
---|
199 | }
|
---|
200 |
|
---|
201 | SphericalTransformIter *
|
---|
202 | IntegralCCA::new_spherical_transform_iter(int l, int inv, int subl)
|
---|
203 | {
|
---|
204 | #ifdef INTV3_ORDER
|
---|
205 |
|
---|
206 | if (l>maxl_ || l<0)
|
---|
207 | throw ProgrammingError("new_spherical_transform_iter: bad l",
|
---|
208 | __FILE__,__LINE__);
|
---|
209 | if (subl == -1) subl = l;
|
---|
210 | if (subl < 0 || subl > l || (l-subl)%2 != 0)
|
---|
211 | throw ProgrammingError("new_spherical_transform_iter: bad subl",
|
---|
212 | __FILE__,__LINE__);
|
---|
213 | if (inv)
|
---|
214 | return new SphericalTransformIter(ist_[l][(l-subl)/2]);
|
---|
215 | return new SphericalTransformIter(st_[l][(l-subl)/2]);
|
---|
216 |
|
---|
217 | #else
|
---|
218 |
|
---|
219 | // CINTS version
|
---|
220 | if (l>maxl_ || l<0)
|
---|
221 | throw ProgrammingError("new_spherical_transform_iter: bad l",
|
---|
222 | __FILE__,__LINE__);
|
---|
223 | if (subl == -1) subl = l;
|
---|
224 | if (subl < 0 || subl > l || (l-subl)%2 != 0)
|
---|
225 | throw ProgrammingError("new_spherical_transform_iter: bad subl",
|
---|
226 | __FILE__,__LINE__);
|
---|
227 | if (inv)
|
---|
228 | return new SphericalTransformIter(ist_[l][(l-subl)/2]);
|
---|
229 | return new SphericalTransformIter(st_[l][(l-subl)/2]);
|
---|
230 |
|
---|
231 | #endif
|
---|
232 |
|
---|
233 | }
|
---|
234 |
|
---|
235 | const SphericalTransform *
|
---|
236 | IntegralCCA::spherical_transform(int l, int inv, int subl)
|
---|
237 | {
|
---|
238 | #ifdef INTV3_ORDER
|
---|
239 |
|
---|
240 | // INTV3 version
|
---|
241 | if (l>maxl_ || l<0)
|
---|
242 | throw ProgrammingError("spherical_transform_iter: bad l",
|
---|
243 | __FILE__,__LINE__);
|
---|
244 | if (subl == -1) subl = l;
|
---|
245 | if (subl < 0 || subl > l || (l-subl)%2 != 0)
|
---|
246 | throw ProgrammingError("spherical_transform_iter: bad subl",
|
---|
247 | __FILE__,__LINE__);
|
---|
248 | if (inv)
|
---|
249 | return ist_[l][(l-subl)/2];
|
---|
250 | return st_[l][(l-subl)/2];
|
---|
251 |
|
---|
252 | #else
|
---|
253 |
|
---|
254 | // CINTS version
|
---|
255 | if (l>maxl_ || l<0)
|
---|
256 | throw ProgrammingError("spherical_transform_iter: bad l",
|
---|
257 | __FILE__,__LINE__);
|
---|
258 | if (subl == -1) subl = l;
|
---|
259 | if (subl < 0 || subl > l || (l-subl)%2 != 0)
|
---|
260 | throw ProgrammingError("spherical_transform_iter: bad subl",
|
---|
261 | __FILE__,__LINE__);
|
---|
262 | if (inv)
|
---|
263 | return ist_[l][(l-subl)/2];
|
---|
264 | return st_[l][(l-subl)/2];
|
---|
265 |
|
---|
266 | #endif
|
---|
267 |
|
---|
268 | }
|
---|
269 |
|
---|
270 | Ref<OneBodyInt>
|
---|
271 | IntegralCCA::overlap()
|
---|
272 | {
|
---|
273 | return new OneBodyIntCCA(this, bs1_, bs2_, eval_factory_, &Int1eCCA::overlap,
|
---|
274 | use_opaque_ );
|
---|
275 | }
|
---|
276 |
|
---|
277 | Ref<OneBodyInt>
|
---|
278 | IntegralCCA::kinetic()
|
---|
279 | {
|
---|
280 | return new OneBodyIntCCA(this, bs1_, bs2_, eval_factory_, &Int1eCCA::kinetic,
|
---|
281 | use_opaque_ );
|
---|
282 | }
|
---|
283 |
|
---|
284 | Ref<OneBodyInt>
|
---|
285 | IntegralCCA::nuclear()
|
---|
286 | {
|
---|
287 | return new OneBodyIntCCA(this, bs1_, bs2_, eval_factory_, &Int1eCCA::nuclear,
|
---|
288 | use_opaque_ );
|
---|
289 | }
|
---|
290 |
|
---|
291 | Ref<OneBodyInt>
|
---|
292 | IntegralCCA::hcore()
|
---|
293 | {
|
---|
294 | return new OneBodyIntCCA(this, bs1_, bs2_, eval_factory_, &Int1eCCA::hcore,
|
---|
295 | use_opaque_ );
|
---|
296 | }
|
---|
297 |
|
---|
298 | Ref<OneBodyInt>
|
---|
299 | IntegralCCA::point_charge(const Ref<PointChargeData>& dat)
|
---|
300 | {
|
---|
301 | throw FeatureNotImplemented("point_charge not implemented",
|
---|
302 | __FILE__,__LINE__);
|
---|
303 | }
|
---|
304 |
|
---|
305 | Ref<OneBodyInt>
|
---|
306 | IntegralCCA::efield_dot_vector(const Ref<EfieldDotVectorData>&dat)
|
---|
307 | {
|
---|
308 | throw FeatureNotImplemented("efield_dot_vector not iplemented",
|
---|
309 | __FILE__,__LINE__);
|
---|
310 | }
|
---|
311 |
|
---|
312 | Ref<OneBodyInt>
|
---|
313 | IntegralCCA::dipole(const Ref<DipoleData>& dat)
|
---|
314 | {
|
---|
315 | throw FeatureNotImplemented("dipole not implemented",
|
---|
316 | __FILE__,__LINE__);
|
---|
317 | }
|
---|
318 |
|
---|
319 | Ref<OneBodyInt>
|
---|
320 | IntegralCCA::quadrupole(const Ref<DipoleData>& dat)
|
---|
321 | {
|
---|
322 | throw FeatureNotImplemented("quadrupole not implemented",
|
---|
323 | __FILE__,__LINE__);
|
---|
324 | }
|
---|
325 |
|
---|
326 | Ref<OneBodyDerivInt>
|
---|
327 | IntegralCCA::overlap_deriv()
|
---|
328 | {
|
---|
329 | return new OneBodyDerivIntCCA(this, bs1_, bs2_, eval_factory_, use_opaque_,
|
---|
330 | "overlap_1der");
|
---|
331 | }
|
---|
332 |
|
---|
333 | Ref<OneBodyDerivInt>
|
---|
334 | IntegralCCA::kinetic_deriv()
|
---|
335 | {
|
---|
336 | return new OneBodyDerivIntCCA(this, bs1_, bs2_, eval_factory_, use_opaque_,
|
---|
337 | "kinetic_1der");
|
---|
338 | }
|
---|
339 |
|
---|
340 | Ref<OneBodyDerivInt>
|
---|
341 | IntegralCCA::nuclear_deriv()
|
---|
342 | {
|
---|
343 | return new OneBodyDerivIntCCA(this, bs1_, bs2_, eval_factory_, use_opaque_,
|
---|
344 | "nuclear_1der");
|
---|
345 | }
|
---|
346 |
|
---|
347 | Ref<OneBodyDerivInt>
|
---|
348 | IntegralCCA::hcore_deriv()
|
---|
349 | {
|
---|
350 | return new OneBodyDerivIntCCA(this, bs1_, bs2_, eval_factory_, use_opaque_,
|
---|
351 | "hcore_1der");
|
---|
352 | }
|
---|
353 |
|
---|
354 | Ref<TwoBodyInt>
|
---|
355 | IntegralCCA::electron_repulsion()
|
---|
356 | {
|
---|
357 | return new TwoBodyIntCCA(this, bs1_, bs2_, bs3_, bs4_,
|
---|
358 | storage_, eval_factory_, use_opaque_, "eri" );
|
---|
359 | }
|
---|
360 |
|
---|
361 | Ref<TwoBodyDerivInt>
|
---|
362 | IntegralCCA::electron_repulsion_deriv()
|
---|
363 | {
|
---|
364 | return new TwoBodyDerivIntCCA(this, bs1_, bs2_, bs3_, bs4_,
|
---|
365 | storage_, eval_factory_, use_opaque_, "eri_1der" );
|
---|
366 | }
|
---|
367 |
|
---|
368 | void
|
---|
369 | IntegralCCA::set_basis(const Ref<GaussianBasisSet> &b1,
|
---|
370 | const Ref<GaussianBasisSet> &b2,
|
---|
371 | const Ref<GaussianBasisSet> &b3,
|
---|
372 | const Ref<GaussianBasisSet> &b4)
|
---|
373 | {
|
---|
374 | free_transforms();
|
---|
375 | Integral::set_basis(b1,b2,b3,b4);
|
---|
376 | initialize_transforms();
|
---|
377 | }
|
---|
378 |
|
---|
379 | void
|
---|
380 | IntegralCCA::free_transforms()
|
---|
381 | {
|
---|
382 | #ifdef INTV3_ORDER
|
---|
383 |
|
---|
384 | // INTV3 version
|
---|
385 | int i,j;
|
---|
386 | for (i=0; i<=maxl_; i++) {
|
---|
387 | for (j=0; j<=i/2; j++) {
|
---|
388 | delete st_[i][j];
|
---|
389 | delete ist_[i][j];
|
---|
390 | }
|
---|
391 | delete[] st_[i];
|
---|
392 | delete[] ist_[i];
|
---|
393 | }
|
---|
394 | delete[] st_;
|
---|
395 | delete[] ist_;
|
---|
396 | st_ = 0;
|
---|
397 | ist_ = 0;
|
---|
398 |
|
---|
399 | #else
|
---|
400 |
|
---|
401 | // CINTS version
|
---|
402 | int i,j;
|
---|
403 | for (i=0; i<=maxl_; i++) {
|
---|
404 | for (j=0; j<=i/2; j++) {
|
---|
405 | delete st_[i][j];
|
---|
406 | delete ist_[i][j];
|
---|
407 | }
|
---|
408 | delete[] st_[i];
|
---|
409 | delete[] ist_[i];
|
---|
410 | }
|
---|
411 | if (maxl_ >= 0) {
|
---|
412 | delete[] st_;
|
---|
413 | delete[] ist_;
|
---|
414 | }
|
---|
415 | st_ = NULL;
|
---|
416 | ist_ = NULL;
|
---|
417 |
|
---|
418 | #endif
|
---|
419 |
|
---|
420 | }
|
---|
421 |
|
---|
422 | void
|
---|
423 | IntegralCCA::initialize_transforms()
|
---|
424 | {
|
---|
425 | maxl_ = -1;
|
---|
426 | int maxam;
|
---|
427 | maxam = bs1_.nonnull()?bs1_->max_angular_momentum():-1;
|
---|
428 | if (maxl_ < maxam) maxl_ = maxam;
|
---|
429 | maxam = bs2_.nonnull()?bs2_->max_angular_momentum():-1;
|
---|
430 | if (maxl_ < maxam) maxl_ = maxam;
|
---|
431 | maxam = bs3_.nonnull()?bs3_->max_angular_momentum():-1;
|
---|
432 | if (maxl_ < maxam) maxl_ = maxam;
|
---|
433 | maxam = bs4_.nonnull()?bs4_->max_angular_momentum():-1;
|
---|
434 | if (maxl_ < maxam) maxl_ = maxam;
|
---|
435 |
|
---|
436 | #ifdef INTV3_ORDER
|
---|
437 |
|
---|
438 | // INTV3 version
|
---|
439 | st_ = new SphericalTransform**[maxl_+1];
|
---|
440 | ist_ = new ISphericalTransform**[maxl_+1];
|
---|
441 | int i,j;
|
---|
442 | for (i=0; i<=maxl_; i++) {
|
---|
443 | st_[i] = new SphericalTransform*[i/2+1];
|
---|
444 | ist_[i] = new ISphericalTransform*[i/2+1];
|
---|
445 | for (j=0; j<=i/2; j++) {
|
---|
446 | st_[i][j] = new SphericalTransformV3(i,i-2*j);
|
---|
447 | ist_[i][j] = new ISphericalTransformV3(i,i-2*j);
|
---|
448 | }
|
---|
449 | }
|
---|
450 |
|
---|
451 | #else
|
---|
452 |
|
---|
453 | // CINTS version
|
---|
454 | if (maxl_ >= 0) {
|
---|
455 | st_ = new SphericalTransform**[maxl_+1];
|
---|
456 | ist_ = new ISphericalTransform**[maxl_+1];
|
---|
457 | int i,j;
|
---|
458 | for (i=0; i<=maxl_; i++) {
|
---|
459 | st_[i] = new SphericalTransform*[i/2+1];
|
---|
460 | ist_[i] = new ISphericalTransform*[i/2+1];
|
---|
461 | for (j=0; j<=i/2; j++) {
|
---|
462 | st_[i][j] = new SphericalTransformCCA(i,i-2*j);
|
---|
463 | ist_[i][j] = new ISphericalTransformCCA(i,i-2*j);
|
---|
464 | }
|
---|
465 | }
|
---|
466 | }
|
---|
467 | else {
|
---|
468 | st_ = NULL;
|
---|
469 | ist_ = NULL;
|
---|
470 | }
|
---|
471 |
|
---|
472 | #endif
|
---|
473 |
|
---|
474 | }
|
---|
475 |
|
---|
476 | /////////////////////////////////////////////////////////////////////////////
|
---|
477 |
|
---|
478 | // Local Variables:
|
---|
479 | // mode: c++
|
---|
480 | // c-file-style: "CLJ"
|
---|
481 | // End:
|
---|