1/*
2 * Copyright (C) 2013-  Qiming Sun <osirpt.sun@gmail.com>
3 *
4 * Parameters and function signature for libcint.
5 */
6
7#define CINT_VERSION    @cint_VERSION@
8
9#cmakedefine I8
10#ifdef I8
11#include <stdint.h>
12#define FINT int64_t
13#else
14#define FINT int
15#endif
16
17#cmakedefine CACHE_SIZE_I8
18#ifdef CACHE_SIZE_I8
19#include <stdint.h>
20#define CACHE_SIZE_T int64_t
21#else
22#define CACHE_SIZE_T FINT
23#endif
24
25// global parameters in env
26// Overall cutoff for integral prescreening, value needs to be ~ln(threshold)
27#define PTR_EXPCUTOFF           0
28// R_C of (r-R_C) in dipole, GIAO operators
29#define PTR_COMMON_ORIG         1
30// R_O in 1/|r-R_O|
31#define PTR_RINV_ORIG           4
32// ZETA parameter for Gaussian charge distribution (Gaussian nuclear model)
33#define PTR_RINV_ZETA           7
34// omega parameter in range-separated coulomb operator
35// LR interaction: erf(omega*r12)/r12 if omega > 0
36// SR interaction: erfc(omega*r12)/r12 if omega < 0
37#define PTR_RANGE_OMEGA         8
38// Yukawa potential and Slater-type geminal e^{-zeta r}
39#define PTR_F12_ZETA            9
40// Gaussian type geminal e^{-zeta r^2}
41#define PTR_GTG_ZETA            10
42#define NGRIDS                  11
43#define PTR_GRIDS               12
44#define PTR_ENV_START           20
45
46
47// slots of atm
48#define CHARGE_OF       0
49#define PTR_COORD       1
50#define NUC_MOD_OF      2
51#define PTR_ZETA        3
52#define PTR_FRAC_CHARGE 3
53#define RESERVE_ATMLOT1 4
54#define RESERVE_ATMLOT2 5
55#define ATM_SLOTS       6
56
57
58// slots of bas
59#define ATOM_OF         0
60#define ANG_OF          1
61#define NPRIM_OF        2
62#define NCTR_OF         3
63#define KAPPA_OF        4
64#define PTR_EXP         5
65#define PTR_COEFF       6
66#define RESERVE_BASLOT  7
67#define BAS_SLOTS       8
68
69// slots of gout
70#define POSX            0
71#define POSY            1
72#define POSZ            2
73#define POS1            3
74// For 2-electron integral with two spin operators
75// SIGMA1X * SIGMA2X     0
76// SIGMA1Y * SIGMA2X     1
77// SIGMA1Z * SIGMA2X     2
78// I1_2x2  * SIGMA2X     3
79// SIGMA1X * SIGMA2Y     4
80// SIGMA1Y * SIGMA2Y     5
81// SIGMA1Z * SIGMA2Y     6
82// I1_2x2  * SIGMA2Y     7
83// SIGMA1X * SIGMA2Z     8
84// SIGMA1Y * SIGMA2Z     9
85// SIGMA1Z * SIGMA2Z     10
86// I1_2x2  * SIGMA2Z     11
87// SIGMA1X * I2_2x2      12
88// SIGMA1Y * I2_2x2      13
89// SIGMA1Z * I2_2x2      14
90// I1_2x2  * I2_2x2      15
91#define POSXX           0
92#define POSYX           1
93#define POSZX           2
94#define POS1X           3
95#define POSXY           4
96#define POSYY           5
97#define POSZY           6
98#define POS1Y           7
99#define POSXZ           8
100#define POSYZ           9
101#define POSZZ           10
102#define POS1Z           11
103#define POSX1           12
104#define POSY1           13
105#define POSZ1           14
106#define POS11           15
107
108// tensor
109#define TSRX        0
110#define TSRY        1
111#define TSRZ        2
112#define TSRXX       0
113#define TSRXY       1
114#define TSRXZ       2
115#define TSRYX       3
116#define TSRYY       4
117#define TSRYZ       5
118#define TSRZX       6
119#define TSRZY       7
120#define TSRZZ       8
121
122// other boundaries
123#define MXRYSROOTS      32 // > ANG_MAX*2+1 for 4c2e
124#define ANG_MAX         15 // l = 0..15
125#define LMAX1           16 // > ANG_MAX
126#define CART_MAX        136 // > (ANG_MAX*(ANG_MAX+1)/2)
127#define SHLS_MAX        1048576
128#define NPRIM_MAX       64
129#define NCTR_MAX        64
130
131#define POINT_NUC       1
132#define GAUSSIAN_NUC    2
133#define FRAC_CHARGE_NUC 3
134
135#define bas(SLOT,I)     bas[BAS_SLOTS * (I) + (SLOT)]
136#define atm(SLOT,I)     atm[ATM_SLOTS * (I) + (SLOT)]
137
138#if !defined HAVE_DEFINED_CINTOPT_H
139#define HAVE_DEFINED_CINTOPT_H
140typedef struct {
141    double rij[3];
142    double eij;
143    double cceij;
144} PairData;
145typedef struct {
146    FINT **index_xyz_array; // LMAX1**4 pointers to index_xyz
147    FINT **non0ctr;
148    FINT **sortedidx;
149    FINT nbas;
150    double **log_max_coeff;
151    PairData **pairdata;  // NULL indicates not-initialized, NO_VALUE can be skipped
152} CINTOpt;
153
154// Add this macro def to make pyscf compatible with both v4 and v5
155#define HAVE_DEFINED_CINTENVVARS_H
156typedef struct {
157        FINT *atm;
158        FINT *bas;
159        double *env;
160        FINT *shls;
161        FINT natm;
162        FINT nbas;
163
164        FINT i_l;
165        FINT j_l;
166        FINT k_l;
167        FINT l_l;
168        FINT nfi;  // number of cartesian components
169        FINT nfj;
170        // in int1e_grids, the grids_offset and the number of grids
171        union {FINT nfk; FINT grids_offset;};
172        union {FINT nfl; FINT ngrids;};
173        FINT nf;  // = nfi*nfj*nfk*nfl;
174        FINT _padding;
175        FINT x_ctr[4];
176
177        FINT gbits;
178        FINT ncomp_e1; // = 1 if spin free, = 4 when spin included, it
179        FINT ncomp_e2; // corresponds to POSX,POSY,POSZ,POS1, see cint.h
180        FINT ncomp_tensor; // e.g. = 3 for gradients
181
182        /* values may diff based on the g0_2d4d algorithm */
183        FINT li_ceil; // power of x, == i_l if nabla is involved, otherwise == i_l
184        FINT lj_ceil;
185        FINT lk_ceil;
186        FINT ll_ceil;
187        FINT g_stride_i; // nrys_roots * shift of (i++,k,l,j)
188        FINT g_stride_k; // nrys_roots * shift of (i,k++,l,j)
189        FINT g_stride_l; // nrys_roots * shift of (i,k,l++,j)
190        FINT g_stride_j; // nrys_roots * shift of (i,k,l,j++)
191        FINT nrys_roots;
192        FINT g_size;  // ref to cint2e.c g = malloc(sizeof(double)*g_size)
193
194        FINT g2d_ijmax;
195        FINT g2d_klmax;
196        double common_factor;
197        double expcutoff;
198        double rirj[3]; // diff by sign in different g0_2d4d algorithm
199        double rkrl[3];
200        double *rx_in_rijrx;
201        double *rx_in_rklrx;
202
203        double *ri;
204        double *rj;
205        double *rk;
206        // in int2e or int3c2e, the coordinates of the fourth shell
207        // in int1e_grids, the pointer for the grids coordinates
208        union {double *rl; double *grids;};
209
210        FINT (*f_g0_2e)();
211        void (*f_g0_2d4d)();
212        void (*f_gout)();
213        CINTOpt *opt;
214
215        /* values are assigned during calculation */
216        int *idx;
217        double ai[1];
218        double aj[1];
219        double ak[1];
220        double al[1];
221        double fac[1];
222        double rij[3];
223        double rkl[3];
224} CINTEnvVars;
225#endif
226
227FINT CINTlen_cart(const FINT l);
228FINT CINTlen_spinor(const FINT bas_id, const FINT *bas);
229
230FINT CINTcgtos_cart(const FINT bas_id, const FINT *bas);
231FINT CINTcgtos_spheric(const FINT bas_id, const FINT *bas);
232FINT CINTcgtos_spinor(const FINT bas_id, const FINT *bas);
233FINT CINTcgto_cart(const FINT bas_id, const FINT *bas);
234FINT CINTcgto_spheric(const FINT bas_id, const FINT *bas);
235FINT CINTcgto_spinor(const FINT bas_id, const FINT *bas);
236
237FINT CINTtot_pgto_spheric(const FINT *bas, const FINT nbas);
238FINT CINTtot_pgto_spinor(const FINT *bas, const FINT nbas);
239
240FINT CINTtot_cgto_cart(const FINT *bas, const FINT nbas);
241FINT CINTtot_cgto_spheric(const FINT *bas, const FINT nbas);
242FINT CINTtot_cgto_spinor(const FINT *bas, const FINT nbas);
243
244void CINTshells_cart_offset(FINT ao_loc[], const FINT *bas, const FINT nbas);
245void CINTshells_spheric_offset(FINT ao_loc[], const FINT *bas, const FINT nbas);
246void CINTshells_spinor_offset(FINT ao_loc[], const FINT *bas, const FINT nbas);
247
248double *CINTc2s_bra_sph(double *sph, FINT nket, double *cart, FINT l);
249double *CINTc2s_ket_sph(double *sph, FINT nket, double *cart, FINT l);
250double *CINTc2s_ket_sph1(double *sph, double *cart, FINT lds, FINT ldc, FINT l);
251
252
253double CINTgto_norm(FINT n, double a);
254
255
256void CINTinit_2e_optimizer(CINTOpt **opt, FINT *atm, FINT natm,
257                           FINT *bas, FINT nbas, double *env);
258void CINTinit_optimizer(CINTOpt **opt, FINT *atm, FINT natm,
259                        FINT *bas, FINT nbas, double *env);
260void CINTdel_2e_optimizer(CINTOpt **opt);
261void CINTdel_optimizer(CINTOpt **opt);
262
263
264FINT cint2e_cart(double *opijkl, FINT *shls,
265                FINT *atm, FINT natm, FINT *bas, FINT nbas, double *env,
266                CINTOpt *opt);
267void cint2e_cart_optimizer(CINTOpt **opt, FINT *atm, FINT natm,
268                           FINT *bas, FINT nbas, double *env);
269FINT cint2e_sph(double *opijkl, FINT *shls,
270               FINT *atm, FINT natm, FINT *bas, FINT nbas, double *env,
271               CINTOpt *opt);
272void cint2e_sph_optimizer(CINTOpt **opt, FINT *atm, FINT natm,
273                          FINT *bas, FINT nbas, double *env);
274FINT cint2e(double *opijkl, FINT *shls,
275           FINT *atm, FINT natm, FINT *bas, FINT nbas, double *env,
276           CINTOpt *opt);
277void cint2e_optimizer(CINTOpt **opt, FINT *atm, FINT natm,
278                      FINT *bas, FINT nbas, double *env);
279
280#ifndef __cplusplus
281#include <complex.h>
282
283void CINTc2s_ket_spinor_sf1(double complex *gspa, double complex *gspb, double *gcart,
284                            FINT lds, FINT ldc, FINT nctr, FINT l, FINT kappa);
285void CINTc2s_iket_spinor_sf1(double complex *gspa, double complex *gspb, double *gcart,
286                             FINT lds, FINT ldc, FINT nctr, FINT l, FINT kappa);
287void CINTc2s_ket_spinor_si1(double complex *gspa, double complex *gspb, double *gcart,
288                            FINT lds, FINT ldc, FINT nctr, FINT l, FINT kappa);
289void CINTc2s_iket_spinor_si1(double complex *gspa, double complex *gspb, double *gcart,
290                             FINT lds, FINT ldc, FINT nctr, FINT l, FINT kappa);
291#endif
292