// // int1e.cc // // Copyright (C) 2001 Edward Valeev // // Author: Edward Valeev // Maintainer: EV // // This file is part of the SC Toolkit. // // The SC Toolkit is free software; you can redistribute it and/or modify // it under the terms of the GNU Library General Public License as published by // the Free Software Foundation; either version 2, or (at your option) // any later version. // // The SC Toolkit is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU Library General Public License for more details. // // You should have received a copy of the GNU Library General Public License // along with the SC Toolkit; see the file COPYING.LIB. If not, write to // the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. // // The U.S. Government is granted a limited license as per AL 91-7. // #ifdef __GNUG__ #pragma implementation #endif #include #include using namespace std; using namespace sc; inline int max(int a,int b) { return (a > b) ? a : b;} inline void fail() { ExEnv::errn() << scprintf("failing module:\n%s",__FILE__) << endl; abort(); } Int1eCints::Int1eCints(Integral *integral, const Ref&b1, const Ref&b2, int order, bool need_overlap, bool need_coulomb, int ntypes) : integral_(integral), bs1_(b1), bs2_(b2), multipole_origin_(0), EdotV_origin_(0), Q_origin_(0), need_overlap_(need_overlap), need_coulomb_(need_coulomb), ntypes_(ntypes) { if (order > 0) { // Complain here } max_doublet_size_ = bs1_->max_nfunction_in_shell() * bs2_->max_nfunction_in_shell(); target_ints_buffer_ = new double[ntypes_*max_doublet_size_]; max_cart_doublet_size_ = bs1_->max_ncartesian_in_shell() * bs2_->max_ncartesian_in_shell(); // These are target integrals in Cartesian basis and in by-contraction-doublets order cart_ints_ = new double[ntypes_*max_cart_doublet_size_]; if (bs1_->has_pure() || bs2_->has_pure() || bs1_->max_ncontraction() != 1 || bs2_->max_ncontraction() != 1) { // These are target integrals in spherical harmonics basis and in by-contraction-doublets order sphharm_ints_ = new double[ntypes_*max_doublet_size_]; // compute how much space one contraction doublet may need int nshell1 = bs1_->nshell(); int maxncart1 = 0; for(int sh1=0; sh1shell(sh1).max_cartesian(); if (maxncart > maxncart1) maxncart1 = maxncart; } int nshell2 = bs2_->nshell(); int maxncart2 = 0; for(int sh2=0; sh2shell(sh2).max_cartesian(); if (maxncart > maxncart2) maxncart2 = maxncart; } tformbuf_ = new double[ntypes_*maxncart1*maxncart2]; } else { sphharm_ints_ = 0; tformbuf_ = 0; } int max_am = max(bs1_->max_angular_momentum(),bs2_->max_angular_momentum()); if (need_overlap_) { // Allocate OIXYZ // max_am+1 - the range of exponents of x, y, and z // 2 - to get kinetic energy integrals // order - to allow for derivatives OIX_ = init_block_(max_am+1+2+order,max_am+1+2+order); OIY_ = init_block_(max_am+1+2+order,max_am+1+2+order); OIZ_ = init_block_(max_am+1+2+order,max_am+1+2+order); } if (need_coulomb_) { Fm_Eval_ = new FJT(bs1_->max_angular_momentum() + bs2_->max_angular_momentum() + order); indmax_ = (max_am+order)*(max_am+1+order)*(max_am+1+order)+1; // Allocate AI0 AI0_ = init_box_(indmax_,indmax_,2*(max_am+order)+1); } } Int1eCints::~Int1eCints() { delete[] cart_ints_; if (sphharm_ints_) { delete[] sphharm_ints_; sphharm_ints_ = 0; } if (tformbuf_) { delete[] tformbuf_; tformbuf_ = 0; } if (need_coulomb_) { free_box_(AI0_); } if (need_overlap_) { free_block_(OIX_); free_block_(OIY_); free_block_(OIZ_); } delete[] target_ints_buffer_; } void Int1eCints::set_multipole_origin(const Ref& origin) { multipole_origin_ = origin; } void Int1eCints::set_EdotV_origin(const Ref& origin) { EdotV_origin_ = origin; } void Int1eCints::set_Q_origin(const Ref& origin) { Q_origin_ = origin; } Ref Int1eCints::multipole_origin() { return multipole_origin_; } Ref Int1eCints::EdotV_origin() { return EdotV_origin_; } Ref Int1eCints::Q_origin() { return Q_origin_; } void Int1eCints::zero_buffers_() { double *buf1 = cart_ints_; for(int i=0; ishell(sh1); int_shell2_ = &bs2_->shell(sh2); int ctr1 = bs1_->shell_to_center(sh1); int ctr2 = bs2_->shell_to_center(sh2); doublet_info_.AB2 = 0.0; for(int i=0; i<3; i++) { doublet_info_.A[i] = bs1_->r(ctr1,i); doublet_info_.B[i] = bs2_->r(ctr2,i); doublet_info_.AB2 += (doublet_info_.A[i] - doublet_info_.B[i])* (doublet_info_.A[i] - doublet_info_.B[i]); } } void Int1eCints::sort_contrdoublets_to_shelldoublet_(double *source, double *target) { /*--- sort to the target ordering ---*/ double *source_ints_buf = source; double *target_ints_buf = target; int target_bf1_offset = 0; int nbf2 = int_shell2_->nfunction(); for (int gc1=0; gc1ncontraction(); gc1++) { int am1 = int_shell1_->am(gc1); int tsize1 = int_shell1_->nfunction(gc1); int target_bf2_offset = 0; for (int gc2=0; gc2ncontraction(); gc2++) { int am2 = int_shell2_->am(gc2); int tsize2 = int_shell2_->nfunction(gc2); for(int bf1=0;bf1nfunction(); for (int gc1=0; gc1ncontraction(); gc1++) { int am1 = int_shell1_->am(gc1); int tsize1 = int_shell1_->nfunction(gc1); int target_bf2_offset = 0; for (int gc2=0; gc2ncontraction(); gc2++) { int am2 = int_shell2_->am(gc2); int tsize2 = int_shell2_->nfunction(gc2); for(int bf1=0;bf1