1 | double form_volume(double radius); |
---|
2 | |
---|
3 | double Iq(double q, double radius, double surface_dim, double cutoff_length); |
---|
4 | double Iqxy(double qx, double qy, double radius, double surface_dim, double cutoff_length); |
---|
5 | |
---|
6 | static double _gamln(double q) |
---|
7 | { |
---|
8 | // Lanczos approximation to the Gamma function. |
---|
9 | // Should be refactored out to lib/, if used elsewhere. |
---|
10 | double x,y,tmp,ser; |
---|
11 | double coeff[6]= |
---|
12 | {76.18009172947146, -86.50532032941677, |
---|
13 | 24.01409824083091, -1.231739572450155, |
---|
14 | 0.1208650973866179e-2,-0.5395239384953e-5}; |
---|
15 | int j; |
---|
16 | |
---|
17 | y=x=q; |
---|
18 | tmp = x+5.5; |
---|
19 | tmp -= (x+0.5)*log(tmp); |
---|
20 | ser = 1.000000000190015; |
---|
21 | for (j=0; j<=5; j++) { |
---|
22 | y+=1.0; |
---|
23 | ser += coeff[j]/y; |
---|
24 | } |
---|
25 | return -tmp+log(2.5066282746310005*ser/x); |
---|
26 | } |
---|
27 | |
---|
28 | static double surface_fractal_kernel(double q, |
---|
29 | double radius, |
---|
30 | double surface_dim, |
---|
31 | double cutoff_length) |
---|
32 | { |
---|
33 | double pq, sq, mmo, result; |
---|
34 | |
---|
35 | //calculate P(q) for the spherical subunits; not normalized |
---|
36 | pq = pow((3.0*(sin(q*radius) - q*radius*cos(q*radius))/pow((q*radius),3)),2); |
---|
37 | |
---|
38 | //calculate S(q) |
---|
39 | mmo = 5.0 - surface_dim; |
---|
40 | sq = exp(_gamln(mmo))*sin(-(mmo)*atan(q*cutoff_length)); |
---|
41 | sq *= pow(cutoff_length, mmo); |
---|
42 | sq /= pow((1.0 + (q*cutoff_length)*(q*cutoff_length)),(mmo/2.0)); |
---|
43 | sq /= q; |
---|
44 | |
---|
45 | //combine and return |
---|
46 | result = pq * sq; |
---|
47 | |
---|
48 | return result; |
---|
49 | } |
---|
50 | double form_volume(double radius){ |
---|
51 | |
---|
52 | return 1.333333333333333*M_PI*radius*radius*radius; |
---|
53 | } |
---|
54 | |
---|
55 | double Iq(double q, |
---|
56 | double radius, |
---|
57 | double surface_dim, |
---|
58 | double cutoff_length |
---|
59 | ) |
---|
60 | { |
---|
61 | return surface_fractal_kernel(q, radius, surface_dim, cutoff_length); |
---|
62 | } |
---|
63 | |
---|
64 | // Iqxy is never called since no orientation or magnetic parameters. |
---|
65 | double Iqxy(double qx, double qy, |
---|
66 | double radius, |
---|
67 | double surface_dim, |
---|
68 | double cutoff_length) |
---|
69 | { |
---|
70 | double q = sqrt(qx*qx + qy*qy); |
---|
71 | return surface_fractal_kernel(q, radius, surface_dim, cutoff_length); |
---|
72 | } |
---|
73 | |
---|