source: sasmodels/sasmodels/models/capped_cylinder.py @ 485aee2

core_shell_microgelscostrafo411magnetic_modelrelease_v0.94release_v0.95ticket-1257-vesicle-productticket_1156ticket_1265_superballticket_822_more_unit_tests
Last change on this file since 485aee2 was 485aee2, checked in by Doucet, Mathieu <doucetm@…>, 9 years ago

Trying to get us starting on the right foot with code style.

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