Changeset e964ab1 in sasmodels for doc


Ignore:
Timestamp:
Oct 28, 2017 9:11:13 PM (7 years ago)
Author:
Paul Kienzle <pkienzle@…>
Branches:
master, core_shell_microgels, magnetic_model, ticket-1257-vesicle-product, ticket_1156, ticket_1265_superball, ticket_822_more_unit_tests
Children:
3d40839
Parents:
5f8b72b
Message:

reformat orientation docs to 80 columns

Location:
doc
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • doc/developer/overview.rst

    reda8b30 re964ab1  
    171171------------------------------------- 
    172172 
    173 For 2d data from oriented anisotropic particles, the mean particle orientation is defined by angles $\theta$, $\phi$ and $\Psi$, which 
    174 are not in general the same as similarly named angles in many form factors. The wikipedia page on Euler angles  
    175 (https://en.wikipedia.org/wiki/Euler_angles) lists the different conventions available. To quote: "Different authors may use different  
    176 sets of rotation axes to define Euler angles, or different names for the same angles. Therefore, any discussion employing Euler angles 
     173For 2d data from oriented anisotropic particles, the mean particle 
     174orientation is defined by angles $\theta$, $\phi$ and $\Psi$, which are not 
     175in general the same as similarly named angles in many form factors. The 
     176wikipedia page on Euler angles (https://en.wikipedia.org/wiki/Euler_angles) 
     177lists the different conventions available. To quote: "Different authors may 
     178use different sets of rotation axes to define Euler angles, or different 
     179names for the same angles. Therefore, any discussion employing Euler angles 
    177180should always be preceded by their definition." 
    178181 
    179 We are using the z-y-z convention with extrinsic rotations $\Psi-\theta-\phi$ for the particle orientation and $x-y-z$ convention with  
    180 extrinsic rotations $\psi-\theta-\phi$ for jitter, with jitter applied before particle orientation. 
    181  
    182 For numerical integration within form factors etc. sasmodels is mostly using Gaussian quadrature with 20, 76 or 150 points depending on  
    183 the model.  It also makes use of symmetries such as calculating only over one quadrant rather than the whole sphere.  There is often a  
    184 U-substitution replacing $\theta$ with $cos(\theta)$ which changes the limits of integration from 0 to $\pi/2$ to 0 to 1 and also conveniently  
    185 absorbs the $sin(\theta)$ scale factor in the integration.  This can cause confusion if checking equations to say include in a paper or thesis! 
    186 Most models use the same core kernel code expressed in terms of the rotated view (qa, qb, qc) for both the 1D and the 2D models, but there  
    187 are also historical quirks such as the parallelepiped model, which has a useless transformation representing j0(a qa) as j0(b qa a/b). 
     182We are using the z-y-z convention with extrinsic rotations $\Psi-\theta-\phi$ 
     183for the particle orientation and $x-y-z$ convention with extrinsic rotations 
     184$\psi-\theta-\phi$ for jitter, with jitter applied before particle 
     185orientation. 
     186 
     187For numerical integration within form factors etc. sasmodels is mostly using 
     188Gaussian quadrature with 20, 76 or 150 points depending on the model. It also 
     189makes use of symmetries such as calculating only over one quadrant rather 
     190than the whole sphere. There is often a U-substitution replacing $\theta$ 
     191with $cos(\theta)$ which changes the limits of integration from 0 to $\pi/2$ 
     192to 0 to 1 and also conveniently absorbs the $sin(\theta)$ scale factor in the 
     193integration. This can cause confusion if checking equations to say include in 
     194a paper or thesis! Most models use the same core kernel code expressed in 
     195terms of the rotated view (qa, qb, qc) for both the 1D and the 2D models, but 
     196there are also historical quirks such as the parallelepiped model, which has 
     197a useless transformation representing j0(a qa) as j0(b qa a/b). 
    188198 
    189199Useful testing routines include - 
    190200 
    191 :mod:`asymint` a direct implementation of the surface integral for certain models to get a more trusted value for the 1D integral using a reimplementation of the 2D kernel in python and mpmath  
    192 (which computes math functions to arbitrary precision). It uses $\theta$ ranging from 0 to $\pi$ and $\phi$ ranging from 0 to $2\pi$.  It perhaps would benefit 
    193 from including the U-substitution for theta. 
    194  
    195 :mod:`check1d` uses sasmodels 1D integration and compares that with a rectangle distribution in $\theta$ and $\phi$, with $\theta$ limits set to 
    196 $\pm90/\sqrt(3)$ and $\phi$ limits set to $\pm180/\sqrt(3)$   
    197 [The rectangle weight function uses the fact that the distribution width column is labelled sigma to decide  
    198 that the 1-sigma width of a rectangular distribution needs to be multiplied by $\sqrt(3)$ to get the corresponding gaussian equivalent,  
    199 or similar reasoning.]  This should rotate the sample through the entire $\theta-\phi$  
    200 surface according to the pattern that you see in jitter.py when you modify it to use 'rectangle' rather than 'gaussian' for its distribution  
    201 without changing the viewing angle. When computing the dispersity integral, weights are scaled by abs(cos(dtheta)) to account for the points in  
    202 phi getting closer together as dtheta increases.  This integrated dispersion is computed at a set of $(qx, qy)$ points $(q cos(\alpha), q sin(\alpha))$  
    203 at some angle $\alpha$ (currently angle=0) for each q used in the 1-D integration.  The individual q points should be equivalent to asymint rect-n  
    204 when the viewing angle is set to (theta,phi,psi) = (90, 0, 0). Such tests can help to validate that 2d intensity is consistent with 1d models. 
    205   
    206 :mod:`sascomp -sphere=n` uses the identical rectangular distribution to compute the pattern of the qx-qy grid.  You can see from triaxial_ellipsoid 
    207 that there may be something wrong conceptually since the pattern is no longer circular when the view (theta,phi,psi) is not (90, phi, 0).   
    208 check1d shows that it is different from the sasmodels 1D integral even when at theta=0, psi=0. Cross checking the values with asymint,  
    209 the sasmodels 1D integral is better at low q, though for very large structures there are not enough points in the integration for sasmodels 1D  
    210 to compute the high q 1D integral correctly. [Some of that may now be fixed?] 
    211  
    212 The :mod:`sascomp` utility can be used for 2d as well as 1d calculations to compare results for two sets of parameters or processor types, for example 
     201:mod:`asymint` a direct implementation of the surface integral for certain 
     202models to get a more trusted value for the 1D integral using a 
     203reimplementation of the 2D kernel in python and mpmath (which computes math 
     204functions to arbitrary precision). It uses $\theta$ ranging from 0 to $\pi$ 
     205and $\phi$ ranging from 0 to $2\pi$. It perhaps would benefit from including 
     206the U-substitution for theta. 
     207 
     208:mod:`check1d` uses sasmodels 1D integration and compares that with a 
     209rectangle distribution in $\theta$ and $\phi$, with $\theta$ limits set to 
     210$\pm90/\sqrt(3)$ and $\phi$ limits set to $\pm180/\sqrt(3)$ [The rectangle 
     211weight function uses the fact that the distribution width column is labelled 
     212sigma to decide that the 1-sigma width of a rectangular distribution needs to 
     213be multiplied by $\sqrt(3)$ to get the corresponding gaussian equivalent, or 
     214similar reasoning.] This should rotate the sample through the entire 
     215$\theta-\phi$ surface according to the pattern that you see in jitter.py when 
     216you modify it to use 'rectangle' rather than 'gaussian' for its distribution 
     217without changing the viewing angle. When computing the dispersity integral, 
     218weights are scaled by abs(cos(dtheta)) to account for the points in phi 
     219getting closer together as dtheta increases. This integrated dispersion is 
     220computed at a set of $(qx, qy)$ points $(q cos(\alpha), q sin(\alpha))$ at 
     221some angle $\alpha$ (currently angle=0) for each q used in the 1-D 
     222integration. The individual q points should be equivalent to asymint rect-n 
     223when the viewing angle is set to (theta,phi,psi) = (90, 0, 0). Such tests can 
     224help to validate that 2d intensity is consistent with 1d models. 
     225 
     226:mod:`sascomp -sphere=n` uses the identical rectangular distribution to 
     227compute the pattern of the qx-qy grid. You can see from triaxial_ellipsoid 
     228that there may be something wrong conceptually since the pattern is no longer 
     229circular when the view (theta,phi,psi) is not (90, phi, 0). check1d shows 
     230that it is different from the sasmodels 1D integral even when at theta=0, 
     231psi=0. Cross checking the values with asymint, the sasmodels 1D integral is 
     232better at low q, though for very large structures there are not enough points 
     233in the integration for sasmodels 1D to compute the high q 1D integral 
     234correctly. [Some of that may now be fixed?] 
     235 
     236The :mod:`sascomp` utility can be used for 2d as well as 1d calculations to 
     237compare results for two sets of parameters or processor types, for example 
    213238these two oriented cylinders here should be equivalent. 
    214239 
  • doc/guide/orientation/orientation.rst

    reda8b30 re964ab1  
    44================== 
    55 
    6 With two dimensional small angle diffraction data SasView will calculate scattering from 
    7 oriented particles, applicable for example to shear flow or orientation in a magnetic field. 
     6With two dimensional small angle diffraction data SasView will calculate 
     7scattering from oriented particles, applicable for example to shear flow 
     8or orientation in a magnetic field. 
    89 
    9 In general we first need to define the mean, or a reference orientation of the particles with respect  
    10 to the incoming neutron or X-ray beam. This is done using three angles: $\theta$ and $\phi$ define the  
    11 orientation of the axis of the particle, angle $\Psi$ is defined as the orientation of the major 
    12 axis of the particle cross section with respect to its starting position along the beam direction. 
    13 The figures below are for an elliptical cross section cylinder, 
    14 but may be applied analogously to other shapes of particle. 
     10In general we first need to define the mean, or a reference orientation 
     11of the particles with respect to the incoming neutron or X-ray beam. This 
     12is done using three angles: $\theta$ and $\phi$ define the orientation of 
     13the axis of the particle, angle $\Psi$ is defined as the orientation of 
     14the major axis of the particle cross section with respect to its starting 
     15position along the beam direction. The figures below are for an elliptical 
     16cross section cylinder, but may be applied analogously to other shapes of 
     17particle. 
    1518 
    1619.. note:: 
    17     It is very important to note that these angles, in particular $\theta$ and $\phi$, are NOT in general 
    18     the same as the $\theta$ and $\phi$ appearing in equations for the scattering form factor which gives  
    19     the scattered intensity or indeed in the equation for scattering vector $Q$. 
    20     The $\theta$ rotation must be applied before the $\phi$ rotation, else there is an ambiguity. 
     20    It is very important to note that these angles, in particular $\theta$ 
     21    and $\phi$, are NOT in general the same as the $\theta$ and $\phi$ 
     22    appearing in equations for the scattering form factor which gives the 
     23    scattered intensity or indeed in the equation for scattering vector $Q$. 
     24    The $\theta$ rotation must be applied before the $\phi$ rotation, else 
     25    there is an ambiguity. 
    2126 
    2227.. figure:: 
    2328    orient_img/elliptical_cylinder_angle_definition.png 
    2429 
    25     Definition of angles for oriented elliptical cylinder, where axis_ratio b/a is shown >1, 
    26     Note that rotation $\theta$, initially in the $xz$ plane, is carried out first, then 
    27     rotation $\phi$ about the $z$ axis, finally rotation $\Psi$ is around the axis of the cylinder. 
    28     The neutron or X-ray beam is along the $z$ axis. 
     30    Definition of angles for oriented elliptical cylinder, where axis_ratio 
     31    b/a is shown >1, Note that rotation $\theta$, initially in the $xz$ 
     32    plane, is carried out first, then rotation $\phi$ about the $z$ axis, 
     33    finally rotation $\Psi$ is around the axis of the cylinder. The neutron 
     34    or X-ray beam is along the $z$ axis. 
    2935 
    3036.. figure:: 
    3137    orient_img/elliptical_cylinder_angle_projection.png 
    3238 
    33     Some examples of the orientation angles for an elliptical cylinder, with $\Psi$ = 0. 
     39    Some examples of the orientation angles for an elliptical cylinder, 
     40    with $\Psi$ = 0. 
    3441 
    35 Having established the mean direction of the particle we can then apply angular orientation distributions. 
    36 This is done by a numerical integration over a range of angles in a similar way to polydispersity for particle size. 
    37 In the current version of sasview the orientational dispersity is defined with respect to the axes of the particle. 
     42Having established the mean direction of the particle we can then apply 
     43angular orientation distributions. This is done by a numerical integration 
     44over a range of angles in a similar way to polydispersity for particle size. 
     45In the current version of sasview the orientational dispersity is defined 
     46with respect to the axes of the particle. 
    3847 
    39 The $\theta$ and $\phi$ parameters to orient the cylinder only appear in the model when fitting 2d data. 
    40 On introducing "Orientational Distribution" in the angles, "distribution of theta" and "distribution of phi" parameters will 
    41 appear. These are actually rotations about the axes $\delta_1$ and $\delta_2$ of the cylinder, the $b$ and $a$ axes of the 
    42 cylinder cross section. (When $\theta = \phi = 0$ these are parallel to the $Y$ and $X$ axes of the instrument.) 
    43 The third orientation distribution, in $\psi$, is about the $c$ axis of the particle. Some experimentation may be required to 
    44 understand the 2d patterns fully. A number of different shapes of distribution are available, as described for  
    45 polydispersity, see :ref:`polydispersityhelp` . 
     48The $\theta$ and $\phi$ parameters to orient the cylinder only appear in the 
     49model when fitting 2d data. On introducing "Orientational Distribution" in 
     50the angles, "distribution of theta" and "distribution of phi" parameters will 
     51appear. These are actually rotations about the axes $\delta_1$ and $\delta_2$ 
     52of the cylinder, the $b$ and $a$ axes of the cylinder cross section. (When 
     53$\theta = \phi = 0$ these are parallel to the $Y$ and $X$ axes of the 
     54instrument.) The third orientation distribution, in $\psi$, is about the $c$ 
     55axis of the particle. Some experimentation may be required to understand the 
     562d patterns fully. A number of different shapes of distribution are 
     57available, as described for polydispersity, see :ref:`polydispersityhelp` . 
    4658 
    47 Earlier versions of SasView had numerical integration issues in some circumstances when  
    48 distributions passed through 90 degrees. The distributions in particle coordinates are more robust, but should still be approached  
    49 with care for large ranges of angle. 
     59Earlier versions of SasView had numerical integration issues in some 
     60circumstances when distributions passed through 90 degrees. The distributions 
     61in particle coordinates are more robust, but should still be approached with 
     62care for large ranges of angle. 
    5063 
    51 Note that the form factors for asymmetric particles are also performing numerical integrations over one or more variables, so  
    52 care should be taken, especially with very large particles or more extreme aspect ratios. Users can experiment with the  
    53 values of Npts and Nsigs, the number of steps used in the integration and the range spanned in number of standard deviations. 
    54 The standard deviation is entered in units of degrees. For a rectangular (uniform) distribution the full width  
    55 should be $\pm\sqrt(3)$ ~ 1.73 standard deviations (this may be changed soon). 
     64Note that the form factors for asymmetric particles are also performing 
     65numerical integrations over one or more variables, so care should be taken, 
     66especially with very large particles or more extreme aspect ratios. Users can 
     67experiment with the values of Npts and Nsigs, the number of steps used in the 
     68integration and the range spanned in number of standard deviations. The 
     69standard deviation is entered in units of degrees. For a rectangular 
     70(uniform) distribution the full width should be $\pm\sqrt(3)$ ~ 1.73 standard 
     71deviations (this may be changed soon). 
    5672 
    57 Where appropriate, for best numerical results, keep $a < b < c$ and the $\theta$ distribution narrower than the $\phi$ distribution. 
     73Where appropriate, for best numerical results, keep $a < b < c$ and the 
     74$\theta$ distribution narrower than the $\phi$ distribution. 
    5875 
    59 Some more detailed technical notes are provided in the developer section of this manual :ref:`orientation_developer` . 
    60      
     76Some more detailed technical notes are provided in the developer section of 
     77this manual :ref:`orientation_developer` . 
     78 
    6179*Document History* 
    6280 
    63 | 2017-10-27 Richard Heenan  
     81| 2017-10-27 Richard Heenan 
Note: See TracChangeset for help on using the changeset viewer.