source: sasmodels/sasmodels/models/hollow_rectangular_prism_thin_walls.c @ 2f8cbb9

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

lint reduction

  • Property mode set to 100644
File size: 2.7 KB
Line 
1static double
2form_volume(double length_a, double b2a_ratio, double c2a_ratio)
3{
4    double length_b = length_a * b2a_ratio;
5    double length_c = length_a * c2a_ratio;
6    double vol_shell = 2.0 * (length_a*length_b + length_a*length_c + length_b*length_c);
7    return vol_shell;
8}
9
10static double
11Iq(double q,
12    double sld,
13    double solvent_sld,
14    double length_a,
15    double b2a_ratio,
16    double c2a_ratio)
17{
18    const double length_b = length_a * b2a_ratio;
19    const double length_c = length_a * c2a_ratio;
20    const double a_half = 0.5 * length_a;
21    const double b_half = 0.5 * length_b;
22    const double c_half = 0.5 * length_c;
23
24   //Integration limits to use in Gaussian quadrature
25    const double v1a = 0.0;
26    const double v1b = M_PI_2;  //theta integration limits
27    const double v2a = 0.0;
28    const double v2b = M_PI_2;  //phi integration limits
29
30    double outer_sum = 0.0;
31    for(int i=0; i<GAUSS_N; i++) {
32        const double theta = 0.5 * ( GAUSS_Z[i]*(v1b-v1a) + v1a + v1b );
33
34        double sin_theta, cos_theta;
35        double sin_c, cos_c;
36        SINCOS(theta, sin_theta, cos_theta);
37        SINCOS(q*c_half*cos_theta, sin_c, cos_c);
38
39        // To check potential problems if denominator goes to zero here !!!
40        const double termAL_theta = 8.0 * cos_c / (q*q*sin_theta*sin_theta);
41        const double termAT_theta = 8.0 * sin_c / (q*q*sin_theta*cos_theta);
42
43        double inner_sum = 0.0;
44        for(int j=0; j<GAUSS_N; j++) {
45            const double phi = 0.5 * ( GAUSS_Z[j]*(v2b-v2a) + v2a + v2b );
46
47            double sin_phi, cos_phi;
48            double sin_a, cos_a;
49            double sin_b, cos_b;
50            SINCOS(phi, sin_phi, cos_phi);
51            SINCOS(q*a_half*sin_theta*sin_phi, sin_a, cos_a);
52            SINCOS(q*b_half*sin_theta*cos_phi, sin_b, cos_b);
53
54            // Amplitude AL from eqn. (7c)
55            const double AL = termAL_theta
56                * sin_a*sin_b / (sin_phi*cos_phi);
57
58            // Amplitude AT from eqn. (9)
59            const double AT = termAT_theta
60                * ( cos_a*sin_b/cos_phi + cos_b*sin_a/sin_phi );
61
62            inner_sum += GAUSS_W[j] * square(AL+AT);
63        }
64
65        inner_sum *= 0.5 * (v2b-v2a);
66        outer_sum += GAUSS_W[i] * inner_sum * sin_theta;
67    }
68
69    outer_sum *= 0.5*(v1b-v1a);
70
71    // Normalize as in Eqn. (15) without the volume factor (as cancels with (V*DelRho)^2 normalization)
72    // The factor 2 is due to the different theta integration limit (pi/2 instead of pi)
73    double answer = outer_sum/M_PI_2;
74
75    // Multiply by contrast^2. Factor corresponding to volume^2 cancels with previous normalization.
76    answer *= square(sld-solvent_sld);
77
78    // Convert from [1e-12 A-1] to [cm-1]
79    answer *= 1.0e-4;
80
81    return answer;
82}
Note: See TracBrowser for help on using the repository browser.