source: sasmodels/sasmodels/models/core_shell_bicelle_elliptical.py @ 4493288

core_shell_microgelsmagnetic_modelticket-1257-vesicle-productticket_1156ticket_1265_superballticket_822_more_unit_tests
Last change on this file since 4493288 was 2d81cfe, checked in by Paul Kienzle <pkienzle@…>, 6 years ago

lint

  • Property mode set to 100644
File size: 7.7 KB
RevLine 
[fcb33e4]1r"""
2Definition
3----------
4
5This model provides the form factor for an elliptical cylinder with a
6core-shell scattering length density profile. Thus this is a variation
7of the core-shell bicelle model, but with an elliptical cylinder for the core.
[8f04da4]8Outer shells on the rims and flat ends may be of different thicknesses and
[2d81cfe]9scattering length densities. The form factor is normalized by the total
10particle volume.
[fcb33e4]11
12
13.. figure:: img/core_shell_bicelle_geometry.png
14
15    Schematic cross-section of bicelle. Note however that the model here
16    calculates for rectangular, not curved, rims as shown below.
17
18.. figure:: img/core_shell_bicelle_parameters.png
19
[8f04da4]20   Cross section of model used here. Users will have
21   to decide how to distribute "heads" and "tails" between the rim, face
[fcb33e4]22   and core regions in order to estimate appropriate starting parameters.
23
24Given the scattering length densities (sld) $\rho_c$, the core sld, $\rho_f$,
25the face sld, $\rho_r$, the rim sld and $\rho_s$ the solvent sld, the
26scattering length density variation along the bicelle axis is:
27
28.. math::
29
[8f04da4]30    \rho(r) =
31      \begin{cases}
[fcb33e4]32      &\rho_c \text{ for } 0 \lt r \lt R; -L \lt z\lt L \\[1.5ex]
33      &\rho_f \text{ for } 0 \lt r \lt R; -(L+2t) \lt z\lt -L;
34      L \lt z\lt (L+2t) \\[1.5ex]
35      &\rho_r\text{ for } 0 \lt r \lt R; -(L+2t) \lt z\lt -L; L \lt z\lt (L+2t)
36      \end{cases}
37
38The form factor for the bicelle is calculated in cylindrical coordinates, where
[2d81cfe]39$\alpha$ is the angle between the $Q$ vector and the cylinder axis, and $\psi$
40is the angle for the ellipsoidal cross section core, to give:
[fcb33e4]41
42.. math::
43
44    I(Q,\alpha,\psi) = \frac{\text{scale}}{V_t} \cdot
[a53bf6b]45        F(Q,\alpha, \psi)^2 \cdot sin(\alpha) + \text{background}
[fcb33e4]46
[2d81cfe]47where a numerical integration of $F(Q,\alpha, \psi)^2 \cdot sin(\alpha)$
48is carried out over \alpha and \psi for:
[fcb33e4]49
50.. math::
[17fb550]51    :nowrap:
52
[30b60d2]53    \begin{align*}
[8f04da4]54    F(Q,\alpha,\psi) = &\bigg[
[2d81cfe]55    (\rho_c - \rho_f) V_c
56     \frac{2J_1(QR'sin \alpha)}{QR'sin\alpha}
57     \frac{sin(QLcos\alpha/2)}{Q(L/2)cos\alpha} \\
58    &+(\rho_f - \rho_r) V_{c+f}
59     \frac{2J_1(QR'sin\alpha)}{QR'sin\alpha}
60     \frac{sin(Q(L/2+t_f)cos\alpha)}{Q(L/2+t_f)cos\alpha} \\
61    &+(\rho_r - \rho_s) V_t
62     \frac{2J_1(Q(R'+t_r)sin\alpha)}{Q(R'+t_r)sin\alpha}
63     \frac{sin(Q(L/2+t_f)cos\alpha)}{Q(L/2+t_f)cos\alpha}
[fcb33e4]64    \bigg]
[30b60d2]65    \end{align*}
[fcb33e4]66
67where
68
69.. math::
70
71    R'=\frac{R}{\sqrt{2}}\sqrt{(1+X_{core}^{2}) + (1-X_{core}^{2})cos(\psi)}
[8f04da4]72
73
[2d81cfe]74and $V_t = \pi.(R+t_r)(Xcore.R+t_r)^2.(L+2.t_f)$ is the total volume of
75the bicelle, $V_c = \pi.Xcore.R^2.L$ the volume of the core,
76$V_{c+f} = \pi.Xcore.R^2.(L+2.t_f)$ the volume of the core plus the volume
77of the faces, $R$ is the radius of the core, $Xcore$ is the axial ratio of
78the core, $L$ the length of the core, $t_f$ the thickness of the face, $t_r$
79the thickness of the rim and $J_1$ the usual first order bessel function.
80The core has radii $R$ and $Xcore.R$ so is circular, as for the
81core_shell_bicelle model, for $Xcore$ =1. Note that you may need to
82limit the range of $Xcore$, especially if using the Monte-Carlo algorithm,
83as setting radius to $R/Xcore$ and axial ratio to $1/Xcore$ gives an
84equivalent solution!
[fcb33e4]85
86The output of the 1D scattering intensity function for randomly oriented
87bicelles is then given by integrating over all possible $\alpha$ and $\psi$.
88
[2d81cfe]89For oriented bicelles the *theta*, *phi* and *psi* orientation parameters will
90appear when fitting 2D data, see the :ref:`elliptical-cylinder` model
91for further information.
[fcb33e4]92
93
[15a90c1]94.. figure:: img/elliptical_cylinder_angle_definition.png
95
[8f04da4]96    Definition of the angles for the oriented core_shell_bicelle_elliptical particles.
[fcb33e4]97
98
99
100References
101----------
102
103.. [#]
104
105Authorship and Verification
106----------------------------
107
108* **Author:** Richard Heenan **Date:** December 14, 2016
109* **Last Modified by:**  Richard Heenan **Date:** December 14, 2016
110* **Last Reviewed by:**  Richard Heenan BEWARE 2d data yet to be checked **Date:** December 14, 2016
111"""
112
[2d81cfe]113import numpy as np
[0b56f38]114from numpy import inf, sin, cos, pi
[fcb33e4]115
116name = "core_shell_bicelle_elliptical"
117title = "Elliptical cylinder with a core-shell scattering length density profile.."
118description = """
119    core_shell_bicelle_elliptical
[8f04da4]120    Elliptical cylinder core, optional shell on the two flat faces, and shell of
121    uniform thickness on its rim (extending around the end faces).
[fcb33e4]122    Please see full documentation for equations and further details.
123    Involves a double numerical integral around the ellipsoid diameter
124    and the angle of the cylinder axis to Q.
125    Compare also the core_shell_bicelle and elliptical_cylinder models.
126      """
127category = "shape:cylinder"
128
129# pylint: disable=bad-whitespace, line-too-long
130#             ["name", "units", default, [lower, upper], "type", "description"],
131parameters = [
132    ["radius",         "Ang",       30, [0, inf],    "volume",      "Cylinder core radius"],
133    ["x_core",        "None",       3,  [0, inf],    "volume",      "axial ratio of core, X = r_polar/r_equatorial"],
[9b79f29]134    ["thick_rim",  "Ang",            8, [0, inf],    "volume",      "Rim shell thickness"],
135    ["thick_face", "Ang",           14, [0, inf],    "volume",      "Cylinder face thickness"],
136    ["length",         "Ang",       50, [0, inf],    "volume",      "Cylinder length"],
[fcb33e4]137    ["sld_core",       "1e-6/Ang^2", 4, [-inf, inf], "sld",         "Cylinder core scattering length density"],
138    ["sld_face",       "1e-6/Ang^2", 7, [-inf, inf], "sld",         "Cylinder face scattering length density"],
139    ["sld_rim",        "1e-6/Ang^2", 1, [-inf, inf], "sld",         "Cylinder rim scattering length density"],
140    ["sld_solvent",    "1e-6/Ang^2", 6, [-inf, inf], "sld",         "Solvent scattering length density"],
[9b79f29]141    ["theta",       "degrees",    90.0, [-360, 360], "orientation", "cylinder axis to beam angle"],
142    ["phi",         "degrees",    0,    [-360, 360], "orientation", "rotation about beam"],
143    ["psi",         "degrees",    0,    [-360, 360], "orientation", "rotation about cylinder axis"]
[fcb33e4]144    ]
145
146# pylint: enable=bad-whitespace, line-too-long
147
[4b541ac]148source = ["lib/sas_Si.c", "lib/polevl.c", "lib/sas_J1.c", "lib/gauss76.c",
149          "core_shell_bicelle_elliptical.c"]
[fcb33e4]150
[8f04da4]151def random():
152    outer_major = 10**np.random.uniform(1, 4.7)
153    outer_minor = 10**np.random.uniform(1, 4.7)
154    # Use a distribution with a preference for thin shell or thin core,
155    # limited by the minimum radius. Avoid core,shell radii < 1
156    min_radius = min(outer_major, outer_minor)
157    thick_rim = np.random.beta(0.5, 0.5)*(min_radius-2) + 1
158    radius_major = outer_major - thick_rim
159    radius_minor = outer_minor - thick_rim
160    radius = radius_major
161    x_core = radius_minor/radius_major
162    outer_length = 10**np.random.uniform(1, 4.7)
163    # Caps should be a small percentage of the total length, but at least one
164    # angstrom long.  Since outer length >= 10, the following will suffice
165    thick_face = 10**np.random.uniform(-np.log10(outer_length), -1)*outer_length
166    length = outer_length - thick_face
167    pars = dict(
168        radius=radius,
169        x_core=x_core,
170        thick_rim=thick_rim,
171        thick_face=thick_face,
172        length=length
173    )
174    return pars
175
[fcb33e4]176
[0b56f38]177q = 0.1
178# april 6 2017, rkh added a 2d unit test, NOT READY YET pull #890 branch assume correct!
179qx = q*cos(pi/6.0)
180qy = q*sin(pi/6.0)
[fcb33e4]181
182tests = [
[2d81cfe]183    [{'radius': 30.0, 'x_core': 3.0,
184      'thick_rim': 8.0, 'thick_face': 14.0, 'length': 50.0}, 'ER', 1],
185    [{'radius': 30.0, 'x_core': 3.0,
186      'thick_rim': 8.0, 'thick_face': 14.0, 'length': 50.0}, 'VR', 1],
187
188    [{'radius': 30.0, 'x_core': 3.0,
189      'thick_rim': 8.0, 'thick_face': 14.0, 'length': 50.0,
190      'sld_core': 4.0, 'sld_face': 7.0, 'sld_rim': 1.0,
191      'sld_solvent': 6.0, 'background': 0.0},
192     0.015, 286.540286],
193    #[{'theta':80., 'phi':10.}, (qx, qy), 7.88866563001],
194]
[0b56f38]195
196del qx, qy  # not necessary to delete, but cleaner
Note: See TracBrowser for help on using the repository browser.