Ignore:
Timestamp:
Mar 11, 2018 2:29:41 PM (6 years ago)
Author:
butler
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
Message:

Add comments to c code and clean documentatin

Added comments to c code in both parallelepiped and core shell
parallelepiped noting the change of integration varialbes in the
computation. Cleaned up and final corrections to the core shell
documentation and did some cleaning of parallelipiped. In particular
tried to bring a bit more consistency between the docs.

addresses #896

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sasmodels/models/core_shell_parallelepiped.py

    r367886f rdbf1a60  
    1111.. math:: 
    1212 
    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  
    1414    + \text{background} 
    1515 
    1616where $\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. 
     17of the rectangular solid, and the usual $\Delta \rho^2 \ V^2$ term cannot be 
     18pulled out of the form factor term due to the multiple slds in the model. 
     19 
    2020The core of the solid is defined by the dimensions $A$, $B$, $C$ such that 
    2121$A < B < C$. 
     
    2929There are rectangular "slabs" of thickness $t_A$ that add to the $A$ dimension 
    3030(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 then 
     31$(=t_C)$ faces. The projection in the $AB$ plane is 
    3232 
    3333.. figure:: img/core_shell_parallelepiped_projection.jpg 
    3434 
    3535   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 
     40The total volume of the solid is thus given as 
    3941 
    4042.. math:: 
    4143 
    4244    V = ABC + 2t_ABC + 2t_BAC + 2t_CAB 
    43  
    44 **meaning that there are "gaps" at the corners of the solid.** 
    4545 
    4646The intensity calculated follows the :ref:`parallelepiped` model, with the 
    4747core-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 
     48amplitudes of the core and the slabs on the edges. The scattering amplitude is 
     49computed for a particular orientation of the core-shell parallelepiped with 
     50respect to the scattering vector and then averaged over all possible 
     51orientations, where $\alpha$ is the angle between the $z$ axis and the $C$ axis 
     52of the parallelepiped, and $\beta$ is the angle between the projection of the 
     53particle 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} 
    6159 
    6260and 
     
    6462.. math:: 
    6563 
    66     F(q) 
     64    F(q,\alpha,\beta) 
    6765    &= (\rho_\text{core}-\rho_\text{solvent}) 
    6866       S(Q_A, A) S(Q_B, B) S(Q_C, C) \\ 
     
    7876.. math:: 
    7977 
    80     S(Q, L) = L \frac{\sin \tfrac{1}{2} Q L}{\tfrac{1}{2} Q L} 
     78    S(Q_X, L) = L \frac{\sin \tfrac{1}{2} Q_X L}{\tfrac{1}{2} Q_X L} 
    8179 
    8280and 
     
    9391slabs of thickness $t_A$, $t_B$ and $t_C$, respectively. $\rho_\text{solvent}$ 
    9492is 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$. 
    95102 
    96103FITTING NOTES 
     
    118125$\Psi = 0$ when the *short_b* axis is parallel to the *x*-axis of the detector. 
    119126 
    120 For 2d, constraints must be applied during fitting to ensure that the 
    121 inequality $A < B < C$ is not violated, and hence the correct definition 
    122 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. 
    124131 
    125132.. figure:: img/parallelepiped_angle_definition.png 
Note: See TracChangeset for help on using the changeset viewer.