source: sasmodels/sasmodels/models/capped_cylinder.py @ 50e1e40

core_shell_microgelscostrafo411magnetic_modelrelease_v0.94release_v0.95ticket-1257-vesicle-productticket_1156ticket_1265_superballticket_822_more_unit_tests
Last change on this file since 50e1e40 was 50e1e40, checked in by Paul Kienzle <pkienzle@…>, 8 years ago

use lib functions to simplify barbell, capped_cylinder, cylinder, ellipsoid, triaxial_ellipsoid; fix barbell calculation

  • Property mode set to 100644
File size: 6.2 KB
RevLine 
[5d4777d]1r"""
2Calculates the scattering from a cylinder with spherical section end-caps.
[eb69cce]3Like :ref:`barbell`, this is a sphereocylinder with end caps that have a
4radius larger than that of the cylinder, but with the center of the end cap
5radius lying within the cylinder. This model simply becomes the a convex
6lens when the length of the cylinder $L=0$. See the diagram for the details
7of the geometry and restrictions on parameter values.
[5d4777d]8
9Definitions
10-----------
11
[eb69cce]12.. figure:: img/capped_cylinder_geometry.jpg
[5d4777d]13
[eb69cce]14    Capped cylinder geometry, where $r$ is *radius*, $R$ is *bell_radius* and
15    $L$ is *length*. Since the end cap radius $R \geq r$ and by definition
16    for this geometry $h < 0$, $h$ is then defined by $r$ and $R$ as
17    $h = - \sqrt{R^2 - r^2}$
[5d4777d]18
[eb69cce]19The scattered intensity $I(q)$ is calculated as
[5d4777d]20
21.. math::
22
[eb69cce]23    I(q) = \frac{\Delta \rho^2}{V} \left<A^2(q)\right>
[5d4777d]24
[eb69cce]25where the amplitude $A(q)$ is given as
[5d4777d]26
27.. math::
28
[eb69cce]29    A(q) =&\ \pi r^2L
30        \frac{\sin\left(\tfrac12 qL\cos\theta\right)}
31            {\tfrac12 qL\cos\theta}
32        \frac{2 J_1(qr\sin\theta)}{qr\sin\theta} \\
[19dcb933]33        &\ + 4 \pi R^3 \int_{-h/R}^1 dt
[eb69cce]34        \cos\left[ q\cos\theta
[19dcb933]35            \left(Rt + h + {\tfrac12} L\right)\right]
36        \times (1-t^2)
[eb69cce]37        \frac{J_1\left[qR\sin\theta \left(1-t^2\right)^{1/2}\right]}
38             {qR\sin\theta \left(1-t^2\right)^{1/2}}
[5d4777d]39
[eb69cce]40The $\left<\ldots\right>$ brackets denote an average of the structure over
41all orientations. $\left< A^2(q)\right>$ is then the form factor, $P(q)$.
[5d4777d]42The scale factor is equivalent to the volume fraction of cylinders, each of
[eb69cce]43volume, $V$. Contrast $\Delta\rho$ is the difference of scattering length
44densities of the cylinder and the surrounding solvent.
[5d4777d]45
46The volume of the capped cylinder is (with $h$ as a positive value here)
47
48.. math::
49
[19dcb933]50    V = \pi r_c^2 L + \tfrac{2\pi}{3}(R-h)^2(2R + h)
[5d4777d]51
52
[eb69cce]53and its radius of gyration is
[5d4777d]54
[19dcb933]55.. math::
56
57    R_g^2 =&\ \left[ \tfrac{12}{5}R^5
58        + R^4\left(6h+\tfrac32 L\right)
59        + R^2\left(4h^2 + L^2 + 4Lh\right)
60        + R^2\left(3Lh^2 + \tfrac32 L^2h\right) \right. \\
61        &\ \left. + \tfrac25 h^5 - \tfrac12 Lh^4 - \tfrac12 L^2h^3
62        + \tfrac14 L^3r^2 + \tfrac32 Lr^4 \right]
63        \left( 4R^3 6R^2h - 2h^3 + 3r^2L \right)^{-1}
64
[5d4777d]65
[19dcb933]66.. note::
[5d4777d]67
[eb69cce]68    The requirement that $R \geq r$ is not enforced in the model!
[19dcb933]69    It is up to you to restrict this during analysis.
[5d4777d]70
[19dcb933]71:num:`Figure #capped-cylinder-1d` shows the output produced by
[5d4777d]72a running the 1D capped cylinder model, using *qmin* = 0.001 |Ang^-1|,
73*qmax* = 0.7 |Ang^-1| and  the default values of the parameters.
74
75.. _capped-cylinder-1d:
76
[19dcb933]77.. figure:: img/capped_cylinder_1d.jpg
[5d4777d]78
79    1D plot using the default values (w/256 data point).
80
81The 2D scattering intensity is calculated similar to the 2D cylinder model.
[19dcb933]82:num:`Figure #capped-cylinder-2d` shows the output for $\theta=45^\circ$
[5d4777d]83and $\phi=0^\circ$ with default values for the other parameters.
84
85.. _capped-cylinder-2d:
86
[19dcb933]87.. figure:: img/capped_cylinder_2d.jpg
[5d4777d]88
89    2D plot (w/(256X265) data points).
90
[19dcb933]91.. figure:: img/orientation.jpg
[5d4777d]92
93    Definition of the angles for oriented 2D cylinders.
94
[19dcb933]95.. figure:: img/orientation2.jpg
[5d4777d]96
97    Examples of the angles for oriented pp against the detector plane.
98
[eb69cce]99References
100----------
[5d4777d]101
102H Kaya, *J. Appl. Cryst.*, 37 (2004) 223-230
103
104H Kaya and N-R deSouza, *J. Appl. Cryst.*, 37 (2004) 508-509 (addenda and errata)
105"""
106from numpy import inf
107
108name = "capped_cylinder"
109title = "Right circular cylinder with spherical end caps and uniform SLD"
110description = """That is, a sphereocylinder
[485aee2]111    with end caps that have a radius larger than
112    that of the cylinder and the center of the
113    end cap radius lies within the cylinder.
114    Note: As the length of cylinder -->0,
115    it becomes a ConvexLens.
116    It must be that radius <(=) cap_radius.
117    [Parameters];
118    scale: volume fraction of spheres,
119    background:incoherent background,
120    radius: radius of the cylinder,
121    length: length of the cylinder,
122    cap_radius: radius of the semi-spherical cap,
123    sld: SLD of the capped cylinder,
124    solvent_sld: SLD of the solvent.
[5d4777d]125"""
[a5d0d00]126category = "shape:cylinder"
[dcdf29d]127# pylint: disable=bad-whitespace, line-too-long
[485aee2]128#             ["name", "units", default, [lower, upper], "type", "description"],
[dcdf29d]129parameters = [["sld",         "1e-6/Ang^2", 4, [-inf, inf], "",       "Cylinder scattering length density"],
130              ["solvent_sld", "1e-6/Ang^2", 1, [-inf, inf], "",       "Solvent scattering length density"],
131              ["radius",      "Ang",       20, [0, inf],    "volume", "Cylinder radius"],
132
[485aee2]133              # TODO: use an expression for cap radius with fixed bounds.
134              # The current form requires cap radius R bigger than cylinder radius r.
135              # Could instead use R/r in [1,inf], r/R in [0,1], or the angle between
136              # cylinder and cap in [0,90].  The problem is similar for the barbell
137              # model.  Propose r/R in [0,1] in both cases, with the model specifying
138              # cylinder radius in the capped cylinder model and sphere radius in the
139              # barbell model.  This leads to the natural value of zero for no cap
140              # in the capped cylinder, and zero for no bar in the barbell model.  In
141              # both models, one would be a pill.
[dcdf29d]142              ["cap_radius", "Ang",     20, [0, inf],    "volume", "Cap radius"],
143              ["length",     "Ang",    400, [0, inf],    "volume", "Cylinder length"],
144              ["theta",      "degrees", 60, [-inf, inf], "orientation", "In plane angle"],
145              ["phi",        "degrees", 60, [-inf, inf], "orientation", "Out of plane angle"],
[485aee2]146             ]
[dcdf29d]147# pylint: enable=bad-whitespace, line-too-long
[485aee2]148
[50e1e40]149source = ["lib/J1c.c", "lib/gauss76.c", "capped_cylinder.c"]
[485aee2]150
151demo = dict(scale=1, background=0,
152            sld=6, solvent_sld=1,
153            radius=260, cap_radius=290, length=290,
154            theta=30, phi=15,
155            radius_pd=.2, radius_pd_n=1,
156            cap_radius_pd=.2, cap_radius_pd_n=1,
157            length_pd=.2, length_pd_n=10,
158            theta_pd=15, theta_pd_n=45,
159            phi_pd=15, phi_pd_n=1)
[a503bfd]160oldname = 'CappedCylinderModel'
[dcdf29d]161oldpars = dict(sld='sld_capcyl',
162               solvent_sld='sld_solv',
163               length='len_cyl',
164               radius='rad_cyl',
165               cap_radius='rad_cap')
Note: See TracBrowser for help on using the repository browser.