source: sasmodels/sasmodels/models/fuzzy_sphere.py @ 8dca856

core_shell_microgelscostrafo411magnetic_modelrelease_v0.94release_v0.95ticket-1257-vesicle-productticket_1156ticket_1265_superballticket_822_more_unit_tests
Last change on this file since 8dca856 was 8dca856, checked in by trnielsen, 8 years ago

Added fuzzy_sphere model

  • Property mode set to 100644
File size: 4.3 KB
Line 
1r"""
2For information about polarised and magnetic scattering, click here_.
3
4.. _here: polar_mag_help.html
5
6Definition
7----------
8
9The scattering intensity *I(q)* is calculated as:
10
11.. math::
12    I(q) = \frac{scale}{V}(\Delta \rho)^2 A^2(q) S(q) +\text{background}
13
14
15where the amplitude *A(q)* is given as the typical sphere scattering convoluted
16with a Gaussian to get a gradual drop-off in the scattering length density:
17
18.. math::
19
20    A(q) = \frac{3\left[\sin(qR) - qR \cos(qR)\right]}{(qR)^3}
21           \exp\left(\frac{-(o_{fuzzy}q)^2}{2}\right)
22
23Here *|A(q)|*:sup:`2`\  is the form factor, *P(q)*. The scale is equivalent to the
24volume fraction of spheres, each of volume, *V*\. Contrast (|drho|) is the
25difference of scattering length densities of the sphere and the surrounding
26solvent.
27
28Poly-dispersion in radius and in fuzziness is provided for.
29
30
31
32From the reference:
33
34  The "fuzziness" of the interface is defined by the parameter
35  |sigma| :sub:`fuzzy`\ . The particle radius *R* represents the radius of the
36  particle where the scattering length density profile decreased to 1/2 of the
37  core density. The |sigma| :sub:`fuzzy`\ is the width of the smeared particle
38  surface; i.e., the standard deviation from the average height of the fuzzy
39  interface. The inner regions of the microgel that display a higher density
40  are described by the radial box profile extending to a radius of
41  approximately *Rbox* ~ *R* - 2\ |sigma|\ . The profile approaches zero as
42  *Rsans* ~ *R* + 2\ |sigma|\ .
43
44For 2D data: The 2D scattering intensity is calculated in the same way as 1D,
45where the *q* vector is defined as
46
47.. math::
48
49    q = \sqrt{{q_x}^2 + {q_y}^2}
50
51
52.. figure:: img/fuzzy_sphere.jpg
53
54     This example dataset is produced by running the FuzzySphereModel,
55     using 200 data points, *qmin* = 0.001 -1,
56     *qmax* = 0.7 |Ang^-1|, background = 0.001 |cm^-1| and the default values.
57
58
59
60References
61----------
62
63M Stieger, J. S Pedersen, P Lindner, W Richtering, *Langmuir*,
6420 (2004) 7283-7292
65"""
66
67from numpy import inf
68
69name = "fuzzy_sphere"
70title = "Scattering from spherical particles with a fuzzy surface."
71description = """\
72scale: scale factor times volume fraction,
73or just volume fraction for absolute scale data
74radius: radius of the solid sphere
75fuzziness = the STD of the height of fuzzy interfacial
76thickness (ie., so-called interfacial roughness)
77sld: the SLD of the sphere
78solvend_sld: the SLD of the solvent
79background: incoherent background
80Note: By definition, this function works only when fuzziness << radius.
81"""
82category = "shape:sphere"
83
84# pylint: disable=bad-whitespace,line-too-long
85# ["name", "units", default, [lower, upper], "type","description"],
86parameters = [["sld",         "1e-6/Ang^2",  1, [-inf, inf], "",       "Layer scattering length density"],
87              ["solvent_sld", "1e-6/Ang^2",  3, [-inf, inf], "",       "Solvent scattering length density"],
88              ["radius",      "Ang",        60, [0, inf],    "volume", "Sphere radius"],
89              ["fuzziness",   "Ang",        10, [0, inf],    "",       "The STD of the height of fuzzy interfacial"],
90             ]
91# pylint: enable=bad-whitespace,line-too-long
92
93source = ["lib/sph_j1c.c"]
94
95# No volume normalization despite having a volume parameter
96# This should perhaps be volume normalized?
97form_volume = """
98    return 1.333333333333333*M_PI*radius*radius*radius;
99    """
100
101Iq = """
102    const double qr = q*radius;
103    const double bes = sph_j1c(qr);
104    const double qf = q*fuzziness;
105    const double fq = bes * (sld - solvent_sld) * form_volume(radius) * exp(-0.5*qf*qf);
106    return 1.0e-4*fq*fq;
107    """
108
109Iqxy = """
110    // never called since no orientation or magnetic parameters.
111    //return -1.0;
112    return Iq(sqrt(qx*qx + qy*qy), sld, solvent_sld, radius, fuzziness);
113    """
114
115def ER(radius):
116    """
117    Return radius
118    """
119    return radius
120
121# VR defaults to 1.0
122
123demo = dict(scale=1, background=0.001,
124            sld=1, solvent_sld=3,
125            radius=60,
126            fuzziness=10,
127            radius_pd=.2, radius_pd_n=45,
128            fuzziness_pd=.2, fuzziness_pd_n=0)
129
130oldname = "FuzzySphereModel"
131oldpars = dict(sld='sldSph', solvent_sld='sldSolv', radius='radius', fuzziness='fuzziness')
132
133
134tests = [
135    # Accuracy tests based on content in test/utest_models_new1_3.py
136    #[{'background': 0.001}, 1.0, 0.001],
137
138    [{}, 0.00301005, 359.2315],
139
140    ]
Note: See TracBrowser for help on using the repository browser.