source: sasmodels/sasmodels/models/lib/fractal_sq.c @ 217590b

core_shell_microgelscostrafo411magnetic_modelticket-1257-vesicle-productticket_1156ticket_1265_superballticket_822_more_unit_tests
Last change on this file since 217590b was 217590b, checked in by Paul Kienzle <pkienzle@…>, 8 years ago

fractal, fractal_core_shell: support fractal_dim as low as 0.

  • Property mode set to 100644
File size: 1.1 KB
Line 
1static double
2fractal_sq(double q, double radius, double fractal_dim, double cor_length)
3{
4    //calculate S(q),  using Teixeira, Eq(15)
5    // mathematica query to check limiting conditions:
6    //    lim x->0 of [ x gamma(x-1) sin(arctan(q c (x-1))) (q r)^(-x) (1 + 1/(q c)^2)^((1-x)/2) ]
7    // Note: gamma(x) may be unreliable for x<0, so the gamma(D-1) is risky.
8    // We instead transform D*gamma(D-1) into gamma(D+1)/(D-1).
9    double term;
10    if (q == 0.) {
11        const double D = fractal_dim;
12        term = pow(cor_length/radius, D)*sas_gamma(D+1.);
13    } else if (fractal_dim == 0.) {
14        term = 1.0;
15    } else if (fractal_dim == 1.) {
16        term = atan(q*cor_length)/(q*radius);
17    } else {
18        // q>0, D>0
19        const double D = fractal_dim;
20        const double Dm1 = fractal_dim - 1.0;
21        // Note: for large Dm1, sin(Dm1*atan(q*cor_length) can go negative
22        const double t1 = sas_gamma(D+1.)/Dm1*sin(Dm1*atan(q*cor_length));
23        const double t2 = pow(q*radius, -D);
24        const double t3 = pow(1.0 + 1.0/square(q*cor_length), -0.5*Dm1);
25        term = t1 * t2 * t3;
26    }
27    return 1.0 + term;
28}
Note: See TracBrowser for help on using the repository browser.