File: surface_fractal.c

package info (click to toggle)
mccode 3.5.19%2Bds5-2
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 1,113,256 kB
  • sloc: ansic: 40,697; python: 25,137; yacc: 8,438; sh: 5,405; javascript: 4,596; lex: 1,632; cpp: 742; perl: 296; lisp: 273; makefile: 226; fortran: 132
file content (47 lines) | stat: -rw-r--r-- 1,368 bytes parent folder | download | duplicates (6)
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

double form_volume(double radius);

double Iq(double q,
          double radius,
          double fractal_dim_surf,
          double cutoff_length);

static double _surface_fractal_kernel(double q,
    double radius,
    double fractal_dim_surf,
    double cutoff_length)
{
    // calculate P(q)
    const double pq = square(sas_3j1x_x(q*radius));

    // calculate S(q)
    // Note: lim q->0 S(q) = -gamma(mmo) cutoff_length^mmo (mmo cutoff_length)
    // however, the surface fractal formula is invalid outside the range
    const double mmo = 5.0 - fractal_dim_surf;
    const double sq = sas_gamma(mmo) * pow(cutoff_length, mmo)
           * pow(1.0 + square(q*cutoff_length), -0.5*mmo)
           * sin(-mmo * atan(q*cutoff_length)) / q;

    // Empirically determined that the results are valid within this range.
    // Above 1/r, the form starts to oscillate;  below
    //const double result = (q > 5./(3-fractal_dim_surf)/cutoff_length) && q < 1./radius
    //                      ? pq * sq : 0.);

    double result = pq * sq;

    // exclude negative results
    return result > 0. ? result : 0.;
}
double form_volume(double radius)
{
    return M_4PI_3*cube(radius);
}

double Iq(double q,
    double radius,
    double fractal_dim_surf,
    double cutoff_length
    )
{
    return _surface_fractal_kernel(q, radius, fractal_dim_surf, cutoff_length);
}