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