Psi4
twobody.h
Go to the documentation of this file.
1 /*
2  * @BEGIN LICENSE
3  *
4  * Psi4: an open-source quantum chemistry software package
5  *
6  * Copyright (c) 2007-2017 The Psi4 Developers.
7  *
8  * The copyrights for code used from other parties are included in
9  * the corresponding files.
10  *
11  * This program is free software; you can redistribute it and/or modify
12  * it under the terms of the GNU General Public License as published by
13  * the Free Software Foundation; either version 2 of the License, or
14  * (at your option) any later version.
15  *
16  * This program 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 General Public License for more details.
20  *
21  * You should have received a copy of the GNU General Public License along
22  * with this program; if not, write to the Free Software Foundation, Inc.,
23  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
24  *
25  * @END LICENSE
26  */
27 
28 #ifndef _psi_src_lib_libmints_twobody_h
29 #define _psi_src_lib_libmints_twobody_h
30 
31 #include "psi4/pragma.h"
32 
33 #include <memory>
34 #include <vector>
35 
36 #ifdef _POSIX_C_SOURCE
37 #undef _POSIX_C_SOURCE
38 #endif
39 #ifdef _XOPEN_SOURCE
40 #undef _XOPEN_SOURCE
41 #endif
43 
44 namespace psi {
45 
46 enum PermutedOrder { ABCD = 0, BACD = 1, ABDC = 2, BADC = 3, CDAB = 4, CDBA = 5, DCAB = 6, DCBA = 7 };
47 
48 typedef std::vector<std::pair<int, int>> ShellPairBlock;
49 
50 
51 class IntegralFactory;
53 class BasisSet;
54 class GaussianShell;
55 
61 {
62 protected:
64 
65  const std::shared_ptr<BasisSet> original_bs1_;
66  const std::shared_ptr<BasisSet> original_bs2_;
67  const std::shared_ptr<BasisSet> original_bs3_;
68  const std::shared_ptr<BasisSet> original_bs4_;
69 
70  std::shared_ptr<BasisSet> bs1_;
71  std::shared_ptr<BasisSet> bs2_;
72  std::shared_ptr<BasisSet> bs3_;
73  std::shared_ptr<BasisSet> bs4_;
74 
75 
77  double *target_full_;
79  double *target_;
80 
84  double *tformbuf_;
86  double *source_full_;
88  double *source_;
92  int natom_;
94  int deriv_;
99 
101  std::vector<ShellPairBlock> blocks12_, blocks34_;
102 
107  void create_blocks(void);
108 
109 
110  void permute_target(double *s, double *t, int sh1, int sh2, int sh3, int sh4, bool p12, bool p34, bool p13p24);
111  void permute_1234_to_1243(double *s, double *t, int nbf1, int nbf2, int nbf3, int nbf4);
112  void permute_1234_to_2134(double *s, double *t, int nbf1, int nbf2, int nbf3, int nbf4);
113  void permute_1234_to_2143(double *s, double *t, int nbf1, int nbf2, int nbf3, int nbf4);
114  void permute_1234_to_3412(double *s, double *t, int nbf1, int nbf2, int nbf3, int nbf4);
115  void permute_1234_to_4312(double *s, double *t, int nbf1, int nbf2, int nbf3, int nbf4);
116  void permute_1234_to_3421(double *s, double *t, int nbf1, int nbf2, int nbf3, int nbf4);
117  void permute_1234_to_4321(double *s, double *t, int nbf1, int nbf2, int nbf3, int nbf4);
118 
119 // TwoBodyInt(std::shared_ptr<BasisSet> bs1,
120 // std::shared_ptr<BasisSet> bs2,
121 // std::shared_ptr<BasisSet> bs3,
122 // std::shared_ptr<BasisSet> bs4,
123 // int deriv = 0);
124 
125  TwoBodyAOInt(const IntegralFactory* intsfactory, int deriv=0);
126 
127  TwoBodyAOInt(const TwoBodyAOInt & rhs);
128 
129 public:
130  virtual ~TwoBodyAOInt();
131 
133  std::shared_ptr<BasisSet> basis();
135  std::shared_ptr<BasisSet> basis1();
137  std::shared_ptr<BasisSet> basis2();
139  std::shared_ptr<BasisSet> basis3();
141  std::shared_ptr<BasisSet> basis4();
142 
144  void set_force_cartesian(bool t_f) { force_cartesian_ = t_f; }
145 
147  int deriv() const { return deriv_; }
148 
150  const double *buffer() const { return target_full_; }
151 
153  const IntegralFactory* integral() const { return integral_; }
154 
156  virtual size_t compute_shell(const AOShellCombinationsIterator&) = 0;
157 
159  virtual size_t compute_shell(int, int, int, int) = 0;
160 
162  std::vector<ShellPairBlock> get_blocks12(void) const;
163 
165  std::vector<ShellPairBlock> get_blocks34(void) const;
166 
167 
180  virtual void
181  compute_shell_blocks(int shellpair12, int shellpair34,
182  int npair12 = -1, int npair34 = -1);
183 
185  virtual int shell_is_zero(int,int,int,int) { return 0; }
186 
188  virtual size_t compute_shell_deriv1(int, int, int, int) = 0;
189 
191  virtual size_t compute_shell_deriv2(int, int, int, int) = 0;
192 
194  void normalize_am(std::shared_ptr<GaussianShell>, std::shared_ptr<GaussianShell>,
195  std::shared_ptr<GaussianShell>, std::shared_ptr<GaussianShell>, int nchunk=1);
196 
198  virtual bool cloneable() const;
199 
201  virtual TwoBodyAOInt* clone() const;
202 
204  void pure_transform(int, int, int, int, int nchunk, bool copy_to_source = true);
205 };
206 
207 typedef std::shared_ptr<TwoBodyAOInt> SharedTwoBodyAOInt;
208 
209 }
210 
211 #endif
const std::shared_ptr< BasisSet > original_bs1_
Definition: twobody.h:65
std::shared_ptr< BasisSet > bs1_
Definition: twobody.h:70
void normalize_am(std::shared_ptr< GaussianShell >, std::shared_ptr< GaussianShell >, std::shared_ptr< GaussianShell >, std::shared_ptr< GaussianShell >, int nchunk=1)
Normalize Cartesian functions based on angular momentum.
Definition: twobody.cc:214
void set_force_cartesian(bool t_f)
Sets whether we&#39;re forcing this object to always generate Cartesian integrals.
Definition: twobody.h:144
Definition: integral.h:228
virtual void compute_shell_blocks(int shellpair12, int shellpair34, int npair12=-1, int npair34=-1)
Definition: twobody.cc:150
std::shared_ptr< BasisSet > bs3_
Definition: twobody.h:72
double * tformbuf_
Buffer to hold the transformation intermediates.
Definition: twobody.h:84
const IntegralFactory * integral() const
Returns the integral factory used to create this object.
Definition: twobody.h:153
virtual size_t compute_shell_deriv2(int, int, int, int)=0
Compute the second derivatives.
double * target_full_
Buffer to hold the final integrals.
Definition: twobody.h:77
std::vector< ShellPairBlock > get_blocks12(void) const
Get optimal blocks of shell pairs for centers 1 &amp; 2.
Definition: twobody.cc:113
std::shared_ptr< BasisSet > basis()
Basis set on center one.
Definition: twobody.cc:78
void permute_1234_to_1243(double *s, double *t, int nbf1, int nbf2, int nbf3, int nbf4)
Definition: twobody.cc:332
int curr_buff_size_
Number of integrals in the current buffer.
Definition: twobody.h:82
void permute_target(double *s, double *t, int sh1, int sh2, int sh3, int sh4, bool p12, bool p34, bool p13p24)
Definition: twobody.cc:278
std::vector< ShellPairBlock > blocks12_
The blocking scheme used for the integrals.
Definition: twobody.h:101
void pure_transform(int, int, int, int, int nchunk, bool copy_to_source=true)
Results go back to buffer_.
Definition: twobody.cc:458
std::shared_ptr< BasisSet > basis3()
Basis set on center three.
Definition: twobody.cc:93
Definition: twobody.h:60
void permute_1234_to_2134(double *s, double *t, int nbf1, int nbf2, int nbf3, int nbf4)
Definition: twobody.cc:350
const double * buffer() const
Buffer where the integrals are placed.
Definition: twobody.h:150
std::vector< ShellPairBlock > blocks34_
Definition: twobody.h:101
Definition: twobody.h:46
int natom_
Number of atoms.
Definition: twobody.h:92
std::shared_ptr< TwoBodyAOInt > SharedTwoBodyAOInt
Definition: twobody.h:207
void permute_1234_to_4321(double *s, double *t, int nbf1, int nbf2, int nbf3, int nbf4)
Definition: twobody.cc:440
double * source_full_
Buffer to hold the initially computed integrals.
Definition: twobody.h:86
std::vector< ShellPairBlock > get_blocks34(void) const
Get optimal blocks of shell pairs for centers 3 &amp; 4.
Definition: twobody.cc:118
Definition: twobody.h:46
const std::shared_ptr< BasisSet > original_bs3_
Definition: twobody.h:67
void permute_1234_to_3412(double *s, double *t, int nbf1, int nbf2, int nbf3, int nbf4)
Definition: twobody.cc:386
PermutedOrder permuted_order_
How the shells were reordered for libint.
Definition: twobody.h:98
void permute_1234_to_4312(double *s, double *t, int nbf1, int nbf2, int nbf3, int nbf4)
Definition: twobody.cc:404
TwoBodyAOInt(const IntegralFactory *intsfactory, int deriv=0)
Definition: twobody.cc:42
const IntegralFactory * integral_
Definition: twobody.h:63
void permute_1234_to_2143(double *s, double *t, int nbf1, int nbf2, int nbf3, int nbf4)
Definition: twobody.cc:368
Definition: twobody.h:46
std::shared_ptr< BasisSet > basis4()
Basis set on center four.
Definition: twobody.cc:98
const std::shared_ptr< BasisSet > original_bs2_
Definition: twobody.h:66
void permute_1234_to_3421(double *s, double *t, int nbf1, int nbf2, int nbf3, int nbf4)
Definition: twobody.cc:422
virtual TwoBodyAOInt * clone() const
Returns a clone of this object. By default throws an exception.
Definition: twobody.cc:108
PermutedOrder
Definition: twobody.h:46
Definition: twobody.h:46
Definition: twobody.h:46
int deriv_
Derivative level.
Definition: twobody.h:94
virtual bool cloneable() const
Return true if the clone member can be called. By default returns false.
Definition: twobody.cc:103
double * target_
Where to put the next integrals (should be part of target_full_)
Definition: twobody.h:79
const std::shared_ptr< BasisSet > original_bs4_
Definition: twobody.h:68
virtual ~TwoBodyAOInt()
Definition: twobody.cc:74
bool force_cartesian_
Whether to force integrals to be generated in the Cartesian (AO) basis;.
Definition: twobody.h:96
Definition: twobody.h:46
Basis set container class.
Definition: basisset.h:69
Definition: integral.h:385
std::shared_ptr< BasisSet > bs4_
Definition: twobody.h:73
std::shared_ptr< BasisSet > bs2_
Definition: twobody.h:71
virtual int shell_is_zero(int, int, int, int)
Is the shell zero?
Definition: twobody.h:185
std::shared_ptr< BasisSet > basis2()
Basis set on center two.
Definition: twobody.cc:88
int max_unique_quartets_
Maximum number of unique quartets needed to compute a set of SO&#39;s.
Definition: twobody.h:90
Definition: twobody.h:46
std::vector< std::pair< int, int > > ShellPairBlock
Definition: twobody.h:48
std::shared_ptr< BasisSet > basis1()
Basis set on center one.
Definition: twobody.cc:83
int deriv() const
Returns the derivative level this object is setup for.
Definition: twobody.h:147
virtual size_t compute_shell_deriv1(int, int, int, int)=0
Compute the first derivatives.
Definition: twobody.h:46
void create_blocks(void)
Definition: twobody.cc:125
virtual size_t compute_shell(const AOShellCombinationsIterator &)=0
Compute ERIs between 4 shells. Result is stored in buffer.
double * source_
Where to put the next temporary integrals (should be part of source_full_)
Definition: twobody.h:88