Changes in / [c64a68e:33969b6] in sasmodels


Ignore:
Location:
sasmodels/models
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • sasmodels/models/core_shell_parallelepiped.c

    rdbf1a60 re077231  
    5959 
    6060    // outer integral (with gauss points), integration limits = 0, 1 
    61     // substitute d_cos_alpha for sin_alpha d_alpha 
    6261    double outer_sum = 0; //initialize integral 
    6362    for( int i=0; i<GAUSS_N; i++) { 
    6463        const double cos_alpha = 0.5 * ( GAUSS_Z[i] + 1.0 ); 
    6564        const double mu = half_q * sqrt(1.0-cos_alpha*cos_alpha); 
     65 
     66        // inner integral (with gauss points), integration limits = 0, pi/2 
    6667        const double siC = length_c * sas_sinx_x(length_c * cos_alpha * half_q); 
    6768        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) 
    7169        double inner_sum = 0.0; 
    7270        for(int j=0; j<GAUSS_N; j++) { 
    73             const double u = 0.5 * ( GAUSS_Z[j] + 1.0 ); 
     71            const double beta = 0.5 * ( GAUSS_Z[j] + 1.0 ); 
    7472            double sin_beta, cos_beta; 
    75             SINCOS(M_PI_2*u, sin_beta, cos_beta); 
     73            SINCOS(M_PI_2*beta, sin_beta, cos_beta); 
    7674            const double siA = length_a * sas_sinx_x(length_a * mu * sin_beta); 
    7775            const double siB = length_b * sas_sinx_x(length_b * mu * cos_beta); 
     
    9391            inner_sum += GAUSS_W[j] * f * f; 
    9492        } 
    95         // now complete change of inner integration variable (1-0)/(1-(-1))= 0.5 
    9693        inner_sum *= 0.5; 
    9794        // now sum up the outer integral 
    9895        outer_sum += GAUSS_W[i] * inner_sum; 
    9996    } 
    100     // now complete change of outer integration variable (1-0)/(1-(-1))= 0.5 
    10197    outer_sum *= 0.5; 
    10298 
  • sasmodels/models/core_shell_parallelepiped.py

    r5bc6d21 r97be877  
    1111.. math:: 
    1212 
    13     I(q) = \frac{\text{scale}}{V} \langle P(q,\alpha,\beta) \rangle  
    14     + \text{background} 
     13    I(q) = \text{scale}\frac{\langle f^2 \rangle}{V} + \text{background} 
    1514 
    1615where $\langle \ldots \rangle$ is an average over all possible orientations 
    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  
     16of the rectangular solid. 
     17 
     18The function calculated is the form factor of the rectangular solid below. 
    2019The core of the solid is defined by the dimensions $A$, $B$, $C$ such that 
    2120$A < B < C$. 
    2221 
    23 .. figure:: img/parallelepiped_geometry.jpg 
    24  
    25    Core of the core shell parallelepiped with the corresponding definition 
    26    of sides. 
    27  
     22.. image:: img/core_shell_parallelepiped_geometry.jpg 
    2823 
    2924There are rectangular "slabs" of thickness $t_A$ that add to the $A$ dimension 
    3025(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 
    32  
    33 .. figure:: img/core_shell_parallelepiped_projection.jpg 
    34  
    35    AB cut through the core-shell parallelipiped showing the cross secion of 
    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 
     26$(=t_C)$ faces. The projection in the $AB$ plane is then 
     27 
     28.. image:: img/core_shell_parallelepiped_projection.jpg 
     29 
     30The volume of the solid is 
    4131 
    4232.. math:: 
    4333 
    4434    V = ABC + 2t_ABC + 2t_BAC + 2t_CAB 
     35 
     36**meaning that there are "gaps" at the corners of the solid.** 
    4537 
    4638The intensity calculated follows the :ref:`parallelepiped` model, with the 
    4739core-shell intensity being calculated as the square of the sum of the 
    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} 
    59  
    60 and 
    61  
    62 .. math:: 
    63  
    64     F(q,\alpha,\beta) 
     40amplitudes of the core and the slabs on the edges. 
     41 
     42the scattering amplitude is computed for a particular orientation of the 
     43core-shell parallelepiped with respect to the scattering vector and then 
     44averaged over all possible orientations, where $\alpha$ is the angle between 
     45the $z$ axis and the $C$ axis of the parallelepiped, $\beta$ is 
     46the angle between projection of the particle in the $xy$ detector plane 
     47and the $y$ axis. 
     48 
     49.. math:: 
     50 
     51    F(Q) 
    6552    &= (\rho_\text{core}-\rho_\text{solvent}) 
    6653       S(Q_A, A) S(Q_B, B) S(Q_C, C) \\ 
    6754    &+ (\rho_\text{A}-\rho_\text{solvent}) 
    68         \left[S(Q_A, A+2t_A) - S(Q_A, A)\right] S(Q_B, B) S(Q_C, C) \\ 
     55        \left[S(Q_A, A+2t_A) - S(Q_A, Q)\right] S(Q_B, B) S(Q_C, C) \\ 
    6956    &+ (\rho_\text{B}-\rho_\text{solvent}) 
    7057        S(Q_A, A) \left[S(Q_B, B+2t_B) - S(Q_B, B)\right] S(Q_C, C) \\ 
     
    7663.. math:: 
    7764 
    78     S(Q_X, L) = L \frac{\sin (\tfrac{1}{2} Q_X L)}{\tfrac{1}{2} Q_X L} 
     65    S(Q, L) = L \frac{\sin \tfrac{1}{2} Q L}{\tfrac{1}{2} Q L} 
    7966 
    8067and 
     
    8269.. math:: 
    8370 
    84     Q_A &= q \sin\alpha \sin\beta \\ 
    85     Q_B &= q \sin\alpha \cos\beta \\ 
    86     Q_C &= q \cos\alpha 
     71    Q_A &= \sin\alpha \sin\beta \\ 
     72    Q_B &= \sin\alpha \cos\beta \\ 
     73    Q_C &= \cos\alpha 
    8774 
    8875 
    8976where $\rho_\text{core}$, $\rho_\text{A}$, $\rho_\text{B}$ and $\rho_\text{C}$ 
    90 are the scattering lengths of the parallelepiped core, and the rectangular 
     77are the scattering length of the parallelepiped core, and the rectangular 
    9178slabs of thickness $t_A$, $t_B$ and $t_C$, respectively. $\rho_\text{solvent}$ 
    9279is 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$. 
    10280 
    10381FITTING NOTES 
     
    11694based on the the averaged effective radius $(=\sqrt{(A+2t_A)(B+2t_B)/\pi})$ 
    11795and length $(C+2t_C)$ values, after appropriately sorting the three dimensions 
    118 to give an oblate or prolate particle, to give an effective radius 
    119 for $S(q)$ when $P(q) * S(q)$ is applied. 
     96to give an oblate or prolate particle, to give an effective radius, 
     97for $S(Q)$ when $P(Q) * S(Q)$ is applied. 
    12098 
    12199For 2d data the orientation of the particle is required, described using 
    122 angles $\theta$, $\phi$ and $\Psi$ as in the diagrams below. For further 
     100angles $\theta$, $\phi$ and $\Psi$ as in the diagrams below, for further 
    123101details of the calculation and angular dispersions see :ref:`orientation`. 
    124102The angle $\Psi$ is the rotational angle around the *long_c* axis. For example, 
    125103$\Psi = 0$ when the *short_b* axis is parallel to the *x*-axis of the detector. 
    126104 
    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. 
     105For 2d, constraints must be applied during fitting to ensure that the 
     106inequality $A < B < C$ is not violated, and hence the correct definition 
     107of angles is preserved. The calculation will not report an error, 
     108but the results may be not correct. 
    131109 
    132110.. figure:: img/parallelepiped_angle_definition.png 
     
    135113    Note that rotation $\theta$, initially in the $xz$ plane, is carried 
    136114    out first, then rotation $\phi$ about the $z$ axis, finally rotation 
    137     $\Psi$ is now around the axis of the particle. The neutron or X-ray 
     115    $\Psi$ is now around the axis of the cylinder. The neutron or X-ray 
    138116    beam is along the $z$ axis. 
    139117 
     
    142120    Examples of the angles for oriented core-shell parallelepipeds against the 
    143121    detector plane. 
    144  
    145  
    146 Validation 
    147 ---------- 
    148  
    149 Cross-checked against hollow rectangular prism and rectangular prism for equal 
    150 thickness overlapping sides, and by Monte Carlo sampling of points within the 
    151 shape for non-uniform, non-overlapping sides. 
    152  
    153122 
    154123References 
     
    166135 
    167136* **Author:** NIST IGOR/DANSE **Date:** pre 2010 
    168 * **Converted to sasmodels by:** Miguel Gonzalez **Date:** February 26, 2016 
     137* **Converted to sasmodels by:** Miguel Gonzales **Date:** February 26, 2016 
    169138* **Last Modified by:** Paul Kienzle **Date:** October 17, 2017 
     139* Cross-checked against hollow rectangular prism and rectangular prism for 
     140  equal thickness overlapping sides, and by Monte Carlo sampling of points 
     141  within the shape for non-uniform, non-overlapping sides. 
    170142""" 
    171143 
  • sasmodels/models/parallelepiped.c

    rdbf1a60 r108e70e  
    3838            inner_total += GAUSS_W[j] * square(si1 * si2); 
    3939        } 
    40         // now complete change of inner integration variable (1-0)/(1-(-1))= 0.5 
    4140        inner_total *= 0.5; 
    4241 
     
    4443        outer_total += GAUSS_W[i] * inner_total * si * si; 
    4544    } 
    46     // now complete change of outer integration variable (1-0)/(1-(-1))= 0.5 
    4745    outer_total *= 0.5; 
    4846 
  • sasmodels/models/parallelepiped.py

    rb343226 ref07e95  
    22# Note: model title and parameter table are inserted automatically 
    33r""" 
     4The form factor is normalized by the particle volume. 
     5For information about polarised and magnetic scattering, see 
     6the :ref:`magnetism` documentation. 
     7 
    48Definition 
    59---------- 
    610 
    7 This model calculates the scattering from a rectangular parallelepiped 
    8 (:numref:`parallelepiped-image`). 
    9 If you need to apply polydispersity, see also :ref:`rectangular-prism`. For 
    10 information about polarised and magnetic scattering, see 
    11 the :ref:`magnetism` documentation. 
     11 This model calculates the scattering from a rectangular parallelepiped 
     12 (\:numref:`parallelepiped-image`\). 
     13 If you need to apply polydispersity, see also :ref:`rectangular-prism`. 
    1214 
    1315.. _parallelepiped-image: 
     
    2426error, or fixing of some dimensions at expected values, may help. 
    2527 
    26 The form factor is normalized by the particle volume and the 1D scattering 
    27 intensity $I(q)$ is then calculated as: 
     28The 1D scattering intensity $I(q)$ is calculated as: 
    2829 
    2930.. Comment by Miguel Gonzalez: 
     
    3839 
    3940    I(q) = \frac{\text{scale}}{V} (\Delta\rho \cdot V)^2 
    40            \left< P(q, \alpha, \beta) \right> + \text{background} 
     41           \left< P(q, \alpha) \right> + \text{background} 
    4142 
    4243where the volume $V = A B C$, the contrast is defined as 
    43 $\Delta\rho = \rho_\text{p} - \rho_\text{solvent}$, $P(q, \alpha, \beta)$ 
    44 is the form factor corresponding to a parallelepiped oriented 
    45 at an angle $\alpha$ (angle between the long axis C and $\vec q$), and $\beta$ 
    46 (the angle between the projection of the particle in the $xy$ detector plane 
    47 and the $y$ axis) and the averaging $\left<\ldots\right>$ is applied over all 
    48 orientations. 
     44$\Delta\rho = \rho_\text{p} - \rho_\text{solvent}$, 
     45$P(q, \alpha)$ is the form factor corresponding to a parallelepiped oriented 
     46at an angle $\alpha$ (angle between the long axis C and $\vec q$), 
     47and the averaging $\left<\ldots\right>$ is applied over all orientations. 
    4948 
    5049Assuming $a = A/B < 1$, $b = B /B = 1$, and $c = C/B > 1$, the 
    51 form factor is given by (Mittelbach and Porod, 1961 [#Mittelbach]_) 
     50form factor is given by (Mittelbach and Porod, 1961) 
    5251 
    5352.. math:: 
     
    6766    \mu &= qB 
    6867 
    69 where substitution of $\sigma = cos\alpha$ and $\beta = \pi/2 \ u$ have been 
    70 applied. 
     68The scattering intensity per unit volume is returned in units of |cm^-1|. 
    7169 
    7270NB: The 2nd virial coefficient of the parallelepiped is calculated based on 
     
    122120.. math:: 
    123121 
    124     P(q_x, q_y) = \left[\frac{\sin(\tfrac{1}{2}qA\cos\alpha)}{(\tfrac{1} 
    125                    {2}qA\cos\alpha)}\right]^2 
    126                   \left[\frac{\sin(\tfrac{1}{2}qB\cos\beta)}{(\tfrac{1} 
    127                    {2}qB\cos\beta)}\right]^2 
    128                   \left[\frac{\sin(\tfrac{1}{2}qC\cos\gamma)}{(\tfrac{1} 
    129                    {2}qC\cos\gamma)}\right]^2 
     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 
    130125 
    131126with 
     
    165160---------- 
    166161 
    167 .. [#Mittelbach] P Mittelbach and G Porod, *Acta Physica Austriaca*, 
    168    14 (1961) 185-211 
    169 .. [#] R Nayuk and K Huber, *Z. Phys. Chem.*, 226 (2012) 837-854 
     162P Mittelbach and G Porod, *Acta Physica Austriaca*, 14 (1961) 185-211 
     163 
     164R Nayuk and K Huber, *Z. Phys. Chem.*, 226 (2012) 837-854 
    170165 
    171166Authorship and Verification 
Note: See TracChangeset for help on using the changeset viewer.