source: sasmodels/sasmodels/models/raspberry.c @ 99658f6

core_shell_microgelsmagnetic_modelticket-1257-vesicle-productticket_1156ticket_1265_superballticket_822_more_unit_tests
Last change on this file since 99658f6 was d42dd4a, checked in by pkienzle, 5 years ago

fix compiler warnings for CUDA

  • Property mode set to 100644
File size: 2.9 KB
Line 
1double form_volume(double radius_lg, double radius_sm, double penetration);
2
3double Iq(double q,
4          double sld_lg, double sld_sm, double sld_solvent,
5          double volfraction_lg, double volfraction_sm, double surf_fraction,
6          double radius_lg, double radius_sm, double penetration);
7
8double form_volume(double radius_lg, double radius_sm, double penetration)
9{
10    //Because of the complex structure, volume normalization must
11    //happen in the Iq code below.  Thus the form volume is set to 1.0 here
12    double volume=1.0;
13    return volume;
14}
15
16static double
17effective_radius(int mode, double radius_lg, double radius_sm, double penetration)
18{
19    switch (mode) {
20    default:
21    case 1: // radius_large
22        return radius_lg;
23    case 2: // radius_outer
24        return radius_lg + 2.0*radius_sm - penetration;
25    }
26}
27
28double Iq(double q,
29          double sld_lg, double sld_sm, double sld_solvent,
30          double volfraction_lg, double volfraction_sm, double surface_fraction,
31          double radius_lg, double radius_sm, double penetration)
32{
33    // Ref: J. coll. inter. sci. (2010) vol. 343 (1) pp. 36-41.
34
35
36    double vfL, rL, sldL, vfS, rS, sldS, deltaS, delrhoL, delrhoS, sldSolv;
37    double VL, VS, Np, f2, fSs;
38    double psiL,psiS;
39    double sfLS,sfSS;
40    double slT;
41
42    vfL = volfraction_lg;
43    rL = radius_lg;
44    sldL = sld_lg;
45    vfS = volfraction_sm;
46    fSs = surface_fraction;
47    rS = radius_sm;
48    sldS = sld_sm;
49    deltaS = penetration;
50    sldSolv = sld_solvent;
51
52    delrhoL = fabs(sldL - sldSolv);
53    delrhoS = fabs(sldS - sldSolv);
54
55    VL = M_4PI_3*rL*rL*rL;
56    VS = M_4PI_3*rS*rS*rS;
57
58    //Number of small particles per large particle
59    Np = vfS*fSs*VL/vfL/VS;
60
61    //Total scattering length difference
62    slT = delrhoL*VL + Np*delrhoS*VS;
63
64    //Form factors for each particle
65    psiL = sas_3j1x_x(q*rL);
66    psiS = sas_3j1x_x(q*rS);
67
68    //Cross term between large and small particles
69    sfLS = psiL*psiS*sas_sinx_x(q*(rL+deltaS*rS));
70    //Cross term between small particles at the surface
71    sfSS = psiS*psiS*sas_sinx_x(q*(rL+deltaS*rS))*sas_sinx_x(q*(rL+deltaS*rS));
72
73    //Large sphere form factor term
74    f2 = delrhoL*delrhoL*VL*VL*psiL*psiL;
75    //Small sphere form factor term
76    f2 += Np*delrhoS*delrhoS*VS*VS*psiS*psiS;
77    //Small particle - small particle cross term
78    f2 += Np*(Np-1)*delrhoS*delrhoS*VS*VS*sfSS;
79    //Large-small particle cross term
80    f2 += 2*Np*delrhoL*delrhoS*VL*VS*sfLS;
81    //Normalise by total scattering length difference
82    if (f2 != 0.0){
83        f2 = f2/slT/slT;
84        }
85
86    //I(q) for large-small composite particles
87    f2 = f2*(vfL*delrhoL*delrhoL*VL + vfS*fSs*Np*delrhoS*delrhoS*VS);
88    //I(q) for free small particles
89    f2+= vfS*(1.0-fSs)*delrhoS*delrhoS*VS*psiS*psiS;
90
91    // normalize to single particle volume and convert to 1/cm
92    f2 *= 1.0e8;        // [=] 1/cm
93    f2 *= 1.0e-12;      // convert for (1/A^-6)^2 to (1/A)^2
94
95    return f2;
96}
Note: See TracBrowser for help on using the repository browser.