1 | r""" |
---|
2 | Definition |
---|
3 | ---------- |
---|
4 | |
---|
5 | This model is a trivial extension of the core_shell_sphere function where the |
---|
6 | core 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 |
---|
8 | returns the same as the vesicle model, except for the normalisation, which here |
---|
9 | is to outermost volume. The shell thicknesses and SLD are constant for all |
---|
10 | shells as expected for a multilayer vesicle. |
---|
11 | |
---|
12 | .. figure:: img/multi_shell_geometry.jpg |
---|
13 | |
---|
14 | Geometry of the multilayer_vesicle model. |
---|
15 | |
---|
16 | See the :ref:`core-shell-sphere` model for more documentation. |
---|
17 | |
---|
18 | The 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 | |
---|
23 | where |
---|
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 | |
---|
31 | for |
---|
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 |
---|
39 | of radius $r$, $r_c$ is the radius of the core, $t_s$ is the thickness of |
---|
40 | the 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 | |
---|
44 | USAGE 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 | |
---|
74 | - Start with the best possible guess |
---|
75 | - Using a priori knowledge, hold as many parameters fixed as possible |
---|
76 | - if N=1, tw (water thickness) must by definition be zero. Both N and tw should |
---|
77 | be fixed during fitting. |
---|
78 | - If N>1, use constraints to keep N > 1 |
---|
79 | - Because N only really moves in integer steps, it may get "stuck" if the |
---|
80 | optimizer step size is too small so care should be taken |
---|
81 | If you experience problems with this please contact the SasView team and let |
---|
82 | them know the issue preferably with example data and model which fail to |
---|
83 | converge. |
---|
84 | |
---|
85 | The 2D scattering intensity is the same as 1D, regardless of the orientation |
---|
86 | of the q vector which is defined as: |
---|
87 | |
---|
88 | .. math:: |
---|
89 | |
---|
90 | q = \sqrt{q_x^2 + q_y^2} |
---|
91 | |
---|
92 | For information about polarised and magnetic scattering, see |
---|
93 | the :ref:`magnetism` documentation. |
---|
94 | |
---|
95 | References |
---|
96 | ---------- |
---|
97 | |
---|
98 | .. [#] B Cabane, *Small Angle Scattering Methods*, in *Surfactant Solutions: |
---|
99 | New Methods of Investigation*, Ch.2, Surfactant Science Series Vol. 22, Ed. |
---|
100 | R Zana and M Dekker, New York, (1987). |
---|
101 | |
---|
102 | Source |
---|
103 | ------ |
---|
104 | |
---|
105 | `multilayer_vesicle.py <https://github.com/SasView/sasmodels/blob/master/sasmodels/models/multilayer_vesicle.py>`_ |
---|
106 | |
---|
107 | `multilayer_vesicle.c <https://github.com/SasView/sasmodels/blob/master/sasmodels/models/multilayer_vesicle.c>`_ |
---|
108 | |
---|
109 | Authorship and Verification |
---|
110 | ---------------------------- |
---|
111 | |
---|
112 | * **Author:** NIST IGOR/DANSE **Date:** pre 2010 |
---|
113 | * **Converted to sasmodels by:** Piotr Rozyczko **Date:** Feb 24, 2016 |
---|
114 | * **Last Modified by:** Paul Kienzle **Date:** Feb 7, 2017 |
---|
115 | * **Last Reviewed by:** Steve King **Date:** March 28, 2019 |
---|
116 | * **Source added by :** Steve King **Date:** March 25, 2019 |
---|
117 | """ |
---|
118 | |
---|
119 | import numpy as np |
---|
120 | from numpy import inf |
---|
121 | |
---|
122 | name = "multilayer_vesicle" |
---|
123 | title = "Calculate form factor for a multi-lamellar vesicle" |
---|
124 | description = """ |
---|
125 | multilayer_vesicle model parameters; |
---|
126 | scale : scale factor for abs intensity if needed else 1.0 |
---|
127 | volfraction: volume fraction |
---|
128 | radius : Core radius of the multishell |
---|
129 | thick_shell: shell thickness |
---|
130 | thick_solvent: water thickness |
---|
131 | sld_solvent: solvent scattering length density |
---|
132 | sld: shell scattering length density |
---|
133 | n_shells:number of "shell plus solvent" layer pairs |
---|
134 | background: incoherent background |
---|
135 | """ |
---|
136 | category = "shape:sphere" |
---|
137 | |
---|
138 | # pylint: disable=bad-whitespace, line-too-long |
---|
139 | # ["name", "units", default, [lower, upper], "type","description"], |
---|
140 | parameters = [ |
---|
141 | ["volfraction", "", 0.05, [0.0, 1], "", "volume fraction of vesicles"], |
---|
142 | ["radius", "Ang", 60.0, [0.0, inf], "volume", "radius of solvent filled core"], |
---|
143 | ["thick_shell", "Ang", 10.0, [0.0, inf], "volume", "thickness of one shell"], |
---|
144 | ["thick_solvent", "Ang", 10.0, [0.0, inf], "volume", "solvent thickness between shells"], |
---|
145 | ["sld_solvent", "1e-6/Ang^2", 6.4, [-inf, inf], "sld", "solvent scattering length density"], |
---|
146 | ["sld", "1e-6/Ang^2", 0.4, [-inf, inf], "sld", "Shell scattering length density"], |
---|
147 | ["n_shells", "", 2.0, [1.0, inf], "volume", "Number of shell plus solvent layer pairs (must be integer)"], |
---|
148 | ] |
---|
149 | # pylint: enable=bad-whitespace, line-too-long |
---|
150 | |
---|
151 | # TODO: proposed syntax for specifying which parameters can be polydisperse |
---|
152 | #polydispersity = ["radius", "thick_shell"] |
---|
153 | |
---|
154 | source = ["lib/sas_3j1x_x.c", "multilayer_vesicle.c"] |
---|
155 | have_Fq = True |
---|
156 | effective_radius_type = ["outer radius"] |
---|
157 | |
---|
158 | def random(): |
---|
159 | """Return a random parameter set for the model.""" |
---|
160 | volfraction = 10**np.random.uniform(-3, -0.5) # scale from 0.1% to 30% |
---|
161 | radius = 10**np.random.uniform(0, 2.5) # core less than 300 A |
---|
162 | total_thick = 10**np.random.uniform(2, 4) # up to 10000 A of shells |
---|
163 | # random number of shells, with shell+solvent thickness > 10 A |
---|
164 | n_shells = int(10**np.random.uniform(0, np.log10(total_thick)-1)+0.5) |
---|
165 | # split total shell thickness with preference for shell over solvent; |
---|
166 | # make sure that shell thickness is at least 1 A |
---|
167 | one_thick = total_thick/n_shells |
---|
168 | thick_solvent = 10**np.random.uniform(-2, 0)*(one_thick - 1) |
---|
169 | thick_shell = one_thick - thick_solvent |
---|
170 | pars = dict( |
---|
171 | scale=1, |
---|
172 | volfraction=volfraction, |
---|
173 | radius=radius, |
---|
174 | thick_shell=thick_shell, |
---|
175 | thick_solvent=thick_solvent, |
---|
176 | n_shells=n_shells, |
---|
177 | ) |
---|
178 | return pars |
---|
179 | |
---|
180 | tests = [ |
---|
181 | # Accuracy tests based on content in test/utest_other_models.py |
---|
182 | [{'radius': 60.0, |
---|
183 | 'thick_shell': 10.0, |
---|
184 | 'thick_solvent': 10.0, |
---|
185 | 'sld_solvent': 6.4, |
---|
186 | 'sld': 0.4, |
---|
187 | 'n_shells': 2.0, |
---|
188 | 'scale': 1.0, |
---|
189 | 'background': 0.001, |
---|
190 | }, 0.001, 122.1405], |
---|
191 | |
---|
192 | [{'volfraction': 1.0, |
---|
193 | 'radius': 60.0, |
---|
194 | 'thick_shell': 10.0, |
---|
195 | 'thick_solvent': 10.0, |
---|
196 | 'sld_solvent': 6.4, |
---|
197 | 'sld': 0.4, |
---|
198 | 'n_shells': 2.0, |
---|
199 | 'scale': 1.0, |
---|
200 | 'background': 0.001, |
---|
201 | }, (0.001, 0.30903), 1.61873], |
---|
202 | ] |
---|