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 file is part of Psi4.
12  *
13  * Psi4 is free software; you can redistribute it and/or modify
14  * it under the terms of the GNU Lesser General Public License as published by
15  * the Free Software Foundation, version 3.
16  *
17  * Psi4 is distributed in the hope that it will be useful,
18  * but WITHOUT ANY WARRANTY; without even the implied warranty of
19  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20  * GNU Lesser General Public License for more details.
21  *
22  * You should have received a copy of the GNU Lesser General Public License along
23  * with Psi4; if not, write to the Free Software Foundation, Inc.,
24  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
25  *
26  * @END LICENSE
27  */
28 
29 #ifndef _psi_src_lib_libmints_twobody_h
30 #define _psi_src_lib_libmints_twobody_h
31 
32 #include "psi4/pragma.h"
33 
34 #include <memory>
35 #include <vector>
36 
37 #ifdef _POSIX_C_SOURCE
38 #undef _POSIX_C_SOURCE
39 #endif
40 #ifdef _XOPEN_SOURCE
41 #undef _XOPEN_SOURCE
42 #endif
44 
45 namespace psi {
46 
47 enum PermutedOrder { ABCD = 0, BACD = 1, ABDC = 2, BADC = 3, CDAB = 4, CDBA = 5, DCAB = 6, DCBA = 7 };
48 
49 typedef std::vector<std::pair<int, int>> ShellPairBlock;
50 
51 
52 class IntegralFactory;
54 class BasisSet;
55 class GaussianShell;
56 
62 {
63 protected:
65 
66  const std::shared_ptr<BasisSet> original_bs1_;
67  const std::shared_ptr<BasisSet> original_bs2_;
68  const std::shared_ptr<BasisSet> original_bs3_;
69  const std::shared_ptr<BasisSet> original_bs4_;
70 
71  std::shared_ptr<BasisSet> bs1_;
72  std::shared_ptr<BasisSet> bs2_;
73  std::shared_ptr<BasisSet> bs3_;
74  std::shared_ptr<BasisSet> bs4_;
75 
76 
78  double *target_full_;
80  double *target_;
81 
85  double *tformbuf_;
87  double *source_full_;
89  double *source_;
93  int natom_;
95  int deriv_;
100 
102  std::vector<ShellPairBlock> blocks12_, blocks34_;
103 
108  void create_blocks(void);
109 
110 
111  void permute_target(double *s, double *t, int sh1, int sh2, int sh3, int sh4, bool p12, bool p34, bool p13p24);
112  void permute_1234_to_1243(double *s, double *t, int nbf1, int nbf2, int nbf3, int nbf4);
113  void permute_1234_to_2134(double *s, double *t, int nbf1, int nbf2, int nbf3, int nbf4);
114  void permute_1234_to_2143(double *s, double *t, int nbf1, int nbf2, int nbf3, int nbf4);
115  void permute_1234_to_3412(double *s, double *t, int nbf1, int nbf2, int nbf3, int nbf4);
116  void permute_1234_to_4312(double *s, double *t, int nbf1, int nbf2, int nbf3, int nbf4);
117  void permute_1234_to_3421(double *s, double *t, int nbf1, int nbf2, int nbf3, int nbf4);
118  void permute_1234_to_4321(double *s, double *t, int nbf1, int nbf2, int nbf3, int nbf4);
119 
120 // TwoBodyInt(std::shared_ptr<BasisSet> bs1,
121 // std::shared_ptr<BasisSet> bs2,
122 // std::shared_ptr<BasisSet> bs3,
123 // std::shared_ptr<BasisSet> bs4,
124 // int deriv = 0);
125 
126  TwoBodyAOInt(const IntegralFactory* intsfactory, int deriv=0);
127 
128  TwoBodyAOInt(const TwoBodyAOInt & rhs);
129 
130 public:
131  virtual ~TwoBodyAOInt();
132 
134  std::shared_ptr<BasisSet> basis();
136  std::shared_ptr<BasisSet> basis1();
138  std::shared_ptr<BasisSet> basis2();
140  std::shared_ptr<BasisSet> basis3();
142  std::shared_ptr<BasisSet> basis4();
143 
145  void set_force_cartesian(bool t_f) { force_cartesian_ = t_f; }
146 
148  int deriv() const { return deriv_; }
149 
151  const double *buffer() const { return target_full_; }
152 
154  const IntegralFactory* integral() const { return integral_; }
155 
157  virtual size_t compute_shell(const AOShellCombinationsIterator&) = 0;
158 
160  virtual size_t compute_shell(int, int, int, int) = 0;
161 
163  std::vector<ShellPairBlock> get_blocks12(void) const;
164 
166  std::vector<ShellPairBlock> get_blocks34(void) const;
167 
168 
181  virtual void
182  compute_shell_blocks(int shellpair12, int shellpair34,
183  int npair12 = -1, int npair34 = -1);
184 
186  virtual int shell_is_zero(int,int,int,int) { return 0; }
187 
189  virtual size_t compute_shell_deriv1(int, int, int, int) = 0;
190 
192  virtual size_t compute_shell_deriv2(int, int, int, int) = 0;
193 
195  void normalize_am(std::shared_ptr<GaussianShell>, std::shared_ptr<GaussianShell>,
196  std::shared_ptr<GaussianShell>, std::shared_ptr<GaussianShell>, int nchunk=1);
197 
199  virtual bool cloneable() const;
200 
202  virtual TwoBodyAOInt* clone() const;
203 
205  void pure_transform(int, int, int, int, int nchunk, bool copy_to_source = true);
206 };
207 
208 typedef std::shared_ptr<TwoBodyAOInt> SharedTwoBodyAOInt;
209 
210 }
211 
212 #endif
const std::shared_ptr< BasisSet > original_bs1_
Definition: twobody.h:66
std::shared_ptr< BasisSet > bs1_
Definition: twobody.h:71
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:216
void set_force_cartesian(bool t_f)
Sets whether we&#39;re forcing this object to always generate Cartesian integrals.
Definition: twobody.h:145
Definition: integral.h:227
virtual void compute_shell_blocks(int shellpair12, int shellpair34, int npair12=-1, int npair34=-1)
Definition: twobody.cc:152
std::shared_ptr< BasisSet > bs3_
Definition: twobody.h:73
double * tformbuf_
Buffer to hold the transformation intermediates.
Definition: twobody.h:85
const IntegralFactory * integral() const
Returns the integral factory used to create this object.
Definition: twobody.h:154
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:78
std::vector< ShellPairBlock > get_blocks12(void) const
Get optimal blocks of shell pairs for centers 1 &amp; 2.
Definition: twobody.cc:115
std::shared_ptr< BasisSet > basis()
Basis set on center one.
Definition: twobody.cc:80
void permute_1234_to_1243(double *s, double *t, int nbf1, int nbf2, int nbf3, int nbf4)
Definition: twobody.cc:334
int curr_buff_size_
Number of integrals in the current buffer.
Definition: twobody.h:83
void permute_target(double *s, double *t, int sh1, int sh2, int sh3, int sh4, bool p12, bool p34, bool p13p24)
Definition: twobody.cc:280
std::vector< ShellPairBlock > blocks12_
The blocking scheme used for the integrals.
Definition: twobody.h:102
void pure_transform(int, int, int, int, int nchunk, bool copy_to_source=true)
Results go back to buffer_.
Definition: twobody.cc:460
std::shared_ptr< BasisSet > basis3()
Basis set on center three.
Definition: twobody.cc:95
Definition: twobody.h:61
void permute_1234_to_2134(double *s, double *t, int nbf1, int nbf2, int nbf3, int nbf4)
Definition: twobody.cc:352
const double * buffer() const
Buffer where the integrals are placed.
Definition: twobody.h:151
std::vector< ShellPairBlock > blocks34_
Definition: twobody.h:102
Definition: twobody.h:47
int natom_
Number of atoms.
Definition: twobody.h:93
std::shared_ptr< TwoBodyAOInt > SharedTwoBodyAOInt
Definition: twobody.h:208
void permute_1234_to_4321(double *s, double *t, int nbf1, int nbf2, int nbf3, int nbf4)
Definition: twobody.cc:442
double * source_full_
Buffer to hold the initially computed integrals.
Definition: twobody.h:87
std::vector< ShellPairBlock > get_blocks34(void) const
Get optimal blocks of shell pairs for centers 3 &amp; 4.
Definition: twobody.cc:120
Definition: twobody.h:47
const std::shared_ptr< BasisSet > original_bs3_
Definition: twobody.h:68
void permute_1234_to_3412(double *s, double *t, int nbf1, int nbf2, int nbf3, int nbf4)
Definition: twobody.cc:388
PermutedOrder permuted_order_
How the shells were reordered for libint.
Definition: twobody.h:99
void permute_1234_to_4312(double *s, double *t, int nbf1, int nbf2, int nbf3, int nbf4)
Definition: twobody.cc:406
TwoBodyAOInt(const IntegralFactory *intsfactory, int deriv=0)
Definition: twobody.cc:44
const IntegralFactory * integral_
Definition: twobody.h:64
void permute_1234_to_2143(double *s, double *t, int nbf1, int nbf2, int nbf3, int nbf4)
Definition: twobody.cc:370
Definition: twobody.h:47
std::shared_ptr< BasisSet > basis4()
Basis set on center four.
Definition: twobody.cc:100
const std::shared_ptr< BasisSet > original_bs2_
Definition: twobody.h:67
void permute_1234_to_3421(double *s, double *t, int nbf1, int nbf2, int nbf3, int nbf4)
Definition: twobody.cc:424
virtual TwoBodyAOInt * clone() const
Returns a clone of this object. By default throws an exception.
Definition: twobody.cc:110
PermutedOrder
Definition: twobody.h:47
Definition: twobody.h:47
Definition: twobody.h:47
int deriv_
Derivative level.
Definition: twobody.h:95
virtual bool cloneable() const
Return true if the clone member can be called. By default returns false.
Definition: twobody.cc:105
double * target_
Where to put the next integrals (should be part of target_full_)
Definition: twobody.h:80
const std::shared_ptr< BasisSet > original_bs4_
Definition: twobody.h:69
virtual ~TwoBodyAOInt()
Definition: twobody.cc:76
bool force_cartesian_
Whether to force integrals to be generated in the Cartesian (AO) basis;.
Definition: twobody.h:97
Definition: twobody.h:47
Basis set container class.
Definition: basisset.h:66
Definition: integral.h:384
std::shared_ptr< BasisSet > bs4_
Definition: twobody.h:74
std::shared_ptr< BasisSet > bs2_
Definition: twobody.h:72
virtual int shell_is_zero(int, int, int, int)
Is the shell zero?
Definition: twobody.h:186
std::shared_ptr< BasisSet > basis2()
Basis set on center two.
Definition: twobody.cc:90
int max_unique_quartets_
Maximum number of unique quartets needed to compute a set of SO&#39;s.
Definition: twobody.h:91
Definition: twobody.h:47
std::vector< std::pair< int, int > > ShellPairBlock
Definition: twobody.h:49
std::shared_ptr< BasisSet > basis1()
Basis set on center one.
Definition: twobody.cc:85
int deriv() const
Returns the derivative level this object is setup for.
Definition: twobody.h:148
virtual size_t compute_shell_deriv1(int, int, int, int)=0
Compute the first derivatives.
Definition: twobody.h:47
void create_blocks(void)
Definition: twobody.cc:127
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:89