Changeset 40a87fa in sasmodels for sasmodels/models/parallelepiped.py
- Timestamp:
- Aug 8, 2016 9:24:11 AM (8 years ago)
- Branches:
- master, core_shell_microgels, costrafo411, magnetic_model, release_v0.94, release_v0.95, ticket-1257-vesicle-product, ticket_1156, ticket_1265_superball, ticket_822_more_unit_tests
- Children:
- 2472141
- Parents:
- 2d65d51
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sasmodels/models/parallelepiped.py
r42356c8 r40a87fa 7 7 ---------- 8 8 9 | This model calculates the scattering from a rectangular parallelepiped (:numref:`parallelepiped-image`). 9 | This model calculates the scattering from a rectangular parallelepiped 10 | (:numref:`parallelepiped-image`). 10 11 | If you need to apply polydispersity, see also :ref:`rectangular-prism`. 11 12 … … 34 35 .. math:: 35 36 36 I(q) = \frac{\text{scale}}{V} (\Delta\rho \cdot V)^2 \left< P(q, \alpha) \right>37 + \text{background}37 I(q) = \frac{\text{scale}}{V} (\Delta\rho \cdot V)^2 38 \left< P(q, \alpha) \right> + \text{background} 38 39 39 40 where the volume $V = A B C$, the contrast is defined as 40 :math:`\Delta\rho = \rho_{\textstyle p} - \rho_{\textstyle solvent}`,41 $\Delta\rho = \rho_\text{p} - \rho_\text{solvent}$, 41 42 $P(q, \alpha)$ is the form factor corresponding to a parallelepiped oriented 42 at an angle $\alpha$ (angle between the long axis C and :math:`\vec q`),43 at an angle $\alpha$ (angle between the long axis C and $\vec q$), 43 44 and the averaging $\left<\ldots\right>$ is applied over all orientations. 44 45 … … 55 56 .. math:: 56 57 57 \phi_Q(\mu,a) = \int_0^158 \phi_Q(\mu,a) &= \int_0^1 58 59 \left\{S\left[\frac{\mu}{2}\cos\left(\frac{\pi}{2}u\right)\right] 59 60 S\left[\frac{\mu a}{2}\sin\left(\frac{\pi}{2}u\right)\right] 60 61 \right\}^2 du 61 62 62 S(x) = \frac{\sin x}{x}63 64 \mu = qB63 S(x) &= \frac{\sin x}{x} 64 65 \mu &= qB 65 66 66 67 … … 105 106 .. figure:: img/parallelepiped_angle_projection.jpg 106 107 107 Examples of the angles for oriented parallelepipeds against the detector plane. 108 109 For a given orientation of the parallelepiped, the 2D form factor is calculated as 110 111 .. math:: 112 113 P(q_x, q_y) = \left[\frac{sin(qA\cos\alpha/2)}{(qA\cos\alpha/2)}\right]^2 114 \left[\frac{sin(qB\cos\beta/2)}{(qB\cos\beta/2)}\right]^2 115 \left[\frac{sin(qC\cos\gamma/2)}{(qC\cos\gamma/2)}\right]^2 108 Examples of the angles for oriented parallelepipeds against the 109 detector plane. 110 111 For a given orientation of the parallelepiped, the 2D form factor is 112 calculated as 113 114 .. math:: 115 116 P(q_x, q_y) = \left[\frac{\sin(qA\cos\alpha/2)}{(qA\cos\alpha/2)}\right]^2 117 \left[\frac{\sin(qB\cos\beta/2)}{(qB\cos\beta/2)}\right]^2 118 \left[\frac{\sin(qC\cos\gamma/2)}{(qC\cos\gamma/2)}\right]^2 116 119 117 120 with … … 119 122 .. math:: 120 123 121 \cos\alpha = \hat A \cdot \hat q, \; 122 \cos\beta = \hat B \cdot \hat q, \; 123 \cos\gamma = \hat C \cdot \hat q 124 \cos\alpha &= \hat A \cdot \hat q, 125 126 \cos\beta &= \hat B \cdot \hat q, 127 128 \cos\gamma &= \hat C \cdot \hat q 124 129 125 130 and the scattering intensity as: … … 127 132 .. math:: 128 133 129 I(q_x, q_y) = \frac{\text{scale}}{V} V^2 \Delta\rho^2 P(q_x, q_y) + \text{background} 134 I(q_x, q_y) = \frac{\text{scale}}{V} V^2 \Delta\rho^2 P(q_x, q_y) 135 + \text{background} 130 136 131 137 .. Comment by Miguel Gonzalez: 132 138 This reflects the logic of the code, as in parallelepiped.c the call 133 to _pkernel returns P(q_x, q_y) and then this is multiplied by V^2 * (delta rho)^2. 134 And finally outside parallelepiped.c it will be multiplied by scale, normalized by 135 V and the background added. But mathematically it makes more sense to write 136 I(q_x, q_y) = \text{scale} V \Delta\rho^2 P(q_x, q_y) + \text{background}, 139 to _pkernel returns $P(q_x, q_y)$ and then this is multiplied by 140 $V^2 * (\Delta \rho)^2$. And finally outside parallelepiped.c it will be 141 multiplied by scale, normalized by $V$ and the background added. But 142 mathematically it makes more sense to write 143 $I(q_x, q_y) = \text{scale} V \Delta\rho^2 P(q_x, q_y) + \text{background}$, 137 144 with scale being the volume fraction. 138 145 … … 143 150 Validation of the code was done by comparing the output of the 1D calculation 144 151 to the angular average of the output of a 2D calculation over all possible 145 angles. 152 angles. 146 153 147 154 This model is based on form factor calculations implemented in a c-library
Note: See TracChangeset
for help on using the changeset viewer.