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 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_sobasis_h_
30 #define _psi_src_lib_libmints_sobasis_h_
31 
32 #include <vector>
33 #include <cstdio>
34 
35 #include "dimension.h"
36 
37 namespace psi {
38 
39 class BasisSet;
40 class IntegralFactory;
41 class Dimension;
42 class PetiteList;
43 
48 public:
50  double coef;
52  int aofunc;
54  int sofunc;
56  int irrep;
57 };
58 
60 public:
61  double coef;
62  int aofunc;
63  int sofunc;
64  int irrep;
65 
66  AOTransformFunction(double cf, int af, int sf, int irr)
67  : coef(cf), aofunc(af), sofunc(sf), irrep(irr) {}
68 };
69 
75 public:
77  int aoshell;
79  int nfunc;
85  void add_func(int irrep, double coef, int aofunc, int sofunc);
86 };
87 
92 class SOTransform {
93 public:
96  int naoshell;
99  SOTransform();
100  ~SOTransform();
101  void set_naoshell(int n);
103  void add_transform(int aoshell, int irrep,
104  double coef, int aofunc, int sofunc);
105 };
106 
107 class AOTransform {
108 public:
109  std::vector<AOTransformFunction> soshell;
110  std::vector<AOTransformFunction> soshellpi[8];
111  unsigned short nfuncpi[8];
112 
113  void add_offsets(int nirreps, int *offsets){
114  for(int h=0; h<nirreps; ++h){
115  for(int n=0; n<nfuncpi[h]; ++n){
116  soshellpi[h][n].sofunc += offsets[h];
117  }
118  }
119  for(size_t z=0; z<soshell.size(); ++z) {
120  soshell[z].sofunc += offsets[soshell[z].irrep];
121  }
122  }
123 
124  AOTransform();
125  ~AOTransform();
126  void add_transform(int irrep, double coef, int aofunc, int sofunc);
127 };
128 
132 {
133 protected:
134  std::shared_ptr<BasisSet> basis_;
136  std::shared_ptr<PetiteList> petite_;
137 
138  int nshell_;
139  int nirrep_;
140  int *ncomp_;
141  int **nfunc_;
142  int *naofunc_;
143  int **funcoff_;
144 
146  int *func_;
147  int *irrep_;
149 
151 
154 
156  std::vector< int > sorted_so_shell_list_;
157 
159  void init();
160 
161 public:
163  SOBasisSet(const std::shared_ptr<BasisSet>&, const std::shared_ptr<IntegralFactory>&);
164  SOBasisSet(const std::shared_ptr<BasisSet>&, const IntegralFactory*);
165  ~SOBasisSet();
166 
167  std::shared_ptr<BasisSet> basis() const;
168 
170  int nshell() const { return nshell_; }
172  int nirrep() const { return nirrep_; }
173  int ncomponent(int iirrep) const { return ncomp_[iirrep]; }
175  int nfunction_in_irrep(int irrep) const { return nfunc_in_irrep_[irrep]; }
177  int function_offset_for_irrep(int irrep) const;
179  int nfunction(int ishell) const;
181  int am(int ishell) const { return ushell_am_[ishell]; }
184  int naofunction(int ishell) const { return naofunc_[ishell]; }
186  int nfunction(int ishell, int iirrep) const;
189  int max_nfunction_in_shell() const;
190  int *function_offset_within_shell(int shell) const { return funcoff_[shell]; }
191 
195  int function_offset_within_shell(int ishell, int iirrep) const;
196 
199  int function(int ishell);
200 
202  int irrep(int ishell, int ifunc) const;
204  int irrep(int ifunc) const;
206  int function_within_irrep(int ishell, int ifunc) const;
208  int function_within_irrep(int ifunc) const;
209 
211  const SOTransform &sotrans(int i) const { return sotrans_[i]; }
213  const AOTransform &aotrans(int i) const { return aotrans_[i]; }
214 
220  const std::shared_ptr<PetiteList> petite_list() const;
221 
223  Dimension dimension() const;
224 
226  int get_so_sorted_shell(const int &i) { return sorted_so_shell_list_[i]; }
228  std::vector<int> get_so_sorted_list() { return sorted_so_shell_list_; }
229 
230  void print(std::string OutFileRMR = "outfile") const;
231 };
232 
233 inline int SOBasisSet::function(int ishell)
234 {
235  return func_[ishell];
236 }
237 
238 inline int SOBasisSet::irrep(int ishell, int ifunc) const
239 {
240  return irrep_[func_[ishell]+ifunc];
241 }
242 
243 inline int SOBasisSet::irrep(int ifunc) const
244 {
245  return irrep_[ifunc];
246 }
247 
248 inline int SOBasisSet::function_offset_for_irrep(int irrep) const
249 {
250  int r = 0;
251  for (int i=0; i<irrep; i++) {
252  r += nfunc_in_irrep_[i];
253  }
254  return r;
255 }
256 
257 inline int SOBasisSet::function_within_irrep(int ishell, int ifunc) const
258 {
259  return func_within_irrep_[func_[ishell]+ifunc];
260 }
261 
262 inline int SOBasisSet::function_within_irrep(int ifunc) const
263 {
264  return func_within_irrep_[ifunc];
265 }
266 
267 inline int SOBasisSet::nfunction(int ishell, int iirrep) const
268 {
269  return nfunc_[ishell][iirrep];
270 }
271 
272 inline int SOBasisSet::function_offset_within_shell(int ishell, int iirrep) const
273 {
274  return funcoff_[ishell][iirrep];
275 }
276 
277 }
278 
279 #endif
void init()
Handles initializing SOBasis.
Definition: sobasis.cc:144
int * func_
Definition: sobasis.h:146
const SOTransform & sotrans(int i) const
Return the SOTransform object for the given shell.
Definition: sobasis.h:211
int naoshell
The number of AO shells that make up this SO shell.
Definition: sobasis.h:96
SOTransformShell * aoshell
The SOTransformShell object for each AO.
Definition: sobasis.h:98
AOTransform()
Definition: sobasis.cc:85
void add_func(int irrep, double coef, int aofunc, int sofunc)
Add another function to the transform.
Definition: sobasis.cc:117
std::shared_ptr< BasisSet > basis_
Definition: sobasis.h:134
int irrep(int ishell, int ifunc) const
Convert SO shell and function number within shell to irrep.
Definition: sobasis.h:238
int function_within_irrep(int ishell, int ifunc) const
Convert SO shell and function number to number within irrep.
Definition: sobasis.h:257
int get_so_sorted_shell(const int &i)
Returns the value of the sorted shell list.
Definition: sobasis.h:226
Definition: sobasis.h:131
int function(int ishell)
Definition: sobasis.h:233
int irrep
Definition: sobasis.h:64
SOBasisSet(const std::shared_ptr< BasisSet > &, const std::shared_ptr< IntegralFactory > &)
Create an SOBasis object given a BasisSet and Integral objects.
Definition: sobasis.cc:138
int naoshell_allocated
Definition: sobasis.h:94
AOTransform * aotrans_
Definition: sobasis.h:153
Definition: pointgrp.h:106
Definition: sobasis.h:59
void add_transform(int irrep, double coef, int aofunc, int sofunc)
Definition: sobasis.cc:95
int nfunction(int ishell) const
Return the number of functions in the given shell.
Definition: sobasis.cc:381
~SOBasisSet()
Definition: sobasis.cc:352
int ** nfunc_
Definition: sobasis.h:141
int * nfunc_in_irrep_
Definition: sobasis.h:145
unsigned short nfuncpi[8]
Definition: sobasis.h:111
std::vector< int > sorted_so_shell_list_
vector of so shells numbers sorted in acending AM order.
Definition: sobasis.h:156
int * ncomp_
Definition: sobasis.h:140
int aoshell
The number of the AO shell from which these functions come.
Definition: sobasis.h:77
int * func_within_irrep_
Definition: sobasis.h:148
int sofunc
The SO function number.
Definition: sobasis.h:54
int nfunc
The number of AO/SO function pairs contributing.
Definition: sobasis.h:79
int nshell() const
Return the number of shells.
Definition: sobasis.h:170
int * function_offset_within_shell(int shell) const
Definition: sobasis.h:190
Definition: sobasis.h:107
SOTransformShell()
Definition: sobasis.cc:105
int aofunc
The AO function number.
Definition: sobasis.h:52
Definition: sobasis.h:47
int nirrep() const
Return the number of irreps.
Definition: sobasis.h:172
int naofunction(int ishell) const
Definition: sobasis.h:184
Definition: dimension.h:38
SOTransformFunction * func
The array of SOTransformFunction objects describing the transform.
Definition: sobasis.h:81
const AOTransform & aotrans(int i) const
Return the AOTransform object for the given shell.
Definition: sobasis.h:213
std::vector< int > get_so_sorted_list()
Returns the vector of sorted shell list.
Definition: sobasis.h:228
~SOTransform()
Definition: sobasis.cc:53
const IntegralFactory * integral_
Definition: sobasis.h:135
double coef
The coefficient of the AO.
Definition: sobasis.h:50
int aofunc
Definition: sobasis.h:62
int * ushell_am_
Definition: sobasis.h:150
int am(int ishell) const
Return tehe angular momentum of the unique shell.
Definition: sobasis.h:181
int ** funcoff_
Definition: sobasis.h:143
int max_nfunction_in_shell() const
Definition: sobasis.cc:371
int nfunction_in_irrep(int irrep) const
Return the number of functions in the given irrep.
Definition: sobasis.h:175
Definition: integral.h:384
~SOTransformShell()
Definition: sobasis.cc:111
const std::shared_ptr< PetiteList > petite_list() const
Definition: sobasis.cc:488
int function_offset_for_irrep(int irrep) const
Return the offset for the first function of the given irrep.
Definition: sobasis.h:248
int irrep
The SO function&#39;s irrep.
Definition: sobasis.h:56
int nshell_
Definition: sobasis.h:138
void print(std::string OutFileRMR="outfile") const
Definition: sobasis.cc:390
Dimension dimension() const
Returns the dimension for each irrep.
Definition: sobasis.cc:482
SOTransform()
Definition: sobasis.cc:46
Definition: sobasis.h:74
int nirrep_
Definition: sobasis.h:139
int * naofunc_
Definition: sobasis.h:142
int ncomponent(int iirrep) const
Definition: sobasis.h:173
int * irrep_
Definition: sobasis.h:147
AOTransformFunction(double cf, int af, int sf, int irr)
Definition: sobasis.h:66
int sofunc
Definition: sobasis.h:63
std::vector< AOTransformFunction > soshell
Definition: sobasis.h:109
std::shared_ptr< BasisSet > basis() const
Definition: sobasis.cc:477
SOTransform * sotrans_
Definition: sobasis.h:152
std::shared_ptr< PetiteList > petite_
Definition: sobasis.h:136
~AOTransform()
Definition: sobasis.cc:91
double coef
Definition: sobasis.h:61
void add_transform(int aoshell, int irrep, double coef, int aofunc, int sofunc)
Adds another term to the transform.
Definition: sobasis.cc:66
void add_offsets(int nirreps, int *offsets)
Definition: sobasis.h:113
void set_naoshell(int n)
Definition: sobasis.cc:58
std::vector< AOTransformFunction > soshellpi[8]
Definition: sobasis.h:110
Definition: sobasis.h:92