Psi4
petitelist.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_petitelist_h_
30 #define _psi_src_lib_libmints_petitelist_h_
31 
32 #include "typedefs.h"
33 #include "pointgrp.h"
34 
35 #include <map>
36 #include <cstdio>
37 #include <stdint.h>
38 
39  #include "psi4/pragma.h"
40  PRAGMA_WARNING_PUSH
41  PRAGMA_WARNING_IGNORE_DEPRECATED_DECLARATIONS
42  #include <memory>
44 
45 namespace psi {
46 
47 
48 
49 class BasisSet;
50 class Molecule;
51 class IntegralFactory;
52 class Matrix;
53 class Dimension;
54 
55 inline int64_t ij_offset64(int64_t i, int64_t j)
56 {
57  return (i>j) ? (((i*(i+1)) >> 1) + j) : (((j*(j+1)) >> 1) + i);
58 }
59 
60 inline int64_t i_offset64(int64_t i)
61 {
62  return ((i*(i+1)) >> 1);
63 }
64 
66 // These are helper functions for PetiteList and GenericPetiteList4
67 
75 int **compute_atom_map(const std::shared_ptr<Molecule> &mol, double tol = 0.1, bool suppress_mol_print_in_exc = false);
76 int **compute_atom_map(const Molecule* mol, double tol = 0.1, bool suppress_mol_print_in_exc = false);
78 
85 void delete_atom_map(int **atom_map, const std::shared_ptr<Molecule> &mol);
86 void delete_atom_map(int **atom_map, const Molecule* mol);
88 
89 int **compute_shell_map(int **atom_map, const std::shared_ptr<BasisSet> &);
90 void delete_shell_map(int **shell_map, const std::shared_ptr<BasisSet> &);
91 
93 
94 struct contribution {
95  int bfn;
96  double coef;
97 
98  contribution();
99  contribution(int b, double c);
100  ~contribution();
101 };
102 
103 struct SO {
104  int len;
105  int length;
107 
108  SO();
109  SO(int);
110  ~SO();
111 
112  SO& operator=(const SO&);
113 
114  void set_length(int);
115  void reset_length(int);
116 
117  // is this equal to so to within a sign
118  int equiv(const SO& so);
119 };
120 
121 struct SO_block {
122  int len;
123  SO *so;
124 
125  SO_block();
126  SO_block(int);
127  ~SO_block();
128 
129  void set_length(int);
130  void reset_length(int);
131 
132  int add(SO& s, int i);
133  void print(const char *title);
134 };
135 
137  std::map<int, double> coefficients;
138  int irrep;
139  // Contribution(std::map<int, double> coefficients_, int irrep_):
140  // coefficients(coefficients_), irrep(irrep_){}
142  void add_contribution(int bf, double coeff, int symm);
143 
144  void print() const;
145 
146  size_t size() const {return(coefficients.size());}
147 
148  void scale_coefficients(double factor);
149 
150  void delete_zeros();
151 };
153 
155 {
156  int natom_;
157  int nshell_;
159  int ng_;
160  int nirrep_;
161  int nblocks_;
162  bool c1_;
163 
164  std::shared_ptr<BasisSet> basis_;
166 
168 
169  char *p1_;
170  int **atom_map_;
171  int **shell_map_;
173  char *lamij_;
175  unsigned short group_;
176 
177  unsigned short *stablizer_;
179 
180  void init(double tol=0.05);
181 
182 public:
183  PetiteList(const std::shared_ptr<BasisSet>&, const std::shared_ptr<IntegralFactory>&, bool include_pure_transform = false);
184  PetiteList(const std::shared_ptr<BasisSet>&, const IntegralFactory*, bool include_pure_transform = false);
185  ~PetiteList();
186 
188 
190  std::shared_ptr<BasisSet> basis() { return basis_; }
192  const IntegralFactory* integral() { return integral_; }
194  std::shared_ptr<PetiteList> clone();
195 
197  int nirrep() const { return nirrep_; }
199  int order() const { return ng_; }
205  int atom_map(int n, int g) const { return (c1_) ? n : atom_map_[n][g]; }
211  int shell_map(int n, int g) const { return (c1_) ? n : shell_map_[n][g]; }
212 
218  int unique_shell_map(int n, int g) const { return (c1_) ? n : unique_shell_map_[n][g]; }
219 
223  int nfunction(int h) const;
224 
227  int nblocks() const { return nblocks_; }
228 
229  void print(std::string out="outfile");
230 
234  unsigned short stablizer(int atom) const { return (c1_) ? group_ : stablizer_[atom]; }
235 
236  int max_stablizer() const { return (c1_) ? 1 : max_stablizer_;}
237 
240  unsigned short group() const { return group_; }
241 
244  unsigned short dcr(unsigned short subgroup1, unsigned short subgroup2) const {
245  std::map<unsigned short,bool> uniqueCosets;
246  for(int g = 0; g < 8; ++g){
247  int coset = 0;
248  if(SKIP_THIS_OPERATOR(group_, g)) continue;
249  for(int mu = 0; mu < 8; ++mu){
250  if(SKIP_THIS_OPERATOR(subgroup1, mu)) continue;
251  for(int nu = 0; nu < 8; ++nu){
252  if(SKIP_THIS_OPERATOR(subgroup2, nu)) continue;
253  coset |= NUM_TO_OPERATOR_ID(mu^g^nu);
254  if(!NUM_TO_OPERATOR_ID(mu^g^nu)) coset |= SymmOps::ID;
255  }
256  }
257  uniqueCosets[coset] = 1;
258  }
259  std::map<unsigned short, bool>::const_iterator iter = uniqueCosets.begin();
260  std::map<unsigned short, bool>::const_iterator stop = uniqueCosets.end();
261  int rOperators = 0;
262  for(; iter != stop; ++iter){
263  int coset = iter->first;
264  for(int op = 1; op < 9; ++op){
265  if(SKIP_THIS_OPERATOR(coset, op)) continue;
266  rOperators |= (coset & SymmOps::ID ? SymmOps::E : NUM_TO_OPERATOR_ID(op));
267  break;
268  }
269  }
270  return rOperators;
271  }
272 
276  int dcr_degeneracy(unsigned short group) const {
277  int degeneracy = 0;
278  for(int op = 0; op < 8; ++op){
279  if(SKIP_THIS_OPERATOR(group, op)) continue;
280  ++degeneracy;
281  }
282  return degeneracy;
283  }
284  unsigned short GnG(unsigned short group1, unsigned short group2) const {
285  return group1 & group2;
286  }
287 
288  std::vector<int> bits_to_operator_list(unsigned short list) {
289  std::vector<int> positions;
290  int position = 1;
291  unsigned short g = group_;
292  positions.push_back(0);
293  for (int n=1; n<9; n++) {
294  if (g & 1) {
295  if (g & (list & 1))
296  positions.push_back(position);
297  position += 1;
298  }
299 
300  g >>= 1;
301  list >>= 1;
302  }
303  return positions;
304  }
305 
306  void print_group(unsigned short group) const;
307 
312 
315  Matrix* r(int g);
316 
318 
331 
345 
347 };
348 
349 }
350 
351 #endif // _psi_src_lib_libmints_petitelist_h_
void title(void)
Definition: ccdensity.cc:648
~SO()
Definition: petitelist.cc:101
double coef
Definition: petitelist.h:96
Dimension AO_basisdim()
Returns the number of atomic orbitals in a convenient Dimension object.
Definition: petitelist.cc:733
unsigned short * stablizer_
Definition: petitelist.h:177
Definition: petitelist.h:103
int ** atom_map_
Definition: petitelist.h:170
int ** compute_atom_map(const Molecule *molecule, double tol, bool suppress_mol_print_in_exc)
Definition: petitelist.cc:302
SO()
Definition: petitelist.cc:91
SOCoefficients()
Definition: petitelist.h:141
int nirrep_
Definition: petitelist.h:160
int add(SO &s, int i)
Definition: petitelist.cc:220
void reset_length(int)
Definition: petitelist.cc:202
int equiv(const SO &so)
Definition: petitelist.cc:150
#define SKIP_THIS_OPERATOR(num, bit)
Definition: pointgrp.h:101
~SO_block()
Definition: petitelist.cc:183
SharedMatrix sotoao()
Definition: petitelist.cc:1021
SharedMatrix evecs_to_AO_basis(SharedMatrix soevecs)
Definition: petitelist.cc:1063
int64_t i_offset64(int64_t i)
Definition: petitelist.h:60
Matrix * r(int g)
void init(double tol=0.05)
Definition: petitelist.cc:523
bool c1_
Definition: petitelist.h:162
int64_t ij_offset64(int64_t i, int64_t j)
Definition: petitelist.h:55
int irrep
Definition: petitelist.h:138
~PetiteList()
Definition: petitelist.cc:468
SO_block * compute_aotoso_info()
Definition: petitelist.cc:823
Definition: pointgrp.h:106
int nirrep() const
Number of irreps.
Definition: petitelist.h:197
int max_stablizer() const
Definition: petitelist.h:236
Definition: petitelist.h:136
unsigned short dcr(unsigned short subgroup1, unsigned short subgroup2) const
Definition: petitelist.h:244
Definition: pointgrp.h:106
Definition: petitelist.h:94
void delete_atom_map(int **atom_map, const Molecule *molecule)
Definition: petitelist.cc:358
SO_block()
Definition: petitelist.cc:174
int order() const
The order of the group.
Definition: petitelist.h:199
int nblocks() const
Definition: petitelist.h:227
int len
Definition: petitelist.h:104
char * lamij_
Definition: petitelist.h:173
std::shared_ptr< BasisSet > basis()
The AO basis set used to create this petite list.
Definition: petitelist.h:190
int max_stablizer_
Definition: petitelist.h:178
int ** unique_shell_map_
Definition: petitelist.h:172
SharedMatrix aotoso()
Definition: petitelist.cc:1026
char * p1_
Definition: petitelist.h:169
int nfunction(int h) const
Definition: petitelist.cc:518
void delete_zeros()
Definition: petitelist.cc:442
int shell_map(int n, int g) const
Definition: petitelist.h:211
bool include_pure_transform() const
Definition: petitelist.h:187
int natom_
Definition: petitelist.h:156
int * nbf_in_ir_
Definition: petitelist.h:174
const IntegralFactory * integral_
Definition: petitelist.h:165
std::shared_ptr< PetiteList > clone()
Create a clone of this petite list.
Definition: petitelist.cc:513
int dcr_degeneracy(unsigned short group) const
Definition: petitelist.h:276
int nshell_
Definition: petitelist.h:157
int unique_shell_map(int n, int g) const
Definition: petitelist.h:218
int ng_
Definition: petitelist.h:159
~contribution()
Definition: petitelist.cc:79
int len
Definition: petitelist.h:122
PRAGMA_WARNING_PUSH PRAGMA_WARNING_IGNORE_DEPRECATED_DECLARATIONS PRAGMA_WARNING_POP
Definition: integraliter.cc:43
std::shared_ptr< BasisSet > basis_
Definition: petitelist.h:164
int length
Definition: petitelist.h:105
void add_contribution(int bf, double coeff, int symm)
Definition: petitelist.cc:417
Definition: dimension.h:38
Makes using matrices just a little easier.
Definition: libmints/matrix.h:66
int ** compute_shell_map(int **atom_map, const std::shared_ptr< BasisSet > &basis)
Definition: petitelist.cc:373
#define NUM_TO_OPERATOR_ID(x)
Definition: pointgrp.h:100
contribution()
Definition: petitelist.cc:74
std::vector< int > bits_to_operator_list(unsigned short list)
Definition: petitelist.h:288
int bfn
Definition: petitelist.h:95
void delete_shell_map(int **shell_map, const std::shared_ptr< BasisSet > &basis)
Definition: petitelist.cc:405
unsigned short stablizer(int atom) const
Definition: petitelist.h:234
int atom_map(int n, int g) const
Definition: petitelist.h:205
Dimension SO_basisdim()
Returns the number of symmetry orbitals per irrep in a convenient Dimension object.
Definition: petitelist.cc:741
void set_length(int)
Definition: petitelist.cc:115
bool include_pure_transform_
Definition: petitelist.h:167
unsigned short group() const
Definition: petitelist.h:240
SO & operator=(const SO &)
Definition: petitelist.cc:106
Definition: integral.h:384
std::shared_ptr< Matrix > SharedMatrix
Definition: adc.h:49
int nunique_shell_
Definition: petitelist.h:158
SO * so
Definition: petitelist.h:123
void print() const
Definition: petitelist.cc:425
unsigned short GnG(unsigned short group1, unsigned short group2) const
Definition: petitelist.h:284
int ** shell_map_
Definition: petitelist.h:171
void print(std::string out="outfile")
Definition: petitelist.cc:761
PetiteList(const std::shared_ptr< BasisSet > &, const std::shared_ptr< IntegralFactory > &, bool include_pure_transform=false)
Definition: petitelist.cc:455
void scale_coefficients(double factor)
Definition: petitelist.cc:434
Definition: pointgrp.h:106
void set_length(int)
Definition: petitelist.cc:189
void print_group(unsigned short group) const
Definition: petitelist.cc:1088
unsigned short group_
Definition: petitelist.h:175
Definition: petitelist.h:154
size_t size() const
Definition: petitelist.h:146
void print(const char *title)
Definition: petitelist.cc:235
const IntegralFactory * integral()
The integral factory used to create this petite list.
Definition: petitelist.h:192
Definition: petitelist.h:121
std::map< int, double > coefficients
Definition: petitelist.h:137
contribution * cont
Definition: petitelist.h:106
int nblocks_
Definition: petitelist.h:161
void reset_length(int)
Definition: petitelist.cc:128