source: sasmodels/sasmodels/models/cylinder.py @ 32c160a

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

support ER/VR python kernels; move metadata to python

  • Property mode set to 100644
File size: 5.3 KB
Line 
1r"""
2CylinderModel
3=============
4
5This model provides the form factor for a right circular cylinder with uniform
6scattering length density. The form factor is normalized by the particle volume.
7
8For information about polarised and magnetic scattering, click here_.
9
10Definition
11----------
12
13The output of the 2D scattering intensity function for oriented cylinders is
14given by (Guinier, 1955)
15
16.. math::
17
18    P(q,\alpha) = \frac{\text{scale}}{V}f^2(q) + \text{bkg}
19
20where
21
22.. math::
23
24    f(q) = 2 (\Delta \rho) V
25           \frac{\sin (q L/2 \cos \alpha)}{q L/2 \cos \alpha}
26           \frac{J_1 (q r \sin \alpha)}{q r \sin \alpha}
27
28and $\alpha$ is the angle between the axis of the cylinder and $\vec q$, $V$
29is the volume of the cylinder, $L$ is the length of the cylinder, $r$ is the
30radius of the cylinder, and $d\rho$ (contrast) is the scattering length density
31difference between the scatterer and the solvent. $J_1$ is the first order
32Bessel function.
33
34To provide easy access to the orientation of the cylinder, we define the
35axis of the cylinder using two angles $\theta$ and $\phi$. Those angles
36are defined in Figure :num:`figure #CylinderModel-orientation`.
37
38.. _CylinderModel-orientation:
39
40.. figure:: img/image061.JPG
41
42    Definition of the angles for oriented cylinders.
43
44.. figure:: img/image062.JPG
45
46    Examples of the angles for oriented pp against the detector plane.
47
48NB: The 2nd virial coefficient of the cylinder is calculated based on the
49radius and length values, and used as the effective radius for $S(Q)$
50when $P(Q) \cdot S(Q)$ is applied.
51
52The returned value is scaled to units of |cm^-1| and the parameters of
53the CylinderModel are the following:
54
55%(parameters)s
56
57The output of the 1D scattering intensity function for randomly oriented
58cylinders is then given by
59
60.. math::
61
62    P(q) = \frac{\text{scale}}{V}
63        \int_0^{\pi/2} f^2(q,\alpha) \sin \alpha d\alpha + \text{background}
64
65The *theta* and *phi* parameters are not used for the 1D output. Our
66implementation of the scattering kernel and the 1D scattering intensity
67use the c-library from NIST.
68
69Validation of the CylinderModel
70-------------------------------
71
72Validation of our code was done by comparing the output of the 1D model
73to the output of the software provided by the NIST (Kline, 2006).
74Figure :num:`figure #CylinderModel-compare` shows a comparison of
75the 1D output of our model and the output of the NIST software.
76
77.. _CylinderModel-compare:
78
79.. figure:: img/image065.JPG
80
81    Comparison of the SasView scattering intensity for a cylinder with the
82    output of the NIST SANS analysis software.
83    The parameters were set to: *Scale* = 1.0, *Radius* = 20 |Ang|,
84    *Length* = 400 |Ang|, *Contrast* = 3e-6 |Ang^-2|, and
85    *Background* = 0.01 |cm^-1|.
86
87In general, averaging over a distribution of orientations is done by
88evaluating the following
89
90.. math::
91
92    P(q) = \int_0^{\pi/2} d\phi
93        \int_0^\pi p(\theta, \phi) P_0(q,\alpha) \sin \theta d\theta
94
95
96where $p(\theta,\phi)$ is the probability distribution for the orientation
97and $P_0(q,\alpha)$ is the scattering intensity for the fully oriented
98system. Since we have no other software to compare the implementation of
99the intensity for fully oriented cylinders, we can compare the result of
100averaging our 2D output using a uniform distribution $p(\theta, \phi) = 1.0$.
101Figure :num:`figure #CylinderModel-crosscheck` shows the result of
102such a cross-check.
103
104.. _CylinderModel-crosscheck:
105
106.. figure:: img/image066.JPG
107
108    Comparison of the intensity for uniformly distributed cylinders
109    calculated from our 2D model and the intensity from the NIST SANS
110    analysis software.
111    The parameters used were: *Scale* = 1.0, *Radius* = 20 |Ang|,
112    *Length* = 400 |Ang|, *Contrast* = 3e-6 |Ang^-2|, and
113    *Background* = 0.0 |cm^-1|.
114"""
115
116from numpy import pi, inf
117
118def ER(radius, length):
119    ddd = 0.75*radius*(2*radius*length + (length+radius)*(length+pi*radius))
120    return 0.5 * (ddd)**(1./3.)
121
122INFO = {
123    "name": "cylinder",
124    "title": "Cylinder with uniform scattering length density",
125    "source": [ "lib/J1.c", "lib/gauss76.c", "lib/cylkernel.c", "cylinder.c"],
126    "parameters": [
127    #   [ "name", "units", default, [lower, upper], "type",
128    #     "description" ],
129        [ "sld", "1e-6/Ang^2", 4, [-inf,inf], "",
130          "Cylinder scattering length density" ],
131        [ "solvent_sld", "1e-6/Ang^2", 1, [-inf,inf], "",
132          "Solvent scattering length density" ],
133        [ "radius", "Ang",  20, [0, inf], "volume",
134          "Cylinder radius" ],
135        [ "length", "Ang",  400, [0, inf], "volume",
136          "Cylinder length" ],
137        [ "theta", "degrees", 60, [-inf, inf], "orientation",
138          "In plane angle" ],
139        [ "phi", "degrees", 60, [-inf, inf], "orientation",
140          "Out of plane angle" ],
141        ],
142    "description": """
143         f(q)= 2*(sldCyl - sldSolv)*V*sin(qLcos(alpha/2))
144                /[qLcos(alpha/2)]*J1(qRsin(alpha/2))/[qRsin(alpha)]
145
146                P(q,alpha)= scale/V*f(q)^(2)+background
147                V: Volume of the cylinder
148                R: Radius of the cylinder
149                L: Length of the cylinder
150                J1: The bessel function
151                alpha: angle betweenthe axis of the
152                cylinder and the q-vector for 1D
153                :the ouput is P(q)=scale/V*integral
154                from pi/2 to zero of...
155                f(q)^(2)*sin(alpha)*dalpha+ bkg
156        """,
157    "ER": ER,
158    }
159
Note: See TracBrowser for help on using the repository browser.