source: sasmodels/sasmodels/models/ellipsoid.c @ c036ddb

core_shell_microgelsmagnetic_modelticket-1257-vesicle-productticket_1156ticket_1265_superballticket_822_more_unit_tests
Last change on this file since c036ddb was c036ddb, checked in by Paul Kienzle <pkienzle@…>, 11 months ago

refactor so Iq is not needed if Fq is defined

  • Property mode set to 100644
File size: 3.2 KB
Line 
1static double
2form_volume(double radius_polar, double radius_equatorial)
3{
4    return M_4PI_3*radius_polar*radius_equatorial*radius_equatorial;
5}
6
7/* Fq overrides Iq
8static  double
9Iq(double q,
10    double sld,
11    double sld_solvent,
12    double radius_polar,
13    double radius_equatorial)
14{
15    // Using ratio v = Rp/Re, we can implement the form given in Guinier (1955)
16    //     i(h) = int_0^pi/2 Phi^2(h a sqrt(cos^2 + v^2 sin^2) cos dT
17    //          = int_0^pi/2 Phi^2(h a sqrt((1-sin^2) + v^2 sin^2) cos dT
18    //          = int_0^pi/2 Phi^2(h a sqrt(1 + sin^2(v^2-1)) cos dT
19    // u-substitution of
20    //     u = sin, du = cos dT
21    //     i(h) = int_0^1 Phi^2(h a sqrt(1 + u^2(v^2-1)) du
22    const double v_square_minus_one = square(radius_polar/radius_equatorial) - 1.0;
23
24    // translate a point in [-1,1] to a point in [0, 1]
25    // const double u = GAUSS_Z[i]*(upper-lower)/2 + (upper+lower)/2;
26    const double zm = 0.5;
27    const double zb = 0.5;
28    double total = 0.0;
29    for (int i=0;i<GAUSS_N;i++) {
30        const double u = GAUSS_Z[i]*zm + zb;
31        const double r = radius_equatorial*sqrt(1.0 + u*u*v_square_minus_one);
32        const double f = sas_3j1x_x(q*r);
33        total += GAUSS_W[i] * f * f;
34    }
35    // translate dx in [-1,1] to dx in [lower,upper]
36    const double form = total*zm;
37    const double s = (sld - sld_solvent) * form_volume(radius_polar, radius_equatorial);
38    return 1.0e-4 * s * s * form;
39}
40*/
41
42static void
43Fq(double q,
44    double *F1,
45    double *F2,
46    double sld,
47    double sld_solvent,
48    double radius_polar,
49    double radius_equatorial)
50{
51    // Using ratio v = Rp/Re, we can implement the form given in Guinier (1955)
52    //     i(h) = int_0^pi/2 Phi^2(h a sqrt(cos^2 + v^2 sin^2) cos dT
53    //          = int_0^pi/2 Phi^2(h a sqrt((1-sin^2) + v^2 sin^2) cos dT
54    //          = int_0^pi/2 Phi^2(h a sqrt(1 + sin^2(v^2-1)) cos dT
55    // u-substitution of
56    //     u = sin, du = cos dT
57    //     i(h) = int_0^1 Phi^2(h a sqrt(1 + u^2(v^2-1)) du
58    const double v_square_minus_one = square(radius_polar/radius_equatorial) - 1.0;
59    // translate a point in [-1,1] to a point in [0, 1]
60    // const double u = GAUSS_Z[i]*(upper-lower)/2 + (upper+lower)/2;
61    const double zm = 0.5;
62    const double zb = 0.5;
63    double total_F2 = 0.0;
64    double total_F1 = 0.0;
65    for (int i=0;i<GAUSS_N;i++) {
66        const double u = GAUSS_Z[i]*zm + zb;
67        const double r = radius_equatorial*sqrt(1.0 + u*u*v_square_minus_one);
68        const double f = sas_3j1x_x(q*r);
69        total_F2 += GAUSS_W[i] * f * f;
70        total_F1 += GAUSS_W[i] * f;
71    }
72    // translate dx in [-1,1] to dx in [lower,upper]
73    const double form_squared_avg = total_F2*zm;
74    const double form_avg = total_F1*zm;
75    const double s = (sld - sld_solvent) * form_volume(radius_polar, radius_equatorial);
76    *F1 = 1e-2 * s * form_avg;
77    *F2 = 1e-4 * s * s * form_squared_avg;
78}
79
80static double
81Iqac(double qab, double qc,
82    double sld,
83    double sld_solvent,
84    double radius_polar,
85    double radius_equatorial)
86{
87    const double qr = sqrt(square(radius_equatorial*qab) + square(radius_polar*qc));
88    const double f = sas_3j1x_x(qr);
89    const double s = (sld - sld_solvent) * form_volume(radius_polar, radius_equatorial);
90
91    return 1.0e-4 * square(f * s);
92}
Note: See TracBrowser for help on using the repository browser.