[5933c7f] | 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 V = \piR^2L. |
---|
[9f60c06] | 5 | For information about polarised and magnetic scattering, see |
---|
[9a4811a] | 6 | the :ref:`magnetism` documentation. |
---|
[5933c7f] | 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{background} |
---|
| 17 | |
---|
| 18 | where |
---|
| 19 | |
---|
| 20 | .. math:: |
---|
| 21 | |
---|
| 22 | F(q) = 2 (\Delta \rho) V |
---|
| 23 | \frac{\sin \left(\tfrac12 qL\cos\alpha \right)} |
---|
| 24 | {\tfrac12 qL \cos \alpha} |
---|
| 25 | \frac{J_1 \left(q R \sin \alpha\right)}{q R \sin \alpha} |
---|
| 26 | |
---|
| 27 | and $\alpha$ is the angle between the axis of the cylinder and $\vec q$, $V$ |
---|
| 28 | is the volume of the cylinder, $L$ is the length of the cylinder, $R$ is the |
---|
| 29 | radius of the cylinder, and $\Delta\rho$ (contrast) is the scattering length |
---|
| 30 | density difference between the scatterer and the solvent. $J_1$ is the |
---|
| 31 | first order Bessel function. |
---|
| 32 | |
---|
| 33 | To provide easy access to the orientation of the cylinder, we define the |
---|
| 34 | axis of the cylinder using two angles $\theta$ and $\phi$. Those angles |
---|
[6ef4293] | 35 | are defined in :numref:`cylinder-angle-definition`. |
---|
[5933c7f] | 36 | |
---|
| 37 | .. _cylinder-angle-definition: |
---|
| 38 | |
---|
| 39 | .. figure:: img/cylinder_angle_definition.jpg |
---|
| 40 | |
---|
| 41 | Definition of the angles for oriented cylinders. |
---|
| 42 | |
---|
| 43 | .. figure:: img/cylinder_angle_projection.jpg |
---|
| 44 | |
---|
| 45 | Examples of the angles for oriented cylinders against the detector plane. |
---|
| 46 | |
---|
| 47 | NB: The 2nd virial coefficient of the cylinder is calculated based on the |
---|
| 48 | radius and length values, and used as the effective radius for $S(q)$ |
---|
| 49 | when $P(q) \cdot S(q)$ is applied. |
---|
| 50 | |
---|
| 51 | The output of the 1D scattering intensity function for randomly oriented |
---|
| 52 | cylinders is then given by |
---|
| 53 | |
---|
| 54 | .. math:: |
---|
| 55 | |
---|
| 56 | P(q) = \frac{\text{scale}}{V} |
---|
| 57 | \int_0^{\pi/2} F^2(q,\alpha) \sin \alpha\ d\alpha + \text{background} |
---|
| 58 | |
---|
| 59 | The $\theta$ and $\phi$ parameters are not used for the 1D output. |
---|
| 60 | |
---|
| 61 | Validation |
---|
| 62 | ---------- |
---|
| 63 | |
---|
| 64 | Validation of the code was done by comparing the output of the 1D model |
---|
| 65 | to the output of the software provided by the NIST (Kline, 2006). |
---|
| 66 | The implementation of the intensity for fully oriented cylinders was done |
---|
| 67 | by averaging over a uniform distribution of orientations using |
---|
| 68 | |
---|
| 69 | .. math:: |
---|
| 70 | |
---|
| 71 | P(q) = \int_0^{\pi/2} d\phi |
---|
| 72 | \int_0^\pi p(\theta, \phi) P_0(q,\alpha) \sin \theta\ d\theta |
---|
| 73 | |
---|
| 74 | |
---|
| 75 | where $p(\theta,\phi)$ is the probability distribution for the orientation |
---|
| 76 | and $P_0(q,\alpha)$ is the scattering intensity for the fully oriented |
---|
| 77 | system, and then comparing to the 1D result. |
---|
| 78 | |
---|
| 79 | References |
---|
| 80 | ---------- |
---|
| 81 | |
---|
| 82 | None |
---|
| 83 | |
---|
| 84 | """ |
---|
| 85 | |
---|
[7ae2b7f] | 86 | import numpy as np # type: ignore |
---|
| 87 | from numpy import pi, inf # type: ignore |
---|
[5933c7f] | 88 | |
---|
| 89 | name = "cylinder" |
---|
| 90 | title = "Right circular cylinder with uniform scattering length density." |
---|
| 91 | description = """ |
---|
| 92 | f(q,alpha) = 2*(sld - sld_solvent)*V*sin(qLcos(alpha)/2)) |
---|
| 93 | /[qLcos(alpha)/2]*J1(qRsin(alpha))/[qRsin(alpha)] |
---|
| 94 | |
---|
| 95 | P(q,alpha)= scale/V*f(q,alpha)^(2)+background |
---|
| 96 | V: Volume of the cylinder |
---|
| 97 | R: Radius of the cylinder |
---|
| 98 | L: Length of the cylinder |
---|
| 99 | J1: The bessel function |
---|
| 100 | alpha: angle between the axis of the |
---|
| 101 | cylinder and the q-vector for 1D |
---|
| 102 | :the ouput is P(q)=scale/V*integral |
---|
| 103 | from pi/2 to zero of... |
---|
| 104 | f(q,alpha)^(2)*sin(alpha)*dalpha + background |
---|
| 105 | """ |
---|
[a557a99] | 106 | #opencl=False |
---|
[5933c7f] | 107 | category = "shape:cylinder" |
---|
| 108 | |
---|
| 109 | # [ "name", "units", default, [lower, upper], "type", "description"], |
---|
[42356c8] | 110 | parameters = [["sld", "4e-6/Ang^2", 4, [-inf, inf], "sld", |
---|
[5933c7f] | 111 | "Cylinder scattering length density"], |
---|
[42356c8] | 112 | ["sld_solvent", "1e-6/Ang^2", 1, [-inf, inf], "sld", |
---|
[5933c7f] | 113 | "Solvent scattering length density"], |
---|
| 114 | ["radius", "Ang", 20, [0, inf], "volume", |
---|
| 115 | "Cylinder radius"], |
---|
| 116 | ["length", "Ang", 400, [0, inf], "volume", |
---|
| 117 | "Cylinder length"], |
---|
| 118 | ["theta", "degrees", 60, [-inf, inf], "orientation", |
---|
| 119 | "In plane angle"], |
---|
| 120 | ["phi", "degrees", 60, [-inf, inf], "orientation", |
---|
| 121 | "Out of plane angle"], |
---|
| 122 | ] |
---|
| 123 | |
---|
[40a87fa] | 124 | source = ["lib/polevl.c", "lib/sas_J1.c", "lib/gauss76.c", "cylinder.c"] |
---|
[5933c7f] | 125 | |
---|
| 126 | def ER(radius, length): |
---|
| 127 | """ |
---|
| 128 | Return equivalent radius (ER) |
---|
| 129 | """ |
---|
| 130 | ddd = 0.75 * radius * (2 * radius * length + (length + radius) * (length + pi * radius)) |
---|
| 131 | return 0.5 * (ddd) ** (1. / 3.) |
---|
| 132 | |
---|
| 133 | # parameters for demo |
---|
| 134 | demo = dict(scale=1, background=0, |
---|
| 135 | sld=6, sld_solvent=1, |
---|
| 136 | radius=20, length=300, |
---|
| 137 | theta=60, phi=60, |
---|
| 138 | radius_pd=.2, radius_pd_n=9, |
---|
| 139 | length_pd=.2, length_pd_n=10, |
---|
| 140 | theta_pd=10, theta_pd_n=5, |
---|
| 141 | phi_pd=10, phi_pd_n=5) |
---|
| 142 | |
---|
| 143 | qx, qy = 0.2 * np.cos(2.5), 0.2 * np.sin(2.5) |
---|
| 144 | tests = [[{}, 0.2, 0.042761386790780453], |
---|
| 145 | [{}, [0.2], [0.042761386790780453]], |
---|
| 146 | [{'theta':10.0, 'phi':10.0}, (qx, qy), 0.03514647218513852], |
---|
| 147 | [{'theta':10.0, 'phi':10.0}, [(qx, qy)], [0.03514647218513852]], |
---|
| 148 | ] |
---|
| 149 | del qx, qy # not necessary to delete, but cleaner |
---|
| 150 | # ADDED by: RKH ON: 18Mar2016 renamed sld's etc |
---|