source: sasmodels/sasmodels/models/core_shell_bicelle.py @ 99658f6

core_shell_microgelsmagnetic_modelticket-1257-vesicle-productticket_1156ticket_1265_superballticket_822_more_unit_tests
Last change on this file since 99658f6 was 99658f6, checked in by grethevj, 5 years ago

updated ER functions including cylinder excluded volume, to match 4.x

  • Property mode set to 100644
File size: 7.1 KB
RevLine 
[8007311]1r"""
2Definition
3----------
[adc753d]4
[40a87fa]5This model provides the form factor for a circular cylinder with a
6core-shell scattering length density profile. Thus this is a variation
7of a core-shell cylinder or disc where the shell on the walls and ends
8may be of different thicknesses and scattering length densities. The form
9factor is normalized by the particle volume.
[8007311]10
11
12.. figure:: img/core_shell_bicelle_geometry.png
13
[a0fee3b]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
[a151caa]19   Cross section of cylindrical symmetry model used here. Users will have
20   to decide how to distribute "heads" and "tails" between the rim, face
[a0fee3b]21   and core regions in order to estimate appropriate starting parameters.
[8007311]22
[adc753d]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 cylinder axis is:
26
[30b60d2]27.. math::
[adc753d]28
[a151caa]29    \rho(r) =
30      \begin{cases}
[adc753d]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
38$\alpha$ is the angle between the $Q$ vector and the cylinder axis, to give:
39
40.. math::
41
[041bc75]42    I(Q,\alpha) = \frac{\text{scale}}{V_t} \cdot
[f52d400]43        F(Q,\alpha)^2 \cdot sin(\alpha) + \text{background}
[416f5c7]44
[adc753d]45where
46
47.. math::
[2e0c0b0]48    :nowrap:
[adc753d]49
[30b60d2]50    \begin{align*}
[a151caa]51    F(Q,\alpha) = &\bigg[
[2d81cfe]52    (\rho_c - \rho_f) V_c
53     \frac{2J_1(QRsin \alpha)}{QRsin\alpha}
54     \frac{sin(QLcos\alpha/2)}{Q(L/2)cos\alpha} \\
55    &+(\rho_f - \rho_r) V_{c+f}
56     \frac{2J_1(QRsin\alpha)}{QRsin\alpha}
57     \frac{sin(Q(L/2+t_f)cos\alpha)}{Q(L/2+t_f)cos\alpha} \\
58    &+(\rho_r - \rho_s) V_t
59     \frac{2J_1(Q(R+t_r)sin\alpha)}{Q(R+t_r)sin\alpha}
60     \frac{sin(Q(L/2+t_f)cos\alpha)}{Q(L/2+t_f)cos\alpha}
[adc753d]61    \bigg]
[30b60d2]62    \end{align*}
[adc753d]63
64where $V_t$ is the total volume of the bicelle, $V_c$ the volume of the core,
65$V_{c+f}$ the volume of the core plus the volume of the faces, $R$ is the radius
66of the core, $L$ the length of the core, $t_f$ the thickness of the face, $t_r$
67the thickness of the rim and $J_1$ the usual first order bessel function.
68
[8007311]69The output of the 1D scattering intensity function for randomly oriented
[adc753d]70cylinders is then given by integrating over all possible $\theta$ and $\phi$.
[8007311]71
[2d81cfe]72For oriented bicelles the *theta*, and *phi* orientation parameters will appear
73when fitting 2D data, see the :ref:`cylinder` model for further information.
[8007311]74Our implementation of the scattering kernel and the 1D scattering intensity
75use the c-library from NIST.
76
[9802ab3]77.. figure:: img/cylinder_angle_definition.png
[8007311]78
[9b79f29]79    Definition of the angles for the oriented core shell bicelle model,
80    note that the cylinder axis of the bicelle starts along the beam direction
81    when $\theta  = \phi = 0$.
[8007311]82
83
84References
85----------
86
[adc753d]87.. [#] D Singh (2009). *Small angle scattering studies of self assembly in
88   lipid mixtures*, John's Hopkins University Thesis (2009) 223-225. `Available
89   from Proquest <http://search.proquest.com/docview/304915826?accountid
90   =26379>`_
[99658f6]91   
92   L. Onsager, Ann. New York Acad. Sci. 51, 627-659 (1949).
[b0c4271]93
94Authorship and Verification
95----------------------------
96
97* **Author:** NIST IGOR/DANSE **Date:** pre 2010
[adc753d]98* **Last Modified by:** Paul Butler **Date:** September 30, 2016
[fcb33e4]99* **Last Reviewed by:** Richard Heenan **Date:** January 4, 2017
[8007311]100"""
101
[2d81cfe]102import numpy as np
[0b56f38]103from numpy import inf, sin, cos, pi
[8007311]104
105name = "core_shell_bicelle"
106title = "Circular cylinder with a core-shell scattering length density profile.."
107description = """
[a151caa]108    P(q,alpha)= (scale/Vs)*f(q)^(2) + bkg,  where:
[a0fee3b]109    f(q)= Vt(sld_rim - sld_solvent)* sin[qLt.cos(alpha)/2]
110    /[qLt.cos(alpha)/2]*J1(qRout.sin(alpha))
111    /[qRout.sin(alpha)]+
112    (sld_core-sld_face)*Vc*sin[qLcos(alpha)/2][[qL
113    *cos(alpha)/2]*J1(qRc.sin(alpha))
114    /qRc.sin(alpha)]+
115    (sld_face-sld_rim)*(Vc+Vf)*sin[q(L+2.thick_face).
116    cos(alpha)/2][[q(L+2.thick_face)*cos(alpha)/2]*
117    J1(qRc.sin(alpha))/qRc.sin(alpha)]
[8007311]118
119    alpha:is the angle between the axis of
120    the cylinder and the q-vector
[a0fee3b]121    Vt = pi.(Rc + thick_rim)^2.Lt : total volume
122    Vc = pi.Rc^2.L :the volume of the core
123    Vf = 2.pi.Rc^2.thick_face
124    Rc = radius: is the core radius
[8007311]125    L: the length of the core
[a0fee3b]126    Lt = L + 2.thick_face: total length
127    Rout = radius + thick_rim
128    sld_core, sld_rim, sld_face:scattering length
129    densities within the particle
[aad336c]130    sld_solvent: the scattering length density
[8007311]131    of the solvent
132    bkg: the background
133    J1: the first order Bessel function
134    theta: axis_theta of the cylinder
135    phi: the axis_phi of the cylinder...
136        """
137category = "shape:cylinder"
138
139# pylint: disable=bad-whitespace, line-too-long
140#             ["name", "units", default, [lower, upper], "type", "description"],
141parameters = [
[416f5c7]142    ["radius",         "Ang",       80, [0, inf],    "volume",      "Cylinder core radius"],
[2222134]143    ["thick_rim",  "Ang",       10, [0, inf],    "volume",      "Rim shell thickness"],
144    ["thick_face", "Ang",       10, [0, inf],    "volume",      "Cylinder face thickness"],
[416f5c7]145    ["length",         "Ang",      50, [0, inf],    "volume",      "Cylinder length"],
[42356c8]146    ["sld_core",       "1e-6/Ang^2", 1, [-inf, inf], "sld",         "Cylinder core scattering length density"],
147    ["sld_face",       "1e-6/Ang^2", 4, [-inf, inf], "sld",         "Cylinder face scattering length density"],
148    ["sld_rim",        "1e-6/Ang^2", 4, [-inf, inf], "sld",         "Cylinder rim scattering length density"],
149    ["sld_solvent",    "1e-6/Ang^2", 1, [-inf, inf], "sld",         "Solvent scattering length density"],
[9b79f29]150    ["theta",          "degrees",   90, [-360, 360], "orientation", "cylinder axis to beam angle"],
151    ["phi",            "degrees",    0, [-360, 360], "orientation", "rotation about beam"]
[8007311]152    ]
153
154# pylint: enable=bad-whitespace, line-too-long
155
[4b541ac]156source = ["lib/sas_Si.c", "lib/polevl.c", "lib/sas_J1.c", "lib/gauss76.c",
[40a87fa]157          "core_shell_bicelle.c"]
[71b751d]158have_Fq = True
[ee60aa7]159effective_radius_type = [
[99658f6]160    "excluded volume","equivalent volume sphere", "outer rim radius",
[ee60aa7]161    "half outer thickness", "half diagonal",
162    ]
[8007311]163
[a151caa]164def random():
165    pars = dict(
166        radius=10**np.random.uniform(1.3, 3),
167        length=10**np.random.uniform(1.3, 4),
168        thick_rim=10**np.random.uniform(0, 1.7),
169        thick_face=10**np.random.uniform(0, 1.7),
170    )
171    return pars
172
[8007311]173demo = dict(scale=1, background=0,
174            radius=20.0,
[2222134]175            thick_rim=10.0,
176            thick_face=10.0,
[8007311]177            length=400.0,
[aad336c]178            sld_core=1.0,
179            sld_face=4.0,
180            sld_rim=4.0,
181            sld_solvent=1.0,
[8007311]182            theta=90,
183            phi=0)
[0b56f38]184q = 0.1
185# april 6 2017, rkh add unit tests, NOT compared with any other calc method, assume correct!
186qx = q*cos(pi/6.0)
187qy = q*sin(pi/6.0)
[2d81cfe]188tests = [
189    [{}, 0.05, 7.4883545957],
190    [{'theta':80., 'phi':10.}, (qx, qy), 2.81048892474]
191]
[0b56f38]192del qx, qy  # not necessary to delete, but cleaner
Note: See TracBrowser for help on using the repository browser.