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

core_shell_microgelsmagnetic_modelticket-1257-vesicle-productticket_1156ticket_1265_superballticket_822_more_unit_tests
Last change on this file since c5f7aa9 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
RevLine 
[d277229]1double form_volume(double radius_lg, double radius_sm, double penetration);
[bad8b12]2
[71b751d]3double Iq(double q,
[bad8b12]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
[d277229]8double form_volume(double radius_lg, double radius_sm, double penetration)
[bad8b12]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
[d277229]16static double
17effective_radius(int mode, double radius_lg, double radius_sm, double penetration)
18{
[ee60aa7]19    switch (mode) {
20    case 1: // radius_large
[d277229]21        return radius_lg;
[ee60aa7]22    case 2: // radius_outer
[d277229]23        return radius_lg + 2.0*radius_sm - penetration;
24    }
25}
26
[bad8b12]27double Iq(double q,
28          double sld_lg, double sld_sm, double sld_solvent,
[0433203]29          double volfraction_lg, double volfraction_sm, double surface_fraction,
[bad8b12]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
[616df8f]35    double vfL, rL, sldL, vfS, rS, sldS, deltaS, delrhoL, delrhoS, sldSolv;
[bad8b12]36    double VL, VS, Np, f2, fSs;
37    double psiL,psiS;
[616df8f]38    double sfLS,sfSS;
[bad8b12]39    double slT;
[71b751d]40
[bad8b12]41    vfL = volfraction_lg;
42    rL = radius_lg;
43    sldL = sld_lg;
44    vfS = volfraction_sm;
[0433203]45    fSs = surface_fraction;
[bad8b12]46    rS = radius_sm;
47    sldS = sld_sm;
48    deltaS = penetration;
49    sldSolv = sld_solvent;
[71b751d]50
[bad8b12]51    delrhoL = fabs(sldL - sldSolv);
[71b751d]52    delrhoS = fabs(sldS - sldSolv);
53
[bad8b12]54    VL = M_4PI_3*rL*rL*rL;
55    VS = M_4PI_3*rS*rS*rS;
[0433203]56
[a2d8a67]57    //Number of small particles per large particle
[0433203]58    Np = vfS*fSs*VL/vfL/VS;
59
[a2d8a67]60    //Total scattering length difference
[bad8b12]61    slT = delrhoL*VL + Np*delrhoS*VS;
62
[a2d8a67]63    //Form factors for each particle
[925ad6e]64    psiL = sas_3j1x_x(q*rL);
65    psiS = sas_3j1x_x(q*rS);
[a2d8a67]66
67    //Cross term between large and small particles
[1e7b0db0]68    sfLS = psiL*psiS*sas_sinx_x(q*(rL+deltaS*rS));
[a2d8a67]69    //Cross term between small particles at the surface
[1e7b0db0]70    sfSS = psiS*psiS*sas_sinx_x(q*(rL+deltaS*rS))*sas_sinx_x(q*(rL+deltaS*rS));
[a2d8a67]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
[0433203]77    f2 += Np*(Np-1)*delrhoS*delrhoS*VS*VS*sfSS;
[a2d8a67]78    //Large-small particle cross term
[0433203]79    f2 += 2*Np*delrhoL*delrhoS*VL*VS*sfLS;
[a2d8a67]80    //Normalise by total scattering length difference
[bad8b12]81    if (f2 != 0.0){
82        f2 = f2/slT/slT;
83        }
84
[a2d8a67]85    //I(q) for large-small composite particles
[0433203]86    f2 = f2*(vfL*delrhoL*delrhoL*VL + vfS*fSs*Np*delrhoS*delrhoS*VS);
[a2d8a67]87    //I(q) for free small particles
88    f2+= vfS*(1.0-fSs)*delrhoS*delrhoS*VS*psiS*psiS;
[71b751d]89
[bad8b12]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
[71b751d]93
[bad8b12]94    return f2;
95}
Note: See TracBrowser for help on using the repository browser.