source: sasmodels/sasmodels/models/hollow_rectangular_prism_thin_walls.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: 3.1 KB
RevLine 
[d86f0fc]1static double
2form_volume(double length_a, double b2a_ratio, double c2a_ratio)
[deb7ee0]3{
[ab2aea8]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);
[deb7ee0]7    return vol_shell;
8}
9
[71b751d]10static void
11Fq(double q,
12    double *F1,
13    double *F2,
[deb7ee0]14    double sld,
15    double solvent_sld,
[a807206]16    double length_a,
[deb7ee0]17    double b2a_ratio,
18    double c2a_ratio)
19{
[ab2aea8]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;
[deb7ee0]25
26   //Integration limits to use in Gaussian quadrature
[ab2aea8]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
[74768cb]31
[71b751d]32    double outer_sum_F1 = 0.0;
33    double outer_sum_F2 = 0.0;
[74768cb]34    for(int i=0; i<GAUSS_N; i++) {
35        const double theta = 0.5 * ( GAUSS_Z[i]*(v1b-v1a) + v1a + v1b );
[deb7ee0]36
[ab2aea8]37        double sin_theta, cos_theta;
38        double sin_c, cos_c;
39        SINCOS(theta, sin_theta, cos_theta);
40        SINCOS(q*c_half*cos_theta, sin_c, cos_c);
[deb7ee0]41
42        // To check potential problems if denominator goes to zero here !!!
[ab2aea8]43        const double termAL_theta = 8.0 * cos_c / (q*q*sin_theta*sin_theta);
44        const double termAT_theta = 8.0 * sin_c / (q*q*sin_theta*cos_theta);
45
[71b751d]46        double inner_sum_F1 = 0.0;
47        double inner_sum_F2 = 0.0;
[74768cb]48        for(int j=0; j<GAUSS_N; j++) {
49            const double phi = 0.5 * ( GAUSS_Z[j]*(v2b-v2a) + v2a + v2b );
[deb7ee0]50
[ab2aea8]51            double sin_phi, cos_phi;
52            double sin_a, cos_a;
53            double sin_b, cos_b;
54            SINCOS(phi, sin_phi, cos_phi);
55            SINCOS(q*a_half*sin_theta*sin_phi, sin_a, cos_a);
56            SINCOS(q*b_half*sin_theta*cos_phi, sin_b, cos_b);
[deb7ee0]57
58            // Amplitude AL from eqn. (7c)
[ab2aea8]59            const double AL = termAL_theta
60                * sin_a*sin_b / (sin_phi*cos_phi);
[deb7ee0]61
62            // Amplitude AT from eqn. (9)
[ab2aea8]63            const double AT = termAT_theta
64                * ( cos_a*sin_b/cos_phi + cos_b*sin_a/sin_phi );
[deb7ee0]65
[71b751d]66            inner_sum_F1 += GAUSS_W[j] * (AL+AT);
67            inner_sum_F2 += GAUSS_W[j] * square(AL+AT);
[ab2aea8]68        }
[deb7ee0]69
[71b751d]70        inner_sum_F1 *= 0.5 * (v2b-v2a);
71        inner_sum_F2 *= 0.5 * (v2b-v2a);
72        outer_sum_F1 += GAUSS_W[i] * inner_sum_F1 * sin_theta;
73        outer_sum_F2 += GAUSS_W[i] * inner_sum_F2 * sin_theta;
[deb7ee0]74    }
75
[71b751d]76    outer_sum_F1 *= 0.5*(v1b-v1a);
77    outer_sum_F2 *= 0.5*(v1b-v1a);
[deb7ee0]78
79    // Normalize as in Eqn. (15) without the volume factor (as cancels with (V*DelRho)^2 normalization)
80    // The factor 2 is due to the different theta integration limit (pi/2 instead of pi)
[71b751d]81    const double form_avg = outer_sum_F1/M_PI_2;
82    const double form_squared_avg = outer_sum_F2/M_PI_2;
[deb7ee0]83
84    // Multiply by contrast^2. Factor corresponding to volume^2 cancels with previous normalization.
[71b751d]85    const double contrast = sld - solvent_sld;
[deb7ee0]86
87    // Convert from [1e-12 A-1] to [cm-1]
[71b751d]88    *F1 = 1e-2 * contrast * form_avg;
89    *F2 = 1e-4 * contrast * contrast * form_squared_avg;
[deb7ee0]90}
Note: See TracBrowser for help on using the repository browser.