1 | r""" |
---|
2 | Definition |
---|
3 | ---------- |
---|
4 | |
---|
5 | Parameters for this model are the core axial ratio $X_{core}$ and a shell |
---|
6 | thickness $t_{shell}$, which are more often what we would like to determine |
---|
7 | and make the model better behaved, particularly when polydispersity is |
---|
8 | applied, than the four independent radii used in the original parameterization |
---|
9 | of this model. |
---|
10 | |
---|
11 | |
---|
12 | .. figure:: img/core_shell_ellipsoid_geometry.png |
---|
13 | |
---|
14 | The geometric parameters of this model are shown in the diagram above, which |
---|
15 | shows (a) a cut through at the circular equator and (b) a cross section through |
---|
16 | the poles, of a prolate ellipsoid. |
---|
17 | |
---|
18 | When $X_{core}$ < 1 the core is oblate; when $X_{core}$ > 1 it is prolate. |
---|
19 | $X_{core}$ = 1 is a spherical core. |
---|
20 | |
---|
21 | For a fixed shell thickness $X_{polar shell}$ = 1, to scale $t_{shell}$ |
---|
22 | pro-rata with the radius set or constrain $X_{polar shell}$ = $X_{core}$. |
---|
23 | |
---|
24 | .. note:: |
---|
25 | |
---|
26 | When including an $S(q)$, the radius in $S(q)$ is calculated to be that of |
---|
27 | a sphere with the same 2nd virial coefficient of the outer surface of the |
---|
28 | ellipsoid. This may have some undesirable effects if the aspect ratio of the |
---|
29 | ellipsoid is large (ie, if $X << 1$ or $X >> 1$), when the $S(q)$ |
---|
30 | - which assumes spheres - will not in any case be valid. Generating a |
---|
31 | custom product model will enable separate effective volume fraction and |
---|
32 | effective radius in the $S(q)$. |
---|
33 | |
---|
34 | If SAS data are in absolute units, and the SLDs are correct, then scale should |
---|
35 | be the total volume fraction of the "outer particle". When $S(q)$ is introduced |
---|
36 | this moves to the $S(q)$ volume fraction, and scale should then be 1.0, or |
---|
37 | contain some other units conversion factor (for example, if you have SAXS data). |
---|
38 | |
---|
39 | The calculation of intensity follows that for the solid ellipsoid, but |
---|
40 | with separate terms for the core-shell and shell-solvent boundaries. |
---|
41 | |
---|
42 | .. math:: |
---|
43 | |
---|
44 | P(q,\alpha) = \frac{\text{scale}}{V} F^2(q,\alpha) + \text{background} |
---|
45 | |
---|
46 | where |
---|
47 | |
---|
48 | .. In following equation SK changed radius\_equat\_core to R_e |
---|
49 | |
---|
50 | .. math:: |
---|
51 | :nowrap: |
---|
52 | |
---|
53 | \begin{align*} |
---|
54 | F(q,\alpha) = &f(q,R_e,R_e.x_{core},\alpha) \\ |
---|
55 | &+ f(q,R_e + t_{shell}, |
---|
56 | R_e.x_{core} + t_{shell}.x_{polar shell},\alpha) |
---|
57 | \end{align*} |
---|
58 | |
---|
59 | where |
---|
60 | |
---|
61 | .. math:: |
---|
62 | |
---|
63 | f(q,R_e,R_p,\alpha) = \frac{3 \Delta \rho V (\sin[qr(R_p,R_e,\alpha)] |
---|
64 | - \cos[qr(R_p,R_e,\alpha)])} |
---|
65 | {[qr(R_p,R_e,\alpha)]^3} |
---|
66 | |
---|
67 | and |
---|
68 | |
---|
69 | .. math:: |
---|
70 | |
---|
71 | r(R_e,R_p,\alpha) = \left[ R_e^2 \sin^2 \alpha |
---|
72 | + R_p^2 \cos^2 \alpha \right]^{1/2} |
---|
73 | |
---|
74 | |
---|
75 | $\alpha$ is the angle between the axis of the ellipsoid and $\vec q$, |
---|
76 | $V = (4/3)\pi R_pR_e^2$ is the volume of the ellipsoid , $R_p$ is the |
---|
77 | polar radius along the rotational axis of the ellipsoid, $R_e$ is the |
---|
78 | equatorial radius perpendicular to the rotational axis of the ellipsoid, |
---|
79 | $t_{shell}$ is the thickness of the shell at the equator, |
---|
80 | and $\Delta \rho$ (the contrast) is the scattering length density difference, |
---|
81 | either $(\rho_{core} - \rho_{shell})$ or $(\rho_{shell} - \rho_{solvent})$. |
---|
82 | |
---|
83 | For randomly oriented particles: |
---|
84 | |
---|
85 | .. math:: |
---|
86 | |
---|
87 | F^2(q)=\int_{0}^{\pi/2}{F^2(q,\alpha)\sin(\alpha)d\alpha} |
---|
88 | |
---|
89 | For oriented ellipsoids the *theta*, *phi* and *psi* orientation parameters |
---|
90 | will appear when fitting 2D data, see the :ref:`elliptical-cylinder` model |
---|
91 | for further information. |
---|
92 | |
---|
93 | References |
---|
94 | ---------- |
---|
95 | see for example: |
---|
96 | |
---|
97 | .. [#] Kotlarchyk, M.; Chen, S.-H. *J. Chem. Phys.*, 1983, 79, 2461 |
---|
98 | .. [#] Berr, S. *J. Phys. Chem.*, 1987, 91, 4760 |
---|
99 | |
---|
100 | Source |
---|
101 | ------ |
---|
102 | |
---|
103 | `core_shell_ellipsoid.py <https://github.com/SasView/sasmodels/blob/master/sasmodels/models/core_shell_ellipsoid.py>`_ |
---|
104 | |
---|
105 | `core_shell_ellipsoid.c <https://github.com/SasView/sasmodels/blob/master/sasmodels/models/core_shell_ellipsoid.c>`_ |
---|
106 | |
---|
107 | Authorship and Verification |
---|
108 | ---------------------------- |
---|
109 | |
---|
110 | * **Author:** NIST IGOR/DANSE **Date:** pre 2010 |
---|
111 | * **Last Modified by:** Richard Heenan (reparametrised model) **Date:** 2015 |
---|
112 | * **Last Reviewed by:** Steve King **Date:** March 27, 2019 |
---|
113 | * **Source added by :** Steve King **Date:** March 25, 2019 |
---|
114 | """ |
---|
115 | |
---|
116 | import numpy as np |
---|
117 | from numpy import inf, sin, cos, pi |
---|
118 | |
---|
119 | name = "core_shell_ellipsoid" |
---|
120 | title = "Form factor for an spheroid ellipsoid particle with a core shell structure." |
---|
121 | description = """ |
---|
122 | [core_shell_ellipsoid] Calculates the form factor for an spheroid |
---|
123 | ellipsoid particle with a core_shell structure. |
---|
124 | The form factor is averaged over all possible |
---|
125 | orientations of the ellipsoid such that P(q) |
---|
126 | = scale*<f^2>/Vol + bkg, where f is the |
---|
127 | single particle scattering amplitude. |
---|
128 | [Parameters]: |
---|
129 | radius_equat_core = equatorial radius of core, |
---|
130 | x_core = ratio of core polar/equatorial radii, |
---|
131 | thick_shell = equatorial radius of outer surface, |
---|
132 | x_polar_shell = ratio of polar shell thickness to equatorial shell thickness, |
---|
133 | sld_core = SLD_core |
---|
134 | sld_shell = SLD_shell |
---|
135 | sld_solvent = SLD_solvent |
---|
136 | background = Incoherent bkg |
---|
137 | scale =scale |
---|
138 | Note:It is the users' responsibility to ensure |
---|
139 | that shell radii are larger than core radii. |
---|
140 | oblate: polar radius < equatorial radius |
---|
141 | prolate : polar radius > equatorial radius - this new model will make this easier |
---|
142 | and polydispersity integrals more logical (as previously the shell could disappear). |
---|
143 | """ |
---|
144 | category = "shape:ellipsoid" |
---|
145 | |
---|
146 | # pylint: disable=bad-whitespace, line-too-long |
---|
147 | # ["name", "units", default, [lower, upper], "type", "description"], |
---|
148 | parameters = [ |
---|
149 | ["radius_equat_core","Ang", 20, [0, inf], "volume", "Equatorial radius of core"], |
---|
150 | ["x_core", "None", 3, [0, inf], "volume", "axial ratio of core, X = r_polar/r_equatorial"], |
---|
151 | ["thick_shell", "Ang", 30, [0, inf], "volume", "thickness of shell at equator"], |
---|
152 | ["x_polar_shell", "", 1, [0, inf], "volume", "ratio of thickness of shell at pole to that at equator"], |
---|
153 | ["sld_core", "1e-6/Ang^2", 2, [-inf, inf], "sld", "Core scattering length density"], |
---|
154 | ["sld_shell", "1e-6/Ang^2", 1, [-inf, inf], "sld", "Shell scattering length density"], |
---|
155 | ["sld_solvent", "1e-6/Ang^2", 6.3, [-inf, inf], "sld", "Solvent scattering length density"], |
---|
156 | ["theta", "degrees", 0, [-360, 360], "orientation", "elipsoid axis to beam angle"], |
---|
157 | ["phi", "degrees", 0, [-360, 360], "orientation", "rotation about beam"], |
---|
158 | ] |
---|
159 | # pylint: enable=bad-whitespace, line-too-long |
---|
160 | |
---|
161 | source = ["lib/sas_3j1x_x.c", "lib/gauss76.c", "core_shell_ellipsoid.c"] |
---|
162 | have_Fq = True |
---|
163 | effective_radius_type = [ |
---|
164 | "average outer curvature", "equivalent volume sphere", |
---|
165 | "min outer radius", "max outer radius", |
---|
166 | ] |
---|
167 | |
---|
168 | def random(): |
---|
169 | """Return a random parameter set for the model.""" |
---|
170 | volume = 10**np.random.uniform(5, 12) |
---|
171 | outer_polar = 10**np.random.uniform(1.3, 4) |
---|
172 | outer_equatorial = np.sqrt(volume/outer_polar) # ignore 4/3 pi |
---|
173 | # Use a distribution with a preference for thin shell or thin core |
---|
174 | # Avoid core,shell radii < 1 |
---|
175 | thickness_polar = np.random.beta(0.5, 0.5)*(outer_polar-2) + 1 |
---|
176 | thickness_equatorial = np.random.beta(0.5, 0.5)*(outer_equatorial-2) + 1 |
---|
177 | radius_polar = outer_polar - thickness_polar |
---|
178 | radius_equatorial = outer_equatorial - thickness_equatorial |
---|
179 | x_core = radius_polar/radius_equatorial |
---|
180 | x_polar_shell = thickness_polar/thickness_equatorial |
---|
181 | pars = dict( |
---|
182 | #background=0, sld=0, sld_solvent=1, |
---|
183 | radius_equat_core=radius_equatorial, |
---|
184 | x_core=x_core, |
---|
185 | thick_shell=thickness_equatorial, |
---|
186 | x_polar_shell=x_polar_shell, |
---|
187 | ) |
---|
188 | return pars |
---|
189 | |
---|
190 | q = 0.1 |
---|
191 | # tests had in old coords theta=0, phi=0; new coords theta=90, phi=0 |
---|
192 | qx = q*cos(pi/6.0) |
---|
193 | qy = q*sin(pi/6.0) |
---|
194 | # 11Jan2017 RKH sorted tests after redefinition of angles |
---|
195 | tests = [ |
---|
196 | # Accuracy tests based on content in test/utest_coreshellellipsoidXTmodel.py |
---|
197 | [{'radius_equat_core': 200.0, |
---|
198 | 'x_core': 0.1, |
---|
199 | 'thick_shell': 50.0, |
---|
200 | 'x_polar_shell': 0.2, |
---|
201 | 'sld_core': 2.0, |
---|
202 | 'sld_shell': 1.0, |
---|
203 | 'sld_solvent': 6.3, |
---|
204 | 'background': 0.001, |
---|
205 | 'scale': 1.0, |
---|
206 | }, 1.0, 0.00189402], |
---|
207 | |
---|
208 | # Additional tests with larger range of parameters |
---|
209 | [{'background': 0.01}, 0.1, 11.6915], |
---|
210 | |
---|
211 | [{'radius_equat_core': 20.0, |
---|
212 | 'x_core': 200.0, |
---|
213 | 'thick_shell': 54.0, |
---|
214 | 'x_polar_shell': 3.0, |
---|
215 | 'sld_core': 20.0, |
---|
216 | 'sld_shell': 10.0, |
---|
217 | 'sld_solvent': 6.0, |
---|
218 | 'background': 0.0, |
---|
219 | 'scale': 1.0, |
---|
220 | }, 0.01, 8688.53], |
---|
221 | |
---|
222 | # 2D tests |
---|
223 | [{'background': 0.001, |
---|
224 | 'theta': 90.0, |
---|
225 | 'phi': 0.0, |
---|
226 | }, (0.4, 0.5), 0.00690673], |
---|
227 | |
---|
228 | [{'radius_equat_core': 20.0, |
---|
229 | 'x_core': 200.0, |
---|
230 | 'thick_shell': 54.0, |
---|
231 | 'x_polar_shell': 3.0, |
---|
232 | 'sld_core': 20.0, |
---|
233 | 'sld_shell': 10.0, |
---|
234 | 'sld_solvent': 6.0, |
---|
235 | 'background': 0.01, |
---|
236 | 'scale': 0.01, |
---|
237 | 'theta': 90.0, |
---|
238 | 'phi': 0.0, |
---|
239 | }, (qx, qy), 0.01000025], |
---|
240 | ] |
---|