source: sasmodels/sasmodels/models/core_shell_cylinder.py @ 0b56f38

core_shell_microgelscostrafo411magnetic_modelticket-1257-vesicle-productticket_1156ticket_1265_superballticket_822_more_unit_tests
Last change on this file since 0b56f38 was 0b56f38, checked in by richardh, 7 years ago

unit tests added, needs opencl testing

  • Property mode set to 100644
File size: 5.7 KB
Line 
1r"""
2Definition
3----------
4
5The output of the 2D scattering intensity function for oriented core-shell
6cylinders is given by (Kline, 2006 [#kline]_). The form factor is normalized
7by the particle volume.
8
9.. math::
10
11    I(q,\alpha) = \frac{\text{scale}}{V_s} F^2(q,\alpha).sin(\alpha) + \text{background}
12
13where
14
15.. math::
16
17    F(q,\alpha) = &\ (\rho_c - \rho_s) V_c
18           \frac{\sin \left( q \tfrac12 L\cos\alpha \right)}
19                {q \tfrac12 L\cos\alpha}
20           \frac{2 J_1 \left( qR\sin\alpha \right)}
21                {qR\sin\alpha} \\
22         &\ + (\rho_s - \rho_\text{solv}) V_s
23           \frac{\sin \left( q \left(\tfrac12 L+T\right) \cos\alpha \right)}
24                {q \left(\tfrac12 L +T \right) \cos\alpha}
25           \frac{ 2 J_1 \left( q(R+T)\sin\alpha \right)}
26                {q(R+T)\sin\alpha}
27
28and
29
30.. math::
31
32    V_s = \pi (R + T)^2 (L + 2T)
33
34and $\alpha$ is the angle between the axis of the cylinder and $\vec q$,
35$V_s$ is the volume of the outer shell (i.e. the total volume, including
36the shell), $V_c$ is the volume of the core, $L$ is the length of the core,
37$R$ is the radius of the core, $T$ is the thickness of the shell, $\rho_c$
38is the scattering length density of the core, $\rho_s$ is the scattering
39length density of the shell, $\rho_\text{solv}$ is the scattering length
40density of the solvent, and *background* is the background level.  The outer
41radius of the shell is given by $R+T$ and the total length of the outer
42shell is given by $L+2T$. $J1$ is the first order Bessel function.
43
44.. _core-shell-cylinder-geometry:
45
46.. figure:: img/core_shell_cylinder_geometry.jpg
47
48    Core shell cylinder schematic.
49
50To provide easy access to the orientation of the core-shell cylinder, we
51define the axis of the cylinder using two angles $\theta$ and $\phi$.
52(see :ref:`cylinder model <cylinder-angle-definition>`)
53
54NB: The 2nd virial coefficient of the cylinder is calculated based on
55the radius and 2 length values, and used as the effective radius for
56$S(q)$ when $P(q) \cdot S(q)$ is applied.
57
58The $\theta$ and $\phi$ parameters are not used for the 1D output.
59
60Reference
61---------
62
63.. [#] see, for example, Ian Livsey  J. Chem. Soc., Faraday Trans. 2, 1987,83,
64   1445-1452
65.. [#kline] S R Kline, *J Appl. Cryst.*, 39 (2006) 895
66
67Authorship and Verification
68----------------------------
69
70* **Author:** NIST IGOR/DANSE **Date:** pre 2010
71* **Last Modified by:** Paul Kienzle **Date:** Aug 8, 2016
72* **Last Reviewed by:** Richard Heenan **Date:** March 18, 2016
73"""
74
75from numpy import pi, inf, sin, cos
76
77name = "core_shell_cylinder"
78title = "Right circular cylinder with a core-shell scattering length density profile."
79description = """
80P(q,alpha)= scale/Vs*f(q)^(2) + background,
81      where: f(q)= 2(sld_core - solvant_sld)
82        * Vc*sin[qLcos(alpha/2)]
83        /[qLcos(alpha/2)]*J1(qRsin(alpha))
84        /[qRsin(alpha)]+2(sld_shell-sld_solvent)
85        *Vs*sin[q(L+T)cos(alpha/2)][[q(L+T)
86        *cos(alpha/2)]*J1(q(R+T)sin(alpha))
87        /q(R+T)sin(alpha)]
88
89    alpha:is the angle between the axis of
90        the cylinder and the q-vector
91    Vs: the volume of the outer shell
92    Vc: the volume of the core
93    L: the length of the core
94        sld_shell: the scattering length density of the shell
95    sld_solvent: the scattering length density of the solvent
96    background: the background
97    T: the thickness
98        R+T: is the outer radius
99     L+2T: The total length of the outershell
100    J1: the first order Bessel function
101     theta: axis_theta of the cylinder
102     phi: the axis_phi of the cylinder
103"""
104category = "shape:cylinder"
105
106#             ["name", "units", default, [lower, upper], "type", "description"],
107parameters = [["sld_core", "1e-6/Ang^2", 4, [-inf, inf], "sld",
108               "Cylinder core scattering length density"],
109              ["sld_shell", "1e-6/Ang^2", 4, [-inf, inf], "sld",
110               "Cylinder shell scattering length density"],
111              ["sld_solvent", "1e-6/Ang^2", 1, [-inf, inf], "sld",
112               "Solvent scattering length density"],
113              ["radius", "Ang", 20, [0, inf], "volume",
114               "Cylinder core radius"],
115              ["thickness", "Ang", 20, [0, inf], "volume",
116               "Cylinder shell thickness"],
117              ["length", "Ang", 400, [0, inf], "volume",
118               "Cylinder length"],
119              ["theta", "degrees", 60, [-inf, inf], "orientation",
120               "In plane angle"],
121              ["phi", "degrees", 60, [-inf, inf], "orientation",
122               "Out of plane angle"],
123             ]
124
125source = ["lib/polevl.c", "lib/sas_J1.c", "lib/gauss76.c", "core_shell_cylinder.c"]
126
127def ER(radius, thickness, length):
128    """
129    Returns the effective radius used in the S*P calculation
130    """
131    radius = radius + thickness
132    length = length + 2 * thickness
133    ddd = 0.75 * radius * (2 * radius * length + (length + radius) * (length + pi * radius))
134    return 0.5 * (ddd) ** (1. / 3.)
135
136def VR(radius, thickness, length):
137    """
138    Returns volume ratio
139    """
140    whole = pi * (radius + thickness) ** 2 * (length + 2 * thickness)
141    core = pi * radius ** 2 * length
142    return whole, whole - core
143
144demo = dict(scale=1, background=0,
145            sld_core=6, sld_shell=8, sld_solvent=1,
146            radius=45, thickness=25, length=340,
147            theta=30, phi=15,
148            radius_pd=.2, radius_pd_n=1,
149            length_pd=.2, length_pd_n=10,
150            thickness_pd=.2, thickness_pd_n=10,
151            theta_pd=15, theta_pd_n=45,
152            phi_pd=15, phi_pd_n=1)
153q = 0.1
154# april 6 2017, rkh add unit tests, NOT compared with any other calc method, assume correct!
155qx = q*cos(pi/6.0)
156qy = q*sin(pi/6.0)
157tests = [[{}, 0.075, 10.8552692237],
158        [{}, (qx, qy), 0.444618752741 ],
159        ]
160del qx, qy  # not necessary to delete, but cleaner
Note: See TracBrowser for help on using the repository browser.