source: sasmodels/sasmodels/models/core_shell_bicelle.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: 3.5 KB
RevLine 
[2a0b2b1]1static double
2form_volume(double radius, double thick_rim, double thick_face, double length)
[8007311]3{
[2a0b2b1]4    return M_PI*square(radius+thick_rim)*(length+2.0*thick_face);
[8007311]5}
6
7static double
[2a0b2b1]8bicelle_kernel(double qab,
9    double qc,
10    double radius,
11    double thick_radius,
12    double thick_face,
13    double halflength,
14    double sld_core,
15    double sld_face,
16    double sld_rim,
17    double sld_solvent)
[8007311]18{
[2a0b2b1]19    const double dr1 = sld_core-sld_face;
20    const double dr2 = sld_rim-sld_solvent;
21    const double dr3 = sld_face-sld_rim;
22    const double vol1 = M_PI*square(radius)*2.0*(halflength);
23    const double vol2 = M_PI*square(radius+thick_radius)*2.0*(halflength+thick_face);
24    const double vol3 = M_PI*square(radius)*2.0*(halflength+thick_face);
25
26    const double be1 = sas_2J1x_x((radius)*qab);
27    const double be2 = sas_2J1x_x((radius+thick_radius)*qab);
28    const double si1 = sas_sinx_x((halflength)*qc);
29    const double si2 = sas_sinx_x((halflength+thick_face)*qc);
[e7678b2]30
31    const double t = vol1*dr1*si1*be1 +
32                     vol2*dr2*si2*be2 +
33                     vol3*dr3*si2*be1;
34
[2a0b2b1]35    return t;
[8007311]36}
37
[d277229]38static double
39radius_from_volume(double radius, double thick_rim, double thick_face, double length)
40{
41    const double volume_bicelle = form_volume(radius,thick_rim,thick_face,length);
[6d5601c]42    return cbrt(volume_bicelle/M_4PI_3);
[d277229]43}
44
45static double
46radius_from_diagonal(double radius, double thick_rim, double thick_face, double length)
47{
48    const double radius_tot = radius + thick_rim;
49    const double length_tot = length + 2.0*thick_face;
50    return sqrt(radius_tot*radius_tot + 0.25*length_tot*length_tot);
51}
52
53static double
54effective_radius(int mode, double radius, double thick_rim, double thick_face, double length)
55{
[ee60aa7]56    switch (mode) {
[d42dd4a]57    default:
[ee60aa7]58    case 1: // equivalent sphere
[d277229]59        return radius_from_volume(radius, thick_rim, thick_face, length);
[ee60aa7]60    case 2: // outer rim radius
[d277229]61        return radius + thick_rim;
[ee60aa7]62    case 3: // half outer thickness
[d277229]63        return 0.5*length + thick_face;
[ee60aa7]64    case 4: // half diagonal
[d277229]65        return radius_from_diagonal(radius,thick_rim,thick_face,length);
66    }
67}
68
[71b751d]69static void
70Fq(double q,
71    double *F1,
72    double *F2,
[2a0b2b1]73    double radius,
74    double thick_radius,
75    double thick_face,
76    double length,
77    double sld_core,
78    double sld_face,
79    double sld_rim,
80    double sld_solvent)
[8007311]81{
[e7678b2]82    // set up the integration end points
[5bddd89]83    const double uplim = M_PI_4;
[b260926]84    const double halflength = 0.5*length;
[e7678b2]85
[71b751d]86    double total_F1 = 0.0;
87    double total_F2 = 0.0;
[74768cb]88    for(int i=0;i<GAUSS_N;i++) {
89        double theta = (GAUSS_Z[i] + 1.0)*uplim;
[2a0b2b1]90        double sin_theta, cos_theta; // slots to hold sincos function output
91        SINCOS(theta, sin_theta, cos_theta);
[71b751d]92        double form = bicelle_kernel(q*sin_theta, q*cos_theta, radius, thick_radius, thick_face,
[2a0b2b1]93                                   halflength, sld_core, sld_face, sld_rim, sld_solvent);
[71b751d]94        total_F1 += GAUSS_W[i]*form*sin_theta;
95        total_F2 += GAUSS_W[i]*form*form*sin_theta;
[e7678b2]96    }
[71b751d]97    // Correct for integration range
98    total_F1 *= uplim;
99    total_F2 *= uplim;
[e7678b2]100
[71b751d]101    *F1 = 1.0e-2*total_F1;
102    *F2 = 1.0e-4*total_F2;
[8007311]103}
104
105static double
[108e70e]106Iqac(double qab, double qc,
[2a0b2b1]107    double radius,
108    double thick_rim,
109    double thick_face,
110    double length,
111    double core_sld,
112    double face_sld,
113    double rim_sld,
[becded3]114    double solvent_sld)
[8007311]115{
[2a0b2b1]116    double fq = bicelle_kernel(qab, qc, radius, thick_rim, thick_face,
[5bddd89]117                           0.5*length, core_sld, face_sld, rim_sld,
[2a0b2b1]118                           solvent_sld);
119    return 1.0e-4*fq*fq;
[d277229]120}
Note: See TracBrowser for help on using the repository browser.