source: sasmodels/sasmodels/models/parallelepiped.c @ 5024a56

core_shell_microgelsmagnetic_modelticket-1257-vesicle-productticket_1156ticket_1265_superballticket_822_more_unit_tests
Last change on this file since 5024a56 was d42dd4a, checked in by pkienzle, 5 years ago

fix compiler warnings for CUDA

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