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-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_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 <cstdint>
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 class BasisSet;
48 class Molecule;
49 class IntegralFactory;
50 class Matrix;
51 class Dimension;
52 
53 inline int64_t ij_offset64(int64_t i, int64_t j) {
54  return (i > j) ? (((i * (i + 1)) >> 1) + j) : (((j * (j + 1)) >> 1) + i);
55 }
56 
57 inline int64_t i_offset64(int64_t i) { return ((i * (i + 1)) >> 1); }
58 
60 // These are helper functions for PetiteList and GenericPetiteList4
61 
69 int **compute_atom_map(const std::shared_ptr<Molecule> &mol, double tol = 0.1, bool suppress_mol_print_in_exc = false);
70 int **compute_atom_map(const Molecule *mol, double tol = 0.1, bool suppress_mol_print_in_exc = false);
72 
79 void delete_atom_map(int **atom_map, const std::shared_ptr<Molecule> &mol);
80 void delete_atom_map(int **atom_map, const Molecule *mol);
82 
83 int **compute_shell_map(int **atom_map, const std::shared_ptr<BasisSet> &);
84 void delete_shell_map(int **shell_map, const std::shared_ptr<BasisSet> &);
85 
87 
88 struct contribution {
89  int bfn;
90  double coef;
91 
92  contribution();
93  contribution(int b, double c);
94  ~contribution();
95 };
96 
97 struct SO {
98  int len;
99  int length;
101 
102  SO();
103  SO(int);
104  ~SO();
105 
106  SO &operator=(const SO &);
107 
108  void set_length(int);
109  void reset_length(int);
110 
111  // is this equal to so to within a sign
112  int equiv(const SO &so);
113 };
114 
115 struct SO_block {
116  int len;
117  SO *so;
118 
119  SO_block();
120  SO_block(int);
121  ~SO_block();
122 
123  void set_length(int);
124  void reset_length(int);
125 
126  int add(SO &s, int i);
127  void print(const char *title);
128 };
129 
131  std::map<int, double> coefficients;
132  int irrep;
133  // Contribution(std::map<int, double> coefficients_, int irrep_):
134  // coefficients(coefficients_), irrep(irrep_){}
136  void add_contribution(int bf, double coeff, int symm);
137 
138  void print() const;
139 
140  size_t size() const { return (coefficients.size()); }
141 
142  void scale_coefficients(double factor);
143 
144  void delete_zeros();
145 };
147 
148 class PetiteList {
149  int natom_;
150  int nshell_;
152  int ng_;
153  int nirrep_;
154  int nblocks_;
155  bool c1_;
156 
157  std::shared_ptr<BasisSet> basis_;
159 
161 
162  char *p1_;
163  int **atom_map_;
164  int **shell_map_;
166  char *lamij_;
168  unsigned short group_;
169 
170  unsigned short *stablizer_;
172 
173  void init(double tol = 0.05);
174 
175  public:
176  PetiteList(const std::shared_ptr<BasisSet> &, const std::shared_ptr<IntegralFactory> &,
177  bool include_pure_transform = false);
178  PetiteList(const std::shared_ptr<BasisSet> &, const IntegralFactory *, bool include_pure_transform = false);
179  ~PetiteList();
180 
182 
184  std::shared_ptr<BasisSet> basis() { return basis_; }
186  const IntegralFactory *integral() { return integral_; }
188  std::shared_ptr<PetiteList> clone();
189 
191  int nirrep() const { return nirrep_; }
193  int order() const { return ng_; }
199  int atom_map(int n, int g) const { return (c1_) ? n : atom_map_[n][g]; }
205  int shell_map(int n, int g) const { return (c1_) ? n : shell_map_[n][g]; }
206 
212  int unique_shell_map(int n, int g) const { return (c1_) ? n : unique_shell_map_[n][g]; }
213 
217  int nfunction(int h) const;
218 
221  int nblocks() const { return nblocks_; }
222 
223  void print(std::string out = "outfile");
224 
228  unsigned short stablizer(int atom) const { return (c1_) ? group_ : stablizer_[atom]; }
229 
230  int max_stablizer() const { return (c1_) ? 1 : max_stablizer_; }
231 
234  unsigned short group() const { return group_; }
235 
238  unsigned short dcr(unsigned short subgroup1, unsigned short subgroup2) const {
239  std::map<unsigned short, bool> uniqueCosets;
240  for (int g = 0; g < 8; ++g) {
241  int coset = 0;
242  if (SKIP_THIS_OPERATOR(group_, g)) continue;
243  for (int mu = 0; mu < 8; ++mu) {
244  if (SKIP_THIS_OPERATOR(subgroup1, mu)) continue;
245  for (int nu = 0; nu < 8; ++nu) {
246  if (SKIP_THIS_OPERATOR(subgroup2, nu)) continue;
247  coset |= NUM_TO_OPERATOR_ID(mu ^ g ^ nu);
248  if (!NUM_TO_OPERATOR_ID(mu ^ g ^ nu)) coset |= SymmOps::ID;
249  }
250  }
251  uniqueCosets[coset] = 1;
252  }
253  std::map<unsigned short, bool>::const_iterator iter = uniqueCosets.begin();
254  std::map<unsigned short, bool>::const_iterator stop = uniqueCosets.end();
255  int rOperators = 0;
256  for (; iter != stop; ++iter) {
257  int coset = iter->first;
258  for (int op = 1; op < 9; ++op) {
259  if (SKIP_THIS_OPERATOR(coset, op)) continue;
260  rOperators |= (coset & SymmOps::ID ? SymmOps::E : NUM_TO_OPERATOR_ID(op));
261  break;
262  }
263  }
264  return rOperators;
265  }
266 
270  int dcr_degeneracy(unsigned short group) const {
271  int degeneracy = 0;
272  for (int op = 0; op < 8; ++op) {
273  if (SKIP_THIS_OPERATOR(group, op)) continue;
274  ++degeneracy;
275  }
276  return degeneracy;
277  }
278  unsigned short GnG(unsigned short group1, unsigned short group2) const { return group1 & group2; }
279 
280  std::vector<int> bits_to_operator_list(unsigned short list) {
281  std::vector<int> positions;
282  int position = 1;
283  unsigned short g = group_;
284  positions.push_back(0);
285  for (int n = 1; n < 9; n++) {
286  if (g & 1) {
287  if (g & (list & 1)) positions.push_back(position);
288  position += 1;
289  }
290 
291  g >>= 1;
292  list >>= 1;
293  }
294  return positions;
295  }
296 
297  void print_group(unsigned short group) const;
298 
303 
306  Matrix *r(int g);
307 
309 
322 
336 
338 };
339 
340 } // namespace psi
341 
342 #endif // _psi_src_lib_libmints_petitelist_h_
~SO()
Definition: petitelist.cc:86
double coef
Definition: petitelist.h:90
Dimension AO_basisdim()
Returns the number of atomic orbitals in a convenient Dimension object.
Definition: petitelist.cc:631
unsigned short * stablizer_
Definition: petitelist.h:170
Definition: petitelist.h:97
int ** atom_map_
Definition: petitelist.h:163
int ** compute_atom_map(const Molecule *molecule, double tol, bool suppress_mol_print_in_exc)
Definition: petitelist.cc:244
SO()
Definition: petitelist.cc:82
SOCoefficients()
Definition: petitelist.h:135
int nirrep_
Definition: petitelist.h:153
int add(SO &s, int i)
Definition: petitelist.cc:176
void title()
Definition: ccdensity.cc:599
void reset_length(int)
Definition: petitelist.cc:161
int equiv(const SO &so)
Definition: petitelist.cc:125
#define SKIP_THIS_OPERATOR(num, bit)
Definition: pointgrp.h:101
~SO_block()
Definition: petitelist.cc:149
SharedMatrix sotoao()
Definition: petitelist.cc:910
SharedMatrix evecs_to_AO_basis(SharedMatrix soevecs)
Definition: petitelist.cc:947
int64_t i_offset64(int64_t i)
Definition: petitelist.h:57
Matrix * r(int g)
void init(double tol=0.05)
Definition: petitelist.cc:432
bool c1_
Definition: petitelist.h:155
int64_t ij_offset64(int64_t i, int64_t j)
Definition: petitelist.h:53
int irrep
Definition: petitelist.h:132
~PetiteList()
Definition: petitelist.cc:391
SO_block * compute_aotoso_info()
Definition: petitelist.cc:711
Definition: pointgrp.h:104
int nirrep() const
Number of irreps.
Definition: petitelist.h:191
int max_stablizer() const
Definition: petitelist.h:230
Definition: petitelist.h:130
unsigned short dcr(unsigned short subgroup1, unsigned short subgroup2) const
Definition: petitelist.h:238
Definition: pointgrp.h:104
Definition: petitelist.h:88
void delete_atom_map(int **atom_map, const Molecule *molecule)
Definition: petitelist.cc:296
SO_block()
Definition: petitelist.cc:145
int order() const
The order of the group.
Definition: petitelist.h:193
int nblocks() const
Definition: petitelist.h:221
int len
Definition: petitelist.h:98
char * lamij_
Definition: petitelist.h:166
std::shared_ptr< BasisSet > basis()
The AO basis set used to create this petite list.
Definition: petitelist.h:184
int max_stablizer_
Definition: petitelist.h:171
int ** unique_shell_map_
Definition: petitelist.h:165
SharedMatrix aotoso()
Definition: petitelist.cc:912
char * p1_
Definition: petitelist.h:162
int nfunction(int h) const
Definition: petitelist.cc:430
void delete_zeros()
Definition: petitelist.cc:369
int shell_map(int n, int g) const
Definition: petitelist.h:205
bool include_pure_transform() const
Definition: petitelist.h:181
int natom_
Definition: petitelist.h:149
int * nbf_in_ir_
Definition: petitelist.h:167
const IntegralFactory * integral_
Definition: petitelist.h:158
std::shared_ptr< PetiteList > clone()
Create a clone of this petite list.
Definition: petitelist.cc:428
int dcr_degeneracy(unsigned short group) const
Definition: petitelist.h:270
int nshell_
Definition: petitelist.h:150
int unique_shell_map(int n, int g) const
Definition: petitelist.h:212
int ng_
Definition: petitelist.h:152
~contribution()
Definition: petitelist.cc:76
int len
Definition: petitelist.h:116
PRAGMA_WARNING_PUSH PRAGMA_WARNING_IGNORE_DEPRECATED_DECLARATIONS PRAGMA_WARNING_POP
Definition: integraliter.cc:43
std::shared_ptr< BasisSet > basis_
Definition: petitelist.h:157
int length
Definition: petitelist.h:99
void add_contribution(int bf, double coeff, int symm)
Definition: petitelist.cc:348
Definition: dimension.h:40
Makes using matrices just a little easier.
Definition: libmints/matrix.h:59
int ** compute_shell_map(int **atom_map, const std::shared_ptr< BasisSet > &basis)
Definition: petitelist.cc:308
#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:280
int bfn
Definition: petitelist.h:89
void delete_shell_map(int **shell_map, const std::shared_ptr< BasisSet > &basis)
Definition: petitelist.cc:338
unsigned short stablizer(int atom) const
Definition: petitelist.h:228
int atom_map(int n, int g) const
Definition: petitelist.h:199
Dimension SO_basisdim()
Returns the number of symmetry orbitals per irrep in a convenient Dimension object.
Definition: petitelist.cc:638
void set_length(int)
Definition: petitelist.cc:95
bool include_pure_transform_
Definition: petitelist.h:160
unsigned short group() const
Definition: petitelist.h:234
SO & operator=(const SO &)
Definition: petitelist.cc:88
Definition: integral.h:374
std::shared_ptr< Matrix > SharedMatrix
Definition: adc.h:49
int nunique_shell_
Definition: petitelist.h:151
SO * so
Definition: petitelist.h:117
void print() const
Definition: petitelist.cc:354
unsigned short GnG(unsigned short group1, unsigned short group2) const
Definition: petitelist.h:278
int ** shell_map_
Definition: petitelist.h:164
void print(std::string out="outfile")
Definition: petitelist.cc:657
PetiteList(const std::shared_ptr< BasisSet > &, const std::shared_ptr< IntegralFactory > &, bool include_pure_transform=false)
Definition: petitelist.cc:380
void scale_coefficients(double factor)
Definition: petitelist.cc:362
Definition: pointgrp.h:104
void set_length(int)
Definition: petitelist.cc:151
void print_group(unsigned short group) const
Definition: petitelist.cc:960
unsigned short group_
Definition: petitelist.h:168
Definition: petitelist.h:148
size_t size() const
Definition: petitelist.h:140
void print(const char *title)
Definition: petitelist.cc:187
const IntegralFactory * integral()
The integral factory used to create this petite list.
Definition: petitelist.h:186
Definition: petitelist.h:115
std::map< int, double > coefficients
Definition: petitelist.h:131
contribution * cont
Definition: petitelist.h:100
int nblocks_
Definition: petitelist.h:154
void reset_length(int)
Definition: petitelist.cc:106