source: sasmodels/sasmodels/models/hollow_rectangular_prism.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: 4.7 KB
RevLine 
[d86f0fc]1static double
2form_volume(double length_a, double b2a_ratio, double c2a_ratio, double thickness)
[deb7ee0]3{
[ab2aea8]4    double length_b = length_a * b2a_ratio;
5    double length_c = length_a * c2a_ratio;
[a807206]6    double a_core = length_a - 2.0*thickness;
[ab2aea8]7    double b_core = length_b - 2.0*thickness;
8    double c_core = length_c - 2.0*thickness;
[deb7ee0]9    double vol_core = a_core * b_core * c_core;
[ab2aea8]10    double vol_total = length_a * length_b * length_c;
[deb7ee0]11    double vol_shell = vol_total - vol_core;
12    return vol_shell;
13}
14
[71b751d]15static void
16Fq(double q,
17    double *F1,
18    double *F2,
[deb7ee0]19    double sld,
20    double solvent_sld,
[a807206]21    double length_a,
[deb7ee0]22    double b2a_ratio,
23    double c2a_ratio,
24    double thickness)
25{
[6f676fb]26    const double length_b = length_a * b2a_ratio;
27    const double length_c = length_a * c2a_ratio;
28    const double a_half = 0.5 * length_a;
29    const double b_half = 0.5 * length_b;
30    const double c_half = 0.5 * length_c;
31    const double vol_total = length_a * length_b * length_c;
32    const double vol_core = 8.0 * (a_half-thickness) * (b_half-thickness) * (c_half-thickness);
[deb7ee0]33
[ab2aea8]34    //Integration limits to use in Gaussian quadrature
[6f676fb]35    const double v1a = 0.0;
36    const double v1b = M_PI_2;  //theta integration limits
37    const double v2a = 0.0;
38    const double v2b = M_PI_2;  //phi integration limits
[8de1477]39
[71b751d]40    double outer_sum_F1 = 0.0;
41    double outer_sum_F2 = 0.0;
[74768cb]42    for(int i=0; i<GAUSS_N; i++) {
[deb7ee0]43
[74768cb]44        const double theta = 0.5 * ( GAUSS_Z[i]*(v1b-v1a) + v1a + v1b );
[6f676fb]45        double sin_theta, cos_theta;
46        SINCOS(theta, sin_theta, cos_theta);
[deb7ee0]47
[1e7b0db0]48        const double termC1 = sas_sinx_x(q * c_half * cos(theta));
49        const double termC2 = sas_sinx_x(q * (c_half-thickness)*cos(theta));
[deb7ee0]50
[71b751d]51        double inner_sum_F1 = 0.0;
52        double inner_sum_F2 = 0.0;
[74768cb]53        for(int j=0; j<GAUSS_N; j++) {
[deb7ee0]54
[74768cb]55            const double phi = 0.5 * ( GAUSS_Z[j]*(v2b-v2a) + v2a + v2b );
[6f676fb]56            double sin_phi, cos_phi;
57            SINCOS(phi, sin_phi, cos_phi);
[deb7ee0]58
59            // Amplitude AP from eqn. (13), rewritten to avoid round-off effects when arg=0
60
[1e7b0db0]61            const double termA1 = sas_sinx_x(q * a_half * sin_theta * sin_phi);
62            const double termA2 = sas_sinx_x(q * (a_half-thickness) * sin_theta * sin_phi);
[deb7ee0]63
[1e7b0db0]64            const double termB1 = sas_sinx_x(q * b_half * sin_theta * cos_phi);
65            const double termB2 = sas_sinx_x(q * (b_half-thickness) * sin_theta * cos_phi);
[deb7ee0]66
[6f676fb]67            const double AP1 = vol_total * termA1 * termB1 * termC1;
68            const double AP2 = vol_core * termA2 * termB2 * termC2;
[deb7ee0]69
[71b751d]70            inner_sum_F1 += GAUSS_W[j] * (AP1-AP2);
71            inner_sum_F2 += GAUSS_W[j] * square(AP1-AP2);
[ab2aea8]72        }
[71b751d]73        inner_sum_F1 *= 0.5 * (v2b-v2a);
74        inner_sum_F2 *= 0.5 * (v2b-v2a);
[deb7ee0]75
[71b751d]76        outer_sum_F1 += GAUSS_W[i] * inner_sum_F1 * sin(theta);
77        outer_sum_F2 += GAUSS_W[i] * inner_sum_F2 * sin(theta);
[deb7ee0]78    }
[71b751d]79    outer_sum_F1 *= 0.5*(v1b-v1a);
80    outer_sum_F2 *= 0.5*(v1b-v1a);
[deb7ee0]81
82    // Normalize as in Eqn. (15) without the volume factor (as cancels with (V*DelRho)^2 normalization)
83    // The factor 2 is due to the different theta integration limit (pi/2 instead of pi)
[71b751d]84    const double form_avg = outer_sum_F1/M_PI_2;
85    const double form_squared_avg = outer_sum_F2/M_PI_2;
[deb7ee0]86
87    // Multiply by contrast^2. Factor corresponding to volume^2 cancels with previous normalization.
[71b751d]88    const double contrast = sld - solvent_sld;
[deb7ee0]89
90    // Convert from [1e-12 A-1] to [cm-1]
[71b751d]91    *F1 = 1.0e-2 * contrast * form_avg;
92    *F2 = 1.0e-4 * contrast * contrast * form_squared_avg;
[deb7ee0]93}
[8de1477]94
[d86f0fc]95static double
96Iqabc(double qa, double qb, double qc,
[8de1477]97    double sld,
98    double solvent_sld,
99    double length_a,
100    double b2a_ratio,
101    double c2a_ratio,
102    double thickness)
103{
104    const double length_b = length_a * b2a_ratio;
105    const double length_c = length_a * c2a_ratio;
106    const double a_half = 0.5 * length_a;
107    const double b_half = 0.5 * length_b;
108    const double c_half = 0.5 * length_c;
109    const double vol_total = length_a * length_b * length_c;
110    const double vol_core = 8.0 * (a_half-thickness) * (b_half-thickness) * (c_half-thickness);
111
112    // Amplitude AP from eqn. (13)
113
114    const double termA1 = sas_sinx_x(qa * a_half);
115    const double termA2 = sas_sinx_x(qa * (a_half-thickness));
116
117    const double termB1 = sas_sinx_x(qb * b_half);
118    const double termB2 = sas_sinx_x(qb * (b_half-thickness));
119
120    const double termC1 = sas_sinx_x(qc * c_half);
121    const double termC2 = sas_sinx_x(qc * (c_half-thickness));
122
123    const double AP1 = vol_total * termA1 * termB1 * termC1;
124    const double AP2 = vol_core * termA2 * termB2 * termC2;
125
126    // Multiply by contrast^2. Factor corresponding to volume^2 cancels with previous normalization.
127    const double delrho = sld - solvent_sld;
128
129    // Convert from [1e-12 A-1] to [cm-1]
130    return 1.0e-4 * square(delrho * (AP1-AP2));
[71b751d]131}
Note: See TracBrowser for help on using the repository browser.