source: sasmodels/sasmodels/models/ellipsoid.c @ 01c8d9e

core_shell_microgelsmagnetic_modelticket-1257-vesicle-productticket_1156ticket_1265_superballticket_822_more_unit_tests
Last change on this file since 01c8d9e was 01c8d9e, checked in by Suczewski <ges3@…>, 11 months ago

beta approximation, first pass

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