| 1 | //
|
|---|
| 2 | // cints.cc
|
|---|
| 3 | //
|
|---|
| 4 | // Copyright (C) 2001 Edward Valeev
|
|---|
| 5 | //
|
|---|
| 6 | // Author: Edward Valeev <edward.valeev@chemistry.gatech.edu>
|
|---|
| 7 | // Maintainer: EV
|
|---|
| 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 <util/misc/formio.h>
|
|---|
| 32 | #include <chemistry/qc/cints/cints.h>
|
|---|
| 33 | #include <chemistry/qc/cints/cartit.h>
|
|---|
| 34 | #include <chemistry/qc/cints/tform.h>
|
|---|
| 35 | #include <chemistry/qc/cints/obintcints.h>
|
|---|
| 36 | #include <chemistry/qc/cints/tbintcints.h>
|
|---|
| 37 | #include <chemistry/qc/cints/eri.h>
|
|---|
| 38 | #include <chemistry/qc/cints/grt.h>
|
|---|
| 39 |
|
|---|
| 40 | using namespace std;
|
|---|
| 41 | using namespace sc;
|
|---|
| 42 |
|
|---|
| 43 | inline void fail()
|
|---|
| 44 | {
|
|---|
| 45 | ExEnv::errn() << scprintf("failing module:\n%s",__FILE__) << endl;
|
|---|
| 46 | abort();
|
|---|
| 47 | }
|
|---|
| 48 |
|
|---|
| 49 | static ClassDesc IntegralCints_cd(
|
|---|
| 50 | typeid(IntegralCints),"IntegralCints",1,"public Integral",
|
|---|
| 51 | 0, create<IntegralCints>, create<IntegralCints>);
|
|---|
| 52 |
|
|---|
| 53 | IntegralCints::IntegralCints(const Ref<GaussianBasisSet> &b1,
|
|---|
| 54 | const Ref<GaussianBasisSet> &b2,
|
|---|
| 55 | const Ref<GaussianBasisSet> &b3,
|
|---|
| 56 | const Ref<GaussianBasisSet> &b4):
|
|---|
| 57 | Integral(b1,b2,b3,b4)
|
|---|
| 58 | {
|
|---|
| 59 | initialize_transforms();
|
|---|
| 60 | }
|
|---|
| 61 |
|
|---|
| 62 | IntegralCints::IntegralCints(StateIn& s) :
|
|---|
| 63 | Integral(s)
|
|---|
| 64 | {
|
|---|
| 65 | initialize_transforms();
|
|---|
| 66 | }
|
|---|
| 67 |
|
|---|
| 68 | IntegralCints::IntegralCints(const Ref<KeyVal>& k) :
|
|---|
| 69 | Integral(k)
|
|---|
| 70 | {
|
|---|
| 71 | initialize_transforms();
|
|---|
| 72 | }
|
|---|
| 73 |
|
|---|
| 74 | void
|
|---|
| 75 | IntegralCints::save_data_state(StateOut& s)
|
|---|
| 76 | {
|
|---|
| 77 | Integral::save_data_state(s);
|
|---|
| 78 | }
|
|---|
| 79 |
|
|---|
| 80 | IntegralCints::~IntegralCints()
|
|---|
| 81 | {
|
|---|
| 82 | free_transforms();
|
|---|
| 83 | }
|
|---|
| 84 |
|
|---|
| 85 | Integral*
|
|---|
| 86 | IntegralCints::clone()
|
|---|
| 87 | {
|
|---|
| 88 | return new IntegralCints;
|
|---|
| 89 | }
|
|---|
| 90 |
|
|---|
| 91 | size_t
|
|---|
| 92 | IntegralCints::storage_required_eri(const Ref<GaussianBasisSet> &b1,
|
|---|
| 93 | const Ref<GaussianBasisSet> &b2,
|
|---|
| 94 | const Ref<GaussianBasisSet> &b3,
|
|---|
| 95 | const Ref<GaussianBasisSet> &b4)
|
|---|
| 96 | {
|
|---|
| 97 | return EriCints::storage_required(b1,b2,b3,b4);
|
|---|
| 98 | }
|
|---|
| 99 |
|
|---|
| 100 | size_t
|
|---|
| 101 | IntegralCints::storage_required_grt(const Ref<GaussianBasisSet> &b1,
|
|---|
| 102 | const Ref<GaussianBasisSet> &b2,
|
|---|
| 103 | const Ref<GaussianBasisSet> &b3,
|
|---|
| 104 | const Ref<GaussianBasisSet> &b4)
|
|---|
| 105 | {
|
|---|
| 106 | return GRTCints::storage_required(b1,b2,b3,b4);
|
|---|
| 107 | }
|
|---|
| 108 |
|
|---|
| 109 | CartesianIter *
|
|---|
| 110 | IntegralCints::new_cartesian_iter(int l)
|
|---|
| 111 | {
|
|---|
| 112 | return new CartesianIterCints(l);
|
|---|
| 113 | }
|
|---|
| 114 |
|
|---|
| 115 | RedundantCartesianIter *
|
|---|
| 116 | IntegralCints::new_redundant_cartesian_iter(int l)
|
|---|
| 117 | {
|
|---|
| 118 | return new RedundantCartesianIterCints(l);
|
|---|
| 119 | }
|
|---|
| 120 |
|
|---|
| 121 | RedundantCartesianSubIter *
|
|---|
| 122 | IntegralCints::new_redundant_cartesian_sub_iter(int l)
|
|---|
| 123 | {
|
|---|
| 124 | return new RedundantCartesianSubIterCints(l);
|
|---|
| 125 | }
|
|---|
| 126 |
|
|---|
| 127 | SphericalTransformIter *
|
|---|
| 128 | IntegralCints::new_spherical_transform_iter(int l, int inv, int subl)
|
|---|
| 129 | {
|
|---|
| 130 | if (l>maxl_ || l<0) {
|
|---|
| 131 | ExEnv::errn() << "IntegralCints::new_spherical_transform_iter: bad l" << endl;
|
|---|
| 132 | abort();
|
|---|
| 133 | }
|
|---|
| 134 | if (subl == -1) subl = l;
|
|---|
| 135 | if (subl < 0 || subl > l || (l-subl)%2 != 0) {
|
|---|
| 136 | ExEnv::errn() << "IntegralCints::new_spherical_transform_iter: bad subl" << endl;
|
|---|
| 137 | abort();
|
|---|
| 138 | }
|
|---|
| 139 | if (inv) {
|
|---|
| 140 | return new SphericalTransformIter(ist_[l][(l-subl)/2]);
|
|---|
| 141 | }
|
|---|
| 142 | return new SphericalTransformIter(st_[l][(l-subl)/2]);
|
|---|
| 143 | }
|
|---|
| 144 |
|
|---|
| 145 | const SphericalTransform *
|
|---|
| 146 | IntegralCints::spherical_transform(int l, int inv, int subl)
|
|---|
| 147 | {
|
|---|
| 148 | if (l>maxl_ || l<0) {
|
|---|
| 149 | ExEnv::errn() << "IntegralCints::spherical_transform_iter: bad l" << endl;
|
|---|
| 150 | abort();
|
|---|
| 151 | }
|
|---|
| 152 | if (subl == -1) subl = l;
|
|---|
| 153 | if (subl < 0 || subl > l || (l-subl)%2 != 0) {
|
|---|
| 154 | ExEnv::errn() << "IntegralCints::spherical_transform_iter: bad subl" << endl;
|
|---|
| 155 | abort();
|
|---|
| 156 | }
|
|---|
| 157 | if (inv) {
|
|---|
| 158 | return ist_[l][(l-subl)/2];
|
|---|
| 159 | }
|
|---|
| 160 | return st_[l][(l-subl)/2];
|
|---|
| 161 | }
|
|---|
| 162 |
|
|---|
| 163 | Ref<OneBodyInt>
|
|---|
| 164 | IntegralCints::overlap()
|
|---|
| 165 | {
|
|---|
| 166 | return new OneBodyIntCints(this, bs1_, bs2_, &Int1eCints::overlap);
|
|---|
| 167 | }
|
|---|
| 168 |
|
|---|
| 169 | Ref<OneBodyInt>
|
|---|
| 170 | IntegralCints::kinetic()
|
|---|
| 171 | {
|
|---|
| 172 | return new OneBodyIntCints(this, bs1_, bs2_, &Int1eCints::kinetic);
|
|---|
| 173 | }
|
|---|
| 174 |
|
|---|
| 175 | Ref<OneBodyInt>
|
|---|
| 176 | IntegralCints::nuclear()
|
|---|
| 177 | {
|
|---|
| 178 | return new OneBodyIntCints(this, bs1_, bs2_, &Int1eCints::nuclear);
|
|---|
| 179 | }
|
|---|
| 180 |
|
|---|
| 181 | Ref<OneBodyInt>
|
|---|
| 182 | IntegralCints::hcore()
|
|---|
| 183 | {
|
|---|
| 184 | return new OneBodyIntCints(this, bs1_, bs2_, &Int1eCints::hcore);
|
|---|
| 185 | }
|
|---|
| 186 |
|
|---|
| 187 | Ref<OneBodyInt>
|
|---|
| 188 | IntegralCints::point_charge(const Ref<PointChargeData>& dat)
|
|---|
| 189 | {
|
|---|
| 190 | ExEnv::errn() << scprintf("IntegralCints::point_charge() is not yet implemented.\n");
|
|---|
| 191 | ExEnv::errn() << scprintf("Try using the IntegralV3 factory instead.\n");
|
|---|
| 192 | fail();
|
|---|
| 193 | return 0;
|
|---|
| 194 | // return new PointChargeIntV3(this, bs1_, bs2_, dat);
|
|---|
| 195 | }
|
|---|
| 196 |
|
|---|
| 197 | Ref<OneBodyInt>
|
|---|
| 198 | IntegralCints::efield_dot_vector(const Ref<EfieldDotVectorData>&dat)
|
|---|
| 199 | {
|
|---|
| 200 | ExEnv::errn() << scprintf("IntegralCints::efield_dot_vector() is not yet implemented.\n");
|
|---|
| 201 | ExEnv::errn() << scprintf("Try using the IntegralV3 factory instead.\n");
|
|---|
| 202 | fail();
|
|---|
| 203 | return 0;
|
|---|
| 204 | // return new EfieldDotVectorIntV3(this, bs1_, bs2_, dat);
|
|---|
| 205 | }
|
|---|
| 206 |
|
|---|
| 207 | Ref<OneBodyInt>
|
|---|
| 208 | IntegralCints::dipole(const Ref<DipoleData>& dat)
|
|---|
| 209 | {
|
|---|
| 210 | Ref<OneBodyIntCints> dipoleint = new OneBodyIntCints(this, bs1_, bs2_, &Int1eCints::edipole);
|
|---|
| 211 | dipoleint->set_multipole_origin(dat);
|
|---|
| 212 | return dipoleint;
|
|---|
| 213 | }
|
|---|
| 214 |
|
|---|
| 215 | Ref<OneBodyInt>
|
|---|
| 216 | IntegralCints::quadrupole(const Ref<DipoleData>& dat)
|
|---|
| 217 | {
|
|---|
| 218 | Ref<OneBodyIntCints> quadint = new OneBodyIntCints(this, bs1_, bs2_, &Int1eCints::equadrupole);
|
|---|
| 219 | quadint->set_multipole_origin(dat);
|
|---|
| 220 | return quadint;
|
|---|
| 221 | }
|
|---|
| 222 |
|
|---|
| 223 | Ref<OneBodyDerivInt>
|
|---|
| 224 | IntegralCints::overlap_deriv()
|
|---|
| 225 | {
|
|---|
| 226 | ExEnv::errn() << scprintf("IntegralCints::overlap_deriv() is not yet implemented.\n");
|
|---|
| 227 | ExEnv::errn() << scprintf("Try using the IntegralV3 factory instead.\n");
|
|---|
| 228 | fail();
|
|---|
| 229 | return 0;
|
|---|
| 230 | // return new OneBodyDerivIntV3(this, bs1_, bs2_, &Int1eV3::overlap_1der);
|
|---|
| 231 | }
|
|---|
| 232 |
|
|---|
| 233 | Ref<OneBodyDerivInt>
|
|---|
| 234 | IntegralCints::kinetic_deriv()
|
|---|
| 235 | {
|
|---|
| 236 | ExEnv::errn() << scprintf("IntegralCints::kinetic_deriv() is not yet implemented.\n");
|
|---|
| 237 | ExEnv::errn() << scprintf("Try using the IntegralV3 factory instead.\n");
|
|---|
| 238 | fail();
|
|---|
| 239 | return 0;
|
|---|
| 240 | // return new OneBodyDerivIntV3(this, bs1_, bs2_, &Int1eV3::kinetic_1der);
|
|---|
| 241 | }
|
|---|
| 242 |
|
|---|
| 243 | Ref<OneBodyDerivInt>
|
|---|
| 244 | IntegralCints::nuclear_deriv()
|
|---|
| 245 | {
|
|---|
| 246 | ExEnv::errn() << scprintf("IntegralCints::nuclear_deriv() is not yet implemented.\n");
|
|---|
| 247 | ExEnv::errn() << scprintf("Try using the IntegralV3 factory instead.\n");
|
|---|
| 248 | fail();
|
|---|
| 249 | return 0;
|
|---|
| 250 | // return new OneBodyDerivIntV3(this, bs1_, bs2_, &Int1eV3::nuclear_1der);
|
|---|
| 251 | }
|
|---|
| 252 |
|
|---|
| 253 | Ref<OneBodyDerivInt>
|
|---|
| 254 | IntegralCints::hcore_deriv()
|
|---|
| 255 | {
|
|---|
| 256 | ExEnv::errn() << scprintf("IntegralCints::hcore_deriv() is not yet implemented.\n");
|
|---|
| 257 | ExEnv::errn() << scprintf("Try using the IntegralV3 factory instead.\n");
|
|---|
| 258 | fail();
|
|---|
| 259 | return 0;
|
|---|
| 260 | // return new OneBodyDerivIntV3(this, bs1_, bs2_, &Int1eV3::hcore_1der);
|
|---|
| 261 | }
|
|---|
| 262 |
|
|---|
| 263 | Ref<TwoBodyInt>
|
|---|
| 264 | IntegralCints::electron_repulsion()
|
|---|
| 265 | {
|
|---|
| 266 | return new TwoBodyIntCints(this, bs1_, bs2_, bs3_, bs4_, storage_, erieval);
|
|---|
| 267 | }
|
|---|
| 268 |
|
|---|
| 269 | Ref<TwoBodyDerivInt>
|
|---|
| 270 | IntegralCints::electron_repulsion_deriv()
|
|---|
| 271 | {
|
|---|
| 272 | ExEnv::errn() << scprintf("IntegralCints::electron_repulsion_deriv() is not yet implemented.\n");
|
|---|
| 273 | ExEnv::errn() << scprintf("Try using the IntegralV3 factory instead.\n");
|
|---|
| 274 | fail();
|
|---|
| 275 | return 0;
|
|---|
| 276 | }
|
|---|
| 277 |
|
|---|
| 278 | Ref<TwoBodyInt>
|
|---|
| 279 | IntegralCints::grt()
|
|---|
| 280 | {
|
|---|
| 281 | return new TwoBodyIntCints(this, bs1_, bs2_, bs3_, bs4_, storage_, grteval);
|
|---|
| 282 | }
|
|---|
| 283 |
|
|---|
| 284 | void
|
|---|
| 285 | IntegralCints::set_basis(const Ref<GaussianBasisSet> &b1,
|
|---|
| 286 | const Ref<GaussianBasisSet> &b2,
|
|---|
| 287 | const Ref<GaussianBasisSet> &b3,
|
|---|
| 288 | const Ref<GaussianBasisSet> &b4)
|
|---|
| 289 | {
|
|---|
| 290 | free_transforms();
|
|---|
| 291 | Integral::set_basis(b1,b2,b3,b4);
|
|---|
| 292 | check_fullgencon();
|
|---|
| 293 | initialize_transforms();
|
|---|
| 294 | }
|
|---|
| 295 |
|
|---|
| 296 | void
|
|---|
| 297 | IntegralCints::free_transforms()
|
|---|
| 298 | {
|
|---|
| 299 | int i,j;
|
|---|
| 300 | for (i=0; i<=maxl_; i++) {
|
|---|
| 301 | for (j=0; j<=i/2; j++) {
|
|---|
| 302 | delete st_[i][j];
|
|---|
| 303 | delete ist_[i][j];
|
|---|
| 304 | }
|
|---|
| 305 | delete[] st_[i];
|
|---|
| 306 | delete[] ist_[i];
|
|---|
| 307 | }
|
|---|
| 308 | if (maxl_ >= 0) {
|
|---|
| 309 | delete[] st_;
|
|---|
| 310 | delete[] ist_;
|
|---|
| 311 | }
|
|---|
| 312 | st_ = NULL;
|
|---|
| 313 | ist_ = NULL;
|
|---|
| 314 | }
|
|---|
| 315 |
|
|---|
| 316 | void
|
|---|
| 317 | IntegralCints::initialize_transforms()
|
|---|
| 318 | {
|
|---|
| 319 | maxl_ = -1;
|
|---|
| 320 | int maxam;
|
|---|
| 321 | maxam = bs1_.nonnull()?bs1_->max_angular_momentum():-1;
|
|---|
| 322 | if (maxl_ < maxam) maxl_ = maxam;
|
|---|
| 323 | maxam = bs2_.nonnull()?bs2_->max_angular_momentum():-1;
|
|---|
| 324 | if (maxl_ < maxam) maxl_ = maxam;
|
|---|
| 325 | maxam = bs3_.nonnull()?bs3_->max_angular_momentum():-1;
|
|---|
| 326 | if (maxl_ < maxam) maxl_ = maxam;
|
|---|
| 327 | maxam = bs4_.nonnull()?bs4_->max_angular_momentum():-1;
|
|---|
| 328 | if (maxl_ < maxam) maxl_ = maxam;
|
|---|
| 329 |
|
|---|
| 330 | if (maxl_ >= 0) {
|
|---|
| 331 | st_ = new SphericalTransformCints**[maxl_+1];
|
|---|
| 332 | ist_ = new ISphericalTransformCints**[maxl_+1];;
|
|---|
| 333 | int i,j;
|
|---|
| 334 | for (i=0; i<=maxl_; i++) {
|
|---|
| 335 | st_[i] = new SphericalTransformCints*[i/2+1];
|
|---|
| 336 | ist_[i] = new ISphericalTransformCints*[i/2+1];
|
|---|
| 337 | for (j=0; j<=i/2; j++) {
|
|---|
| 338 | st_[i][j] = new SphericalTransformCints(i,i-2*j);
|
|---|
| 339 | ist_[i][j] = new ISphericalTransformCints(i,i-2*j);
|
|---|
| 340 | }
|
|---|
| 341 | }
|
|---|
| 342 | }
|
|---|
| 343 | else {
|
|---|
| 344 | st_ = NULL;
|
|---|
| 345 | ist_ = NULL;
|
|---|
| 346 | }
|
|---|
| 347 | }
|
|---|
| 348 |
|
|---|
| 349 |
|
|---|
| 350 | static bool has_fullgencon(const Ref<GaussianBasisSet>&);
|
|---|
| 351 |
|
|---|
| 352 | void
|
|---|
| 353 | IntegralCints::check_fullgencon() const
|
|---|
| 354 | {
|
|---|
| 355 | if ( has_fullgencon(bs1_) ||
|
|---|
| 356 | has_fullgencon(bs2_) ||
|
|---|
| 357 | has_fullgencon(bs3_) ||
|
|---|
| 358 | has_fullgencon(bs4_) ) {
|
|---|
| 359 | throw std::runtime_error("IntegralCints cannot handle basis sets with fully general contractions yet, try IntegralV3 instead");
|
|---|
| 360 | }
|
|---|
| 361 | }
|
|---|
| 362 |
|
|---|
| 363 | bool
|
|---|
| 364 | has_fullgencon(const Ref<GaussianBasisSet>& bs)
|
|---|
| 365 | {
|
|---|
| 366 | bool has_it = false;
|
|---|
| 367 | int nshell = bs->nshell();
|
|---|
| 368 | for(int i=0; i<nshell; i++) {
|
|---|
| 369 | GaussianShell& shell = bs->shell(i);
|
|---|
| 370 | int minam = shell.min_am();
|
|---|
| 371 | int maxam = shell.max_am();
|
|---|
| 372 | if (minam != maxam)
|
|---|
| 373 | has_it = true;
|
|---|
| 374 | }
|
|---|
| 375 |
|
|---|
| 376 | return has_it;
|
|---|
| 377 | }
|
|---|
| 378 |
|
|---|
| 379 | /////////////////////////////////////////////////////////////////////////////
|
|---|
| 380 |
|
|---|
| 381 | // Local Variables:
|
|---|
| 382 | // mode: c++
|
|---|
| 383 | // c-file-style: "CLJ"
|
|---|
| 384 | // End:
|
|---|