[81dd619] | 1 | r""" |
---|
| 2 | Definition |
---|
| 3 | ---------- |
---|
| 4 | |
---|
[e5a8f33] | 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. |
---|
[b99734a] | 10 | |
---|
| 11 | |
---|
[5031ca3] | 12 | .. figure:: img/core_shell_ellipsoid_geometry.png |
---|
[81dd619] | 13 | |
---|
[9272cbd] | 14 | The geometric parameters of this model are shown in the diagram above, which |
---|
[416f5c7] | 15 | shows (a) a cut through at the circular equator and (b) a cross section through |
---|
[9272cbd] | 16 | the poles, of a prolate ellipsoid. |
---|
[81dd619] | 17 | |
---|
[e5a8f33] | 18 | When $X_{core}$ < 1 the core is oblate; when $X_{core}$ > 1 it is prolate. |
---|
| 19 | $X_{core}$ = 1 is a spherical core. |
---|
[81dd619] | 20 | |
---|
[e5a8f33] | 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}$. |
---|
[81dd619] | 23 | |
---|
[e5a8f33] | 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)$. |
---|
[81dd619] | 33 | |
---|
[5031ca3] | 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 |
---|
[2d81cfe] | 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). |
---|
[81dd619] | 38 | |
---|
[2d81cfe] | 39 | The calculation of intensity follows that for the solid ellipsoid, but |
---|
| 40 | with separate terms for the core-shell and shell-solvent boundaries. |
---|
[416f5c7] | 41 | |
---|
| 42 | .. math:: |
---|
| 43 | |
---|
| 44 | P(q,\alpha) = \frac{\text{scale}}{V} F^2(q,\alpha) + \text{background} |
---|
| 45 | |
---|
| 46 | where |
---|
| 47 | |
---|
[e5a8f33] | 48 | .. In following equation SK changed radius\_equat\_core to R_e |
---|
| 49 | |
---|
[416f5c7] | 50 | .. math:: |
---|
[2e0c0b0] | 51 | :nowrap: |
---|
[17fb550] | 52 | |
---|
[30b60d2] | 53 | \begin{align*} |
---|
[e5a8f33] | 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) |
---|
[30b60d2] | 57 | \end{align*} |
---|
[416f5c7] | 58 | |
---|
| 59 | where |
---|
[2a0b2b1] | 60 | |
---|
[416f5c7] | 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$, |
---|
[2d81cfe] | 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 |
---|
[e5a8f33] | 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})$. |
---|
[416f5c7] | 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 | |
---|
[2d81cfe] | 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. |
---|
[416f5c7] | 92 | |
---|
[81dd619] | 93 | References |
---|
| 94 | ---------- |
---|
[9272cbd] | 95 | see for example: |
---|
[0507e09] | 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>`_ |
---|
[9272cbd] | 106 | |
---|
| 107 | Authorship and Verification |
---|
| 108 | ---------------------------- |
---|
[81dd619] | 109 | |
---|
[9272cbd] | 110 | * **Author:** NIST IGOR/DANSE **Date:** pre 2010 |
---|
| 111 | * **Last Modified by:** Richard Heenan (reparametrised model) **Date:** 2015 |
---|
[e5a8f33] | 112 | * **Last Reviewed by:** Steve King **Date:** March 27, 2019 |
---|
[0507e09] | 113 | * **Source added by :** Steve King **Date:** March 25, 2019 |
---|
[81dd619] | 114 | """ |
---|
| 115 | |
---|
[2d81cfe] | 116 | import numpy as np |
---|
[81dd619] | 117 | from numpy import inf, sin, cos, pi |
---|
| 118 | |
---|
[b99734a] | 119 | name = "core_shell_ellipsoid" |
---|
[81dd619] | 120 | title = "Form factor for an spheroid ellipsoid particle with a core shell structure." |
---|
| 121 | description = """ |
---|
[b99734a] | 122 | [core_shell_ellipsoid] Calculates the form factor for an spheroid |
---|
[5031ca3] | 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). |
---|
[81dd619] | 143 | """ |
---|
| 144 | category = "shape:ellipsoid" |
---|
| 145 | |
---|
| 146 | # pylint: disable=bad-whitespace, line-too-long |
---|
[5031ca3] | 147 | # ["name", "units", default, [lower, upper], "type", "description"], |
---|
[81dd619] | 148 | parameters = [ |
---|
[73e08ae] | 149 | ["radius_equat_core","Ang", 20, [0, inf], "volume", "Equatorial radius of core"], |
---|
[5031ca3] | 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"], |
---|
[9b79f29] | 156 | ["theta", "degrees", 0, [-360, 360], "orientation", "elipsoid axis to beam angle"], |
---|
| 157 | ["phi", "degrees", 0, [-360, 360], "orientation", "rotation about beam"], |
---|
[81dd619] | 158 | ] |
---|
| 159 | # pylint: enable=bad-whitespace, line-too-long |
---|
| 160 | |
---|
[2a0b2b1] | 161 | source = ["lib/sas_3j1x_x.c", "lib/gauss76.c", "core_shell_ellipsoid.c"] |
---|
[71b751d] | 162 | have_Fq = True |
---|
[ee60aa7] | 163 | effective_radius_type = [ |
---|
[b297ba9] | 164 | "average outer curvature", "equivalent volume sphere", |
---|
[ee60aa7] | 165 | "min outer radius", "max outer radius", |
---|
| 166 | ] |
---|
[65bf704] | 167 | |
---|
[31df0c9] | 168 | def random(): |
---|
[b297ba9] | 169 | """Return a random parameter set for the model.""" |
---|
[2d81cfe] | 170 | volume = 10**np.random.uniform(5, 12) |
---|
[8f04da4] | 171 | outer_polar = 10**np.random.uniform(1.3, 4) |
---|
[2d81cfe] | 172 | outer_equatorial = np.sqrt(volume/outer_polar) # ignore 4/3 pi |
---|
[8f04da4] | 173 | # Use a distribution with a preference for thin shell or thin core |
---|
| 174 | # Avoid core,shell radii < 1 |
---|
[9f6823b] | 175 | thickness_polar = np.random.beta(0.5, 0.5)*(outer_polar-2) + 1 |
---|
[8f04da4] | 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 |
---|
[31df0c9] | 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 |
---|
[81dd619] | 189 | |
---|
| 190 | q = 0.1 |
---|
[b7e8b94] | 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 |
---|
[fcb33e4] | 195 | tests = [ |
---|
[2d81cfe] | 196 | # Accuracy tests based on content in test/utest_coreshellellipsoidXTmodel.py |
---|
[fcb33e4] | 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], |
---|
[81dd619] | 207 | |
---|
| 208 | # Additional tests with larger range of parameters |
---|
[fcb33e4] | 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], |
---|
[7c2935c] | 221 | |
---|
[2d81cfe] | 222 | # 2D tests |
---|
| 223 | [{'background': 0.001, |
---|
| 224 | 'theta': 90.0, |
---|
| 225 | 'phi': 0.0, |
---|
[7c2935c] | 226 | }, (0.4, 0.5), 0.00690673], |
---|
[fcb33e4] | 227 | |
---|
[2d81cfe] | 228 | [{'radius_equat_core': 20.0, |
---|
[fcb33e4] | 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, |
---|
[b7e8b94] | 237 | 'theta': 90.0, |
---|
[7c2935c] | 238 | 'phi': 0.0, |
---|
[fcb33e4] | 239 | }, (qx, qy), 0.01000025], |
---|
[2d81cfe] | 240 | ] |
---|