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-2018 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 class IntegralFactory;
53 class BasisSet;
54 class GaussianShell;
55 
61  protected:
63 
64  const std::shared_ptr<BasisSet> original_bs1_;
65  const std::shared_ptr<BasisSet> original_bs2_;
66  const std::shared_ptr<BasisSet> original_bs3_;
67  const std::shared_ptr<BasisSet> original_bs4_;
68 
69  std::shared_ptr<BasisSet> bs1_;
70  std::shared_ptr<BasisSet> bs2_;
71  std::shared_ptr<BasisSet> bs3_;
72  std::shared_ptr<BasisSet> bs4_;
73 
75  double *target_full_;
77  double *target_;
78 
82  double *tformbuf_;
84  double *source_full_;
86  double *source_;
90  int natom_;
92  int deriv_;
97 
99  std::vector<ShellPairBlock> blocks12_, blocks34_;
100 
105  void create_blocks();
106 
107  void permute_target(double *s, double *t, int sh1, int sh2, int sh3, int sh4, bool p12, bool p34, bool p13p24);
108  void permute_1234_to_1243(double *s, double *t, int nbf1, int nbf2, int nbf3, int nbf4);
109  void permute_1234_to_2134(double *s, double *t, int nbf1, int nbf2, int nbf3, int nbf4);
110  void permute_1234_to_2143(double *s, double *t, int nbf1, int nbf2, int nbf3, int nbf4);
111  void permute_1234_to_3412(double *s, double *t, int nbf1, int nbf2, int nbf3, int nbf4);
112  void permute_1234_to_4312(double *s, double *t, int nbf1, int nbf2, int nbf3, int nbf4);
113  void permute_1234_to_3421(double *s, double *t, int nbf1, int nbf2, int nbf3, int nbf4);
114  void permute_1234_to_4321(double *s, double *t, int nbf1, int nbf2, int nbf3, int nbf4);
115 
116  // TwoBodyInt(std::shared_ptr<BasisSet> bs1,
117  // std::shared_ptr<BasisSet> bs2,
118  // std::shared_ptr<BasisSet> bs3,
119  // std::shared_ptr<BasisSet> bs4,
120  // int deriv = 0);
121 
122  TwoBodyAOInt(const IntegralFactory *intsfactory, int deriv = 0);
123 
124  TwoBodyAOInt(const TwoBodyAOInt &rhs);
125 
126  public:
127  virtual ~TwoBodyAOInt();
128 
130  std::shared_ptr<BasisSet> basis();
132  std::shared_ptr<BasisSet> basis1();
134  std::shared_ptr<BasisSet> basis2();
136  std::shared_ptr<BasisSet> basis3();
138  std::shared_ptr<BasisSet> basis4();
139 
141  void set_force_cartesian(bool t_f) { force_cartesian_ = t_f; }
142 
144  int deriv() const { return deriv_; }
145 
147  const double *buffer() const { return target_full_; }
148 
150  const IntegralFactory *integral() const { return integral_; }
151 
153  virtual size_t compute_shell(const AOShellCombinationsIterator &) = 0;
154 
156  virtual size_t compute_shell(int, int, int, int) = 0;
157 
159  std::vector<ShellPairBlock> get_blocks12() const;
160 
162  std::vector<ShellPairBlock> get_blocks34() const;
163 
176  virtual void compute_shell_blocks(int shellpair12, int shellpair34, int npair12 = -1, int npair34 = -1);
177 
179  virtual int shell_is_zero(int, int, int, int) { return 0; }
180 
182  virtual size_t compute_shell_deriv1(int, int, int, int) = 0;
183 
185  virtual size_t compute_shell_deriv2(int, int, int, int) = 0;
186 
188  void normalize_am(std::shared_ptr<GaussianShell>, std::shared_ptr<GaussianShell>, std::shared_ptr<GaussianShell>,
189  std::shared_ptr<GaussianShell>, int nchunk = 1);
190 
192  virtual bool cloneable() const;
193 
195  virtual TwoBodyAOInt *clone() const;
196 
198  void pure_transform(int, int, int, int, int nchunk, bool copy_to_source = true);
199 };
200 
201 typedef std::shared_ptr<TwoBodyAOInt> SharedTwoBodyAOInt;
202 
203 } // namespace psi
204 
205 #endif
const std::shared_ptr< BasisSet > original_bs1_
Definition: twobody.h:64
std::shared_ptr< BasisSet > bs1_
Definition: twobody.h:69
void set_force_cartesian(bool t_f)
Sets whether we&#39;re forcing this object to always generate Cartesian integrals.
Definition: twobody.h:141
Definition: integral.h:223
std::shared_ptr< BasisSet > basis
Definition: dx_write.cc:59
std::shared_ptr< BasisSet > bs3_
Definition: twobody.h:71
double * tformbuf_
Buffer to hold the transformation intermediates.
Definition: twobody.h:82
const IntegralFactory * integral() const
Returns the integral factory used to create this object.
Definition: twobody.h:150
double * target_full_
Buffer to hold the final integrals.
Definition: twobody.h:75
int curr_buff_size_
Number of integrals in the current buffer.
Definition: twobody.h:80
Definition: twobody.h:60
const double * buffer() const
Buffer where the integrals are placed.
Definition: twobody.h:147
std::vector< ShellPairBlock > blocks34_
Definition: twobody.h:99
Definition: twobody.h:47
int natom_
Number of atoms.
Definition: twobody.h:90
std::shared_ptr< TwoBodyAOInt > SharedTwoBodyAOInt
Definition: twobody.h:201
double * source_full_
Buffer to hold the initially computed integrals.
Definition: twobody.h:84
Definition: twobody.h:47
const std::shared_ptr< BasisSet > original_bs3_
Definition: twobody.h:66
PermutedOrder permuted_order_
How the shells were reordered for libint.
Definition: twobody.h:96
const IntegralFactory * integral_
Definition: twobody.h:62
Definition: twobody.h:47
const std::shared_ptr< BasisSet > original_bs2_
Definition: twobody.h:65
PermutedOrder
Definition: twobody.h:47
Definition: twobody.h:47
Definition: twobody.h:47
int deriv_
Derivative level.
Definition: twobody.h:92
double * target_
Where to put the next integrals (should be part of target_full_)
Definition: twobody.h:77
const std::shared_ptr< BasisSet > original_bs4_
Definition: twobody.h:67
bool force_cartesian_
Whether to force integrals to be generated in the Cartesian (AO) basis;.
Definition: twobody.h:94
Definition: twobody.h:47
Basis set container class.
Definition: basisset.h:63
Definition: integral.h:374
std::shared_ptr< BasisSet > bs4_
Definition: twobody.h:72
std::shared_ptr< BasisSet > bs2_
Definition: twobody.h:70
#define PSI_API
Definition: pragma.h:155
virtual int shell_is_zero(int, int, int, int)
Is the shell zero?
Definition: twobody.h:179
int max_unique_quartets_
Maximum number of unique quartets needed to compute a set of SO&#39;s.
Definition: twobody.h:88
Definition: twobody.h:47
std::vector< std::pair< int, int > > ShellPairBlock
Definition: twobody.h:49
int deriv() const
Returns the derivative level this object is setup for.
Definition: twobody.h:144
Definition: twobody.h:47
double * source_
Where to put the next temporary integrals (should be part of source_full_)
Definition: twobody.h:86