source: sasmodels/sasmodels/models/core_shell_parallelepiped.c @ a261a83

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

Merge branch 'ticket-786' into generic_integration_loop

  • Property mode set to 100644
File size: 5.1 KB
Line 
1// Set OVERLAPPING to 1 in order to fill in the edges of the box, with
2// c endcaps and b overlapping a.  With the proper choice of parameters,
3// (setting rim slds to sld, core sld to solvent, rim thickness to thickness
4// and subtracting 2*thickness from length, this should match the hollow
5// rectangular prism.)  Set it to 0 for the documented behaviour.
6#define OVERLAPPING 0
7static double
8form_volume(double length_a, double length_b, double length_c,
9    double thick_rim_a, double thick_rim_b, double thick_rim_c)
10{
11    return
12#if OVERLAPPING
13        // Hollow rectangular prism only includes the volume of the shell
14        // so uncomment the next line when comparing.  Solid rectangular
15        // prism, or parallelepiped want filled cores, so comment when
16        // comparing.
17        //-length_a * length_b * length_c +
18        (length_a + 2.0*thick_rim_a) *
19        (length_b + 2.0*thick_rim_b) *
20        (length_c + 2.0*thick_rim_c);
21#else
22        length_a * length_b * length_c +
23        2.0 * thick_rim_a * length_b * length_c +
24        2.0 * length_a * thick_rim_b * length_c +
25        2.0 * length_a * length_b * thick_rim_c;
26#endif
27}
28
29static double
30Iq(double q,
31    double core_sld,
32    double arim_sld,
33    double brim_sld,
34    double crim_sld,
35    double solvent_sld,
36    double length_a,
37    double length_b,
38    double length_c,
39    double thick_rim_a,
40    double thick_rim_b,
41    double thick_rim_c)
42{
43    // Code converted from functions CSPPKernel and CSParallelepiped in libCylinder.c
44    // Did not understand the code completely, it should be rechecked (Miguel Gonzalez)
45    // Code is rewritten,the code is compliant with Diva Singhs thesis now (Dirk Honecker)
46    // Code rewritten (PAK)
47
48    const double half_q = 0.5*q;
49
50    const double tA = length_a + 2.0*thick_rim_a;
51    const double tB = length_b + 2.0*thick_rim_b;
52    const double tC = length_c + 2.0*thick_rim_c;
53
54    // Scale factors
55    const double dr0 = (core_sld-solvent_sld);
56    const double drA = (arim_sld-solvent_sld);
57    const double drB = (brim_sld-solvent_sld);
58    const double drC = (crim_sld-solvent_sld);
59
60    // outer integral (with gauss points), integration limits = 0, 1
61    double outer_sum = 0; //initialize integral
62    for( int i=0; i<GAUSS_N; i++) {
63        const double cos_alpha = 0.5 * ( GAUSS_Z[i] + 1.0 );
64        const double mu = half_q * sqrt(1.0-cos_alpha*cos_alpha);
65
66        // inner integral (with gauss points), integration limits = 0, pi/2
67        const double siC = length_c * sas_sinx_x(length_c * cos_alpha * half_q);
68        const double siCt = tC * sas_sinx_x(tC * cos_alpha * half_q);
69        double inner_sum = 0.0;
70        for(int j=0; j<GAUSS_N; j++) {
71            const double beta = 0.5 * ( GAUSS_Z[j] + 1.0 );
72            double sin_beta, cos_beta;
73            SINCOS(M_PI_2*beta, sin_beta, cos_beta);
74            const double siA = length_a * sas_sinx_x(length_a * mu * sin_beta);
75            const double siB = length_b * sas_sinx_x(length_b * mu * cos_beta);
76            const double siAt = tA * sas_sinx_x(tA * mu * sin_beta);
77            const double siBt = tB * sas_sinx_x(tB * mu * cos_beta);
78
79#if OVERLAPPING
80            const double f = dr0*siA*siB*siC
81                + drA*(siAt-siA)*siB*siC
82                + drB*siAt*(siBt-siB)*siC
83                + drC*siAt*siBt*(siCt-siC);
84#else
85            const double f = dr0*siA*siB*siC
86                + drA*(siAt-siA)*siB*siC
87                + drB*siA*(siBt-siB)*siC
88                + drC*siA*siB*(siCt-siC);
89#endif
90
91            inner_sum += GAUSS_W[j] * f * f;
92        }
93        inner_sum *= 0.5;
94        // now sum up the outer integral
95        outer_sum += GAUSS_W[i] * inner_sum;
96    }
97    outer_sum *= 0.5;
98
99    //convert from [1e-12 A-1] to [cm-1]
100    return 1.0e-4 * outer_sum;
101}
102
103static double
104Iqxy(double qa, double qb, double qc,
105    double core_sld,
106    double arim_sld,
107    double brim_sld,
108    double crim_sld,
109    double solvent_sld,
110    double length_a,
111    double length_b,
112    double length_c,
113    double thick_rim_a,
114    double thick_rim_b,
115    double thick_rim_c)
116{
117    // cspkernel in csparallelepiped recoded here
118    const double dr0 = core_sld-solvent_sld;
119    const double drA = arim_sld-solvent_sld;
120    const double drB = brim_sld-solvent_sld;
121    const double drC = crim_sld-solvent_sld;
122
123    // The definitions of ta, tb, tc are not the same as in the 1D case because there is no
124    // the scaling by B.
125    const double tA = length_a + 2.0*thick_rim_a;
126    const double tB = length_b + 2.0*thick_rim_b;
127    const double tC = length_c + 2.0*thick_rim_c;
128    const double siA = length_a*sas_sinx_x(0.5*length_a*qa);
129    const double siB = length_b*sas_sinx_x(0.5*length_b*qb);
130    const double siC = length_c*sas_sinx_x(0.5*length_c*qc);
131    const double siAt = tA*sas_sinx_x(0.5*tA*qa);
132    const double siBt = tB*sas_sinx_x(0.5*tB*qb);
133    const double siCt = tC*sas_sinx_x(0.5*tC*qc);
134
135#if OVERLAPPING
136    const double f = dr0*siA*siB*siC
137        + drA*(siAt-siA)*siB*siC
138        + drB*siAt*(siBt-siB)*siC
139        + drC*siAt*siBt*(siCt-siC);
140#else
141    const double f = dr0*siA*siB*siC
142        + drA*(siAt-siA)*siB*siC
143        + drB*siA*(siBt-siB)*siC
144        + drC*siA*siB*(siCt-siC);
145#endif
146
147    return 1.0e-4 * f * f;
148}
Note: See TracBrowser for help on using the repository browser.