source: sasmodels/sasmodels/models/core_shell_bicelle_elliptical_belt_rough.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: 5.0 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 +
10                 square(r_minor)*x_core*2.0*thick_face  );
11}
12
13static void
14Fq(double q,
15        double *F1,
16        double *F2,
17        double r_minor,
18        double x_core,
19        double thick_rim,
20        double thick_face,
21        double length,
22        double rhoc,
23        double rhoh,
24        double rhor,
25        double rhosolv,
26        double sigma)
27{
28     // core_shell_bicelle_elliptical_belt, RKH 5th Oct 2017, core_shell_bicelle_elliptical
29     // tested briefly against limiting cases of cylinder, hollow cylinder & elliptical cylinder models
30     //    const double uplim = M_PI_4;
31    const double halfheight = 0.5*length;
32    //const double va = 0.0;
33    //const double vb = 1.0;
34    // inner integral limits
35    //const double vaj=0.0;
36    //const double vbj=M_PI;
37
38    const double r_major = r_minor * x_core;
39    const double r2A = 0.5*(square(r_major) + square(r_minor));
40    const double r2B = 0.5*(square(r_major) - square(r_minor));
41    const double vol1 = M_PI*r_minor*r_major*(2.0*halfheight);
42    const double vol2 = M_PI*(r_minor+thick_rim)*(r_major+thick_rim)*2.0*halfheight;
43    const double vol3 = M_PI*r_minor*r_major*2.0*(halfheight+thick_face);
44    // dr1,2,3 are now for Vcore, Vcore+rim, Vcore+face,
45    const double dr1 = vol1*(-rhor - rhoh + rhoc + rhosolv);
46    const double dr2 = vol2*(rhor-rhosolv);
47    const double dr3 = vol3*(rhoh-rhosolv);
48
49    //initialize integral
50    double outer_total_F1 = 0.0;
51    double outer_total_F2 = 0.0;
52    for(int i=0;i<GAUSS_N;i++) {
53        //setup inner integral over the ellipsoidal cross-section
54        // since we generate these lots of times, why not store them somewhere?
55        //const double cos_theta = ( GAUSS_Z[i]*(vb-va) + va + vb )/2.0;
56        const double cos_theta = ( GAUSS_Z[i] + 1.0 )/2.0;
57        const double sin_theta = sqrt(1.0 - cos_theta*cos_theta);
58        const double qab = q*sin_theta;
59        const double qc = q*cos_theta;
60        const double si1 = sas_sinx_x(halfheight*qc);
61        const double si2 = sas_sinx_x((halfheight+thick_face)*qc);
62        double inner_total_F1 = 0;
63        double inner_total_F2 = 0;
64        for(int j=0;j<GAUSS_N;j++) {
65            //76 gauss points for the inner integral (WAS 20 points,so this may make unecessarily slow, but playing safe)
66            //const double beta = ( GAUSS_Z[j]*(vbj-vaj) + vaj + vbj )/2.0;
67            const double beta = ( GAUSS_Z[j] +1.0)*M_PI_2;
68            const double rr = sqrt(r2A - r2B*cos(beta));
69            const double be1 = sas_2J1x_x(rr*qab);
70            const double be2 = sas_2J1x_x((rr+thick_rim)*qab);
71            const double f = dr1*si1*be1 + dr2*si1*be2 + dr3*si2*be1;
72
73            inner_total_F1 += GAUSS_W[j] * f;
74            inner_total_F2 += GAUSS_W[j] * f * f;
75        }
76        //now calculate outer integral
77        outer_total_F1 += GAUSS_W[i] * inner_total_F1;
78        outer_total_F2 += GAUSS_W[i] * inner_total_F2;
79    }
80    // now complete change of integration variables (1-0)/(1-(-1))= 0.5
81    outer_total_F1 *= 0.25;
82    outer_total_F2 *= 0.25;
83
84    //convert from [1e-12 A-1] to [cm-1]
85    *F1 = 1e-2*outer_total_F1*exp(-0.25*square(q*sigma));
86    *F2 = 1e-4*outer_total_F2*exp(-0.5*square(q*sigma));
87}
88
89static double
90Iqabc(double qa, double qb, double qc,
91          double r_minor,
92          double x_core,
93          double thick_rim,
94          double thick_face,
95          double length,
96          double rhoc,
97          double rhoh,
98          double rhor,
99          double rhosolv,
100          double sigma)
101{
102    // integrated 2d seems to match 1d reasonably well, except perhaps at very high Q
103    // Vol1,2,3 and dr1,2,3 are now for Vcore, Vcore+rim, Vcore+face,
104    const double dr1 = -rhor - rhoh + rhoc + rhosolv;
105    const double dr2 = rhor-rhosolv;
106    const double dr3 = rhoh-rhosolv;
107    const double r_major = r_minor*x_core;
108    const double halfheight = 0.5*length;
109    const double vol1 = M_PI*r_minor*r_major*length;
110    const double vol2 = M_PI*(r_minor+thick_rim)*(r_major+thick_rim)*2.0*halfheight;
111    const double vol3 = M_PI*r_minor*r_major*2.0*(halfheight+thick_face);
112
113    // Compute effective radius in rotated coordinates
114    const double qr_hat = sqrt(square(r_major*qb) + square(r_minor*qa));
115    // does this need to be changed for the "missing corners" where there there is no "belt" ?
116    const double qrshell_hat = sqrt(square((r_major+thick_rim)*qb)
117                                   + square((r_minor+thick_rim)*qa));
118    const double be1 = sas_2J1x_x( qr_hat );
119    const double be2 = sas_2J1x_x( qrshell_hat );
120    const double si1 = sas_sinx_x( halfheight*qc );
121    const double si2 = sas_sinx_x( (halfheight + thick_face)*qc );
122    const double fq = vol1*dr1*si1*be1 + vol2*dr2*si1*be2 +  vol3*dr3*si2*be1;
123    const double atten = exp(-0.5*(qa*qa + qb*qb + qc*qc)*(sigma*sigma));
124    return 1.0e-4 * fq*fq * atten;
125}
Note: See TracBrowser for help on using the repository browser.