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-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_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) : 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, double coef, int aofunc, int sofunc);
103 };
104 
105 class AOTransform {
106  public:
107  std::vector<AOTransformFunction> soshell;
108  std::vector<AOTransformFunction> soshellpi[8];
109  unsigned short nfuncpi[8];
110 
111  void add_offsets(int nirreps, int *offsets) {
112  for (int h = 0; h < nirreps; ++h) {
113  for (int n = 0; n < nfuncpi[h]; ++n) {
114  soshellpi[h][n].sofunc += offsets[h];
115  }
116  }
117  for (size_t z = 0; z < soshell.size(); ++z) {
118  soshell[z].sofunc += offsets[soshell[z].irrep];
119  }
120  }
121 
122  AOTransform();
123  ~AOTransform();
124  void add_transform(int irrep, double coef, int aofunc, int sofunc);
125 };
126 
130  protected:
131  std::shared_ptr<BasisSet> basis_;
133  std::shared_ptr<PetiteList> petite_;
134 
135  int nshell_;
136  int nirrep_;
137  int *ncomp_;
138  int **nfunc_;
139  int *naofunc_;
140  int **funcoff_;
141 
143  int *func_;
144  int *irrep_;
146 
148 
151 
153  std::vector<int> sorted_so_shell_list_;
154 
156  void init();
157 
158  public:
160  SOBasisSet(const std::shared_ptr<BasisSet> &, const std::shared_ptr<IntegralFactory> &);
161  SOBasisSet(const std::shared_ptr<BasisSet> &, const IntegralFactory *);
162  ~SOBasisSet();
163 
164  std::shared_ptr<BasisSet> basis() const;
165 
167  int nshell() const { return nshell_; }
169  int nirrep() const { return nirrep_; }
170  int ncomponent(int iirrep) const { return ncomp_[iirrep]; }
172  int nfunction_in_irrep(int irrep) const { return nfunc_in_irrep_[irrep]; }
174  int function_offset_for_irrep(int irrep) const;
176  int nfunction(int ishell) const;
178  int am(int ishell) const { return ushell_am_[ishell]; }
181  int naofunction(int ishell) const { return naofunc_[ishell]; }
183  int nfunction(int ishell, int iirrep) const;
186  int max_nfunction_in_shell() const;
187  int *function_offset_within_shell(int shell) const { return funcoff_[shell]; }
188 
192  int function_offset_within_shell(int ishell, int iirrep) const;
193 
196  int function(int ishell);
197 
199  int irrep(int ishell, int ifunc) const;
201  int irrep(int ifunc) const;
203  int function_within_irrep(int ishell, int ifunc) const;
205  int function_within_irrep(int ifunc) const;
206 
208  const SOTransform &sotrans(int i) const { return sotrans_[i]; }
210  const AOTransform &aotrans(int i) const { return aotrans_[i]; }
211 
217  const std::shared_ptr<PetiteList> petite_list() const;
218 
220  Dimension dimension() const;
221 
223  int get_so_sorted_shell(const int &i) { return sorted_so_shell_list_[i]; }
225  std::vector<int> get_so_sorted_list() { return sorted_so_shell_list_; }
226 
227  void print(std::string out_fname = "outfile") const;
228 };
229 
230 inline int SOBasisSet::function(int ishell) { return func_[ishell]; }
231 
232 inline int SOBasisSet::irrep(int ishell, int ifunc) const { return irrep_[func_[ishell] + ifunc]; }
233 
234 inline int SOBasisSet::irrep(int ifunc) const { return irrep_[ifunc]; }
235 
236 inline int SOBasisSet::function_offset_for_irrep(int irrep) const {
237  int r = 0;
238  for (int i = 0; i < irrep; i++) {
239  r += nfunc_in_irrep_[i];
240  }
241  return r;
242 }
243 
244 inline int SOBasisSet::function_within_irrep(int ishell, int ifunc) const {
245  return func_within_irrep_[func_[ishell] + ifunc];
246 }
247 
248 inline int SOBasisSet::function_within_irrep(int ifunc) const { return func_within_irrep_[ifunc]; }
249 
250 inline int SOBasisSet::nfunction(int ishell, int iirrep) const { return nfunc_[ishell][iirrep]; }
251 
252 inline int SOBasisSet::function_offset_within_shell(int ishell, int iirrep) const { return funcoff_[ishell][iirrep]; }
253 
254 } // namespace psi
255 
256 #endif
int * func_
Definition: sobasis.h:143
const SOTransform & sotrans(int i) const
Return the SOTransform object for the given shell.
Definition: sobasis.h:208
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:79
std::shared_ptr< BasisSet > basis
Definition: dx_write.cc:59
void add_func(int irrep, double coef, int aofunc, int sofunc)
Add another function to the transform.
Definition: sobasis.cc:102
std::shared_ptr< BasisSet > basis_
Definition: sobasis.h:131
int irrep(int ishell, int ifunc) const
Convert SO shell and function number within shell to irrep.
Definition: sobasis.h:232
int function_within_irrep(int ishell, int ifunc) const
Convert SO shell and function number to number within irrep.
Definition: sobasis.h:244
int get_so_sorted_shell(const int &i)
Returns the value of the sorted shell list.
Definition: sobasis.h:223
Definition: sobasis.h:129
int function(int ishell)
Definition: sobasis.h:230
int irrep
Definition: sobasis.h:64
int naoshell_allocated
Definition: sobasis.h:93
AOTransform * aotrans_
Definition: sobasis.h:150
Definition: pointgrp.h:104
Definition: sobasis.h:59
void add_transform(int irrep, double coef, int aofunc, int sofunc)
Definition: sobasis.cc:85
int nfunction(int ishell) const
Return the number of functions in the given shell.
Definition: sobasis.cc:361
int ** nfunc_
Definition: sobasis.h:138
std::vector< int > sorted_so_shell_list_
vector of so shells numbers sorted in acending AM order.
Definition: sobasis.h:153
int * nfunc_in_irrep_
Definition: sobasis.h:142
unsigned short nfuncpi[8]
Definition: sobasis.h:109
int * ncomp_
Definition: sobasis.h:137
int aoshell
The number of the AO shell from which these functions come.
Definition: sobasis.h:76
int * func_within_irrep_
Definition: sobasis.h:145
int sofunc
The SO function number.
Definition: sobasis.h:54
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:167
int * function_offset_within_shell(int shell) const
Definition: sobasis.h:187
Definition: sobasis.h:105
SOTransformShell()
Definition: sobasis.cc:93
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:169
int naofunction(int ishell) const
Definition: sobasis.h:181
Definition: dimension.h:40
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:210
std::vector< int > get_so_sorted_list()
Returns the vector of sorted shell list.
Definition: sobasis.h:225
~SOTransform()
Definition: sobasis.cc:52
const IntegralFactory * integral_
Definition: sobasis.h:132
double coef
The coefficient of the AO.
Definition: sobasis.h:50
int aofunc
Definition: sobasis.h:62
int * ushell_am_
Definition: sobasis.h:147
int am(int ishell) const
Return tehe angular momentum of the unique shell.
Definition: sobasis.h:178
int ** funcoff_
Definition: sobasis.h:140
int nfunction_in_irrep(int irrep) const
Return the number of functions in the given irrep.
Definition: sobasis.h:172
Definition: integral.h:374
~SOTransformShell()
Definition: sobasis.cc:98
int function_offset_for_irrep(int irrep) const
Return the offset for the first function of the given irrep.
Definition: sobasis.h:236
#define PSI_API
Definition: pragma.h:155
int irrep
The SO function&#39;s irrep.
Definition: sobasis.h:56
int nshell_
Definition: sobasis.h:135
SOTransform()
Definition: sobasis.cc:46
Definition: sobasis.h:73
int nirrep_
Definition: sobasis.h:136
int * naofunc_
Definition: sobasis.h:139
int ncomponent(int iirrep) const
Definition: sobasis.h:170
int * irrep_
Definition: sobasis.h:144
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:107
SOTransform * sotrans_
Definition: sobasis.h:149
std::shared_ptr< PetiteList > petite_
Definition: sobasis.h:133
~AOTransform()
Definition: sobasis.cc:83
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:61
void add_offsets(int nirreps, int *offsets)
Definition: sobasis.h:111
void set_naoshell(int n)
Definition: sobasis.cc:54
std::vector< AOTransformFunction > soshellpi[8]
Definition: sobasis.h:108
Definition: sobasis.h:91