source: sasmodels/sasmodels/models/core_shell_bicelle_elliptical.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, 6 years ago

fix compiler warnings for CUDA

  • Property mode set to 100644
File size: 5.6 KB
RevLine 
[fcb33e4]1// NOTE that "length" here is the full height of the core!
[44e8a93]2static double
3form_volume(double r_minor,
[becded3]4    double x_core,
5    double thick_rim,
6    double thick_face,
7    double length)
[fcb33e4]8{
[44e8a93]9    return M_PI*(r_minor+thick_rim)*(r_minor*x_core+thick_rim)*(length+2.0*thick_face);
[fcb33e4]10}
11
[d277229]12static double
13radius_from_volume(double r_minor, double x_core, double thick_rim, double thick_face, double length)
14{
15    const double volume_bicelle = form_volume(r_minor, x_core, thick_rim,thick_face,length);
[6d5601c]16    return cbrt(volume_bicelle/M_4PI_3);
[d277229]17}
18
19static double
20radius_from_diagonal(double r_minor, double x_core, double thick_rim, double thick_face, double length)
21{
22    const double radius_max = (x_core < 1.0 ? r_minor : x_core*r_minor);
23    const double radius_max_tot = radius_max + thick_rim;
24    const double length_tot = length + 2.0*thick_face;
25    return sqrt(radius_max_tot*radius_max_tot + 0.25*length_tot*length_tot);
26}
27
28static double
29effective_radius(int mode, double r_minor, double x_core, double thick_rim, double thick_face, double length)
30{
[ee60aa7]31    switch (mode) {
[d42dd4a]32    default:
[ee60aa7]33    case 1: // equivalent sphere
[d277229]34        return radius_from_volume(r_minor, x_core, thick_rim, thick_face, length);
[ee60aa7]35    case 2: // outer rim average radius
[d277229]36        return 0.5*r_minor*(1.0 + x_core) + thick_rim;
[ee60aa7]37    case 3: // outer rim min radius
[d277229]38        return (x_core < 1.0 ? x_core*r_minor+thick_rim : r_minor+thick_rim);
[ee60aa7]39    case 4: // outer max radius
[d277229]40        return (x_core > 1.0 ? x_core*r_minor+thick_rim : r_minor+thick_rim);
[ee60aa7]41    case 5: // half outer thickness
[d277229]42        return 0.5*length + thick_face;
[ee60aa7]43    case 6: // half diagonal
[d277229]44        return radius_from_diagonal(r_minor,x_core,thick_rim,thick_face,length);
45    }
46}
47
[71b751d]48static void
49Fq(double q,
50    double *F1,
51    double *F2,
[becded3]52    double r_minor,
53    double x_core,
54    double thick_rim,
55    double thick_face,
56    double length,
57    double sld_core,
58    double sld_face,
59    double sld_rim,
60    double sld_solvent)
[fcb33e4]61{
62     // core_shell_bicelle_elliptical, RKH Dec 2016, based on elliptical_cylinder and core_shell_bicelle
[dedcf34]63     // tested against limiting cases of cylinder, elliptical_cylinder, stacked_discs, and core_shell_bicelle
[fcb33e4]64    const double halfheight = 0.5*length;
[44e8a93]65    const double r_major = r_minor * x_core;
[dedcf34]66    const double r2A = 0.5*(square(r_major) + square(r_minor));
67    const double r2B = 0.5*(square(r_major) - square(r_minor));
[2a0b2b1]68    const double vol1 = M_PI*r_minor*r_major*(2.0*halfheight);
69    const double vol2 = M_PI*(r_minor+thick_rim)*(r_major+thick_rim)*2.0*(halfheight+thick_face);
70    const double vol3 = M_PI*r_minor*r_major*2.0*(halfheight+thick_face);
71    const double dr1 = vol1*(sld_core-sld_face);
72    const double dr2 = vol2*(sld_rim-sld_solvent);
73    const double dr3 = vol3*(sld_face-sld_rim);
[fcb33e4]74
75    //initialize integral
[71b751d]76    double outer_total_F1 = 0.0;
77    double outer_total_F2 = 0.0;
[74768cb]78    for(int i=0;i<GAUSS_N;i++) {
[fcb33e4]79        //setup inner integral over the ellipsoidal cross-section
[74768cb]80        //const double cos_theta = ( GAUSS_Z[i]*(vb-va) + va + vb )/2.0;
81        const double cos_theta = ( GAUSS_Z[i] + 1.0 )/2.0;
[2a0b2b1]82        const double sin_theta = sqrt(1.0 - cos_theta*cos_theta);
83        const double qab = q*sin_theta;
84        const double qc = q*cos_theta;
85        const double si1 = sas_sinx_x(halfheight*qc);
86        const double si2 = sas_sinx_x((halfheight+thick_face)*qc);
[71b751d]87        double inner_total_F1 = 0;
88        double inner_total_F2 = 0;
[74768cb]89        for(int j=0;j<GAUSS_N;j++) {
[fcb33e4]90            //76 gauss points for the inner integral (WAS 20 points,so this may make unecessarily slow, but playing safe)
[71b751d]91            //const double beta = ( GAUSS_Z[j]*(vbj-vaj) + vaj + vbj )/2.0;
92            const double beta = ( GAUSS_Z[j] +1.0)*M_PI_2;
93            const double rr = sqrt(r2A - r2B*cos(beta));
[2a0b2b1]94            const double be1 = sas_2J1x_x(rr*qab);
95            const double be2 = sas_2J1x_x((rr+thick_rim)*qab);
[71b751d]96            const double f = dr1*si1*be1 + dr2*si2*be2 + dr3*si2*be1;
[2a0b2b1]97
[71b751d]98            inner_total_F1 += GAUSS_W[j] * f;
99            inner_total_F2 += GAUSS_W[j] * f * f;
[fcb33e4]100        }
101        //now calculate outer integral
[71b751d]102        outer_total_F1 += GAUSS_W[i] * inner_total_F1;
103        outer_total_F2 += GAUSS_W[i] * inner_total_F2;
[fcb33e4]104    }
[71b751d]105    // now complete change of integration variables (1-0)/(1-(-1))= 0.5
106    outer_total_F1 *= 0.25;
107    outer_total_F2 *= 0.25;
[fcb33e4]108
[71b751d]109    //convert from [1e-12 A-1] to [cm-1]
110    *F1 = 1e-2*outer_total_F1;
111    *F2 = 1e-4*outer_total_F2;
[fcb33e4]112}
113
[44e8a93]114static double
[108e70e]115Iqabc(double qa, double qb, double qc,
[becded3]116    double r_minor,
117    double x_core,
118    double thick_rim,
119    double thick_face,
120    double length,
121    double sld_core,
122    double sld_face,
123    double sld_rim,
124    double sld_solvent)
[fcb33e4]125{
[2a0b2b1]126    const double dr1 = sld_core-sld_face;
127    const double dr2 = sld_rim-sld_solvent;
128    const double dr3 = sld_face-sld_rim;
[44e8a93]129    const double r_major = r_minor*x_core;
[fcb33e4]130    const double halfheight = 0.5*length;
[44e8a93]131    const double vol1 = M_PI*r_minor*r_major*length;
132    const double vol2 = M_PI*(r_minor+thick_rim)*(r_major+thick_rim)*2.0*(halfheight+thick_face);
133    const double vol3 = M_PI*r_minor*r_major*2.0*(halfheight+thick_face);
[fcb33e4]134
[44e8a93]135    // Compute effective radius in rotated coordinates
[82592da]136    const double qr_hat = sqrt(square(r_major*qb) + square(r_minor*qa));
137    const double qrshell_hat = sqrt(square((r_major+thick_rim)*qb)
138                                   + square((r_minor+thick_rim)*qa));
[2a0b2b1]139    const double be1 = sas_2J1x_x( qr_hat );
140    const double be2 = sas_2J1x_x( qrshell_hat );
141    const double si1 = sas_sinx_x( halfheight*qc );
142    const double si2 = sas_sinx_x( (halfheight + thick_face)*qc );
143    const double fq = vol1*dr1*si1*be1 + vol2*dr2*si2*be2 +  vol3*dr3*si2*be1;
144    return 1.0e-4 * fq*fq;
[fcb33e4]145}
Note: See TracBrowser for help on using the repository browser.