MPQC  3.0.0-alpha
petite.h
1 //
2 // petite.h --- definition of the PetiteList class
3 //
4 // Copyright (C) 1996 Limit Point Systems, Inc.
5 //
6 // Author: Edward Seidl <seidl@janed.com>
7 // Maintainer: LPS
8 //
9 // This file is part of the SC Toolkit.
10 //
11 // The SC Toolkit is free software; you can redistribute it and/or modify
12 // it under the terms of the GNU Library General Public License as published by
13 // the Free Software Foundation; either version 2, or (at your option)
14 // any later version.
15 //
16 // The SC Toolkit 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 Library General Public License for more details.
20 //
21 // You should have received a copy of the GNU Library General Public License
22 // along with the SC Toolkit; see the file COPYING.LIB. If not, write to
23 // the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
24 //
25 // The U.S. Government is granted a limited license as per AL 91-7.
26 //
27 
28 #ifndef _chemistry_qc_basis_petite_h
29 #define _chemistry_qc_basis_petite_h
30 
31 #include <mpqc_config.h>
32 #include <iostream>
33 #include <mpqc_config.h>
34 
35 #include <util/misc/scint.h>
36 #include <util/ref/ref.h>
37 #include <math/scmat/blocked.h>
38 #include <math/scmat/offset.h>
39 #include <chemistry/molecule/molecule.h>
40 #include <chemistry/qc/basis/gaussbas.h>
41 #include <chemistry/qc/basis/integral.h>
42 
43 // //////////////////////////////////////////////////////////////////////////
44 
45 namespace sc {
46 
47 inline sc_int_least64_t
48 ij_offset64(sc_int_least64_t i, sc_int_least64_t j)
49 {
50  return (i>j) ? (((i*(i+1)) >> 1) + j) : (((j*(j+1)) >> 1) + i);
51 }
52 
53 inline sc_int_least64_t
54 i_offset64(sc_int_least64_t i)
55 {
56  return ((i*(i+1)) >> 1);
57 }
58 
59 // //////////////////////////////////////////////////////////////////////////
60 // These are helper functions for PetiteList and GenericPetiteList4
61 
62 int **compute_atom_map(const Ref<GaussianBasisSet> &);
63 void delete_atom_map(int **atom_map, const Ref<GaussianBasisSet> &);
64 
65 int **compute_shell_map(int **atom_map, const Ref<GaussianBasisSet> &);
66 void delete_shell_map(int **shell_map, const Ref<GaussianBasisSet> &);
67 
68 // //////////////////////////////////////////////////////////////////////////
69 
70 struct contribution {
71  int bfn;
72  double coef;
73 
74  contribution();
75  contribution(int b, double c);
76  ~contribution();
77 };
78 
79 struct SO {
80  int len;
81  int length;
82  contribution *cont;
83 
84  SO();
85  SO(int);
86  ~SO();
87 
88  SO& operator=(const SO&);
89 
90  void set_length(int);
91  void reset_length(int);
92 
93  // is this equal to so to within a sign
94  int equiv(const SO& so);
95 };
96 
97 struct SO_block {
98  int len;
99  SO *so;
100 
101  SO_block();
102  SO_block(int);
103  ~SO_block();
104 
105  void set_length(int);
106  void reset_length(int);
107 
108  int add(SO& s, int i);
109  void print(const char *title);
110 };
111 
112 // //////////////////////////////////////////////////////////////////////////
113 
120 class PetiteList : public RefCount {
121  private:
122  int natom_;
123  int nshell_;
124  int ng_;
125  int nirrep_;
126  int nblocks_;
127  int c1_;
128 
130  Ref<Integral> ints_;
131 
132  char *p1_; // p1[n] is 1 if shell n is in the group P1
133  int **atom_map_; // atom_map[n][g] is the atom that symop g maps atom n
134  // into
135  int **shell_map_; // shell_map[n][g] is the shell that symop g maps shell n
136  // into
137  char *lamij_; // see Dupuis & King, IJQC 11,613,(1977)
138 
139  int *nbf_in_ir_;
140 
141  void init();
142 
143  public:
145  ~PetiteList();
146 
147  Ref<GaussianBasisSet> basis() { return gbs_; }
148  Ref<Integral> integral() { return ints_; }
149  Ref<PetiteList> clone() { return new PetiteList(gbs_, ints_); }
150 
151  int nirrep() const { return nirrep_; }
152  int order() const { return ng_; }
153  int atom_map(int n, int g) const { return (c1_) ? n : atom_map_[n][g]; }
154  int shell_map(int n, int g) const { return (c1_) ? n : shell_map_[n][g]; }
155  int lambda(int ij) const { return (c1_) ? 1 : (int) lamij_[ij]; }
156  int lambda(int i, int j) const
157  { return (c1_) ? 1 : (int) lamij_[ij_offset(i,j)]; }
158 
159  int in_p1(int n) const { return (c1_) ? 1 : (int) p1_[n]; }
160  int in_p2(int ij) const { return (c1_) ? 1 : (int) lamij_[ij]; }
162  int in_p2(int i, int j) const { return (c1_) ? 1 : (int) lamij_[ij_offset(i,j)]; }
163  int in_p4(int ij, int kl, int i, int j, int k, int l) const;
165  int in_p4(int i, int j, int k, int l) const;
166 
167  int nfunction(int i) const
168  { return (c1_) ? gbs_->nbasis() : nbf_in_ir_[i]; }
169 
170  int nblocks() const { return nblocks_; }
171 
172  void print(std::ostream& =ExEnv::out0(), int verbose=1);
173 
176  RefSCDimension AO_basisdim();
178  RefSCDimension SO_basisdim();
179 
182  RefSCMatrix r(int g);
183 
185  SO_block * aotoso_info();
186 
198  RefSCMatrix aotoso();
211  RefSCMatrix sotoao();
212 
213  // given a skeleton matrix, form the symmetrized matrix in the SO basis
214  void symmetrize(const RefSymmSCMatrix& skel, const RefSymmSCMatrix& sym);
215 
219  RefSymmSCMatrix to_SO_basis(const RefSymmSCMatrix& O_ao);
223  RefSymmSCMatrix to_AO_basis(const RefSymmSCMatrix& O_so);
224 
228  RefSCMatrix evecs_to_AO_basis(const RefSCMatrix&);
232  RefSCMatrix evecs_to_SO_basis(const RefSCMatrix&);
233 };
234 
235 inline int
236 PetiteList::in_p4(int ij, int kl, int i, int j, int k, int l) const
237 {
238  if (c1_)
239  return 1;
240 
241  sc_int_least64_t ijkl = i_offset64(ij)+kl;
242  int nijkl=1;
243 
244  for (int g=1; g < ng_; g++) {
245  int gij = ij_offset(shell_map_[i][g],shell_map_[j][g]);
246  int gkl = ij_offset(shell_map_[k][g],shell_map_[l][g]);
247  sc_int_least64_t gijkl = ij_offset64(gij,gkl);
248 
249  if (gijkl > ijkl)
250  return 0;
251  else if (gijkl == ijkl)
252  nijkl++;
253  }
254 
255  return ng_/nijkl;
256 }
257 
258 inline int
259 PetiteList::in_p4(int i, int j, int k, int l) const
260 {
261  if (c1_)
262  return 1;
263 
264  int ij = ij_offset(i,j);
265  int kl = ij_offset(k,l);
266  sc_int_least64_t ijkl = ij_offset64(ij,kl);
267  int nijkl=1;
268 
269  for (int g=1; g < ng_; g++) {
270  int gij = ij_offset(shell_map_[i][g],shell_map_[j][g]);
271  int gkl = ij_offset(shell_map_[k][g],shell_map_[l][g]);
272  sc_int_least64_t gijkl = ij_offset64(gij,gkl);
273 
274  if (gijkl > ijkl)
275  return 0;
276  else if (gijkl == ijkl)
277  nijkl++;
278  }
279 
280  return ng_/nijkl;
281 }
282 
283 }
284 
285 
286 
287 #endif
288 
289 // Local Variables:
290 // mode: c++
291 // c-file-style: "ETS"
292 // End:
sc::PetiteList::AO_basisdim
RefSCDimension AO_basisdim()
blocked AO dimension (if symmetry = c1, equivalent to SO_basisdim(); otherwise number of blocks = 1,...
sc::PetiteList::aotoso
RefSCMatrix aotoso()
sc::Ref
A template class that maintains references counts.
Definition: ref.h:361
sc::PetiteList::to_SO_basis
RefSymmSCMatrix to_SO_basis(const RefSymmSCMatrix &O_ao)
converts an operator matrix from AO to SO basis.
sc::PetiteList::SO_basisdim
RefSCDimension SO_basisdim()
blocked SO dimension (number of blocks = order of the point group, each subdimension has 1 block)
sc::SO_block
Definition: petite.h:97
sc::PetiteList
PetiteList is a petite list (see Dupuis & King, IJQC 11,613,(1977) ) that can be used for constructin...
Definition: petite.h:120
sc::PetiteList::to_AO_basis
RefSymmSCMatrix to_AO_basis(const RefSymmSCMatrix &O_so)
converts an operator matrix from SO to AO basis.
sc::PetiteList::evecs_to_AO_basis
RefSCMatrix evecs_to_AO_basis(const RefSCMatrix &)
converts a set of functions (vectors) from SO to AO basis.
sc::PetiteList::sotoao
RefSCMatrix sotoao()
sc::PetiteList::aotoso_info
SO_block * aotoso_info()
sc::SO
Definition: petite.h:79
sc::ExEnv::out0
static std::ostream & out0()
Return an ostream that writes from node 0.
sc::PetiteList::in_p2
int in_p2(int i, int j) const
Same as previous, except for it takes i and j separately.
Definition: petite.h:162
sc::PetiteList::r
RefSCMatrix r(int g)
return the basis function rotation matrix R(g)
sc::PetiteList::evecs_to_SO_basis
RefSCMatrix evecs_to_SO_basis(const RefSCMatrix &)
converts a set of functions (vectors) from AO to SO basis.
sc::RefCount
The base class for all reference counted objects.
Definition: ref.h:192
sc::contribution
Definition: petite.h:70
sc
Contains all MPQC code up to version 3.
Definition: mpqcin.h:14

Generated at Sun Jan 26 2020 23:23:57 for MPQC 3.0.0-alpha using the documentation package Doxygen 1.8.16.