source: sasmodels/sasmodels/models/triaxial_ellipsoid.c @ 71b751d

core_shell_microgelsmagnetic_modelticket-1257-vesicle-productticket_1156ticket_1265_superballticket_822_more_unit_tests
Last change on this file since 71b751d was 71b751d, checked in by Paul Kienzle <pkienzle@…>, 2 years ago

update remaining form factors to use Fq interface

  • Property mode set to 100644
File size: 2.7 KB
Line 
1//#define INVALID(v) (v.radius_equat_minor > v.radius_equat_major || v.radius_equat_major > v.radius_polar)
2
3static double
4form_volume(double radius_equat_minor, double radius_equat_major, double radius_polar)
5{
6    return M_4PI_3*radius_equat_minor*radius_equat_major*radius_polar;
7}
8
9
10static void
11Fq(double q,
12    double *F1,
13    double *F2,
14    double sld,
15    double sld_solvent,
16    double radius_equat_minor,
17    double radius_equat_major,
18    double radius_polar)
19{
20    const double pa = square(radius_equat_minor/radius_equat_major) - 1.0;
21    const double pc = square(radius_polar/radius_equat_major) - 1.0;
22    // translate a point in [-1,1] to a point in [0, pi/2]
23    const double zm = M_PI_4;
24    const double zb = M_PI_4;
25    double outer_sum_F1 = 0.0;
26    double outer_sum_F2 = 0.0;
27    for (int i=0;i<GAUSS_N;i++) {
28        //const double u = GAUSS_Z[i]*(upper-lower)/2 + (upper + lower)/2;
29        const double phi = GAUSS_Z[i]*zm + zb;
30        const double pa_sinsq_phi = pa*square(sin(phi));
31
32        double inner_sum_F1 = 0.0;
33        double inner_sum_F2 = 0.0;
34        const double um = 0.5;
35        const double ub = 0.5;
36        for (int j=0;j<GAUSS_N;j++) {
37            // translate a point in [-1,1] to a point in [0, 1]
38            const double usq = square(GAUSS_Z[j]*um + ub);
39            const double r = radius_equat_major*sqrt(pa_sinsq_phi*(1.0-usq) + 1.0 + pc*usq);
40            const double fq = sas_3j1x_x(q*r);
41            inner_sum_F1 += GAUSS_W[j] * fq;
42            inner_sum_F2 += GAUSS_W[j] * fq * fq;
43        }
44        outer_sum_F1 += GAUSS_W[i] * inner_sum_F1;  // correcting for dx later
45        outer_sum_F2 += GAUSS_W[i] * inner_sum_F2;  // correcting for dx later
46    }
47    // translate integration ranges from [-1,1] to [lower,upper] and normalize by 4 pi
48    outer_sum_F1 *= 0.25;  // = outer*um*zm*8.0/(4.0*M_PI);
49    outer_sum_F2 *= 0.25;  // = outer*um*zm*8.0/(4.0*M_PI);
50
51    const double volume = form_volume(radius_equat_minor, radius_equat_major, radius_polar);
52    const double contrast = (sld - sld_solvent);
53    *F1 = 1.0e-2 * contrast * volume * outer_sum_F1;
54    *F2 = 1.0e-4 * square(contrast * volume) * outer_sum_F2;
55}
56
57
58static double
59Iqabc(double qa, double qb, double qc,
60    double sld,
61    double sld_solvent,
62    double radius_equat_minor,
63    double radius_equat_major,
64    double radius_polar)
65{
66    const double qr = sqrt(square(radius_equat_minor*qa)
67                           + square(radius_equat_major*qb)
68                           + square(radius_polar*qc));
69    const double fq = sas_3j1x_x(qr);
70    const double vol = form_volume(radius_equat_minor, radius_equat_major, radius_polar);
71    const double drho = (sld - sld_solvent);
72
73    return 1.0e-4 * square(vol * drho * fq);
74}
Note: See TracBrowser for help on using the repository browser.