| [0b990d] | 1 | //
 | 
|---|
 | 2 | // integral.h --- definition of the Integral class
 | 
|---|
 | 3 | //
 | 
|---|
 | 4 | // Copyright (C) 1996 Limit Point Systems, Inc.
 | 
|---|
 | 5 | //
 | 
|---|
 | 6 | // Author: Edward Seidl <seidl@janed.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 | #ifndef _chemistry_qc_basis_integral_h
 | 
|---|
 | 29 | #define _chemistry_qc_basis_integral_h
 | 
|---|
 | 30 | 
 | 
|---|
 | 31 | #ifdef __GNUC__
 | 
|---|
 | 32 | #pragma interface
 | 
|---|
 | 33 | #endif
 | 
|---|
 | 34 | 
 | 
|---|
 | 35 | #include <stddef.h>
 | 
|---|
 | 36 | 
 | 
|---|
 | 37 | #include <util/state/state.h>
 | 
|---|
 | 38 | #include <util/group/message.h>
 | 
|---|
 | 39 | #include <chemistry/qc/basis/basis.h>
 | 
|---|
 | 40 | #include <chemistry/qc/basis/obint.h>
 | 
|---|
 | 41 | #include <chemistry/qc/basis/tbint.h>
 | 
|---|
 | 42 | 
 | 
