forked from sunqm/libcint
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmisc.c
97 lines (86 loc) · 2.35 KB
/
misc.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
/*
* Copyright (C) 2013 Qiming Sun <[email protected]>
*
* basic functions
*/
#include <math.h>
#include <complex.h>
#include "cint_config.h"
void CINTdcmplx_re(const FINT n, double complex *z, const double *re)
{
FINT i;
for (i = 0; i < n; i++) {
z[i] = re[i] + 0 * _Complex_I;
}
}
void CINTdcmplx_im(const FINT n, double complex *z, const double *im)
{
FINT i;
for (i = 0; i < n; i++) {
z[i] = 0 + im[i] * _Complex_I;
}
}
void CINTdcmplx_pp(const FINT n, double complex *z,
const double *re, const double *im)
{
FINT i;
for (i = 0; i < n; i++) {
z[i] = re[i] + im[i] * _Complex_I;
}
}
void CINTdcmplx_pn(const FINT n, double complex *z,
const double *re, const double *im)
{
FINT i;
for (i = 0; i < n; i++) {
z[i] = re[i] - im[i] * _Complex_I;
}
}
void CINTdcmplx_np(const FINT n, double complex *z,
const double *re, const double *im)
{
FINT i;
for (i = 0; i < n; i++) {
z[i] = -re[i] + im[i] * _Complex_I;
}
}
void CINTdcmplx_nn(const FINT n, double complex *z,
const double *re, const double *im)
{
FINT i;
for (i = 0; i < n; i++) {
z[i] = -re[i] - im[i] * _Complex_I;
}
}
double CINTsquare_dist(const double *r1, const double *r2)
{
double r12[3];
r12[0] = r1[0] - r2[0];
r12[1] = r1[1] - r2[1];
r12[2] = r1[2] - r2[2];
return r12[0] * r12[0] + r12[1] * r12[1] + r12[2] * r12[2];
}
static double _gaussian_int(FINT n, double alpha)
{
double n1 = (n + 1) * .5;
return exp(lgamma(n1)) / (2. * pow(alpha, n1));
}
/*
* Normalized factor for GTO radial part g=r^l e^{-\alpha r^2}
*
* \frac{1}{\sqrt{\int g^2 r^2 dr}}
* = \sqrt{\frac{2^{2l+3} (l+1)! (2a)^{l+1.5}}{(2l+2)!\sqrt{\pi}}}
*
* Ref: H. B. Schlegel and M. J. Frisch, Int. J. Quant. Chem., 54(1995), 83-87.
*/
double CINTgto_norm(FINT n, double a)
{
//double nn = pow(2, (2*n+3)) * factorial(n+1) * pow((2*a), (n+1.5)) \
// / (factorial(2*n+2) * sqrt(M_PI));
//return sqrt(nn);
return 1. / sqrt(_gaussian_int(n*2+2, 2*a));
}
double CINTgto_norm_(FINT *n, double *a)
{
return CINTgto_norm(*n, *a);
}