Changeset dbf1a60 in sasmodels
- Timestamp:
- Mar 11, 2018 2:29:41 PM (7 years ago)
- Branches:
- master, core_shell_microgels, magnetic_model, ticket-1257-vesicle-product, ticket_1156, ticket_1265_superball, ticket_822_more_unit_tests
- Children:
- 9616dfe
- Parents:
- 367886f
- Location:
- sasmodels/models
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
sasmodels/models/core_shell_parallelepiped.c
re077231 rdbf1a60 59 59 60 60 // outer integral (with gauss points), integration limits = 0, 1 61 // substitute d_cos_alpha for sin_alpha d_alpha 61 62 double outer_sum = 0; //initialize integral 62 63 for( int i=0; i<GAUSS_N; i++) { 63 64 const double cos_alpha = 0.5 * ( GAUSS_Z[i] + 1.0 ); 64 65 const double mu = half_q * sqrt(1.0-cos_alpha*cos_alpha); 65 66 // inner integral (with gauss points), integration limits = 0, pi/267 66 const double siC = length_c * sas_sinx_x(length_c * cos_alpha * half_q); 68 67 const double siCt = tC * sas_sinx_x(tC * cos_alpha * half_q); 68 69 // inner integral (with gauss points), integration limits = 0, 1 70 // substitute beta = PI/2 u (so 2/PI * d_(PI/2 * beta) = d_beta) 69 71 double inner_sum = 0.0; 70 72 for(int j=0; j<GAUSS_N; j++) { 71 const double beta= 0.5 * ( GAUSS_Z[j] + 1.0 );73 const double u = 0.5 * ( GAUSS_Z[j] + 1.0 ); 72 74 double sin_beta, cos_beta; 73 SINCOS(M_PI_2* beta, sin_beta, cos_beta);75 SINCOS(M_PI_2*u, sin_beta, cos_beta); 74 76 const double siA = length_a * sas_sinx_x(length_a * mu * sin_beta); 75 77 const double siB = length_b * sas_sinx_x(length_b * mu * cos_beta); … … 91 93 inner_sum += GAUSS_W[j] * f * f; 92 94 } 95 // now complete change of inner integration variable (1-0)/(1-(-1))= 0.5 93 96 inner_sum *= 0.5; 94 97 // now sum up the outer integral 95 98 outer_sum += GAUSS_W[i] * inner_sum; 96 99 } 100 // now complete change of outer integration variable (1-0)/(1-(-1))= 0.5 97 101 outer_sum *= 0.5; 98 102 -
sasmodels/models/core_shell_parallelepiped.py
r367886f rdbf1a60 11 11 .. math:: 12 12 13 I(q) = \ text{scale}\frac{\langle P(q,\alpha,\beta) \rangle}{V}13 I(q) = \frac{\text{scale}}{V} \langle P(q,\alpha,\beta) \rangle 14 14 + \text{background} 15 15 16 16 where $\langle \ldots \rangle$ is an average over all possible orientations 17 of the rectangular solid .18 19 The function calculated is the form factor of the rectangular solid below. 17 of the rectangular solid, and the usual $\Delta \rho^2 \ V^2$ term cannot be 18 pulled out of the form factor term due to the multiple slds in the model. 19 20 20 The core of the solid is defined by the dimensions $A$, $B$, $C$ such that 21 21 $A < B < C$. … … 29 29 There are rectangular "slabs" of thickness $t_A$ that add to the $A$ dimension 30 30 (on the $BC$ faces). There are similar slabs on the $AC$ $(=t_B)$ and $AB$ 31 $(=t_C)$ faces. The projection in the $AB$ plane is then31 $(=t_C)$ faces. The projection in the $AB$ plane is 32 32 33 33 .. figure:: img/core_shell_parallelepiped_projection.jpg 34 34 35 35 AB cut through the core-shell parllelipiped showing the cross secion of 36 four of the six shell slabs 37 38 The volume of the solid is 36 four of the six shell slabs. As can be seen This model leaves **"gaps"** 37 at the corners of the solid. 38 39 40 The total volume of the solid is thus given as 39 41 40 42 .. math:: 41 43 42 44 V = ABC + 2t_ABC + 2t_BAC + 2t_CAB 43 44 **meaning that there are "gaps" at the corners of the solid.**45 45 46 46 The intensity calculated follows the :ref:`parallelepiped` model, with the 47 47 core-shell intensity being calculated as the square of the sum of the 48 amplitudes of the core and the slabs on the edges. 49 50 the scattering amplitude is computed for a particular orientation of the 51 core-shell parallelepiped with respect to the scattering vector and then 52 averaged over all possible orientations, where $\alpha$ is the angle between 53 the $z$ axis and the $C$ axis of the parallelepiped, $\beta$ is 54 the angle between projection of the particle in the $xy$ detector plane 55 and the $y$ axis. 56 57 .. math:: 58 59 P(q)=\int_{0}^{\pi/2}\int_{0}^{\pi/2}F^2(q,\alpha,\beta) \ cos\alpha 60 \ d\alpha \ d\beta 48 amplitudes of the core and the slabs on the edges. The scattering amplitude is 49 computed for a particular orientation of the core-shell parallelepiped with 50 respect to the scattering vector and then averaged over all possible 51 orientations, where $\alpha$ is the angle between the $z$ axis and the $C$ axis 52 of the parallelepiped, and $\beta$ is the angle between the projection of the 53 particle in the $xy$ detector plane and the $y$ axis. 54 55 .. math:: 56 57 P(q)=\frac {\int_{0}^{\pi/2}\int_{0}^{\pi/2}F^2(q,\alpha,\beta) \ sin\alpha 58 \ d\alpha \ d\beta} {\int_{0}^{\pi/2} \ sin\alpha \ d\alpha \ d\beta} 61 59 62 60 and … … 64 62 .. math:: 65 63 66 F(q )64 F(q,\alpha,\beta) 67 65 &= (\rho_\text{core}-\rho_\text{solvent}) 68 66 S(Q_A, A) S(Q_B, B) S(Q_C, C) \\ … … 78 76 .. math:: 79 77 80 S(Q , L) = L \frac{\sin \tfrac{1}{2} Q L}{\tfrac{1}{2} QL}78 S(Q_X, L) = L \frac{\sin \tfrac{1}{2} Q_X L}{\tfrac{1}{2} Q_X L} 81 79 82 80 and … … 93 91 slabs of thickness $t_A$, $t_B$ and $t_C$, respectively. $\rho_\text{solvent}$ 94 92 is the scattering length of the solvent. 93 94 .. note:: 95 96 the code actually implements two substitutions: $d(cos\alpha)$ is 97 substituted for -$sin\alpha \ d\alpha$ (note that in the 98 :ref:`parallelepiped` code this is explicitly implemented with 99 $\sigma = cos\alpha$), and $\beta$ is set to $\beta = u \pi/2$ so that 100 $du = \pi/2 \ d\beta$. Thus both integrals go from 0 to 1 rather than 0 101 to $\pi/2$. 95 102 96 103 FITTING NOTES … … 118 125 $\Psi = 0$ when the *short_b* axis is parallel to the *x*-axis of the detector. 119 126 120 For 2d, constraints must be applied during fitting to ensure that the121 inequality $A < B < C$ is not violated, and hence the correct definition122 of angles is preserved. The calculation will not report an error,123 but the results may be not correct.127 .. note:: For 2d, constraints must be applied during fitting to ensure that the 128 inequality $A < B < C$ is not violated, and hence the correct definition 129 of angles is preserved. The calculation will not report an error, 130 but the results may be not correct. 124 131 125 132 .. figure:: img/parallelepiped_angle_definition.png -
sasmodels/models/parallelepiped.c
r108e70e rdbf1a60 38 38 inner_total += GAUSS_W[j] * square(si1 * si2); 39 39 } 40 // now complete change of inner integration variable (1-0)/(1-(-1))= 0.5 40 41 inner_total *= 0.5; 41 42 … … 43 44 outer_total += GAUSS_W[i] * inner_total * si * si; 44 45 } 46 // now complete change of outer integration variable (1-0)/(1-(-1))= 0.5 45 47 outer_total *= 0.5; 46 48 -
sasmodels/models/parallelepiped.py
r5bc373b rdbf1a60 39 39 40 40 I(q) = \frac{\text{scale}}{V} (\Delta\rho \cdot V)^2 41 \left< P(q, \alpha ) \right> + \text{background}41 \left< P(q, \alpha, \beta) \right> + \text{background} 42 42 43 43 where the volume $V = A B C$, the contrast is defined as 44 $\Delta\rho = \rho_\text{p} - \rho_\text{solvent}$, 45 $P(q, \alpha)$ is the form factor corresponding to a parallelepiped oriented 46 at an angle $\alpha$ (angle between the long axis C and $\vec q$), 47 and the averaging $\left<\ldots\right>$ is applied over all orientations. 44 $\Delta\rho = \rho_\text{p} - \rho_\text{solvent}$, $P(q, \alpha, \beta)$ 45 is the form factor corresponding to a parallelepiped oriented 46 at an angle $\alpha$ (angle between the long axis C and $\vec q$), and $\beta$ 47 ( the angle between the projection of the particle in the $xy$ detector plane 48 and the $y$ axis) and the averaging $\left<\ldots\right>$ is applied over all 49 orientations. 48 50 49 51 Assuming $a = A/B < 1$, $b = B /B = 1$, and $c = C/B > 1$, the 50 form factor is given by (Mittelbach and Porod, 1961 )52 form factor is given by (Mittelbach and Porod, 1961 [#Mittelbach]_) 51 53 52 54 .. math:: … … 66 68 \mu &= qB 67 69 68 The scattering intensity per unit volume is returned in units of |cm^-1|. 70 where substitution of $\sigma = cos\alpha$ and $\beta = \pi/2 \ u$ have been 71 applied. 69 72 70 73 NB: The 2nd virial coefficient of the parallelepiped is calculated based on … … 120 123 .. math:: 121 124 122 P(q_x, q_y) = \left[\frac{\sin(\tfrac{1}{2}qA\cos\alpha)}{(\tfrac{1}{2}qA\cos\alpha)}\right]^2 123 \left[\frac{\sin(\tfrac{1}{2}qB\cos\beta)}{(\tfrac{1}{2}qB\cos\beta)}\right]^2 124 \left[\frac{\sin(\tfrac{1}{2}qC\cos\gamma)}{(\tfrac{1}{2}qC\cos\gamma)}\right]^2 125 P(q_x, q_y) = \left[\frac{\sin(\tfrac{1}{2}qA\cos\alpha)}{(\tfrac{1} 126 {2}qA\cos\alpha)}\right]^2 127 \left[\frac{\sin(\tfrac{1}{2}qB\cos\beta)}{(\tfrac{1} 128 {2}qB\cos\beta)}\right]^2 129 \left[\frac{\sin(\tfrac{1}{2}qC\cos\gamma)}{(\tfrac{1} 130 {2}qC\cos\gamma)}\right]^2 125 131 126 132 with … … 160 166 ---------- 161 167 162 P Mittelbach and G Porod, *Acta Physica Austriaca*, 14 (1961) 185-211 163 164 R Nayuk and K Huber, *Z. Phys. Chem.*, 226 (2012) 837-854168 .. [#Mittelbach] P Mittelbach and G Porod, *Acta Physica Austriaca*, 169 14 (1961) 185-211 170 .. [#] R Nayuk and K Huber, *Z. Phys. Chem.*, 226 (2012) 837-854 165 171 166 172 Authorship and Verification
Note: See TracChangeset
for help on using the changeset viewer.