source: sasmodels/sasmodels/models/raspberry.c @ ee60aa7

core_shell_microgelsmagnetic_modelticket-1257-vesicle-productticket_1156ticket_1265_superballticket_822_more_unit_tests
Last change on this file since ee60aa7 was ee60aa7, checked in by Paul Kienzle <pkienzle@…>, 6 years ago

clean up effective radius functions; improve mono_gauss_coil accuracy; start moving VR into C

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