source: sasmodels/sasmodels/models/multilayer_vesicle.py @ 5d23de2

core_shell_microgelscostrafo411magnetic_modelticket-1257-vesicle-productticket_1156ticket_1265_superballticket_822_more_unit_tests
Last change on this file since 5d23de2 was 5d23de2, checked in by butler, 4 years ago

Fold caveats from original IGOR documentation back into sasmodels
version as requested on sasmodels pull request 27 addressing ticket 843.
Also reformated refs and authorship section as per ticket #646

  • Property mode set to 100644
File size: 6.7 KB
Line 
1r"""
2Definition
3----------
4
5This model is a trivial extension of the core_shell_sphere function where the
6core is filled with solvent and is surrounded by $N$ shells of material
7(such as lipids) interleaved with $N - 1$ layers of solvent. For $N = 1$, this
8returns the same as the vesicle model, except for the normalisation, which here
9is to outermost volume. The shell thicknesses and SLD are constant for all
10shells as expected for a multilayer vesicle.
11
12.. figure:: img/multi_shell_geometry.jpg
13
14    Geometry of the multilayer_vesicle model.
15
16See the :ref:`core-shell-sphere` model for more documentation.
17
18The 1D scattering intensity is calculated in the following way (Guinier, 1955)
19
20.. math::
21    P(q) = \text{scale} \cdot \frac{\phi}{V(R_N)} F^2(q) + \text{background}
22
23where
24
25.. math::
26     F(q) = (\rho_\text{shell}-\rho_\text{solv}) \sum_{i=1}^{N} \left[
27     3V(r_i)\frac{\sin(qr_i) - qr_i\cos(qr_i)}{(qr_i)^3}
28     - 3V(R_i)\frac{\sin(qR_i) - qR_i\cos(qR_i)}{(qR_i)^3}
29     \right]
30
31for
32
33.. math::
34
35     r_i &= r_c + (i-1)(t_s + t_w) && \text{ solvent radius before shell } i \\
36     R_i &= r_i + t_s && \text{ shell radius for shell } i
37
38$\phi$ is the volume fraction of particles, $V(r)$ is the volume of a sphere
39of radius $r$, $r_c$ is the radius of the core, $t_s$ is the thickness of
40the shell, $t_w$ is the thickness of the solvent layer between the shells,
41$\rho_\text{shell}$ is the scattering length density of a shell, and
42$\rho_\text{solv}$ is the scattering length density of the solvent.
43
44USAGE NOTES
45
46* The outer-most shell radius $R_N$ is used as the effective radius
47  for $P(Q)$ when $P(Q) * S(Q)$ is applied.
48  calculations rather slow.
49* The number of shells is always rounded to an integer value as a non interger
50  number of layers is not physical.
51* Thus Polydispersity should only be applied to number of shells **VERY
52  CAREFULLY**.  A possible legitimate use would be for mixed systems in which
53  some vesicles have 1 shell, some have 2, etc. A polydispersity on $N$ can be
54  used to model the data by using the "array distriubtion" feature. First
55  create a file such as *shell_dist.txt* containing the relative portion
56  of each vesicle size::
57
58    1 20
59    2  4
60    3  1
61
62  Turn on polydispersity and select an array distribution for the *n_shells*
63  parameter.  Choose the above *shell_dist.txt* file, and the model will be
64  computed with 80% 1-shell vesicles, 16% 2-shell vesicles and 4%
65  3-shell vesicles.
66* This is a highly non-linear, highly oscillatory (especially around the
67  q-values that correspond to the repeat distance of the layers), model
68  function complicated by the fact that the number of water/shell pairs must
69  physically be an integer value, although the optimization treats it as a
70  floating point value. Thus it may be that the resolution interpolation is not
71  sufficiently fine grained in certain cases. Please report any such occurences
72  to the SasView team. Generally, for the best possible experience:
73 * Start with the best possible guess
74 * Using a priori knowledge, hold as many parameters fixed as possible
75 * if N=1, tw (water thickness) must by definition be zero. Both N and tw should
76   be fixed during fitting.
77 * If N>1, use constraints to keep N > 1
78 * Because N only really moves in integer steps, it may get "stuck" if the
79   optimizer step size is too small so care should be taken
80   If you experience problems with this please contact the SasView team and let
81   them know the issue preferably with example data and model which fail to
82   converge.
83
84The 2D scattering intensity is the same as 1D, regardless of the orientation
85of the q vector which is defined as:
86
87.. math::
88
89    q = \sqrt{q_x^2 + q_y^2}
90
91For information about polarised and magnetic scattering, see
92the :ref:`magnetism` documentation.
93
94References
95----------
96
97.. [#] B Cabane, *Small Angle Scattering Methods*, in *Surfactant Solutions:
98   New Methods of Investigation*, Ch.2, Surfactant Science Series Vol. 22, Ed.
99   R Zana and M Dekker, New York, (1987).
100
101Authorship and Verification
102----------------------------
103
104* **Author:** NIST IGOR/DANSE **Date:** pre 2010
105* **Converted to sasmodels by:** Piotr Rozyczko **Date:** Feb 24, 2016
106* **Last Modified by:** Paul Kienzle **Date:** Feb 7, 2017
107* **Last Reviewed by:** Paul Butler **Date:** March 12, 2017
108
109"""
110
111from numpy import inf
112
113name = "multilayer_vesicle"
114title = "P(Q) for a Multi-lamellar vesicle"
115description = """
116    multilayer_vesicle model parameters;
117    scale : scale factor for abs intensity if needed else 1.0
118    volfraction: volume fraction
119    radius : Core radius of the multishell
120    thick_shell: shell thickness
121    thick_solvent: water thickness
122    sld_solvent: solvent scattering length density
123    sld: shell scattering length density
124    n_shells:number of "shell plus solvent" layer pairs
125    background: incoherent background
126        """
127category = "shape:sphere"
128
129# pylint: disable=bad-whitespace, line-too-long
130#   ["name", "units", default, [lower, upper], "type","description"],
131parameters = [
132    ["volfraction", "",  0.05, [0.0, 1],  "", "volume fraction of vesicles"],
133    ["radius", "Ang", 60.0, [0.0, inf],  "volume", "radius of solvent filled core"],
134    ["thick_shell", "Ang",        10.0, [0.0, inf],  "volume", "thickness of one shell"],
135    ["thick_solvent", "Ang",        10.0, [0.0, inf],  "volume", "solvent thickness between shells"],
136    ["sld_solvent",    "1e-6/Ang^2",  6.4, [-inf, inf], "sld", "solvent scattering length density"],
137    ["sld",   "1e-6/Ang^2",  0.4, [-inf, inf], "sld", "Shell scattering length density"],
138    ["n_shells",     "",            2.0, [1.0, inf],  "volume", "Number of shell plus solvent layer pairs"],
139    ]
140# pylint: enable=bad-whitespace, line-too-long
141
142# TODO: proposed syntax for specifying which parameters can be polydisperse
143#polydispersity = ["radius", "thick_shell"]
144
145source = ["lib/sas_3j1x_x.c", "multilayer_vesicle.c"]
146
147def ER(radius, thick_shell, thick_solvent, n_shells):
148    n_shells = int(n_shells+0.5)
149    return radius + n_shells * (thick_shell + thick_solvent) - thick_solvent
150
151demo = dict(scale=1, background=0,
152            volfraction=0.05,
153            radius=60.0,
154            thick_shell=10.0,
155            thick_solvent=10.0,
156            sld_solvent=6.4,
157            sld=0.4,
158            n_shells=2.0)
159
160tests = [
161    # Accuracy tests based on content in test/utest_other_models.py
162    [{'radius': 60.0,
163      'thick_shell': 10.0,
164      'thick_solvent': 10.0,
165      'sld_solvent': 6.4,
166      'sld': 0.4,
167      'n_shells': 2.0,
168      'scale': 1.0,
169      'background': 0.001,
170     }, 0.001, 122.1405],
171
172    [{'volfraction': 1.0,
173      'radius': 60.0,
174      'thick_shell': 10.0,
175      'thick_solvent': 10.0,
176      'sld_solvent': 6.4,
177      'sld': 0.4,
178      'n_shells': 2.0,
179      'scale': 1.0,
180      'background': 0.001,
181     }, (0.001, 0.30903), 1.61873],
182    ]
Note: See TracBrowser for help on using the repository browser.