Changeset fcb33e4 in sasmodels for sasmodels/models/cylinder.py
- Timestamp:
- Jan 4, 2017 6:09:53 AM (7 years ago)
- Branches:
- master, core_shell_microgels, costrafo411, magnetic_model, ticket-1257-vesicle-product, ticket_1156, ticket_1265_superball, ticket_822_more_unit_tests
- Children:
- 473a9f1, b7e8b94
- Parents:
- 64614ad
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sasmodels/models/cylinder.py
r4cdd0cc rfcb33e4 2 2 # Note: model title and parameter table are inserted automatically 3 3 r""" 4 The form factor is normalized by the particle volume V = \piR^2L. 4 5 5 For information about polarised and magnetic scattering, see 6 6 the :ref:`magnetism` documentation. … … 14 14 .. math:: 15 15 16 P(q,\alpha) = \frac{\text{scale}}{V} F^2(q,\alpha) + \text{background}16 P(q,\alpha) = \frac{\text{scale}}{V} F^2(q,\alpha).sin(\alpha) + \text{background} 17 17 18 18 where … … 25 25 \frac{J_1 \left(q R \sin \alpha\right)}{q R \sin \alpha} 26 26 27 and $\alpha$ is the angle between the axis of the cylinder and $\vec q$, $V $27 and $\alpha$ is the angle between the axis of the cylinder and $\vec q$, $V =\pi R^2L$ 28 28 is the volume of the cylinder, $L$ is the length of the cylinder, $R$ is the 29 29 radius of the cylinder, and $\Delta\rho$ (contrast) is the scattering length … … 35 35 .. math:: 36 36 37 F^2(q)=\int_{0}^{\pi/2}{F^2(q,\ theta)\sin(\theta)d\theta}37 F^2(q)=\int_{0}^{\pi/2}{F^2(q,\alpha)\sin(\alpha)d\alpha}=\int_{0}^{1}{F^2(q,u)du} 38 38 39 39 40 To provide easy access to the orientation of the cylinder, we define the 41 axis of the cylinder using two angles $\theta$ and $\phi$. Those angles 40 Numerical integration is simplified by a change of variable to $u = cos(\alpha)$ with 41 $sin(\alpha)=\sqrt{1-u^2}$. 42 43 The output of the 1D scattering intensity function for randomly oriented 44 cylinders is thus given by 45 46 .. math:: 47 48 P(q) = \frac{\text{scale}}{V} 49 \int_0^{\pi/2} F^2(q,\alpha) \sin \alpha\ d\alpha + \text{background} 50 51 52 NB: The 2nd virial coefficient of the cylinder is calculated based on the 53 radius and length values, and used as the effective radius for $S(q)$ 54 when $P(q) \cdot S(q)$ is applied. 55 56 For oriented cylinders, we define the direction of the 57 axis of the cylinder using two angles $\theta$ (note this is not the 58 same as the scattering angle used in q) and $\phi$. Those angles 42 59 are defined in :numref:`cylinder-angle-definition` . 43 60 … … 48 65 Definition of the angles for oriented cylinders. 49 66 50 51 NB: The 2nd virial coefficient of the cylinder is calculated based on the 52 radius and length values, and used as the effective radius for $S(q)$ 53 when $P(q) \cdot S(q)$ is applied. 54 55 The output of the 1D scattering intensity function for randomly oriented 56 cylinders is then given by 57 58 .. math:: 59 60 P(q) = \frac{\text{scale}}{V} 61 \int_0^{\pi/2} F^2(q,\alpha) \sin \alpha\ d\alpha + \text{background} 62 63 The $\theta$ and $\phi$ parameters are not used for the 1D output. 67 The $\theta$ and $\phi$ parameters only appear in the model when fitting 2d data. 64 68 65 69 Validation … … 74 78 75 79 P(q) = \int_0^{\pi/2} d\phi 76 \int_0^\pi p(\ alpha) P_0(q,\alpha) \sin \alpha\ d\alpha80 \int_0^\pi p(\theta) P_0(q,\theta) \sin \theta\ d\theta 77 81 78 82 79 83 where $p(\theta,\phi) = 1$ is the probability distribution for the orientation 80 and $P_0(q,\ alpha)$ is the scattering intensity for the fully oriented84 and $P_0(q,\theta)$ is the scattering intensity for the fully oriented 81 85 system, and then comparing to the 1D result. 82 86 … … 145 149 146 150 qx, qy = 0.2 * np.cos(2.5), 0.2 * np.sin(2.5) 147 # After redefinition of angles, find new tests values 148 #tests = [[{}, 0.2, 0.042761386790780453], 149 # [{}, [0.2], [0.042761386790780453]], 150 # [{'theta':10.0, 'phi':10.0}, (qx, qy), 0.03514647218513852], 151 # [{'theta':10.0, 'phi':10.0}, [(qx, qy)], [0.03514647218513852]], 152 # ] 151 # After redefinition of angles, find new tests values. Was 10 10 in old coords 152 tests = [[{}, 0.2, 0.042761386790780453], 153 [{}, [0.2], [0.042761386790780453]], 154 # expect new [{'theta':80.1534480601659, 'phi':10.1510817110481}, (qx, qy), 0.03514647218513852], 155 # [{'theta':80.1534480601659, 'phi':10.1510817110481}, [(qx, qy)], [0.03514647218513852]], 156 # old, but calcs .0344268 [{'theta':10.0, 'phi':10.0}, (qx, qy), 0.03514647218513852], 157 # [{'theta':10.0, 'phi':10.0}, [(qx, qy)], [0.03514647218513852]], 158 ] 153 159 del qx, qy # not necessary to delete, but cleaner 154 160 # ADDED by: RKH ON: 18Mar2016 renamed sld's etc
Note: See TracChangeset
for help on using the changeset viewer.