1 | r""" |
---|
2 | Calculates the scattering from a cylinder with spherical section end-caps. |
---|
3 | Like :ref:`barbell`, this is a sphereocylinder with end caps that have a |
---|
4 | radius larger than that of the cylinder, but with the center of the end cap |
---|
5 | radius lying within the cylinder. This model simply becomes a convex |
---|
6 | lens when the length of the cylinder $L=0$. See the diagram for the details |
---|
7 | of the geometry and restrictions on parameter values. |
---|
8 | |
---|
9 | Definitions |
---|
10 | ----------- |
---|
11 | |
---|
12 | .. figure:: img/capped_cylinder_geometry.jpg |
---|
13 | |
---|
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}$ |
---|
18 | |
---|
19 | The scattered intensity $I(q)$ is calculated as |
---|
20 | |
---|
21 | .. math:: |
---|
22 | |
---|
23 | I(q) = \frac{\Delta \rho^2}{V} \left<A^2(q)\right> |
---|
24 | |
---|
25 | where the amplitude $A(q)$ is given as |
---|
26 | |
---|
27 | .. math:: |
---|
28 | |
---|
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} \\ |
---|
33 | &\ + 4 \pi R^3 \int_{-h/R}^1 dt |
---|
34 | \cos\left[ q\cos\theta |
---|
35 | \left(Rt + h + {\tfrac12} L\right)\right] |
---|
36 | \times (1-t^2) |
---|
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}} |
---|
39 | |
---|
40 | The $\left<\ldots\right>$ brackets denote an average of the structure over |
---|
41 | all orientations. $\left< A^2(q)\right>$ is then the form factor, $P(q)$. |
---|
42 | The scale factor is equivalent to the volume fraction of cylinders, each of |
---|
43 | volume, $V$. Contrast $\Delta\rho$ is the difference of scattering length |
---|
44 | densities of the cylinder and the surrounding solvent. |
---|
45 | |
---|
46 | The volume of the capped cylinder is (with $h$ as a positive value here) |
---|
47 | |
---|
48 | .. math:: |
---|
49 | |
---|
50 | V = \pi r_c^2 L + \tfrac{2\pi}{3}(R-h)^2(2R + h) |
---|
51 | |
---|
52 | |
---|
53 | and its radius of gyration is |
---|
54 | |
---|
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 | |
---|
65 | |
---|
66 | .. note:: |
---|
67 | |
---|
68 | The requirement that $R \geq r$ is not enforced in the model! |
---|
69 | It is up to you to restrict this during analysis. |
---|
70 | |
---|
71 | The 2D scattering intensity is calculated similar to the 2D cylinder model. |
---|
72 | |
---|
73 | .. figure:: img/cylinder_angle_definition.jpg |
---|
74 | |
---|
75 | Definition of the angles for oriented 2D cylinders. |
---|
76 | |
---|
77 | .. figure:: img/cylinder_angle_projection.jpg |
---|
78 | |
---|
79 | Examples of the angles for oriented 2D cylinders against the detector plane. |
---|
80 | |
---|
81 | References |
---|
82 | ---------- |
---|
83 | |
---|
84 | H Kaya, *J. Appl. Cryst.*, 37 (2004) 223-230 |
---|
85 | |
---|
86 | H Kaya and N-R deSouza, *J. Appl. Cryst.*, 37 (2004) 508-509 (addenda and errata) |
---|
87 | """ |
---|
88 | from numpy import inf |
---|
89 | |
---|
90 | name = "capped_cylinder" |
---|
91 | title = "Right circular cylinder with spherical end caps and uniform SLD" |
---|
92 | description = """That is, a sphereocylinder |
---|
93 | with end caps that have a radius larger than |
---|
94 | that of the cylinder and the center of the |
---|
95 | end cap radius lies within the cylinder. |
---|
96 | Note: As the length of cylinder -->0, |
---|
97 | it becomes a Convex Lens. |
---|
98 | It must be that radius <(=) cap_radius. |
---|
99 | [Parameters]; |
---|
100 | scale: volume fraction of spheres, |
---|
101 | background:incoherent background, |
---|
102 | radius: radius of the cylinder, |
---|
103 | length: length of the cylinder, |
---|
104 | cap_radius: radius of the semi-spherical cap, |
---|
105 | sld: SLD of the capped cylinder, |
---|
106 | sld_solvent: SLD of the solvent. |
---|
107 | """ |
---|
108 | category = "shape:cylinder" |
---|
109 | # pylint: disable=bad-whitespace, line-too-long |
---|
110 | # ["name", "units", default, [lower, upper], "type", "description"], |
---|
111 | parameters = [["sld", "1e-6/Ang^2", 4, [-inf, inf], "", "Cylinder scattering length density"], |
---|
112 | ["sld_solvent", "1e-6/Ang^2", 1, [-inf, inf], "", "Solvent scattering length density"], |
---|
113 | ["radius", "Ang", 20, [0, inf], "volume", "Cylinder radius"], |
---|
114 | |
---|
115 | # TODO: use an expression for cap radius with fixed bounds. |
---|
116 | # The current form requires cap radius R bigger than cylinder radius r. |
---|
117 | # Could instead use R/r in [1,inf], r/R in [0,1], or the angle between |
---|
118 | # cylinder and cap in [0,90]. The problem is similar for the barbell |
---|
119 | # model. Propose r/R in [0,1] in both cases, with the model specifying |
---|
120 | # cylinder radius in the capped cylinder model and sphere radius in the |
---|
121 | # barbell model. This leads to the natural value of zero for no cap |
---|
122 | # in the capped cylinder, and zero for no bar in the barbell model. In |
---|
123 | # both models, one would be a pill. |
---|
124 | ["cap_radius", "Ang", 20, [0, inf], "volume", "Cap radius"], |
---|
125 | ["length", "Ang", 400, [0, inf], "volume", "Cylinder length"], |
---|
126 | ["theta", "degrees", 60, [-inf, inf], "orientation", "In plane angle"], |
---|
127 | ["phi", "degrees", 60, [-inf, inf], "orientation", "Out of plane angle"], |
---|
128 | ] |
---|
129 | # pylint: enable=bad-whitespace, line-too-long |
---|
130 | |
---|
131 | source = ["lib/polevl.c", "lib/sas_J1.c", "lib/gauss76.c", "capped_cylinder.c"] |
---|
132 | |
---|
133 | demo = dict(scale=1, background=0, |
---|
134 | sld=6, sld_solvent=1, |
---|
135 | radius=260, cap_radius=290, length=290, |
---|
136 | theta=30, phi=15, |
---|
137 | radius_pd=.2, radius_pd_n=1, |
---|
138 | cap_radius_pd=.2, cap_radius_pd_n=1, |
---|
139 | length_pd=.2, length_pd_n=10, |
---|
140 | theta_pd=15, theta_pd_n=45, |
---|
141 | phi_pd=15, phi_pd_n=1) |
---|