|---|
 | 43 | namespace sc {
 | 
|---|
 | 44 | 
 | 
|---|
 | 45 | class SymmetryOperation;
 | 
|---|
 | 46 | class RefSymmSCMatrix;
 | 
|---|
 | 47 | class ShellRotation;
 | 
|---|
 | 48 | class CartesianIter;
 | 
|---|
 | 49 | class RedundantCartesianIter;
 | 
|---|
 | 50 | class RedundantCartesianSubIter;
 | 
|---|
 | 51 | class SphericalTransformIter;
 | 
|---|
 | 52 | class SphericalTransform;
 | 
|---|
 | 53 | class PointBag_double;
 | 
|---|
 | 54 | class PetiteList;
 | 
|---|
 | 55 | 
 | 
|---|
 | 56 | /** The Integral abstract class acts as a factory to provide objects that
 | 
|---|
 | 57 | compute one and two electron integrals.  */
 | 
|---|
 | 58 | class Integral : public SavableState {
 | 
|---|
 | 59 |   protected:
 | 
|---|
 | 60 |     /** Initialize the Integral object given a GaussianBasisSet for
 | 
|---|
 | 61 |         each center. */
 | 
|---|
 | 62 |     Integral(const Ref<GaussianBasisSet> &b1,
 | 
|---|
 | 63 |              const Ref<GaussianBasisSet> &b2,
 | 
|---|
 | 64 |              const Ref<GaussianBasisSet> &b3,
 | 
|---|
 | 65 |              const Ref<GaussianBasisSet> &b4);
 | 
|---|
 | 66 |     Ref<GaussianBasisSet> bs1_;
 | 
|---|
 | 67 |     Ref<GaussianBasisSet> bs2_;
 | 
|---|
 | 68 |     Ref<GaussianBasisSet> bs3_;
 | 
|---|
 | 69 |     Ref<GaussianBasisSet> bs4_;
 | 
|---|
 | 70 | 
 | 
|---|
 | 71 |     // the maximum number of bytes that should be used for
 | 
|---|
 | 72 |     // storing intermediates
 | 
|---|
 | 73 |     size_t storage_;
 | 
|---|
 | 74 |     size_t storage_used_;
 | 
|---|
 | 75 | 
 | 
|---|
 | 76 |     Ref<MessageGrp> grp_;
 | 
|---|
 | 77 |   public:
 | 
|---|
 | 78 |     /// Restore the Integral object from the given StateIn object.
 | 
|---|
 | 79 |     Integral(StateIn&);
 | 
|---|
 | 80 |     /// Construct the Integral object from the given KeyVal object.
 | 
|---|
 | 81 |     Integral(const Ref<KeyVal>&);
 | 
|---|
 | 82 | 
 | 
|---|
 | 83 |     virtual ~Integral();
 | 
|---|
 | 84 |     
 | 
|---|
 | 85 |     void save_data_state(StateOut&);
 | 
|---|
 | 86 | 
 | 
|---|
 | 87 |     /** Create an integral factory.  This routine looks for a -integral
 | 
|---|
 | 88 |         argument, then the environmental variable INTEGRAL.
 | 
|---|
 | 89 |         The argument to -integral should
 | 
|---|
 | 90 |         be either string for a ParsedKeyVal constructor or a classname.
 | 
|---|
 | 91 |         This factory is not guaranteed to have its storage and basis
 | 
|---|
 | 92 |         sets set up properly, hence set_basis and set_storage
 | 
|---|
 | 93 |         need to be called on it. */
 | 
|---|
 | 94 |     static Integral* initial_integral(int &argc, char **argv);
 | 
|---|
 | 95 |     /// Specifies a new default Integral factory
 | 
|---|
 | 96 |     static void set_default_integral(const Ref<Integral>&);
 | 
|---|
 | 97 |     /// Returns the default Integral factory
 | 
|---|
 | 98 |     static Integral* get_default_integral();
 | 
|---|
 | 99 |     /// Clones the given Integral factory. The new factory may need to have set_basis and set_storage to be called on it.
 | 
|---|
 | 100 |     virtual Integral* clone() =0;
 | 
|---|
 | 101 | 
 | 
|---|
 | 102 |     /** Returns nonzero if this and the given Integral object have the same
 | 
|---|
 | 103 |         integral ordering, normalization conventions, etc.  */
 | 
|---|
 | 104 |     virtual int equiv(const Ref<Integral> &);
 | 
|---|
 | 105 | 
 | 
|---|
 | 106 |     /// Sets the total amount of storage, in bytes, that is available.
 | 
|---|
 | 107 |     void set_storage(size_t i) { storage_=i; };
 | 
|---|
 | 108 |     /// Returns how much storage has been used.
 | 
|---|
 | 109 |     size_t storage_used() { return storage_used_; }
 | 
|---|
 | 110 |     /// Returns how much storage was not needed.
 | 
|---|
 | 111 |     size_t storage_unused();
 | 
|---|
 | 112 |   /** Returns how much storage will be needed to initialize a two-body integrals
 | 
|---|
 | 113 |       evaluator for electron repulsion integrals. */
 | 
|---|
 | 114 |     virtual size_t storage_required_eri(const Ref<GaussianBasisSet> &b1,
 | 
|---|
 | 115 |                                         const Ref<GaussianBasisSet> &b2 = 0,
 | 
|---|
 | 116 |                                         const Ref<GaussianBasisSet> &b3 = 0,
 | 
|---|
 | 117 |                                         const Ref<GaussianBasisSet> &b4 = 0);
 | 
|---|
 | 118 |   /** Returns how much storage will be needed to initialize a two-body integrals
 | 
|---|
 | 119 |       evaluator for linear R12 integrals. */
 | 
|---|
 | 120 |     virtual size_t storage_required_grt(const Ref<GaussianBasisSet> &b1,
 | 
|---|
 | 121 |                                         const Ref<GaussianBasisSet> &b2 = 0,
 | 
|---|
 | 122 |                                         const Ref<GaussianBasisSet> &b3 = 0,
 | 
|---|
 | 123 |                                         const Ref<GaussianBasisSet> &b4 = 0);
 | 
|---|
 | 124 |   /** Returns how much storage will be needed to initialize a two-body integrals
 | 
|---|
 | 125 |       evaluator for derivative electron repulsion integrals. */
 | 
|---|
 | 126 |     virtual size_t storage_required_eri_deriv(const Ref<GaussianBasisSet> &b1,
 | 
|---|
 | 127 |                                               const Ref<GaussianBasisSet> &b2 = 0,
 | 
|---|
 | 128 |                                               const Ref<GaussianBasisSet> &b3 = 0,
 | 
|---|
 | 129 |                                               const Ref<GaussianBasisSet> &b4 = 0);
 | 
|---|
 | 130 | 
 | 
|---|
 | 131 |     /** The specific integral classes use this to tell Integral
 | 
|---|
 | 132 |         how much memory they are using/freeing. */
 | 
|---|
 | 133 |     void adjust_storage(ptrdiff_t s) { storage_used_ += s; }
 | 
|---|
 | 134 | 
 | 
|---|
 | 135 |     /// Return the PetiteList object.
 | 
|---|
 | 136 |     Ref<PetiteList> petite_list();
 | 
|---|
 | 137 |     /// Return the PetiteList object for the given basis set.
 | 
|---|
 | 138 |     Ref<PetiteList> petite_list(const Ref<GaussianBasisSet>&);
 | 
|---|
 | 139 |     /** Return the ShellRotation object for a shell of the given angular
 | 
|---|
 | 140 |         momentum.  Pass nonzero to pure to do solid harmonics. */
 | 
|---|
 | 141 |     ShellRotation shell_rotation(int am, SymmetryOperation&, int pure=0);
 | 
|---|
 | 142 | 
 | 
|---|
 | 143 |     /// Set the basis set for each center.
 | 
|---|
 | 144 |     virtual void set_basis(const Ref<GaussianBasisSet> &b1,
 | 
|---|
 | 145 |                            const Ref<GaussianBasisSet> &b2 = 0,
 | 
|---|
 | 146 |                            const Ref<GaussianBasisSet> &b3 = 0,
 | 
|---|
 | 147 |                            const Ref<GaussianBasisSet> &b4 = 0);
 | 
|---|
 | 148 | 
 | 
|---|
 | 149 |     // /////////////////////////////////////////////////////////////////////
 | 
|---|
 | 150 |     // the following must be defined in the specific integral package
 | 
|---|
 | 151 | 
 | 
|---|
 | 152 |     /** Return a CartesianIter object.  The caller is responsible for
 | 
|---|
 | 153 |         freeing the object. */
 | 
|---|
 | 154 |     virtual CartesianIter * new_cartesian_iter(int) =0;
 | 
|---|
 | 155 |     /** Return a RedundantCartesianIter object.  The caller is responsible
 | 
|---|
 | 156 |         for freeing the object. */
 | 
|---|
 | 157 |     virtual RedundantCartesianIter * new_redundant_cartesian_iter(int) =0;
 | 
|---|
 | 158 |     /** Return a RedundantCartesianSubIter object.  The caller is
 | 
|---|
 | 159 |         responsible for freeing the object. */
 | 
|---|
 | 160 |     virtual RedundantCartesianSubIter*
 | 
|---|
 | 161 |                                  new_redundant_cartesian_sub_iter(int) =0;
 | 
|---|
 | 162 |     /** Return a SphericalTransformIter object.  The caller is
 | 
|---|
 | 163 |         responsible for freeing the object. */
 | 
|---|
 | 164 |     virtual SphericalTransformIter *
 | 
|---|
 | 165 |                   new_spherical_transform_iter(int l,
 | 
|---|
 | 166 |                                                int inv=0, int subl=-1) =0;
 | 
|---|
 | 167 |     /** Return a SphericalTransform object.  The pointer is only valid
 | 
|---|
 | 168 |         while this Integral object is valid. */
 | 
|---|
 | 169 |     virtual const SphericalTransform *
 | 
|---|
 | 170 |                   spherical_transform(int l,
 | 
|---|
 | 171 |                                       int inv=0, int subl=-1) =0;
 | 
|---|
 | 172 |     
 | 
|---|
 | 173 |     /// Return a OneBodyInt that computes the overlap.
 | 
|---|
 | 174 |     virtual Ref<OneBodyInt> overlap() =0;
 | 
|---|
 | 175 |     
 | 
|---|
 | 176 |     /// Return a OneBodyInt that computes the kinetic energy.
 | 
|---|
 | 177 |     virtual Ref<OneBodyInt> kinetic() =0;
 | 
|---|
 | 178 | 
 | 
|---|
 | 179 |     /** Return a OneBodyInt that computes the integrals for interactions
 | 
|---|
 | 180 |         with point charges. */
 | 
|---|
 | 181 |     virtual Ref<OneBodyInt> point_charge(const Ref<PointChargeData>&) =0;
 | 
|---|
 | 182 | 
 | 
|---|
 | 183 |     /** Return a OneBodyInt that computes the integrals for interactions
 | 
|---|
 | 184 |         with point charges. */
 | 
|---|
 | 185 |     virtual Ref<OneBodyOneCenterInt> point_charge1(const Ref<PointChargeData>&);
 | 
|---|
 | 186 | 
 | 
|---|
 | 187 |     /** Return a OneBodyInt that computes the nuclear repulsion integrals.
 | 
|---|
 | 188 |         Charges from the atoms on center one are used.  If center two is
 | 
|---|
 | 189 |         not identical to center one, then the charges on center two are
 | 
|---|
 | 190 |         included as well.  */
 | 
|---|
 | 191 |     virtual Ref<OneBodyInt> nuclear() = 0;
 | 
|---|
 | 192 | 
 | 
|---|
 | 193 |     /// Return a OneBodyInt that computes the core Hamiltonian integrals.
 | 
|---|
 | 194 |     virtual Ref<OneBodyInt> hcore() = 0;
 | 
|---|
 | 195 | 
 | 
|---|
 | 196 |     /** Return a OneBodyInt that computes the electric field integrals
 | 
|---|
 | 197 |         dotted with a given vector. */
 | 
|---|
 | 198 |     virtual Ref<OneBodyInt> efield_dot_vector(const Ref<EfieldDotVectorData>&) =0;
 | 
|---|
 | 199 | 
 | 
|---|
 | 200 |     /** Return a OneBodyInt that computes electric dipole moment integrals.
 | 
|---|
 | 201 |         The canonical order of integrals in a set is x, y, z. */
 | 
|---|
 | 202 |     virtual Ref<OneBodyInt> dipole(const Ref<DipoleData>&) =0;
 | 
|---|
 | 203 | 
 | 
|---|
 | 204 |     /** Return a OneBodyInt that computes electric quadrupole moment integrals.
 | 
|---|
 | 205 |         The canonical order of integrals in a set is x^2, xy, xz, y^2, yz, z^2. */
 | 
|---|
 | 206 |     virtual Ref<OneBodyInt> quadrupole(const Ref<DipoleData>&) =0;
 | 
|---|
 | 207 | 
 | 
|---|
 | 208 |     /// Return a OneBodyDerivInt that computes overlap derivatives.
 | 
|---|
 | 209 |     virtual Ref<OneBodyDerivInt> overlap_deriv() =0;
 | 
|---|
 | 210 |                                              
 | 
|---|
 | 211 |     /// Return a OneBodyDerivInt that computes kinetic energy derivatives.
 | 
|---|
 | 212 |     virtual Ref<OneBodyDerivInt> kinetic_deriv() =0;
 | 
|---|
 | 213 |                                              
 | 
|---|
 | 214 |     /// Return a OneBodyDerivInt that computes nuclear repulsion derivatives.
 | 
|---|
 | 215 |     virtual Ref<OneBodyDerivInt> nuclear_deriv() =0;
 | 
|---|
 | 216 |                                      
 | 
|---|
 | 217 |     /// Return a OneBodyDerivInt that computes core Hamiltonian derivatives.
 | 
|---|
 | 218 |     virtual Ref<OneBodyDerivInt> hcore_deriv() =0;
 | 
|---|
 | 219 | 
 | 
|---|
 | 220 |     /** Return a TwoBodyThreeCenterInt that computes electron repulsion
 | 
|---|
 | 221 |         integrals.  If this is not re-implemented it will throw. */
 | 
|---|
 | 222 |     virtual Ref<TwoBodyThreeCenterInt> electron_repulsion3();
 | 
|---|
 | 223 | 
 | 
|---|
 | 224 |     /** Return a TwoBodyThreeCenterInt that computes electron repulsion
 | 
|---|
 | 225 |         integrals.  If this is not re-implemented it will throw. */
 | 
|---|
 | 226 |     virtual Ref<TwoBodyThreeCenterDerivInt> electron_repulsion3_deriv();
 | 
|---|
 | 227 | 
 | 
|---|
 | 228 |     /** Return a TwoBodyTwoCenterInt that computes electron repulsion
 | 
|---|
 | 229 |         integrals. If this is not re-implemented it will throw. */
 | 
|---|
 | 230 |     virtual Ref<TwoBodyTwoCenterInt> electron_repulsion2();
 | 
|---|
 | 231 | 
 | 
|---|
 | 232 |     /** Return a TwoBodyTwoCenterInt that computes electron repulsion
 | 
|---|
 | 233 |         integrals. If this is not re-implemented it will throw. */
 | 
|---|
 | 234 |     virtual Ref<TwoBodyTwoCenterDerivInt> electron_repulsion2_deriv();
 | 
|---|
 | 235 | 
 | 
|---|
 | 236 |     /// Return a TwoBodyInt that computes electron repulsion integrals.
 | 
|---|
 | 237 |     virtual Ref<TwoBodyInt> electron_repulsion() =0;
 | 
|---|
 | 238 | 
 | 
|---|
 | 239 |     /// Return a TwoBodyDerivInt that computes electron repulsion derivatives.
 | 
|---|
 | 240 |     virtual Ref<TwoBodyDerivInt> electron_repulsion_deriv() =0;
 | 
|---|
 | 241 | 
 | 
|---|
 | 242 |     /** Return a TwoBodyInt that computes two-electron integrals specific
 | 
|---|
 | 243 |         to linear R12 methods.  According to the convention in the
 | 
|---|
 | 244 |         literature, "g" stands for electron repulsion integral, "r" for the
 | 
|---|
 | 245 |         integral of r12 operator, and "t" for the commutator
 | 
|---|
 | 246 |         integrals. Implementation for this kind of TwoBodyInt is
 | 
|---|
 | 247 |         optional. */
 | 
|---|
 | 248 |     virtual Ref<TwoBodyInt> grt();
 | 
|---|
 | 249 |     
 | 
|---|
 | 250 |     /// Return the MessageGrp used by the integrals objects.
 | 
|---|
 | 251 |     Ref<MessageGrp> messagegrp() { return grp_; }
 | 
|---|
 | 252 | };
 | 
|---|
 | 253 | 
 | 
|---|
 | 254 | }
 | 
|---|
 | 255 | 
 | 
|---|
 | 256 | #endif
 | 
|---|
 | 257 | 
 | 
|---|
 | 258 | // Local Variables:
 | 
|---|
 | 259 | // mode: c++
 | 
|---|
 | 260 | // c-file-style: "ETS"
 | 
|---|
 | 261 | // End:
 | 
|---|