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
RevLine 
[5d4777d]1r"""
2Definition
3----------
4
5The output of the 2D scattering intensity function for oriented core-shell
[755ecc2]6cylinders is given by (Kline, 2006 [#kline]_). The form factor is normalized
7by the particle volume.
[5d4777d]8
9.. math::
10
[fcb33e4]11    I(q,\alpha) = \frac{\text{scale}}{V_s} F^2(q,\alpha).sin(\alpha) + \text{background}
[5d4777d]12
13where
14
15.. math::
16
[fcb33e4]17    F(q,\alpha) = &\ (\rho_c - \rho_s) V_c
[eb69cce]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} \\
[19dcb933]22         &\ + (\rho_s - \rho_\text{solv}) V_s
[eb69cce]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}
[5d4777d]27
28and
29
30.. math::
31
[19dcb933]32    V_s = \pi (R + T)^2 (L + 2T)
[5d4777d]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
[19dcb933]44.. _core-shell-cylinder-geometry:
45
46.. figure:: img/core_shell_cylinder_geometry.jpg
[5d4777d]47
48    Core shell cylinder schematic.
49
50To provide easy access to the orientation of the core-shell cylinder, we
[40a87fa]51define the axis of the cylinder using two angles $\theta$ and $\phi$.
[01eece6]52(see :ref:`cylinder model <cylinder-angle-definition>`)
[5d4777d]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
[eb69cce]56$S(q)$ when $P(q) \cdot S(q)$ is applied.
[5d4777d]57
[eb69cce]58The $\theta$ and $\phi$ parameters are not used for the 1D output.
[5d4777d]59
[01eece6]60Reference
61---------
62
[755ecc2]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
[5d4777d]73"""
74
[0b56f38]75from numpy import pi, inf, sin, cos
[5d4777d]76
[19dcb933]77name = "core_shell_cylinder"
[5d4777d]78title = "Right circular cylinder with a core-shell scattering length density profile."
79description = """
80P(q,alpha)= scale/Vs*f(q)^(2) + background,
[01eece6]81      where: f(q)= 2(sld_core - solvant_sld)
[485aee2]82        * Vc*sin[qLcos(alpha/2)]
83        /[qLcos(alpha/2)]*J1(qRsin(alpha))
[01eece6]84        /[qRsin(alpha)]+2(sld_shell-sld_solvent)
[485aee2]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
[01eece6]94        sld_shell: the scattering length density of the shell
95    sld_solvent: the scattering length density of the solvent
[485aee2]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
[5d4777d]103"""
[a5d0d00]104category = "shape:cylinder"
[5d4777d]105
[485aee2]106#             ["name", "units", default, [lower, upper], "type", "description"],
[42356c8]107parameters = [["sld_core", "1e-6/Ang^2", 4, [-inf, inf], "sld",
[485aee2]108               "Cylinder core scattering length density"],
[42356c8]109              ["sld_shell", "1e-6/Ang^2", 4, [-inf, inf], "sld",
[485aee2]110               "Cylinder shell scattering length density"],
[42356c8]111              ["sld_solvent", "1e-6/Ang^2", 1, [-inf, inf], "sld",
[485aee2]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
[40a87fa]125source = ["lib/polevl.c", "lib/sas_J1.c", "lib/gauss76.c", "core_shell_cylinder.c"]
[5d4777d]126
127def ER(radius, thickness, length):
[f0aa7f8]128    """
[40a87fa]129    Returns the effective radius used in the S*P calculation
[f0aa7f8]130    """
[5d4777d]131    radius = radius + thickness
[485aee2]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.)
[5d4777d]135
136def VR(radius, thickness, length):
[f0aa7f8]137    """
[40a87fa]138    Returns volume ratio
[f0aa7f8]139    """
[485aee2]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,
[01eece6]145            sld_core=6, sld_shell=8, sld_solvent=1,
[485aee2]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)
[0b56f38]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.