source: sasmodels/sasmodels/models/parallelepiped.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@…>, 6 years ago

update remaining form factors to use Fq interface

  • Property mode set to 100644
File size: 2.7 KB
Line 
1static double
2form_volume(double length_a, double length_b, double length_c)
3{
4    return length_a * length_b * length_c;
5}
6
7
8static void
9Fq(double q,
10    double *F1,
11    double *F2,
12    double sld,
13    double solvent_sld,
14    double length_a,
15    double length_b,
16    double length_c)
17{
18    const double mu = 0.5 * q * length_b;
19
20    // Scale sides by B
21    const double a_scaled = length_a / length_b;
22    const double c_scaled = length_c / length_b;
23
24    // outer integral (with gauss points), integration limits = 0, 1
25    double outer_total_F1 = 0.0; //initialize integral
26    double outer_total_F2 = 0.0; //initialize integral
27    for( int i=0; i<GAUSS_N; i++) {
28        const double sigma = 0.5 * ( GAUSS_Z[i] + 1.0 );
29        const double mu_proj = mu * sqrt(1.0-sigma*sigma);
30
31        // inner integral (with gauss points), integration limits = 0, 1
32        // corresponding to angles from 0 to pi/2.
33        double inner_total_F1 = 0.0;
34        double inner_total_F2 = 0.0;
35        for(int j=0; j<GAUSS_N; j++) {
36            const double uu = 0.5 * ( GAUSS_Z[j] + 1.0 );
37            double sin_uu, cos_uu;
38            SINCOS(M_PI_2*uu, sin_uu, cos_uu);
39            const double si1 = sas_sinx_x(mu_proj * sin_uu * a_scaled);
40            const double si2 = sas_sinx_x(mu_proj * cos_uu);
41            const double fq = si1 * si2;
42            inner_total_F1 += GAUSS_W[j] * fq;
43            inner_total_F2 += GAUSS_W[j] * fq * fq;
44        }
45        // now complete change of inner integration variable (1-0)/(1-(-1))= 0.5
46        inner_total_F1 *= 0.5;
47        inner_total_F2 *= 0.5;
48
49        const double si = sas_sinx_x(mu * c_scaled * sigma);
50        outer_total_F1 += GAUSS_W[i] * inner_total_F1 * si;
51        outer_total_F2 += GAUSS_W[i] * inner_total_F2 * si * si;
52    }
53    // now complete change of outer integration variable (1-0)/(1-(-1))= 0.5
54    outer_total_F1 *= 0.5;
55    outer_total_F2 *= 0.5;
56
57    // Multiply by contrast^2 and convert from [1e-12 A-1] to [cm-1]
58    const double V = form_volume(length_a, length_b, length_c);
59    const double contrast = (sld-solvent_sld);
60    const double s = contrast * V;
61    *F1 = 1.0e-2 * s * outer_total_F1;
62    *F2 = 1.0e-4 * s * s * outer_total_F2;
63}
64
65static double
66Iqabc(double qa, double qb, double qc,
67    double sld,
68    double solvent_sld,
69    double length_a,
70    double length_b,
71    double length_c)
72{
73    const double siA = sas_sinx_x(0.5*length_a*qa);
74    const double siB = sas_sinx_x(0.5*length_b*qb);
75    const double siC = sas_sinx_x(0.5*length_c*qc);
76    const double V = form_volume(length_a, length_b, length_c);
77    const double drho = (sld - solvent_sld);
78    const double form = V * drho * siA * siB * siC;
79    // Square and convert from [1e-12 A-1] to [cm-1]
80    return 1.0e-4 * form * form;
81}
Note: See TracBrowser for help on using the repository browser.