source: sasmodels/sasmodels/models/capped_cylinder.py @ f4cf580

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

resolve remaining differences between sasview and sasmodels

  • Property mode set to 100644
File size: 5.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/image112.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 \frac{sin(Q(L/2) \cos \theta)}{Q(L/2) \cos \theta} \
37        \frac{2 J_1(Q r \sin \theta)}{Q r \sin \theta} \
38        + 4 \pi R^3 \int_{-h/R}^1{dt \cos [ Q cos\theta (Rt + h + L/2)] \
39        x (1-t^2)\frac{J_1[Q R \sin \theta (1-t^2)^{1/2}]}{Q R \sin \theta (1-t^2)^{1/2}
40
41The $\left< \ldots \right>$ brackets denote an average of the structure over
42all orientations. $\left< A^2(q)\right>$ is then the form factor, $P(q)$.
43The scale factor is equivalent to the volume fraction of cylinders, each of
44volume, $V$. Contrast is the difference of scattering length densities of
45the cylinder and the surrounding solvent.
46
47The volume of the capped cylinder is (with $h$ as a positive value here)
48
49.. math::
50
51    V = \pi r_c^2 L + \frac{2\pi}{3}(R-h)^2(2R + h)
52
53
54and its radius-of-gyration is
55
56    R_g^2 = \left[ \frac{12}{5}R^5 + R^4(6h+\frac{3}{2}L) \
57        + R^2(4h^2 + L^2 + 4Lh) + R^2(3Lh^2 + [frac{3}{2}L^2h) \
58        + \frac{2}{5}h^5 - \frac{1}{2}Lh^4 - \frac{1}{2}L^2h^3 \
59        + \frac{1}{4}L^3r^2 + \frac{3}{2}Lr^4\right] \
60        (4R^3 6R^2h - 2h^3 + 3r^2L)^{-1}
61
62
63**The requirement that $R \ge r$ is not enforced in the model! It is up to
64you to restrict this during analysis.**
65
66Figure :num:`figure #capped-cylinder-1d` shows the output produced by
67a running the 1D capped cylinder model, using *qmin* = 0.001 |Ang^-1|,
68*qmax* = 0.7 |Ang^-1| and  the default values of the parameters.
69
70.. _capped-cylinder-1d:
71
72.. figure:: img/image117.jpg
73
74    1D plot using the default values (w/256 data point).
75
76The 2D scattering intensity is calculated similar to the 2D cylinder model.
77Figure :num:`figure #capped-cylinder-2d` shows the output for $\theta=45^\circ$
78and $\phi=0^\circ$ with default values for the other parameters.
79
80.. _capped-cylinder-2d:
81
82.. figure:: img/image118.JPG
83
84    2D plot (w/(256X265) data points).
85
86.. figure:: img/image061.JPG
87
88    Definition of the angles for oriented 2D cylinders.
89
90.. figure:: img/image062.jpg
91
92    Examples of the angles for oriented pp against the detector plane.
93
94REFERENCE
95
96H Kaya, *J. Appl. Cryst.*, 37 (2004) 223-230
97
98H Kaya and N-R deSouza, *J. Appl. Cryst.*, 37 (2004) 508-509 (addenda and errata)
99"""
100from numpy import inf
101
102name = "capped_cylinder"
103title = "Right circular cylinder with spherical end caps and uniform SLD"
104description = """That is, a sphereocylinder
105        with end caps that have a radius larger than
106        that of the cylinder and the center of the
107        end cap radius lies within the cylinder.
108        Note: As the length of cylinder -->0,
109        it becomes a ConvexLens.
110        It must be that radius <(=) cap_radius.
111        [Parameters];
112        scale: volume fraction of spheres,
113        background:incoherent background,
114        radius: radius of the cylinder,
115        length: length of the cylinder,
116        cap_radius: radius of the semi-spherical cap,
117        sld: SLD of the capped cylinder,
118        solvent_sld: SLD of the solvent.
119"""
120
121parameters = [
122    #   [ "name", "units", default, [lower, upper], "type",
123    #     "description" ],
124    [ "sld", "1e-6/Ang^2", 4, [-inf,inf], "",
125      "Cylinder scattering length density" ],
126    [ "solvent_sld", "1e-6/Ang^2", 1, [-inf,inf], "",
127      "Solvent scattering length density" ],
128    [ "radius", "Ang",  20, [0, inf], "volume",
129      "Cylinder radius" ],
130    # TODO: use an expression for cap radius with fixed bounds.
131    # The current form requires cap radius R bigger than cylinder radius r.
132    # Could instead use R/r in [1,inf], r/R in [0,1], or the angle between
133    # cylinder and cap in [0,90].  The problem is similar for the barbell
134    # model.  Propose r/R in [0,1] in both cases, with the model specifying
135    # cylinder radius in the capped cylinder model and sphere radius in the
136    # barbell model.  This leads to the natural value of zero for no cap
137    # in the capped cylinder, and zero for no bar in the barbell model.  In
138    # both models, one would be a pill.
139    [ "cap_radius", "Ang", 20, [0, inf], "volume",
140      "Cap radius" ],
141    [ "length", "Ang",  400, [0, inf], "volume",
142      "Cylinder length" ],
143    [ "theta", "degrees", 60, [-inf, inf], "orientation",
144      "In plane angle" ],
145    [ "phi", "degrees", 60, [-inf, inf], "orientation",
146      "Out of plane angle" ],
147    ]
148
149source = [ "lib/J1.c", "lib/gauss76.c", "capped_cylinder.c" ]
150
151
152
Note: See TracBrowser for help on using the repository browser.