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

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

lint

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