Psi4
sobasis.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_sobasis_h_
29 #define _psi_src_lib_libmints_sobasis_h_
30 
31 #include <vector>
32 #include <cstdio>
33 
34 #include "dimension.h"
35 
36 namespace psi {
37 
38 class BasisSet;
39 class IntegralFactory;
40 class Dimension;
41 class PetiteList;
42 
47 public:
49  double coef;
51  int aofunc;
53  int sofunc;
55  int irrep;
56 };
57 
59 public:
60  double coef;
61  int aofunc;
62  int sofunc;
63  int irrep;
64 
65  AOTransformFunction(double cf, int af, int sf, int irr)
66  : coef(cf), aofunc(af), sofunc(sf), irrep(irr) {}
67 };
68 
74 public:
76  int aoshell;
78  int nfunc;
84  void add_func(int irrep, double coef, int aofunc, int sofunc);
85 };
86 
91 class SOTransform {
92 public:
95  int naoshell;
98  SOTransform();
99  ~SOTransform();
100  void set_naoshell(int n);
102  void add_transform(int aoshell, int irrep,
103  double coef, int aofunc, int sofunc);
104 };
105 
106 class AOTransform {
107 public:
108  std::vector<AOTransformFunction> soshell;
109  std::vector<AOTransformFunction> soshellpi[8];
110  unsigned short nfuncpi[8];
111 
112  void add_offsets(int nirreps, int *offsets){
113  for(int h=0; h<nirreps; ++h){
114  for(int n=0; n<nfuncpi[h]; ++n){
115  soshellpi[h][n].sofunc += offsets[h];
116  }
117  }
118  for(size_t z=0; z<soshell.size(); ++z) {
119  soshell[z].sofunc += offsets[soshell[z].irrep];
120  }
121  }
122 
123  AOTransform();
124  ~AOTransform();
125  void add_transform(int irrep, double coef, int aofunc, int sofunc);
126 };
127 
131 {
132 protected:
133  std::shared_ptr<BasisSet> basis_;
135  std::shared_ptr<PetiteList> petite_;
136 
137  int nshell_;
138  int nirrep_;
139  int *ncomp_;
140  int **nfunc_;
141  int *naofunc_;
142  int **funcoff_;
143 
145  int *func_;
146  int *irrep_;
148 
150 
153 
155  std::vector< int > sorted_so_shell_list_;
156 
158  void init();
159 
160 public:
162  SOBasisSet(const std::shared_ptr<BasisSet>&, const std::shared_ptr<IntegralFactory>&);
163  SOBasisSet(const std::shared_ptr<BasisSet>&, const IntegralFactory*);
164  ~SOBasisSet();
165 
166  std::shared_ptr<BasisSet> basis() const;
167 
169  int nshell() const { return nshell_; }
171  int nirrep() const { return nirrep_; }
172  int ncomponent(int iirrep) const { return ncomp_[iirrep]; }
174  int nfunction_in_irrep(int irrep) const { return nfunc_in_irrep_[irrep]; }
176  int function_offset_for_irrep(int irrep) const;
178  int nfunction(int ishell) const;
180  int am(int ishell) const { return ushell_am_[ishell]; }
183  int naofunction(int ishell) const { return naofunc_[ishell]; }
185  int nfunction(int ishell, int iirrep) const;
188  int max_nfunction_in_shell() const;
189  int *function_offset_within_shell(int shell) const { return funcoff_[shell]; }
190 
194  int function_offset_within_shell(int ishell, int iirrep) const;
195 
198  int function(int ishell);
199 
201  int irrep(int ishell, int ifunc) const;
203  int irrep(int ifunc) const;
205  int function_within_irrep(int ishell, int ifunc) const;
207  int function_within_irrep(int ifunc) const;
208 
210  const SOTransform &sotrans(int i) const { return sotrans_[i]; }
212  const AOTransform &aotrans(int i) const { return aotrans_[i]; }
213 
219  const std::shared_ptr<PetiteList> petite_list() const;
220 
222  Dimension dimension() const;
223 
225  int get_so_sorted_shell(const int &i) { return sorted_so_shell_list_[i]; }
227  std::vector<int> get_so_sorted_list() { return sorted_so_shell_list_; }
228 
229  void print(std::string OutFileRMR = "outfile") const;
230 };
231 
232 inline int SOBasisSet::function(int ishell)
233 {
234  return func_[ishell];
235 }
236 
237 inline int SOBasisSet::irrep(int ishell, int ifunc) const
238 {
239  return irrep_[func_[ishell]+ifunc];
240 }
241 
242 inline int SOBasisSet::irrep(int ifunc) const
243 {
244  return irrep_[ifunc];
245 }
246 
247 inline int SOBasisSet::function_offset_for_irrep(int irrep) const
248 {
249  int r = 0;
250  for (int i=0; i<irrep; i++) {
251  r += nfunc_in_irrep_[i];
252  }
253  return r;
254 }
255 
256 inline int SOBasisSet::function_within_irrep(int ishell, int ifunc) const
257 {
258  return func_within_irrep_[func_[ishell]+ifunc];
259 }
260 
261 inline int SOBasisSet::function_within_irrep(int ifunc) const
262 {
263  return func_within_irrep_[ifunc];
264 }
265 
266 inline int SOBasisSet::nfunction(int ishell, int iirrep) const
267 {
268  return nfunc_[ishell][iirrep];
269 }
270 
271 inline int SOBasisSet::function_offset_within_shell(int ishell, int iirrep) const
272 {
273  return funcoff_[ishell][iirrep];
274 }
275 
276 }
277 
278 #endif
void init()
Handles initializing SOBasis.
Definition: sobasis.cc:143
int * func_
Definition: sobasis.h:145
const SOTransform & sotrans(int i) const
Return the SOTransform object for the given shell.
Definition: sobasis.h:210
int naoshell
The number of AO shells that make up this SO shell.
Definition: sobasis.h:95
SOTransformShell * aoshell
The SOTransformShell object for each AO.
Definition: sobasis.h:97
AOTransform()
Definition: sobasis.cc:84
void add_func(int irrep, double coef, int aofunc, int sofunc)
Add another function to the transform.
Definition: sobasis.cc:116
std::shared_ptr< BasisSet > basis_
Definition: sobasis.h:133
int irrep(int ishell, int ifunc) const
Convert SO shell and function number within shell to irrep.
Definition: sobasis.h:237
int function_within_irrep(int ishell, int ifunc) const
Convert SO shell and function number to number within irrep.
Definition: sobasis.h:256
int get_so_sorted_shell(const int &i)
Returns the value of the sorted shell list.
Definition: sobasis.h:225
Definition: sobasis.h:130
int function(int ishell)
Definition: sobasis.h:232
int irrep
Definition: sobasis.h:63
SOBasisSet(const std::shared_ptr< BasisSet > &, const std::shared_ptr< IntegralFactory > &)
Create an SOBasis object given a BasisSet and Integral objects.
Definition: sobasis.cc:137
int naoshell_allocated
Definition: sobasis.h:93
AOTransform * aotrans_
Definition: sobasis.h:152
Definition: pointgrp.h:105
Definition: sobasis.h:58
void add_transform(int irrep, double coef, int aofunc, int sofunc)
Definition: sobasis.cc:94
int nfunction(int ishell) const
Return the number of functions in the given shell.
Definition: sobasis.cc:380
~SOBasisSet()
Definition: sobasis.cc:351
int ** nfunc_
Definition: sobasis.h:140
int * nfunc_in_irrep_
Definition: sobasis.h:144
unsigned short nfuncpi[8]
Definition: sobasis.h:110
std::vector< int > sorted_so_shell_list_
vector of so shells numbers sorted in acending AM order.
Definition: sobasis.h:155
int * ncomp_
Definition: sobasis.h:139
int aoshell
The number of the AO shell from which these functions come.
Definition: sobasis.h:76
int * func_within_irrep_
Definition: sobasis.h:147
int sofunc
The SO function number.
Definition: sobasis.h:53
int nfunc
The number of AO/SO function pairs contributing.
Definition: sobasis.h:78
int nshell() const
Return the number of shells.
Definition: sobasis.h:169
int * function_offset_within_shell(int shell) const
Definition: sobasis.h:189
Definition: sobasis.h:106
SOTransformShell()
Definition: sobasis.cc:104
int aofunc
The AO function number.
Definition: sobasis.h:51
Definition: sobasis.h:46
int nirrep() const
Return the number of irreps.
Definition: sobasis.h:171
int naofunction(int ishell) const
Definition: sobasis.h:183
Definition: dimension.h:39
SOTransformFunction * func
The array of SOTransformFunction objects describing the transform.
Definition: sobasis.h:80
const AOTransform & aotrans(int i) const
Return the AOTransform object for the given shell.
Definition: sobasis.h:212
std::vector< int > get_so_sorted_list()
Returns the vector of sorted shell list.
Definition: sobasis.h:227
~SOTransform()
Definition: sobasis.cc:52
const IntegralFactory * integral_
Definition: sobasis.h:134
double coef
The coefficient of the AO.
Definition: sobasis.h:49
int aofunc
Definition: sobasis.h:61
int * ushell_am_
Definition: sobasis.h:149
int am(int ishell) const
Return tehe angular momentum of the unique shell.
Definition: sobasis.h:180
int ** funcoff_
Definition: sobasis.h:142
int max_nfunction_in_shell() const
Definition: sobasis.cc:370
int nfunction_in_irrep(int irrep) const
Return the number of functions in the given irrep.
Definition: sobasis.h:174
Definition: integral.h:385
~SOTransformShell()
Definition: sobasis.cc:110
const std::shared_ptr< PetiteList > petite_list() const
Definition: sobasis.cc:487
int function_offset_for_irrep(int irrep) const
Return the offset for the first function of the given irrep.
Definition: sobasis.h:247
int irrep
The SO function&#39;s irrep.
Definition: sobasis.h:55
int nshell_
Definition: sobasis.h:137
void print(std::string OutFileRMR="outfile") const
Definition: sobasis.cc:389
Dimension dimension() const
Returns the dimension for each irrep.
Definition: sobasis.cc:481
SOTransform()
Definition: sobasis.cc:45
Definition: sobasis.h:73
int nirrep_
Definition: sobasis.h:138
int * naofunc_
Definition: sobasis.h:141
int ncomponent(int iirrep) const
Definition: sobasis.h:172
int * irrep_
Definition: sobasis.h:146
AOTransformFunction(double cf, int af, int sf, int irr)
Definition: sobasis.h:65
int sofunc
Definition: sobasis.h:62
std::vector< AOTransformFunction > soshell
Definition: sobasis.h:108
std::shared_ptr< BasisSet > basis() const
Definition: sobasis.cc:476
SOTransform * sotrans_
Definition: sobasis.h:151
std::shared_ptr< PetiteList > petite_
Definition: sobasis.h:135
~AOTransform()
Definition: sobasis.cc:90
double coef
Definition: sobasis.h:60
void add_transform(int aoshell, int irrep, double coef, int aofunc, int sofunc)
Adds another term to the transform.
Definition: sobasis.cc:65
void add_offsets(int nirreps, int *offsets)
Definition: sobasis.h:112
void set_naoshell(int n)
Definition: sobasis.cc:57
std::vector< AOTransformFunction > soshellpi[8]
Definition: sobasis.h:109
Definition: sobasis.h:91