source: sasmodels/sasmodels/models/core_shell_bicelle_elliptical.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: 4.2 KB
Line 
1// NOTE that "length" here is the full height of the core!
2static double
3form_volume(double r_minor,
4    double x_core,
5    double thick_rim,
6    double thick_face,
7    double length)
8{
9    return M_PI*(r_minor+thick_rim)*(r_minor*x_core+thick_rim)*(length+2.0*thick_face);
10}
11
12static void
13Fq(double q,
14    double *F1,
15    double *F2,
16    double r_minor,
17    double x_core,
18    double thick_rim,
19    double thick_face,
20    double length,
21    double sld_core,
22    double sld_face,
23    double sld_rim,
24    double sld_solvent)
25{
26     // core_shell_bicelle_elliptical, RKH Dec 2016, based on elliptical_cylinder and core_shell_bicelle
27     // tested against limiting cases of cylinder, elliptical_cylinder, stacked_discs, and core_shell_bicelle
28    const double halfheight = 0.5*length;
29    const double r_major = r_minor * x_core;
30    const double r2A = 0.5*(square(r_major) + square(r_minor));
31    const double r2B = 0.5*(square(r_major) - square(r_minor));
32    const double vol1 = M_PI*r_minor*r_major*(2.0*halfheight);
33    const double vol2 = M_PI*(r_minor+thick_rim)*(r_major+thick_rim)*2.0*(halfheight+thick_face);
34    const double vol3 = M_PI*r_minor*r_major*2.0*(halfheight+thick_face);
35    const double dr1 = vol1*(sld_core-sld_face);
36    const double dr2 = vol2*(sld_rim-sld_solvent);
37    const double dr3 = vol3*(sld_face-sld_rim);
38
39    //initialize integral
40    double outer_total_F1 = 0.0;
41    double outer_total_F2 = 0.0;
42    for(int i=0;i<GAUSS_N;i++) {
43        //setup inner integral over the ellipsoidal cross-section
44        //const double cos_theta = ( GAUSS_Z[i]*(vb-va) + va + vb )/2.0;
45        const double cos_theta = ( GAUSS_Z[i] + 1.0 )/2.0;
46        const double sin_theta = sqrt(1.0 - cos_theta*cos_theta);
47        const double qab = q*sin_theta;
48        const double qc = q*cos_theta;
49        const double si1 = sas_sinx_x(halfheight*qc);
50        const double si2 = sas_sinx_x((halfheight+thick_face)*qc);
51        double inner_total_F1 = 0;
52        double inner_total_F2 = 0;
53        for(int j=0;j<GAUSS_N;j++) {
54            //76 gauss points for the inner integral (WAS 20 points,so this may make unecessarily slow, but playing safe)
55            //const double beta = ( GAUSS_Z[j]*(vbj-vaj) + vaj + vbj )/2.0;
56            const double beta = ( GAUSS_Z[j] +1.0)*M_PI_2;
57            const double rr = sqrt(r2A - r2B*cos(beta));
58            const double be1 = sas_2J1x_x(rr*qab);
59            const double be2 = sas_2J1x_x((rr+thick_rim)*qab);
60            const double f = dr1*si1*be1 + dr2*si2*be2 + dr3*si2*be1;
61
62            inner_total_F1 += GAUSS_W[j] * f;
63            inner_total_F2 += GAUSS_W[j] * f * f;
64        }
65        //now calculate outer integral
66        outer_total_F1 += GAUSS_W[i] * inner_total_F1;
67        outer_total_F2 += GAUSS_W[i] * inner_total_F2;
68    }
69    // now complete change of integration variables (1-0)/(1-(-1))= 0.5
70    outer_total_F1 *= 0.25;
71    outer_total_F2 *= 0.25;
72
73    //convert from [1e-12 A-1] to [cm-1]
74    *F1 = 1e-2*outer_total_F1;
75    *F2 = 1e-4*outer_total_F2;
76}
77
78static double
79Iqabc(double qa, double qb, double qc,
80    double r_minor,
81    double x_core,
82    double thick_rim,
83    double thick_face,
84    double length,
85    double sld_core,
86    double sld_face,
87    double sld_rim,
88    double sld_solvent)
89{
90    const double dr1 = sld_core-sld_face;
91    const double dr2 = sld_rim-sld_solvent;
92    const double dr3 = sld_face-sld_rim;
93    const double r_major = r_minor*x_core;
94    const double halfheight = 0.5*length;
95    const double vol1 = M_PI*r_minor*r_major*length;
96    const double vol2 = M_PI*(r_minor+thick_rim)*(r_major+thick_rim)*2.0*(halfheight+thick_face);
97    const double vol3 = M_PI*r_minor*r_major*2.0*(halfheight+thick_face);
98
99    // Compute effective radius in rotated coordinates
100    const double qr_hat = sqrt(square(r_major*qb) + square(r_minor*qa));
101    const double qrshell_hat = sqrt(square((r_major+thick_rim)*qb)
102                                   + square((r_minor+thick_rim)*qa));
103    const double be1 = sas_2J1x_x( qr_hat );
104    const double be2 = sas_2J1x_x( qrshell_hat );
105    const double si1 = sas_sinx_x( halfheight*qc );
106    const double si2 = sas_sinx_x( (halfheight + thick_face)*qc );
107    const double fq = vol1*dr1*si1*be1 + vol2*dr2*si2*be2 +  vol3*dr3*si2*be1;
108    return 1.0e-4 * fq*fq;
109}
Note: See TracBrowser for help on using the repository browser.