Changeset 91d7ec4 in sasmodels
- Timestamp:
- Mar 20, 2016 10:36:52 AM (9 years ago)
- Branches:
- master, core_shell_microgels, costrafo411, magnetic_model, release_v0.94, release_v0.95, ticket-1257-vesicle-product, ticket_1156, ticket_1265_superball, ticket_822_more_unit_tests
- Children:
- 5745f0b
- Parents:
- a2d8a67 (diff), 1dd2854 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent. - Location:
- sasmodels/models
- Files:
-
- 1 deleted
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
sasmodels/models/correlation_length.py
r326281f r0cc31e1 16 16 incoherent background B and the two exponents n and m are used as fitting 17 17 parameters. (Respectively $porod\_scale$, $lorentz\_scale$, $background$, $exponent\_p$ and 18 $exponent\_l$ in the parameter list.) The remaining parameter \ xiis a correlation18 $exponent\_l$ in the parameter list.) The remaining parameter \ |xi|\ is a correlation 19 19 length for the polymer chains. Note that when m=2 this functional form becomes the 20 20 familiar Lorentzian function. Some interpretation of the values of A and C may be -
sasmodels/models/elliptical_cylinder.py
r74fd96f r0cc31e1 12 12 .. figure:: img/elliptical_cylinder_geometry.png 13 13 14 Elliptical cylinder geometry $a$ = $r_{minor}$ and \ nu= $axis\_ratio$ = $r_{major} / r_{minor}$14 Elliptical cylinder geometry $a$ = $r_{minor}$ and \ |nu|\ = $axis\_ratio$ = $r_{major} / r_{minor}$ 15 15 16 16 The function calculated is -
sasmodels/models/fractal_core_shell.c
r7d4b2ae r6794301 47 47 double qr = q*radius; 48 48 49 double t1 = frac_dim* exp(lanczos_gamma(frac_1))*sin(frac_1*atan(q*cor_length));49 double t1 = frac_dim*sas_gamma(frac_1)*sin(frac_1*atan(q*cor_length)); 50 50 double t2 = (1.0 + 1.0/(q*cor_length)/(q*cor_length)); 51 51 double t3 = pow(qr, frac_dim) * pow(t2, (frac_1/2.0)); -
sasmodels/models/fractal_core_shell.py
raa2edb2 r6794301 73 73 # pylint: enable=bad-whitespace, line-too-long 74 74 75 source = ["lib/sph_j1c.c", "lib/ lanczos_gamma.c", "lib/core_shell.c", "fractal_core_shell.c"]75 source = ["lib/sph_j1c.c", "lib/sas_gamma.c", "lib/core_shell.c", "fractal_core_shell.c"] 76 76 77 77 demo = dict(scale=0.05, -
sasmodels/models/fuzzy_sphere.py
raa2edb2 r0cc31e1 19 19 20 20 A(q) = \frac{3\left[\sin(qR) - qR \cos(qR)\right]}{(qR)^3} 21 \exp\left(\frac{-( o_{fuzzy}q)^2}{2}\right)21 \exp\left(\frac{-(\sigma_{fuzzy}q)^2}{2}\right) 22 22 23 23 Here *|A(q)|*:sup:`2`\ is the form factor, *P(q)*. The scale is equivalent to the … … 26 26 solvent. 27 27 28 Poly-dispersion in radius and in fuzziness is provided for. 28 Poly-dispersion in radius and in fuzziness is provided for, though the fuzziness 29 must be kept much smaller than the sphere radius for meaningful results. 29 30 30 31 … … 65 66 or just volume fraction for absolute scale data 66 67 radius: radius of the solid sphere 67 fuzziness = the STD of the height offuzzy interfacial68 fuzziness = the standard deviation of the fuzzy interfacial 68 69 thickness (ie., so-called interfacial roughness) 69 70 sld: the SLD of the sphere … … 76 77 # pylint: disable=bad-whitespace,line-too-long 77 78 # ["name", "units", default, [lower, upper], "type","description"], 78 parameters = [["sld", "1e-6/Ang^2", 1, [-inf, inf], "", " Layerscattering length density"],79 ["s olvent_sld", "1e-6/Ang^2", 3, [-inf, inf], "", "Solvent scattering length density"],79 parameters = [["sld", "1e-6/Ang^2", 1, [-inf, inf], "", "Particle scattering length density"], 80 ["sld_solvent", "1e-6/Ang^2", 3, [-inf, inf], "", "Solvent scattering length density"], 80 81 ["radius", "Ang", 60, [0, inf], "volume", "Sphere radius"], 81 ["fuzziness", "Ang", 10, [0, inf], "", " The STD of the height of fuzzy interfacial"],82 ["fuzziness", "Ang", 10, [0, inf], "", "std deviation of Gaussian convolution for interface (must be << radius)"], 82 83 ] 83 84 # pylint: enable=bad-whitespace,line-too-long … … 95 96 const double bes = sph_j1c(qr); 96 97 const double qf = q*fuzziness; 97 const double fq = bes * (sld - s olvent_sld) * form_volume(radius) * exp(-0.5*qf*qf);98 const double fq = bes * (sld - sld_solvent) * form_volume(radius) * exp(-0.5*qf*qf); 98 99 return 1.0e-4*fq*fq; 99 100 """ … … 102 103 // never called since no orientation or magnetic parameters. 103 104 //return -1.0; 104 return Iq(sqrt(qx*qx + qy*qy), sld, s olvent_sld, radius, fuzziness);105 return Iq(sqrt(qx*qx + qy*qy), sld, sld_solvent, radius, fuzziness); 105 106 """ 106 107 … … 114 115 115 116 demo = dict(scale=1, background=0.001, 116 sld=1, s olvent_sld=3,117 sld=1, sld_solvent=3, 117 118 radius=60, 118 119 fuzziness=10, … … 121 122 122 123 oldname = "FuzzySphereModel" 123 oldpars = dict(sld='sldSph', s olvent_sld='sldSolv', radius='radius', fuzziness='fuzziness')124 oldpars = dict(sld='sldSph', sld_solvent='sldSolv', radius='radius', fuzziness='fuzziness') 124 125 125 126 -
sasmodels/models/mass_fractal.c
r61fd21d r6794301 28 28 //calculate S(q) 29 29 double mmo = mass_dim-1.0; 30 double sq = exp(lanczos_gamma(mmo))*sin((mmo)*atan(q*cutoff_length));30 double sq = sas_gamma(mmo)*sin((mmo)*atan(q*cutoff_length)); 31 31 sq *= pow(cutoff_length, mmo); 32 32 sq /= pow((1.0 + (q*cutoff_length)*(q*cutoff_length)),(mmo/2.0)); -
sasmodels/models/mass_fractal.py
raa2edb2 r6794301 85 85 # pylint: enable=bad-whitespace, line-too-long 86 86 87 source = ["lib/sph_j1c.c", "lib/ lanczos_gamma.c", "mass_fractal.c"]87 source = ["lib/sph_j1c.c", "lib/sas_gamma.c", "mass_fractal.c"] 88 88 89 89 demo = dict(scale=1, background=0, -
sasmodels/models/surface_fractal.c
r9c461c7 r6794301 26 26 //calculate S(q) 27 27 mmo = 5.0 - surface_dim; 28 sq = exp(lanczos_gamma(mmo))*sin(-(mmo)*atan(q*cutoff_length));28 sq = sas_gamma(mmo)*sin(-(mmo)*atan(q*cutoff_length)); 29 29 sq *= pow(cutoff_length, mmo); 30 30 sq /= pow((1.0 + (q*cutoff_length)*(q*cutoff_length)),(mmo/2.0)); -
sasmodels/models/surface_fractal.py
raa2edb2 r6794301 87 87 # pylint: enable=bad-whitespace, line-too-long 88 88 89 source = ["lib/sph_j1c.c", "lib/ lanczos_gamma.c", "surface_fractal.c"]89 source = ["lib/sph_j1c.c", "lib/sas_gamma.c", "surface_fractal.c"] 90 90 91 91 demo = dict(scale=1, background=0, -
sasmodels/models/raspberry.c
rbad8b12 ra2d8a67 21 21 double Iq(double q, 22 22 double sld_lg, double sld_sm, double sld_solvent, 23 double volfraction_lg, double volfraction_sm, double surf _fraction,23 double volfraction_lg, double volfraction_sm, double surface_fraction, 24 24 double radius_lg, double radius_sm, double penetration) 25 25 { … … 37 37 sldL = sld_lg; 38 38 vfS = volfraction_sm; 39 fSs = surface_fraction; 39 40 rS = radius_sm; 40 aSs = surf_fraction;41 41 sldS = sld_sm; 42 42 deltaS = penetration; … … 48 48 VL = M_4PI_3*rL*rL*rL; 49 49 VS = M_4PI_3*rS*rS*rS; 50 Np = aSs*4.0*pow(((rL+deltaS)/rS), 2.0); 51 fSs = Np*vfL*VS/vfS/VL;52 53 Np2 = aSs*4.0*(rS/(rL+deltaS))*VL/VS; 54 fSs2 = Np2*vfL*VS/vfS/VL;50 51 //Number of small particles per large particle 52 Np = vfS*fSs*VL/vfL/VS; 53 54 //Total scattering length difference 55 55 slT = delrhoL*VL + Np*delrhoS*VS; 56 56 57 sfLS = sph_j1c(q*rL)*sph_j1c(q*rS)*sinc(q*(rL+deltaS*rS)); 58 sfSS = sph_j1c(q*rS)*sph_j1c(q*rS)*sinc(q*(rL+deltaS*rS))*sinc(q*(rL+deltaS*rS)); 59 60 f2 = delrhoL*delrhoL*VL*VL*sph_j1c(q*rL)*sph_j1c(q*rL); 61 f2 += Np2*delrhoS*delrhoS*VS*VS*sph_j1c(q*rS)*sph_j1c(q*rS); 62 f2 += Np2*(Np2-1)*delrhoS*delrhoS*VS*VS*sfSS; 63 f2 += 2*Np2*delrhoL*delrhoS*VL*VS*sfLS; 57 //Form factors for each particle 58 psiL = sph_j1c(q*rL); 59 psiS = sph_j1c(q*rS); 60 61 //Cross term between large and small particles 62 sfLS = psiL*psiS*sinc(q*(rL+deltaS*rS)); 63 //Cross term between small particles at the surface 64 sfSS = psiS*psiS*sinc(q*(rL+deltaS*rS))*sinc(q*(rL+deltaS*rS)); 65 66 //Large sphere form factor term 67 f2 = delrhoL*delrhoL*VL*VL*psiL*psiL; 68 //Small sphere form factor term 69 f2 += Np*delrhoS*delrhoS*VS*VS*psiS*psiS; 70 //Small particle - small particle cross term 71 f2 += Np*(Np-1)*delrhoS*delrhoS*VS*VS*sfSS; 72 //Large-small particle cross term 73 f2 += 2*Np*delrhoL*delrhoS*VL*VS*sfLS; 74 //Normalise by total scattering length difference 64 75 if (f2 != 0.0){ 65 76 f2 = f2/slT/slT; 66 77 } 67 78 68 f2 = f2*(vfL*delrhoL*delrhoL*VL + vfS*fSs2*Np2*delrhoS*delrhoS*VS); 69 70 f2+= vfS*(1.0-fSs)*pow(delrhoS, 2)*VS*sph_j1c(q*rS)*sph_j1c(q*rS); 79 //I(q) for large-small composite particles 80 f2 = f2*(vfL*delrhoL*delrhoL*VL + vfS*fSs*Np*delrhoS*delrhoS*VS); 81 //I(q) for free small particles 82 f2+= vfS*(1.0-fSs)*delrhoS*delrhoS*VS*psiS*psiS; 71 83 72 84 // normalize to single particle volume and convert to 1/cm -
sasmodels/models/raspberry.py
rbad8b12 ra2d8a67 3 3 ---------- 4 4 5 The large and small spheres have their own SLD, as well as the solvent. The 6 surface coverage term is a fractional coverage (maximum of approximately 0.9 7 for hexagonally-packed spheres on a surface). Since not all of the small 8 spheres are necessarily attached to the surface, the excess free (small) 9 spheres scattering is also included in the calculation. The function calculate 10 follows equations (8)-(12) of the reference below, and the equations are not 11 reproduced here. 12 13 No inter-particle scattering is included in this model. 14 5 The figure below shows a schematic of a large droplet surrounded by several smaller particles 6 forming a structure similar to that of Pickering emulsions. 15 7 16 8 .. figure:: img/raspberry_geometry.jpg 17 9 18 10 Schematic of the raspberry model 19 20 where *Ro* is the radius of the large sphere, *Rp* the radius of the smaller21 spheres on the surface and |delta| = the fractional penetration depth.22 11 23 For 2D data: The 2D scattering intensity is calculated in the same way as 1D, 24 where the *q* vector is defined as 12 In order to calculate the form factor of the entire complex, the self-correlation of the large droplet, 13 the self-correlation of the particles, the correlation terms between different particles 14 and the cross terms between large droplet and small particles all need to be calculated. 15 16 Consider two infinitely thin shells of radii R2 and R2 separated by distance r. The general 17 structure of the equation is then the form factor of the two shells multiplied by the phase 18 factor that accounts for the separation of their centers. 25 19 26 20 .. math:: 27 21 28 q = \sqrt{q_x^2 + q_y^2} 22 S(q) = \frac{sin(qR_1)}{qR_1}\frac{sin(qR_2)}{qR_2}\frac{sin(qr)}{qr} 23 24 In this case, the large droplet and small particles are solid spheres rather than thin shells. Thus 25 the two terms must be integrated over $R_L$ and $R_S$ respectively using the weighting function of 26 a sphere. We then obtain the functions for the form of the two spheres: 27 28 .. math:: 29 30 \Psi_L = \Int_0^{R_L}(4\piR^2_L)\frac{sin(qR_L)}{qR_L}dR_L = \frac{3[sin(qR_L)-qR_Lcos(qR_L)]}{(qR_L)^2} 31 32 .. math:: 33 34 \Psi_S = \Int_0^{R_S}(4\piR^2_S)\frac{sin(qR_S)}{qR_S}dR_S = \frac{3[sin(qR_S)-qR_Lcos(qR_S)]}{(qR_S)^2} 35 36 The cross term between the large droplet and small particles is given by: 37 38 .. math:: 39 S_{LS} = \Psi_L\Psi_S\frac{sin(q(R_L+\deltaR_S))}{q(R_L+\deltaR_S)} 40 41 and the self term between small particles is given by: 42 43 .. math:: 44 S_{SS} = \Psi_S^2\bigl[\frac{sin(q(R_L+\deltaR_S))}{q(R_L+\deltaR_S)}\bigr]^2 45 46 The number of small particles per large droplet, $N_p$, is given by: 47 48 .. math:: 49 50 N_p = \frac{\phi_S\phi_{surface}V_L}{\phi_L\V_S} 51 52 where $\phi_S$ is the volume fraction of small particles in the sample, $\phi_{surface}$ is the 53 fraction of the small particles that are adsorbed to the large droplets, $\phi_L$ is the volume fraction 54 of large droplets in the sample, and $V_S$ and $V_L$ are the volumes of individual small particles and 55 large droplets respectively. 56 57 The form factor of the entire complex can now be calculated including the excess scattering length 58 densities of the components $\Delta\rho_L$ and $\Delta\rho_S$, where $\Delta\rho_x = |\rho_x-\rho_{solvent}|$ : 59 60 .. math:: 61 62 P_{LS} = \frac{1}{M^2}\bigl[(\Delta\rho_L)^2V_L^2\Psi_L^2+N_p(\Delta\rho_S)^2V_S^2\Psi_S^2 63 + N_p(1-N_p)(\Delta\rho_S)^2V_S^2S_{SS} + 2N_p\Delta\rho_L\Delta\rho_SV_LV_SS_{LS} 64 65 where M is the total scattering length of the whole complex : 66 67 .. math:: 68 M = \Delta\rho_LV_L + N_p\Delta\rho_SV_S 69 70 In a real system, there will ususally be an excess of small particles such that some fraction remain unbound. 71 Therefore the overall scattering intensity is given by: 72 73 .. math:: 74 I(Q) = I_{LS}(Q) + I_S(Q) = (\phi_L(\Delta\rho_L)^2V_L + \phi_S\phi_{surface}N_p(\Delta\rho_S)^2V_S)P_{LS} 75 + \phi_S(1-\phi_{surface})(\Delta\rho_S)^2V_S\Psi_S^2 76 77 A useful parameter to extract is the fraction of the surface area of the large droplets that is covered by small 78 particles. This can be calculated from the model parameters as: 79 80 .. math:: 81 \Chi = \frac{4\phi_L\phi_{surface}(R_L+\delta\R_S)}{\phi_LR_S} 29 82 30 83 … … 35 88 *particles*, *Journal of Colloid and Interface Science*, 343(1) (2010) 36-41 36 89 37 **Author:** Andrew jackson **on:** 200890 **Author:** Andrew Jackson **on:** 2008 38 91 39 **Modified by:** Paul Butler **on:** March 18, 201692 **Modified by:** Andrew Jackson **on:** March 20, 2016 40 93 41 **Reviewed by:** Paul Butler **on:** March 18, 201694 **Reviewed by:** Andrew Jackson **on:** March 20, 2016 42 95 """ 43 96 44 97 from numpy import pi, inf 45 98 46 name = "raspberry "99 name = "raspberry_surface_fraction" 47 100 title = "Calculates the form factor, *P(q)*, for a 'Raspberry-like' structure \ 48 101 where there are smaller spheres at the surface of a larger sphere, such as the \ … … 50 103 description = """ 51 104 RaspBerryModel: 52 volf _Lsph= volume fraction large spheres53 radius_ Lsph= radius large sphere (A)54 sld_ Lsph= sld large sphere (A-2)55 volf _Ssph= volume fraction small spheres56 radius_ Ssph= radius small sphere (A)57 surf rac_Ssph= fraction of small spheres at surface58 sld_ Ssph= sld small sphere59 delta_Ssph = small sphere penetration (A)60 sld_solv = sld solvent105 volfraction_lg = volume fraction large spheres 106 radius_lg = radius large sphere (A) 107 sld_lg = sld large sphere (A-2) 108 volfraction_sm = volume fraction small spheres 109 radius_sm = radius small sphere (A) 110 surface_fraction = fraction of small spheres at surface 111 sld_sm = sld small sphere 112 penetration = small sphere penetration (A) 113 sld_solvent = sld solvent 61 114 background = background (cm-1) 62 115 Ref: J. coll. inter. sci. (2010) vol. 343 (1) pp. 36-41.""" … … 74 127 ["volfraction_sm", "", 0.005, [-inf, inf], "", 75 128 "volume fraction of small spheres"], 76 ["surf _fraction", "", 0.4, [-inf, inf], "",129 ["surface_fraction", "", 0.4, [-inf, inf], "", 77 130 "fraction of small spheres at surface"], 78 131 ["radius_lg", "Ang", 5000, [0, inf], "volume", … … 80 133 ["radius_sm", "Ang", 100, [0, inf], "", 81 134 "radius of small spheres"], 82 ["penetration", "Ang", 0 .0, [0, inf], "",83 " penetration depth of small spheres into large sphere"],135 ["penetration", "Ang", 0, [-1, 1], "", 136 "fractional penetration depth of small spheres into large sphere"], 84 137 ] 85 138 … … 89 142 demo = dict(scale=1, background=0.001, 90 143 sld_lg=-0.4, sld_sm=3.5, sld_solvent=6.36, 91 volfraction_lg=0.05, volfraction_sm=0.005, surf _fraction=0.4,144 volfraction_lg=0.05, volfraction_sm=0.005, surface_fraction=0.4, 92 145 radius_lg=5000, radius_sm=100, penetration=0.0, 93 146 radius_lg_pd=.2, radius_lg_pd_n=10) … … 95 148 # For testing against the old sasview models, include the converted parameter 96 149 # names and the target sasview model name. 97 oldname = 'RaspBerryModel'98 oldpars = dict(sld_lg='sld_Lsph', sld_sm='sld_Ssph', sld_solvent='sld_solv',99 volfraction_lg='volf_Lsph', volfraction_sm='volf_Ssph',100 surf_fraction='surfrac_Ssph',101 radius_lg='radius_Lsph', radius_sm='radius_Ssph',102 penetration='delta_Ssph')103 104 150 105 151 # NOTE: test results taken from values returned by SasView 3.1.2, with
Note: See TracChangeset
for help on using the changeset viewer.