source: sasmodels/sasmodels/models/hollow_rectangular_prism_thin_walls.c @ 74768cb

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

update models to use generic GAUSS_N, GAUSS_Z, GAUSS_W rather than specific gauss size

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