source: sasmodels/sasmodels/models/cylinder_clone.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.2 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
118name = "CylinderModel"
119title = "Cylinder with uniform scattering length density"
120description = """\
121         f(q)= 2*(sldCyl - sldSolv)*V*sin(qLcos(alpha/2))
122                /[qLcos(alpha/2)]*J1(qRsin(alpha/2))/[qRsin(alpha)]
123
124                P(q,alpha)= scale/V*f(q)^(2)+background
125                V: Volume of the cylinder
126                R: Radius of the cylinder
127                L: Length of the cylinder
128                J1: The bessel function
129                alpha: angle betweenthe axis of the
130                cylinder and the q-vector for 1D
131                :the ouput is P(q)=scale/V*integral
132                from pi/2 to zero of...
133                f(q)^(2)*sin(alpha)*dalpha+ bkg
134"""
135
136parameters = [
137    #   [ "name", "units", default, [lower, upper], "type",
138    #     "description" ],
139    [ "sldCyl", "1/Ang^2", 4e-6, [-inf,inf], "",
140      "Cylinder scattering length density" ],
141    [ "sldSolv", "1/Ang^2", 1e-6, [-inf,inf], "",
142      "Solvent scattering length density" ],
143    [ "radius", "Ang",  20, [0, inf], "volume",
144      "Cylinder radius" ],
145    [ "length", "Ang",  400, [0, inf], "volume",
146      "Cylinder length" ],
147    [ "cyl_theta", "degrees", 60, [-inf, inf], "orientation",
148      "In plane angle" ],
149    [ "cyl_phi", "degrees", 60, [-inf, inf], "orientation",
150      "Out of plane angle" ],
151    ]
152source = [ "lib/J1.c", "lib/gauss76.c", "cylinder_clone.c" ]
153
154def ER(radius, length):
155    ddd = 0.75*radius*(2*radius*length + (length+radius)*(length+pi*radius))
156    return 0.5 * (ddd)**(1./3.)
157
Note: See TracBrowser for help on using the repository browser.