1 /*
2 * Copyright (C) 2013 Qiming Sun <osirpt.sun@gmail.com>
3 *
4 * basic cGTO function
5 */
6
7 #include "cint_bas.h"
8
9 /*
10 * No. components of a Cartesian GTO, = (l+1)*(l+2)/2
11 */
CINTlen_cart(const FINT l)12 FINT CINTlen_cart(const FINT l)
13 {
14 return (l + 1) * (l + 2) / 2;
15 }
16
CINTlen_spinor(const FINT bas_id,const FINT * bas)17 FINT CINTlen_spinor(const FINT bas_id, const FINT *bas)
18 {
19 if (0 == bas(KAPPA_OF, bas_id)) {
20 return 4 * bas(ANG_OF, bas_id) + 2;
21 } else if (bas(KAPPA_OF, bas_id) < 0) {
22 return 2 * bas(ANG_OF, bas_id) + 2;
23 } else {
24 return 2 * bas(ANG_OF, bas_id);
25 }
26 }
27
28 /*
29 * Num. of contracted cartesian GTO = 2j+1 * n_contraction
30 */
CINTcgtos_cart(const FINT bas_id,const FINT * bas)31 FINT CINTcgtos_cart(const FINT bas_id, const FINT *bas)
32 {
33 FINT l = bas(ANG_OF, bas_id);
34 return (l+1)*(l+2)/2 * bas(NCTR_OF, bas_id);
35 }
CINTcgto_cart(const FINT bas_id,const FINT * bas)36 FINT CINTcgto_cart(const FINT bas_id, const FINT *bas)
37 {
38 FINT l = bas(ANG_OF, bas_id);
39 return (l+1)*(l+2)/2 * bas(NCTR_OF, bas_id);
40 }
41
42 /*
43 * Num. of contracted spheric GTO = 2j+1 * n_contraction
44 */
CINTcgtos_spheric(const FINT bas_id,const FINT * bas)45 FINT CINTcgtos_spheric(const FINT bas_id, const FINT *bas)
46 {
47 return (bas(ANG_OF, bas_id) * 2 + 1) * bas(NCTR_OF, bas_id);
48 }
CINTcgto_spheric(const FINT bas_id,const FINT * bas)49 FINT CINTcgto_spheric(const FINT bas_id, const FINT *bas)
50 {
51 return (bas(ANG_OF, bas_id) * 2 + 1) * bas(NCTR_OF, bas_id);
52 }
53
54 /*
55 * Num. of contracted spinor GTO
56 */
CINTcgtos_spinor(const FINT bas_id,const FINT * bas)57 FINT CINTcgtos_spinor(const FINT bas_id, const FINT *bas)
58 {
59 return CINTlen_spinor(bas_id, bas) * bas(NCTR_OF, bas_id);
60 }
CINTcgto_spinor(const FINT bas_id,const FINT * bas)61 FINT CINTcgto_spinor(const FINT bas_id, const FINT *bas)
62 {
63 return CINTlen_spinor(bas_id, bas) * bas(NCTR_OF, bas_id);
64 }
65
66 /*
67 * tot. primitive atomic spheric GTOs in a shell
68 */
CINTtot_pgto_spheric(const FINT * bas,const FINT nbas)69 FINT CINTtot_pgto_spheric(const FINT *bas, const FINT nbas)
70 {
71 FINT i;
72 FINT s = 0;
73
74 for (i = 0; i < nbas; i++) {
75 s += (bas(ANG_OF, i) * 2 + 1)
76 * bas(NPRIM_OF, i);
77 }
78 return s;
79 }
80
81 /*
82 * tot. primitive atomic spinors in a shell
83 */
CINTtot_pgto_spinor(const FINT * bas,const FINT nbas)84 FINT CINTtot_pgto_spinor(const FINT *bas, const FINT nbas)
85 {
86 FINT i;
87 FINT s = 0;
88
89 for (i = 0; i < nbas; i++) {
90 s += CINTlen_spinor(i, bas) * bas(NPRIM_OF, i);
91 }
92 return s;
93 }
94
tot_cgto_accum(FINT (* f)(),const FINT * bas,const FINT nbas)95 static FINT tot_cgto_accum(FINT (*f)(), const FINT *bas, const FINT nbas)
96 {
97 FINT i;
98 FINT s = 0;
99
100 for (i = 0; i < nbas; i++) {
101 s += (*f)(i, bas);
102 }
103 return s;
104 }
105 /*
106 * tot. contracted atomic spheric GTOs in a shell
107 */
CINTtot_cgto_spheric(const FINT * bas,const FINT nbas)108 FINT CINTtot_cgto_spheric(const FINT *bas, const FINT nbas)
109 {
110 return tot_cgto_accum(&CINTcgto_spheric, bas, nbas);
111 }
112
113 /*
114 * tot. contracted atomic spinors in a shell
115 */
CINTtot_cgto_spinor(const FINT * bas,const FINT nbas)116 FINT CINTtot_cgto_spinor(const FINT *bas, const FINT nbas)
117 {
118 return tot_cgto_accum(&CINTcgto_spinor, bas, nbas);
119 }
120
121 /*
122 * tot. contracted atomic spinors in a shell
123 */
CINTtot_cgto_cart(const FINT * bas,const FINT nbas)124 FINT CINTtot_cgto_cart(const FINT *bas, const FINT nbas)
125 {
126 return tot_cgto_accum(&CINTcgto_cart, bas, nbas);
127 }
128
shells_cgto_offset(FINT (* f)(),FINT ao_loc[],const FINT * bas,const FINT nbas)129 static void shells_cgto_offset(FINT (*f)(), FINT ao_loc[],
130 const FINT *bas, const FINT nbas)
131 {
132 FINT i;
133 ao_loc[0] = 0;
134 for (i = 1; i < nbas; i++) {
135 ao_loc[i] = ao_loc[i-1] + (*f)(i-1, bas);
136 }
137 }
138 /*
139 * offset of each shell for real spheric GTOs
140 */
CINTshells_cart_offset(FINT ao_loc[],const FINT * bas,const FINT nbas)141 void CINTshells_cart_offset(FINT ao_loc[], const FINT *bas, const FINT nbas)
142 {
143 shells_cgto_offset(&CINTcgto_cart, ao_loc, bas, nbas);
144 }
145
146 /*
147 * offset of each shell for real spheric GTOs
148 */
CINTshells_spheric_offset(FINT ao_loc[],const FINT * bas,const FINT nbas)149 void CINTshells_spheric_offset(FINT ao_loc[], const FINT *bas, const FINT nbas)
150 {
151 shells_cgto_offset(&CINTcgto_spheric, ao_loc, bas, nbas);
152 }
153
154 /*
155 * offset of each shell for AO spinors
156 */
CINTshells_spinor_offset(FINT ao_loc[],const FINT * bas,const FINT nbas)157 void CINTshells_spinor_offset(FINT ao_loc[], const FINT *bas, const FINT nbas)
158 {
159 shells_cgto_offset(&CINTcgto_spinor, ao_loc, bas, nbas);
160 }
161
162
163 /*
164 * GTO = x^{nx}y^{ny}z^{nz}e^{-ar^2}
165 */
CINTcart_comp(FINT * nx,FINT * ny,FINT * nz,const FINT lmax)166 void CINTcart_comp(FINT *nx, FINT *ny, FINT *nz, const FINT lmax)
167 {
168 FINT inc = 0;
169 FINT lx, ly, lz;
170
171 for (lx = lmax; lx >= 0; lx--) {
172 for (ly = lmax - lx; ly >= 0; ly--) {
173 lz = lmax - lx - ly;
174 nx[inc] = lx;
175 ny[inc] = ly;
176 nz[inc] = lz;
177 inc++;
178 }
179 }
180 }
181
182