source: sasmodels/sasmodels/models/cylinder.py @ 5d4777d

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

reorganize, check and update models

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