source: sasmodels/sasmodels/models/adsorbed_layer.py @ b297ba9

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

lint

  • Property mode set to 100644
File size: 4.9 KB
Line 
1r"""
2Definition
3----------
4
5This model describes the scattering from a layer of surfactant or polymer
6adsorbed on large, smooth, notionally spherical particles under the conditions
7that (i) the particles (cores) are contrast-matched to the dispersion medium,
8(ii) $S(Q) \sim 1$ (ie, the particle volume fraction is dilute), (iii) the
9particle radius is >> layer thickness (ie, the interface is locally flat),
10and (iv) scattering from excess unadsorbed adsorbate in the bulk medium is
11absent or has been corrected for.
12
13Unlike many other core-shell models, this model does not assume any form
14for the density distribution of the adsorbed species normal to the interface
15(cf, a core-shell model normally assumes the density distribution to be a
16homogeneous step-function). For comparison, if the thickness of a (traditional
17core-shell like) step function distribution is $t$, the second moment about
18the mean of the density distribution (ie, the distance of the centre-of-mass
19of the distribution from the interface), $\sigma = \sqrt{t^2/12}$.
20
21.. math::
22
23     I(q) = \text{scale} \cdot (\rho_\text{poly}-\rho_\text{solvent})^2
24         \left[
25             \frac{6\pi\phi_\text{core}}{Q^2}
26             \frac{\Gamma^2}{\delta_\text{poly}^2R_\text{core}}
27             \exp(-Q^2\sigma^2)
28         \right] + \text{background}
29
30where *scale* is a scale factor, $\rho_\text{poly}$ is the sld of the
31polymer (or surfactant) layer, $\rho_\text{solv}$ is the sld of the
32solvent/medium and cores, $\phi_\text{core}$ is the volume fraction of
33the core particles, $\delta_\text{poly}$ is the bulk density of the
34polymer, $\Gamma$ is the adsorbed amount, and $\sigma$ is the second
35moment of the thickness distribution.
36
37Note that all parameters except $\sigma$ are correlated so fitting more
38than one of these parameters will generally fail. Also note that unlike
39other shape models, no volume normalization is applied to this model (the
40calculation is exact).
41
42The code for this model is based originally on a a fortran implementation by
43Steve King at ISIS in the SANDRA package c. 1990.
44
45References
46----------
47
48.. [#] S King, P Griffiths, J Hone, and T Cosgrove, *SANS from Adsorbed Polymer
49   Layers*, *Macromol. Symp.*, 190 (2002) 33-42.
50
51Authorship and Verification
52----------------------------
53
54* **Author:** Jae-Hi Cho **Date:** pre 2010
55* **Last Modified by:** Paul Kienzle **Date:** April 14, 2016
56* **Last Reviewed by:** Steve King **Date:** March 18, 2016
57"""
58
59import numpy as np
60from numpy import inf, pi, exp, errstate
61
62name = "adsorbed_layer"
63title = "Scattering from an adsorbed layer on particles"
64
65description = """
66    Evaluates the scattering from large particles
67    with an adsorbed layer of surfactant or
68    polymer, independent of the form of the
69    density distribution.
70    """
71category = "shape:sphere"
72
73# pylint: disable=bad-whitespace, line-too-long
74#   ["name", "units", default, [lower, upper], "type", "description"],
75parameters = [
76    ["second_moment", "Ang", 23.0, [0.0, inf], "", "Second moment of polymer distribution"],
77    ["adsorbed_amount", "mg/m^2", 1.9, [0.0, inf], "", "Adsorbed amount of polymer"],
78    ["density_shell", "g/cm^3", 0.7, [0.0, inf], "", "Bulk density of polymer in the shell"],
79    ["radius", "Ang", 500.0, [0.0, inf], "", "Core particle radius"],
80    ["volfraction", "None", 0.14, [0.0, inf], "", "Core particle volume fraction"],
81    ["sld_shell", "1e-6/Ang^2", 1.5, [-inf, inf], "sld", "Polymer shell SLD"],
82    ["sld_solvent", "1e-6/Ang^2", 6.3, [-inf, inf], "sld", "Solvent SLD"],
83]
84# pylint: enable=bad-whitespace, line-too-long
85
86# NB: Scale and Background are implicit parameters on every model
87def Iq(q, second_moment, adsorbed_amount, density_shell, radius,
88       volfraction, sld_shell, sld_solvent):
89    """Return I(q) for adsorbed layer model."""
90    with errstate(divide='ignore'):
91        aa = ((sld_shell - sld_solvent)/density_shell * adsorbed_amount) / q
92    bb = q * second_moment
93    #scale by 10^-2 for units conversion to cm^-1
94    inten = 6.0e-02 * pi * volfraction * aa**2 * exp(-bb**2) / radius
95    return inten
96Iq.vectorized = True  # Iq accepts an array of q values
97
98def random():
99    """Return a random parameter set for the model."""
100    # only care about the value of second_moment:
101    #    curve = scale * e**(-second_moment^2 q^2)/q^2
102    #    scale = 6 pi/100 (contrast/density*absorbed_amount)^2 * Vf/radius
103    # the remaining parameters can be randomly generated from zero to
104    # twice the default value as done by default in compare.py
105    pars = dict(
106        scale=1,
107        second_moment=10**np.random.uniform(1, 3),
108    )
109    return pars
110
111# unit test values taken from SasView 3.1.2
112tests = [
113    [{'scale': 1.0, 'second_moment': 23.0, 'adsorbed_amount': 1.9,
114      'density_shell': 0.7, 'radius': 500.0, 'volfraction': 0.14,
115      'sld_shell': 1.5, 'sld_solvent': 6.3, 'background': 0.0},
116     [0.0106939, 0.1], [73.741, 4.51684e-3]],
117]
118
119# 2016-03-16 SMK converted from sasview, checked vs SANDRA
120# 2016-03-18 RKH some edits & renaming
121# 2016-04-14 PAK reformatting
Note: See TracBrowser for help on using the repository browser.