1 | # cylinder model |
---|
2 | # Note: model title and parameter table are inserted automatically |
---|
3 | r""" |
---|
4 | The form factor is normalized by the particle volume. |
---|
5 | |
---|
6 | For information about polarised and magnetic scattering, click here_. |
---|
7 | |
---|
8 | Definition |
---|
9 | ---------- |
---|
10 | |
---|
11 | The output of the 2D scattering intensity function for oriented cylinders is |
---|
12 | given by (Guinier, 1955) |
---|
13 | |
---|
14 | .. math:: |
---|
15 | |
---|
16 | P(q,\alpha) = \frac{\text{scale}}{V}f^2(q) + \text{bkg} |
---|
17 | |
---|
18 | where |
---|
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 | |
---|
26 | and $\alpha$ is the angle between the axis of the cylinder and $\vec q$, $V$ |
---|
27 | is the volume of the cylinder, $L$ is the length of the cylinder, $r$ is the |
---|
28 | radius of the cylinder, and $d\rho$ (contrast) is the scattering length density |
---|
29 | difference between the scatterer and the solvent. $J_1$ is the first order |
---|
30 | Bessel function. |
---|
31 | |
---|
32 | To provide easy access to the orientation of the cylinder, we define the |
---|
33 | axis of the cylinder using two angles $\theta$ and $\phi$. Those angles |
---|
34 | are 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 | |
---|
46 | NB: The 2nd virial coefficient of the cylinder is calculated based on the |
---|
47 | radius and length values, and used as the effective radius for $S(Q)$ |
---|
48 | when $P(Q) \cdot S(Q)$ is applied. |
---|
49 | |
---|
50 | The output of the 1D scattering intensity function for randomly oriented |
---|
51 | cylinders 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 | |
---|
58 | The *theta* and *phi* parameters are not used for the 1D output. Our |
---|
59 | implementation of the scattering kernel and the 1D scattering intensity |
---|
60 | use the c-library from NIST. |
---|
61 | |
---|
62 | Validation |
---|
63 | ---------- |
---|
64 | |
---|
65 | Validation of our code was done by comparing the output of the 1D model |
---|
66 | to the output of the software provided by the NIST (Kline, 2006). |
---|
67 | Figure :num:`figure #cylinder-compare` shows a comparison of |
---|
68 | the 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 | |
---|
80 | In general, averaging over a distribution of orientations is done by |
---|
81 | evaluating 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 | |
---|
89 | where $p(\theta,\phi)$ is the probability distribution for the orientation |
---|
90 | and $P_0(q,\alpha)$ is the scattering intensity for the fully oriented |
---|
91 | system. Since we have no other software to compare the implementation of |
---|
92 | the intensity for fully oriented cylinders, we can compare the result of |
---|
93 | averaging our 2D output using a uniform distribution $p(\theta, \phi) = 1.0$. |
---|
94 | Figure :num:`figure #cylinder-crosscheck` shows the result of |
---|
95 | such 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 | |
---|
109 | from numpy import pi, inf |
---|
110 | |
---|
111 | name = "cylinder" |
---|
112 | title = "Right circular cylinder with uniform scattering length density." |
---|
113 | description = """ |
---|
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 | |
---|
129 | parameters = [ |
---|
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 | |
---|
146 | source = [ "lib/J1.c", "lib/gauss76.c", "cylinder.c" ] |
---|
147 | |
---|
148 | def ER(radius, length): |
---|
149 | ddd = 0.75*radius*(2*radius*length + (length+radius)*(length+pi*radius)) |
---|
150 | return 0.5 * (ddd)**(1./3.) |
---|
151 | |
---|