LIBINT  2.6.0
cgshell_ordering.h
1 /*
2  * Copyright (C) 2004-2019 Edward F. Valeev
3  *
4  * This file is part of Libint.
5  *
6  * Libint is free software: you can redistribute it and/or modify
7  * it under the terms of the GNU Lesser General Public License as published by
8  * the Free Software Foundation, either version 3 of the License, or
9  * (at your option) any later version.
10  *
11  * Libint is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public License
17  * along with Libint. If not, see <http://www.gnu.org/licenses/>.
18  *
19  */
20 
21 #ifndef _libint2_src_bin_libint_cgshellordering_h_
22 #define _libint2_src_bin_libint_cgshellordering_h_
23 
24 #include <libint2/config.h>
25 /* if this is not defined, then using exported source -- redefine using macro from libint2_params.h */
26 #ifndef LIBINT_CARTGAUSS_MAX_AM
27 # include <libint2/util/generated/libint2_params.h>
28 # define LIBINT_CARTGAUSS_MAX_AM LIBINT2_CARTGAUSS_MAX_AM
29 #endif
30 #ifndef LIBINT_CGSHELL_ORDERING
31 # include <libint2/util/generated/libint2_params.h>
32 # define LIBINT_CGSHELL_ORDERING LIBINT2_CGSHELL_ORDERING
33 # define LIBINT_CGSHELL_ORDERING_STANDARD LIBINT2_CGSHELL_ORDERING_STANDARD
34 # define LIBINT_CGSHELL_ORDERING_INTV3 LIBINT2_CGSHELL_ORDERING_INTV3
35 # define LIBINT_CGSHELL_ORDERING_GAMESS LIBINT2_CGSHELL_ORDERING_GAMESS
36 # define LIBINT_CGSHELL_ORDERING_ORCA LIBINT2_CGSHELL_ORDERING_ORCA
37 # define LIBINT_CGSHELL_ORDERING_BAGEL LIBINT2_CGSHELL_ORDERING_BAGEL
38 #endif
39 
40 namespace libint2 {
41 
42  enum CGShellOrdering {
43  CGShellOrdering_Standard = LIBINT_CGSHELL_ORDERING_STANDARD,
44  CGShellOrdering_IntV3 = LIBINT_CGSHELL_ORDERING_INTV3,
45  CGShellOrdering_GAMESS = LIBINT_CGSHELL_ORDERING_GAMESS,
46  CGShellOrdering_ORCA = LIBINT_CGSHELL_ORDERING_ORCA,
47  CGShellOrdering_BAGEL = LIBINT_CGSHELL_ORDERING_BAGEL,
48  CGShellOrdering_MOLDEN
49  };
50 
51 };
52 
53 #include <libint2/cgshellinfo.h>
54 
55 //
56 // Macros common to all orderings
57 //
58 
59 /* Computes the number of Cartesian function in a shell given
60  * am = total angular momentum
61  * formula: (am*(am+1))/2 + am+1;
62  */
63 #define INT_NCART(am) ((((am)+2)*((am)+1))>>1)
64 
65 /* For a given ang. mom., am, with n cartesian functions, compute the
66  * number of cartesian functions for am+1 or am-1
67  */
68 #define INT_NCART_DEC(am,n) ((n)-(am)-1)
69 #define INT_NCART_INC(am,n) ((n)+(am)+2)
70 
71 //
72 // Macros that define orderings
73 //
74 
75 #if LIBINT_CGSHELL_ORDERING == LIBINT_CGSHELL_ORDERING_STANDARD
76 // this piece of code is from https://github.com/ValeevGroup/mpqc/blob/master/src/lib/chemistry/qc/basis/macros_cca.h#L31
77 // Copyright Edward Valeev
78 
79 /* Computes an index to a Cartesian function within a shell given
80  * am = total angular momentum
81  * i = the exponent of x (i is used twice in the macro--beware side effects)
82  * j = the exponent of y
83  * formula: (am - i + 1)*(am - i)/2 + am - i - j unless i==am, then 0
84  * The following loop will generate indices in the proper order:
85  * cartindex = 0;
86  * for (i=am; i>=0; i--) {
87  * for (j=am-i; j>=0; j--) {
88  * do_it_with(cartindex);
89  * cartindex++;
90  * }
91  * }
92  */
93 #define INT_CARTINDEX(am,i,j) ( (((((am) - (i) + 1)*((am) - (i)))>>1) + (am) - (i) - (j)) )
94 
95 /* This sets up the above loop over cartesian exponents as follows
96  * int i, j, k;
97  * FOR_CART(i,j,k,am)
98  * Stuff using i,j,k.
99  * END_FOR_CART
100  */
101 #define FOR_CART(i,j,k,am) for((i)=(am);(i)>=0;(i)--) {\
102  for((j)=(am)-(i);(j)>=0;(j)--) \
103  { (k) = (am) - (i) - (j);
104 #define END_FOR_CART }}
105 
106 // end of code from https://github.com/ValeevGroup/mpqc/blob/master/src/lib/chemistry/qc/basis/macros_cca.h#L31
107 
108 #endif // STANDARD ordering
109 
110 #if LIBINT_CGSHELL_ORDERING == LIBINT_CGSHELL_ORDERING_INTV3
111 // this piece of code is from MPQC:src/lib/chemistry/qc/intv3/macros.h
112 // Copyright Curtis Janssen
113 
114 /* Computes an index to a Cartesian function within a shell given
115  * am = total angular momentum
116  * i = the exponent of x (i is used twice in the macro--beware side effects)
117  * j = the exponent of y
118  * formula: am*(i+1) - (i*(i+1))/2 + i+1 - j - 1
119  * The following loop will generate indices in the proper order:
120  * cartindex = 0;
121  * for (i=0; i<=am; i++) {
122  * for (k=0; k<=am-i; k++) {
123  * j = am - i - k;
124  * do_it_with(cartindex); // cartindex == INT_CARTINDEX(am,i,j)
125  * cartindex++;
126  * }
127  * }
128  */
129 #define INT_CARTINDEX(am,i,j) (((((((am)+1)<<1)-(i))*((i)+1))>>1)-(j)-1)
130 
131 /* This sets up the above loop over cartesian exponents as follows
132  * FOR_CART(i,j,k,am)
133  * Stuff using i,j,k.
134  * END_FOR_CART
135  */
136 #define FOR_CART(i,j,k,am) for((i)=0;(i)<=(am);(i)++) {\
137  for((k)=0;(k)<=(am)-(i);(k)++) \
138  { (j) = (am) - (i) - (k);
139 #define END_FOR_CART }}
140 
141 #endif // INTV3 ordering
142 
143 #if LIBINT_CGSHELL_ORDERING == LIBINT_CGSHELL_ORDERING_GAMESS
144 // for definition of the ordering see CGShellInfo
145 
146 /* Computes an index to a Cartesian function within a shell given
147  * am = total angular momentum
148  * i = the exponent of x (i is used twice in the macro--beware side effects)
149  * j = the exponent of y
150  * for this ordering there is no formula
151  */
152 #define INT_CARTINDEX(am,i,j) CGShellInfo< CGShellOrderingData<CGShellOrdering_GAMESS> >::cartindex(am,i,j)
153 
154 /* This sets up the above loop over cartesian exponents as follows
155  * FOR_CART(i,j,k,am)
156  * Stuff using i,j,k.
157  * END_FOR_CART
158  */
159 #define FOR_CART(i,j,k,am) for(int __xyz=0; __xyz<INT_NCART(am); ++__xyz) { \
160  CGShellInfo< CGShellOrderingData<CGShellOrdering_GAMESS> >::cartindex_to_ijk(am,__xyz,i,j,k);
161 #define END_FOR_CART }
162 
163 #endif // GAMESS ordering
164 
165 #if LIBINT_CGSHELL_ORDERING == LIBINT_CGSHELL_ORDERING_ORCA
166 // for definition of the ordering see CGShellInfo
167 
168 /* Computes an index to a Cartesian function within a shell given
169  * am = total angular momentum
170  * i = the exponent of x (i is used twice in the macro--beware side effects)
171  * j = the exponent of y
172  * for this ordering there is no formula
173  */
174 #define INT_CARTINDEX(am,i,j) CGShellInfo< CGShellOrderingData<CGShellOrdering_ORCA> >::cartindex(am,i,j)
175 
176 /* This sets up the above loop over cartesian exponents as follows
177  * FOR_CART(i,j,k,am)
178  * Stuff using i,j,k.
179  * END_FOR_CART
180  */
181 #define FOR_CART(i,j,k,am) for(int __xyz=0; __xyz<INT_NCART(am); ++__xyz) { \
182  CGShellInfo< CGShellOrderingData<CGShellOrdering_ORCA> >::cartindex_to_ijk(am,__xyz,i,j,k);
183 #define END_FOR_CART }
184 
185 #endif // ORCA ordering
186 
187 #if LIBINT_CGSHELL_ORDERING == LIBINT_CGSHELL_ORDERING_BAGEL
188 // permuted version of IntV3 (y in IntV3 = x in Bagel, etc.)
189 
190 /* Computes an index to a Cartesian function within a shell given
191  * all arguments are used multiple times in the macro--beware side effects)
192  * am = total angular momentum
193  * i = the exponent of x
194  * j = the exponent of y
195  * formula: am*(k+1) - (k*(k+1))/2 + k+1 - i - 1 =
196  * The following loop will generate indices in the proper order:
197  * cartindex = 0;
198  * for (k=0; k<=am; k++) {
199  * for (j=0; j<=am-k; j++) {
200  * i = am - j - k;
201  * do_it_with(cartindex); // cartindex == INT_CARTINDEX(am,i,j)
202  * cartindex++;
203  * }
204  * }
205  */
206 #define INT_CARTINDEX(am,i,j) ((((am)+((i)+(j))+2)*((am)-((i)+(j))+1)>>1)-(i)-1)
207 
208 /* This sets up the above loop over cartesian exponents as follows
209  * FOR_CART(i,j,k,am)
210  * Stuff using i,j,k.
211  * END_FOR_CART
212  */
213 #define FOR_CART(i,j,k,am) for((k)=0;(k)<=(am);(k)++) {\
214  for((j)=0;(j)<=(am)-(k);(j)++) \
215  { (i) = (am) - (j) - (k);
216 #define END_FOR_CART }}
217 
218 #endif // Bagel ordering
219 
221 
222 #define INT_CARTINDEX_MOLDEN(am,i,j) CGShellInfo< CGShellOrderingData<CGShellOrdering_MOLDEN,4u> >::cartindex(am,i,j)
223 
224 /* FOR_CART_MOLDEN(i,j,k,am)
225  * END_FOR_CART_MOLDEN
226  */
227 #define FOR_CART_MOLDEN(i,j,k,am) for(int __xyz=0; __xyz<INT_NCART(am); ++__xyz) { \
228  CGShellInfo< CGShellOrderingData<CGShellOrdering_MOLDEN,4u> >::cartindex_to_ijk(am,__xyz,i,j,k);
229 #define END_FOR_CART_MOLDEN }
230 
231 #endif // header guard
Defaults definitions for various parameters assumed by Libint.
Definition: algebra.cc:24