1 | r""" |
---|
2 | CylinderModel |
---|
3 | ============= |
---|
4 | |
---|
5 | This model provides the form factor for a right circular cylinder with uniform |
---|
6 | scattering length density. The form factor is normalized by the particle volume. |
---|
7 | |
---|
8 | For information about polarised and magnetic scattering, click here_. |
---|
9 | |
---|
10 | Definition |
---|
11 | ---------- |
---|
12 | |
---|
13 | The output of the 2D scattering intensity function for oriented cylinders is |
---|
14 | given by (Guinier, 1955) |
---|
15 | |
---|
16 | .. math:: |
---|
17 | |
---|
18 | P(q,\alpha) = \frac{\text{scale}}{V}f^2(q) + \text{bkg} |
---|
19 | |
---|
20 | where |
---|
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 | |
---|
28 | and $\alpha$ is the angle between the axis of the cylinder and $\vec q$, $V$ |
---|
29 | is the volume of the cylinder, $L$ is the length of the cylinder, $r$ is the |
---|
30 | radius of the cylinder, and $d\rho$ (contrast) is the scattering length density |
---|
31 | difference between the scatterer and the solvent. $J_1$ is the first order |
---|
32 | Bessel function. |
---|
33 | |
---|
34 | To provide easy access to the orientation of the cylinder, we define the |
---|
35 | axis of the cylinder using two angles $\theta$ and $\phi$. Those angles |
---|
36 | are 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 | |
---|
48 | NB: The 2nd virial coefficient of the cylinder is calculated based on the |
---|
49 | radius and length values, and used as the effective radius for $S(Q)$ |
---|
50 | when $P(Q) \cdot S(Q)$ is applied. |
---|
51 | |
---|
52 | The returned value is scaled to units of |cm^-1| and the parameters of |
---|
53 | the CylinderModel are the following: |
---|
54 | |
---|
55 | %(parameters)s |
---|
56 | |
---|
57 | The output of the 1D scattering intensity function for randomly oriented |
---|
58 | cylinders 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 | |
---|
65 | The *theta* and *phi* parameters are not used for the 1D output. Our |
---|
66 | implementation of the scattering kernel and the 1D scattering intensity |
---|
67 | use the c-library from NIST. |
---|
68 | |
---|
69 | Validation of the CylinderModel |
---|
70 | ------------------------------- |
---|
71 | |
---|
72 | Validation of our code was done by comparing the output of the 1D model |
---|
73 | to the output of the software provided by the NIST (Kline, 2006). |
---|
74 | Figure :num:`figure #CylinderModel-compare` shows a comparison of |
---|
75 | the 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 | |
---|
87 | In general, averaging over a distribution of orientations is done by |
---|
88 | evaluating 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 | |
---|
96 | where $p(\theta,\phi)$ is the probability distribution for the orientation |
---|
97 | and $P_0(q,\alpha)$ is the scattering intensity for the fully oriented |
---|
98 | system. Since we have no other software to compare the implementation of |
---|
99 | the intensity for fully oriented cylinders, we can compare the result of |
---|
100 | averaging our 2D output using a uniform distribution $p(\theta, \phi) = 1.0$. |
---|
101 | Figure :num:`figure #CylinderModel-crosscheck` shows the result of |
---|
102 | such 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 | |
---|
116 | from numpy import pi, inf |
---|
117 | |
---|
118 | name = "CylinderModel" |
---|
119 | title = "Cylinder with uniform scattering length density" |
---|
120 | source = [ "lib/J1.c", "lib/gauss76.c", "lib/cylkernel.c", "cylinder_clone.c"] |
---|
121 | parameters = [ |
---|
122 | # [ "name", "units", default, [lower, upper], "type", |
---|
123 | # "description" ], |
---|
124 | [ "sldCyl", "1/Ang^2", 4e-6, [-inf,inf], "", |
---|
125 | "Cylinder scattering length density" ], |
---|
126 | [ "sldSolv", "1/Ang^2", 1e-6, [-inf,inf], "", |
---|
127 | "Solvent scattering length density" ], |
---|
128 | [ "radius", "Ang", 20, [0, inf], "volume", |
---|
129 | "Cylinder radius" ], |
---|
130 | [ "length", "Ang", 400, [0, inf], "volume", |
---|
131 | "Cylinder length" ], |
---|
132 | [ "cyl_theta", "degrees", 60, [-inf, inf], "orientation", |
---|
133 | "In plane angle" ], |
---|
134 | [ "cyl_phi", "degrees", 60, [-inf, inf], "orientation", |
---|
135 | "Out of plane angle" ], |
---|
136 | ] |
---|
137 | description = """\ |
---|
138 | f(q)= 2*(sldCyl - sldSolv)*V*sin(qLcos(alpha/2)) |
---|
139 | /[qLcos(alpha/2)]*J1(qRsin(alpha/2))/[qRsin(alpha)] |
---|
140 | |
---|
141 | P(q,alpha)= scale/V*f(q)^(2)+background |
---|
142 | V: Volume of the cylinder |
---|
143 | R: Radius of the cylinder |
---|
144 | L: Length of the cylinder |
---|
145 | J1: The bessel function |
---|
146 | alpha: angle betweenthe axis of the |
---|
147 | cylinder and the q-vector for 1D |
---|
148 | :the ouput is P(q)=scale/V*integral |
---|
149 | from pi/2 to zero of... |
---|
150 | f(q)^(2)*sin(alpha)*dalpha+ bkg |
---|
151 | """ |
---|
152 | |
---|
153 | def ER(radius, length): |
---|
154 | ddd = 0.75*radius*(2*radius*length + (length+radius)*(length+pi*radius)) |
---|
155 | return 0.5 * (ddd)**(1./3.) |
---|
156 | |
---|