Changeset a0ebc96 in sasmodels


Ignore:
Timestamp:
Apr 11, 2017 2:24:40 AM (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:
535fee6
Parents:
8678a34 (diff), e645373 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge branch 'ticket-890' into ticket-776-orientation

Files:
1 added
1 deleted
21 edited

Legend:

Unmodified
Added
Removed
  • sasmodels/models/barbell.py

    r0b56f38 r9802ab3  
    6868The 2D scattering intensity is calculated similar to the 2D cylinder model. 
    6969 
    70 .. figure:: img/cylinder_angle_definition.jpg 
     70.. figure:: img/cylinder_angle_definition.png 
    7171 
    7272    Definition of the angles for oriented 2D barbells. 
     
    108108              ["radius",      "Ang",         20, [0, inf],    "volume",      "Cylindrical bar radius"], 
    109109              ["length",      "Ang",        400, [0, inf],    "volume",      "Cylinder bar length"], 
    110               ["theta",       "degrees",     60, [-inf, inf], "orientation", "In plane angle"], 
    111               ["phi",         "degrees",     60, [-inf, inf], "orientation", "Out of plane angle"], 
     110              ["theta",       "degrees",     60, [-360, 360], "orientation", "Barbell axis to beam angle"], 
     111              ["phi",         "degrees",     60, [-360, 360], "orientation", "Rotation about beam"], 
    112112             ] 
    113113# pylint: enable=bad-whitespace, line-too-long 
  • sasmodels/models/bcc_paracrystal.py

    r1f65db5 r69e1afc  
    123123              ["sld",         "1e-6/Ang^2",  4,    [-inf, inf], "sld",         "Particle scattering length density"], 
    124124              ["sld_solvent", "1e-6/Ang^2",  1,    [-inf, inf], "sld",         "Solvent scattering length density"], 
    125               ["theta",       "degrees",    60,    [-inf, inf], "orientation", "In plane angle"], 
    126               ["phi",         "degrees",    60,    [-inf, inf], "orientation", "Out of plane angle"], 
    127               ["psi",         "degrees",    60,    [-inf, inf], "orientation", "Out of plane angle"] 
     125              ["theta",       "degrees",    60,    [-360, 360], "orientation", "c axis to beam angle"], 
     126              ["phi",         "degrees",    60,    [-360, 360], "orientation", "rotation about beam"], 
     127              ["psi",         "degrees",    60,    [-360, 360], "orientation", "rotation about c axis"] 
    128128             ] 
    129129# pylint: enable=bad-whitespace, line-too-long 
     
    148148    [{ }, 
    149149     [0.001, q, 0.215268], [1.46601394721, 2.85851284174, 0.00866710287078]], 
    150 ] 
     150    [{'theta':20.0,'phi':30,'psi':40.0},(-0.017,0.035),2082.20264399 ], 
     151    [{'theta':20.0,'phi':30,'psi':40.0},(-0.081,0.011),0.436323144781 ] 
     152    ] 
  • sasmodels/models/capped_cylinder.py

    r0b56f38 r9802ab3  
    7171The 2D scattering intensity is calculated similar to the 2D cylinder model. 
    7272 
    73 .. figure:: img/cylinder_angle_definition.jpg 
     73.. figure:: img/cylinder_angle_definition.png 
    7474 
    7575    Definition of the angles for oriented 2D cylinders. 
     
    129129              ["radius_cap", "Ang",     20, [0, inf],    "volume", "Cap radius"], 
    130130              ["length",     "Ang",    400, [0, inf],    "volume", "Cylinder length"], 
    131               ["theta",      "degrees", 60, [-inf, inf], "orientation", "inclination angle"], 
    132               ["phi",        "degrees", 60, [-inf, inf], "orientation", "deflection angle"], 
     131              ["theta",      "degrees", 60, [-360, 360], "orientation", "cylinder axis to beam angle"], 
     132              ["phi",        "degrees", 60, [-360, 360], "orientation", "rotation about beam"], 
    133133             ] 
    134134# pylint: enable=bad-whitespace, line-too-long 
  • sasmodels/models/core_shell_bicelle.py

    r0b56f38 r9802ab3  
    4747.. math:: 
    4848 
    49         \begin{align}     
     49    \begin{align}     
    5050    F(Q,\alpha) = &\bigg[  
    5151    (\rho_c - \rho_f) V_c \frac{2J_1(QRsin \alpha)}{QRsin\alpha}\frac{sin(QLcos\alpha/2)}{Q(L/2)cos\alpha} \\ 
     
    6363cylinders is then given by integrating over all possible $\theta$ and $\phi$. 
    6464 
    65 The *theta* and *phi* parameters are not used for the 1D output. 
     65For oriented bicelles the *theta*, and *phi* orientation parameters will appear when fitting 2D data,  
     66see the :ref:`cylinder` model for further information. 
    6667Our implementation of the scattering kernel and the 1D scattering intensity 
    6768use the c-library from NIST. 
    6869 
    69 .. figure:: img/cylinder_angle_definition.jpg 
     70.. figure:: img/cylinder_angle_definition.png 
    7071 
    71     Definition of the angles for the oriented core shell bicelle tmodel. 
     72    Definition of the angles for the oriented core shell bicelle model, 
     73    note that the cylinder axis of the bicelle starts along the beam direction 
     74    when $\theta  = \phi = 0$. 
    7275 
    7376 
     
    135138    ["sld_rim",        "1e-6/Ang^2", 4, [-inf, inf], "sld",         "Cylinder rim scattering length density"], 
    136139    ["sld_solvent",    "1e-6/Ang^2", 1, [-inf, inf], "sld",         "Solvent scattering length density"], 
    137     ["theta",          "degrees",   90, [-inf, inf], "orientation", "In plane angle"], 
    138     ["phi",            "degrees",    0, [-inf, inf], "orientation", "Out of plane angle"], 
     140    ["theta",          "degrees",   90, [-360, 360], "orientation", "cylinder axis to beam angle"], 
     141    ["phi",            "degrees",    0, [-360, 360], "orientation", "rotation about beam"] 
    139142    ] 
    140143 
     
    160163qy = q*sin(pi/6.0) 
    161164tests = [[{}, 0.05, 7.4883545957], 
    162         [{'theta':80., 'phi':10.}, (qx, qy), 2.81048892474 ], 
     165        [{'theta':80., 'phi':10.}, (qx, qy), 2.81048892474 ] 
    163166        ] 
    164167del qx, qy  # not necessary to delete, but cleaner 
  • sasmodels/models/core_shell_bicelle_elliptical.c

    r44e8a93 rdedcf34  
    2424    double si1,si2,be1,be2; 
    2525     // core_shell_bicelle_elliptical, RKH Dec 2016, based on elliptical_cylinder and core_shell_bicelle 
    26      // tested against limiting cases of cylinder, elliptical_cylinder and core_shell_bicelle 
     26     // tested against limiting cases of cylinder, elliptical_cylinder, stacked_discs, and core_shell_bicelle 
    2727     //    const double uplim = M_PI_4; 
    2828    const double halfheight = 0.5*length; 
     
    3434 
    3535    const double r_major = r_minor * x_core; 
    36     const double rA = 0.5*(square(r_major) + square(r_minor)); 
    37     const double rB = 0.5*(square(r_major) - square(r_minor)); 
     36    const double r2A = 0.5*(square(r_major) + square(r_minor)); 
     37    const double r2B = 0.5*(square(r_major) - square(r_minor)); 
    3838    const double dr1 = (rhoc-rhoh)   *M_PI*r_minor*r_major*(2.0*halfheight);; 
    3939    const double dr2 = (rhor-rhosolv)*M_PI*(r_minor+thick_rim)*(r_major+thick_rim)*2.0*(halfheight+thick_face); 
     
    6060            //const double beta = ( Gauss76Z[j]*(vbj-vaj) + vaj + vbj )/2.0; 
    6161            const double beta = ( Gauss76Z[j] +1.0)*M_PI_2; 
    62             const double rr = sqrt(rA - rB*cos(beta)); 
     62            const double rr = sqrt(r2A - r2B*cos(beta)); 
    6363            double besarg1 = q*rr*sin_alpha; 
    6464            double besarg2 = q*(rr+thick_rim)*sin_alpha; 
  • sasmodels/models/core_shell_bicelle_elliptical.py

    r16a8c63 r9802ab3  
    7676bicelles is then given by integrating over all possible $\alpha$ and $\psi$. 
    7777 
    78 For oriented bicellles the *theta*, *phi* and *psi* orientation parameters only appear when fitting 2D data,  
     78For oriented bicelles the *theta*, *phi* and *psi* orientation parameters will appear when fitting 2D data,  
    7979see the :ref:`elliptical-cylinder` model for further information. 
    8080 
     
    119119    ["radius",         "Ang",       30, [0, inf],    "volume",      "Cylinder core radius"], 
    120120    ["x_core",        "None",       3,  [0, inf],    "volume",      "axial ratio of core, X = r_polar/r_equatorial"], 
    121     ["thick_rim",  "Ang",        8, [0, inf],    "volume",      "Rim shell thickness"], 
    122     ["thick_face", "Ang",       14, [0, inf],    "volume",      "Cylinder face thickness"], 
    123     ["length",         "Ang",      50, [0, inf],    "volume",      "Cylinder length"], 
     121    ["thick_rim",  "Ang",            8, [0, inf],    "volume",      "Rim shell thickness"], 
     122    ["thick_face", "Ang",           14, [0, inf],    "volume",      "Cylinder face thickness"], 
     123    ["length",         "Ang",       50, [0, inf],    "volume",      "Cylinder length"], 
    124124    ["sld_core",       "1e-6/Ang^2", 4, [-inf, inf], "sld",         "Cylinder core scattering length density"], 
    125125    ["sld_face",       "1e-6/Ang^2", 7, [-inf, inf], "sld",         "Cylinder face scattering length density"], 
    126126    ["sld_rim",        "1e-6/Ang^2", 1, [-inf, inf], "sld",         "Cylinder rim scattering length density"], 
    127127    ["sld_solvent",    "1e-6/Ang^2", 6, [-inf, inf], "sld",         "Solvent scattering length density"], 
    128     ["theta",          "degrees",   90, [-360, 360], "orientation", "In plane angle"], 
    129     ["phi",            "degrees",    0, [-360, 360], "orientation", "Out of plane angle"], 
    130     ["psi",            "degrees",    0, [-360, 360], "orientation", "Major axis angle relative to Q"], 
     128    ["theta",       "degrees",    90.0, [-360, 360], "orientation", "cylinder axis to beam angle"], 
     129    ["phi",         "degrees",    0,    [-360, 360], "orientation", "rotation about beam"], 
     130    ["psi",         "degrees",    0,    [-360, 360], "orientation", "rotation about cylinder axis"] 
    131131    ] 
    132132 
  • sasmodels/models/core_shell_cylinder.py

    r0b56f38 r9b79f29  
    117117              ["length", "Ang", 400, [0, inf], "volume", 
    118118               "Cylinder length"], 
    119               ["theta", "degrees", 60, [-inf, inf], "orientation", 
    120                "In plane angle"], 
    121               ["phi", "degrees", 60, [-inf, inf], "orientation", 
    122                "Out of plane angle"], 
     119              ["theta", "degrees", 60, [-360, 360], "orientation", 
     120               "cylinder axis to beam angle"], 
     121              ["phi", "degrees",   60, [-360, 360], "orientation", 
     122               "rotation about beam"], 
    123123             ] 
    124124 
  • sasmodels/models/core_shell_ellipsoid.py

    rdaeef4c r9802ab3  
    7777   F^2(q)=\int_{0}^{\pi/2}{F^2(q,\alpha)\sin(\alpha)d\alpha} 
    7878 
     79For oriented ellipsoids the *theta*, *phi* and *psi* orientation parameters will appear when fitting 2D data,  
     80see the :ref:`elliptical-cylinder` model for further information. 
    7981 
    8082References 
     
    132134    ["sld_shell",     "1e-6/Ang^2", 1,   [-inf, inf], "sld",         "Shell scattering length density"], 
    133135    ["sld_solvent",   "1e-6/Ang^2", 6.3, [-inf, inf], "sld",         "Solvent scattering length density"], 
    134     ["theta",         "degrees",    0,   [-inf, inf], "orientation", "Oblate orientation wrt incoming beam"], 
    135     ["phi",           "degrees",    0,   [-inf, inf], "orientation", "Oblate orientation in the plane of the detector"], 
     136    ["theta",         "degrees",    0,   [-360, 360], "orientation", "elipsoid axis to beam angle"], 
     137    ["phi",           "degrees",    0,   [-360, 360], "orientation", "rotation about beam"], 
    136138    ] 
    137139# pylint: enable=bad-whitespace, line-too-long 
  • sasmodels/models/core_shell_parallelepiped.py

    r1f65db5 r9b79f29  
    153153              ["thick_rim_c", "Ang", 10, [0, inf], "volume", 
    154154               "Thickness of C rim"], 
    155               ["theta", "degrees", 0, [-inf, inf], "orientation", 
    156                "In plane angle"], 
    157               ["phi", "degrees", 0, [-inf, inf], "orientation", 
    158                "Out of plane angle"], 
    159               ["psi", "degrees", 0, [-inf, inf], "orientation", 
    160                "Rotation angle around its own c axis against q plane"], 
     155              ["theta", "degrees", 0, [-360, 360], "orientation", 
     156               "c axis to beam angle"], 
     157              ["phi", "degrees", 0, [-360, 360], "orientation", 
     158               "rotation about beam"], 
     159              ["psi", "degrees", 0, [-360, 360], "orientation", 
     160               "rotation about c axis"], 
    161161             ] 
    162162 
  • sasmodels/models/cylinder.py

    r3fd0499 r9802ab3  
    6161.. _cylinder-angle-definition: 
    6262 
    63 .. figure:: img/cylinder_angle_definition.jpg 
     63.. figure:: img/cylinder_angle_definition.png 
    6464 
    65     Definition of the angles for oriented cylinders. 
     65    Definition of the $\theta$ and $\phi$ orientation angles for a cylinder relative  
     66    to the beam line coordinates, plus an indication of their orientation distributions  
     67    which are described as rotations about each of the perpendicular axes $\delta_1$ and $\delta_2$  
     68    in the frame of the cylinder itself, which when $\theta = \phi = 0$ are parallel to the $Y$ and $X$ axes. 
    6669 
    6770.. figure:: img/cylinder_angle_projection.png 
     
    6972    Examples for oriented cylinders. 
    7073 
    71 The $\theta$ and $\phi$ parameters only appear in the model when fitting 2d data. 
     74The $\theta$ and $\phi$ parameters to orient the cylinder only appear in the model when fitting 2d data.  
     75On introducing "Orientational Distribution" in the angles, "distribution of theta" and "distribution of phi" parameters will 
     76appear. These are actually rotations about the axes $\delta_1$ and $\delta_2$ of the cylinder, which when $\theta = \phi = 0$ are parallel  
     77to the $Y$ and $X$ axes of the instrument respectively. Some experimentation may be required to understand the 2d patterns fully. 
     78(Earlier implementations had numerical integration issues in some circumstances when orientation distributions passed through 90 degrees, such  
     79situations, with very broad distributions, should still be approached with care.)  
    7280 
    7381Validation 
     
    127135              ["length", "Ang", 400, [0, inf], "volume", 
    128136               "Cylinder length"], 
    129               ["theta", "degrees", 60, [-inf, inf], "orientation", 
    130                "latitude"], 
    131               ["phi", "degrees", 60, [-inf, inf], "orientation", 
    132                "longitude"], 
     137              ["theta", "degrees", 60, [-360, 360], "orientation", 
     138               "cylinder axis to beam angle"], 
     139              ["phi", "degrees",   60, [-360, 360], "orientation", 
     140               "rotation about beam"], 
    133141             ] 
    134142 
  • sasmodels/models/ellipsoid.py

    r0b56f38 r9b79f29  
    151151              ["radius_equatorial", "Ang", 400, [0, inf], "volume", 
    152152               "Equatorial radius"], 
    153               ["theta", "degrees", 60, [-inf, inf], "orientation", 
    154                "In plane angle"], 
    155               ["phi", "degrees", 60, [-inf, inf], "orientation", 
    156                "Out of plane angle"], 
     153              ["theta", "degrees", 60, [-360, 360], "orientation", 
     154               "ellipsoid axis to beam angle"], 
     155              ["phi", "degrees", 60, [-360, 360], "orientation", 
     156               "rotation about beam"], 
    157157             ] 
    158158 
  • sasmodels/models/elliptical_cylinder.py

    r16a8c63 r9802ab3  
    5757define the axis of the cylinder using two angles $\theta$, $\phi$ and $\Psi$ 
    5858(see :ref:`cylinder orientation <cylinder-angle-definition>`). The angle 
    59 $\Psi$ is the rotational angle around its own long_c axis against the $q$ plane. 
    60 For example, $\Psi = 0$ when the $r_\text{minor}$ axis is parallel to the 
    61 $x$ axis of the detector. 
     59$\Psi$ is the rotational angle around its own long_c axis.  
    6260 
    6361All angle parameters are valid and given only for 2D calculation; ie, an 
     
    6664.. figure:: img/elliptical_cylinder_angle_definition.png 
    6765 
    68     Definition of angles for oriented elliptical cylinder, where axis_ratio >1, 
    69     and angle $\Psi$ is a rotation around the axis of the cylinder. 
     66    Definition of angles for oriented elliptical cylinder, where axis_ratio is drawn >1, 
     67    and angle $\Psi$ is now a rotation around the axis of the cylinder. 
    7068 
    7169.. figure:: img/elliptical_cylinder_angle_projection.png 
     
    7371    Examples of the angles for oriented elliptical cylinders against the 
    7472    detector plane, with $\Psi$ = 0. 
     73 
     74The $\theta$ and $\phi$ parameters to orient the cylinder only appear in the model when fitting 2d data.  
     75On introducing "Orientational Distribution" in the angles, "distribution of theta" and "distribution of phi" parameters will 
     76appear. These are actually rotations about the axes $\delta_1$ and $\delta_2$ of the cylinder, the $b$ and $a$ axes of the  
     77cylinder cross section. (When $\theta = \phi = 0$ these are parallel to the $Y$ and $X$ axes of the instrument.)  
     78The third orientation distribution, in $\psi$, is about the $c$ axis of the particle. Some experimentation may be required to  
     79understand the 2d patterns fully. (Earlier implementations had numerical integration issues in some circumstances when orientation  
     80distributions passed through 90 degrees, such situations, with very broad distributions, should still be approached with care.)  
    7581 
    7682NB: The 2nd virial coefficient of the cylinder is calculated based on the 
     
    126132              ["sld",         "1e-6/Ang^2", 4.0,   [-inf, inf], "sld",         "Cylinder scattering length density"], 
    127133              ["sld_solvent", "1e-6/Ang^2", 1.0,   [-inf, inf], "sld",         "Solvent scattering length density"], 
    128               ["theta",       "degrees",    90.0,  [-360, 360], "orientation", "In plane angle"], 
    129               ["phi",         "degrees",    0,     [-360, 360], "orientation", "Out of plane angle"], 
    130               ["psi",         "degrees",    0,     [-360, 360], "orientation", "Major axis angle relative to Q"]] 
     134              ["theta",       "degrees",    90.0,  [-360, 360], "orientation", "cylinder axis to beam angle"], 
     135              ["phi",         "degrees",    0,     [-360, 360], "orientation", "rotation about beam"], 
     136              ["psi",         "degrees",    0,     [-360, 360], "orientation", "rotation about cylinder axis"]] 
    131137 
    132138# pylint: enable=bad-whitespace, line-too-long 
  • sasmodels/models/fcc_paracrystal.py

    r1f65db5 r69e1afc  
    111111              ["sld", "1e-6/Ang^2", 4, [-inf, inf], "sld", "Particle scattering length density"], 
    112112              ["sld_solvent", "1e-6/Ang^2", 1, [-inf, inf], "sld", "Solvent scattering length density"], 
    113               ["theta", "degrees", 60, [-inf, inf], "orientation", "In plane angle"], 
    114               ["phi", "degrees", 60, [-inf, inf], "orientation", "Out of plane angle"], 
    115               ["psi", "degrees", 60, [-inf, inf], "orientation", "Out of plane angle"] 
     113              ["theta",       "degrees",    60,    [-360, 360], "orientation", "c axis to beam angle"], 
     114              ["phi",         "degrees",    60,    [-360, 360], "orientation", "rotation about beam"], 
     115              ["psi",         "degrees",    60,    [-360, 360], "orientation", "rotation about c axis"] 
    116116             ] 
    117117# pylint: enable=bad-whitespace, line-too-long 
     
    129129            psi_pd=15, psi_pd_n=0, 
    130130           ) 
    131 # april 6 2017, rkh add unit tests, NOT compared with any other calc method, assume correct! 
    132 # add 2d test later 
     131# april 10 2017, rkh add unit tests, NOT compared with any other calc method, assume correct! 
    133132q =4.*pi/220. 
    134133tests = [ 
    135134    [{ }, 
    136135     [0.001, q, 0.215268], [0.275164706668, 5.7776842567, 0.00958167119232]], 
     136     [{}, (-0.047,-0.007), 238.103096286], 
     137     [{}, (0.053,0.063), 0.863609587796 ], 
    137138] 
  • sasmodels/models/hollow_cylinder.py

    r0b56f38 r9b79f29  
    8282    ["sld",         "1/Ang^2",  6.3, [-inf, inf], "sld",         "Cylinder sld"], 
    8383    ["sld_solvent", "1/Ang^2",  1,   [-inf, inf], "sld",         "Solvent sld"], 
    84     ["theta",       "degrees", 90,   [-360, 360], "orientation", "Theta angle"], 
    85     ["phi",         "degrees",  0,   [-360, 360], "orientation", "Phi angle"], 
     84    ["theta",       "degrees", 90,   [-360, 360], "orientation", "Cylinder axis to beam angle"], 
     85    ["phi",         "degrees",  0,   [-360, 360], "orientation", "Rotation about beam"], 
    8686    ] 
    8787# pylint: enable=bad-whitespace, line-too-long 
  • sasmodels/models/parallelepiped.py

    rafd4692 r9802ab3  
    99---------- 
    1010 
    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`. 
     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`. 
    1414 
    1515.. _parallelepiped-image: 
     
    6767 
    6868    \mu &= qB 
    69  
    7069 
    7170The scattering intensity per unit volume is returned in units of |cm^-1|. 
     
    113112    detector plane. 
    114113 
     114On introducing "Orientational Distribution" in the angles, "distribution of theta" and "distribution of phi" parameters will 
     115appear. These are actually rotations about axes $\delta_1$ and $\delta_2$ of the parallelepiped, perpendicular to the $a$ x $c$ and $b$ x $c$ faces.  
     116(When $\theta = \phi = 0$ these are parallel to the $Y$ and $X$ axes of the instrument.) The third orientation distribution, in $\psi$, is  
     117about the $c$ axis of the particle, perpendicular to the $a$ x $b$ face. Some experimentation may be required to  
     118understand the 2d patterns fully. (Earlier implementations had numerical integration issues in some circumstances when orientation  
     119distributions passed through 90 degrees, such situations, with very broad distributions, should still be approached with care.)  
     120 
     121     
    115122For a given orientation of the parallelepiped, the 2D form factor is 
    116123calculated as 
     
    168175 
    169176* **Author:** This model is based on form factor calculations implemented 
    170 in a c-library provided by the NIST Center for Neutron Research (Kline, 2006). 
     177    in a c-library provided by the NIST Center for Neutron Research (Kline, 2006). 
    171178* **Last Modified by:**  Paul Kienzle **Date:** April 05, 2017 
    172179* **Last Reviewed by:**  Richard Heenan **Date:** April 06, 2017 
     
    205212              ["length_c", "Ang", 400, [0, inf], "volume", 
    206213               "Larger side of the parallelepiped"], 
    207               ["theta", "degrees", 60, [-inf, inf], "orientation", 
    208                "In plane angle"], 
    209               ["phi", "degrees", 60, [-inf, inf], "orientation", 
    210                "Out of plane angle"], 
    211               ["psi", "degrees", 60, [-inf, inf], "orientation", 
    212                "Rotation angle around its own c axis against q plane"], 
     214              ["theta", "degrees", 60, [-360, 360], "orientation", 
     215               "c axis to beam angle"], 
     216              ["phi", "degrees", 60, [-360, 360], "orientation", 
     217               "rotation about beam"], 
     218              ["psi", "degrees", 60, [-360, 360], "orientation", 
     219               "rotation about c axis"], 
    213220             ] 
    214221 
  • sasmodels/models/sc_paracrystal.py

    r0881f4e r69e1afc  
    130130              ["sld",  "1e-6/Ang^2",         3.0, [0.0, inf],  "sld",         "Sphere scattering length density"], 
    131131              ["sld_solvent", "1e-6/Ang^2",  6.3, [0.0, inf],  "sld",         "Solvent scattering length density"], 
    132               ["theta",       "degrees",     0.0, [-inf, inf], "orientation", "Orientation of the a1 axis w/respect incoming beam"], 
    133               ["phi",         "degrees",     0.0, [-inf, inf], "orientation", "Orientation of the a2 in the plane of the detector"], 
    134               ["psi",         "degrees",     0.0, [-inf, inf], "orientation", "Orientation of the a3 in the plane of the detector"], 
     132              ["theta",       "degrees",    0,    [-360, 360], "orientation", "c axis to beam angle"], 
     133              ["phi",         "degrees",    0,    [-360, 360], "orientation", "rotation about beam"], 
     134              ["psi",         "degrees",    0,    [-360, 360], "orientation", "rotation about c axis"] 
    135135             ] 
    136136# pylint: enable=bad-whitespace, line-too-long 
     
    149149 
    150150tests = [ 
    151     # Accuracy tests based on content in test/utest_extra_models.py 
     151    # Accuracy tests based on content in test/utest_extra_models.py, 2d tests added April 10, 2017 
    152152    [{}, 0.001, 10.3048], 
    153153    [{}, 0.215268, 0.00814889], 
    154     [{}, (0.414467), 0.001313289] 
     154    [{}, (0.414467), 0.001313289], 
     155    [{'theta':10.0,'phi':20,'psi':30.0},(0.045,-0.035),18.0397138402 ], 
     156    [{'theta':10.0,'phi':20,'psi':30.0},(0.023,0.045),0.0177333171285 ] 
    155157    ] 
    156158 
  • sasmodels/models/stacked_disks.py

    rf3073b0 r9802ab3  
    7777the axis of the cylinder using two angles $\theta$ and $\varphi$. 
    7878 
    79 .. figure:: img/cylinder_angle_definition.jpg 
     79.. figure:: img/cylinder_angle_definition.png 
    8080 
    8181    Examples of the angles against the detector plane. 
     
    131131    ["sld_layer",   "1e-6/Ang^2",  0.0, [-inf, inf], "sld",         "Layer scattering length density"], 
    132132    ["sld_solvent", "1e-6/Ang^2",  5.0, [-inf, inf], "sld",         "Solvent scattering length density"], 
    133     ["theta",       "degrees",     0,   [-inf, inf], "orientation", "Orientation of the stacked disk axis w/respect incoming beam"], 
    134     ["phi",         "degrees",     0,   [-inf, inf], "orientation", "Orientation of the stacked disk in the plane of the detector"], 
     133    ["theta",       "degrees",     0,   [-360, 360], "orientation", "Orientation of the stacked disk axis w/respect incoming beam"], 
     134    ["phi",         "degrees",     0,   [-360, 360], "orientation", "Rotation about beam"], 
    135135    ] 
    136136# pylint: enable=bad-whitespace, line-too-long 
  • sasmodels/models/triaxial_ellipsoid.py

    r0881f4e re645373  
    7676    of the particle. 
    7777 
    78 The angle $\psi$ is the rotational angle around its own $c$ axis 
    79 against the $q$ plane. For example, $\psi = 0$ when the 
    80 $a$ axis is parallel to the $x$ axis of the detector. 
     78For oriented ellipsoids the *theta*, *phi* and *psi* orientation parameters will appear when fitting 2D data,  
     79see the :ref:`elliptical-cylinder` model for further information. 
    8180 
    8281.. _triaxial-ellipsoid-angles: 
     
    126125 
    127126description = """ 
    128 Note: During fitting ensure that the inequality ra<rb<rc is not 
    129         violated. Otherwise the calculation will 
    130         not be correct. 
     127   Note - fitting ensure that the inequality ra<rb<rc is not 
     128   violated. Otherwise the calculation may not be correct. 
    131129""" 
    132130category = "shape:ellipsoid" 
     
    143141              ["radius_polar", "Ang", 10, [0, inf], "volume", 
    144142               "Polar radius, Rc"], 
    145               ["theta", "degrees", 60, [-inf, inf], "orientation", 
    146                "In plane angle"], 
    147               ["phi", "degrees", 60, [-inf, inf], "orientation", 
    148                "Out of plane angle"], 
    149               ["psi", "degrees", 60, [-inf, inf], "orientation", 
    150                "Out of plane angle"], 
     143              ["theta", "degrees", 60, [-360, 360], "orientation", 
     144               "polar axis to beam angle"], 
     145              ["phi", "degrees", 60, [-360, 360], "orientation", 
     146               "rotation about beam"], 
     147              ["psi", "degrees", 60, [-360, 360], "orientation", 
     148               "rotation about polar axis"], 
    151149             ] 
    152150 
     
    183181# april 6 2017, rkh add unit tests 
    184182#     NOT compared with any other calc method, assume correct! 
    185 # add 2d test after pull #890 
     183# check 2d test after pull #890 
    186184qx = q*cos(pi/6.0) 
    187185qy = q*sin(pi/6.0) 
    188186tests = [[{}, 0.05, 24.8839548033], 
    189 #        [{'theta':80., 'phi':10.}, (qx, qy), 9999. ], 
     187        [{'theta':80., 'phi':10.}, (qx, qy), 166.712060266 ], 
    190188        ] 
    191189del qx, qy  # not necessary to delete, but cleaner 
  • explore/jitter.py

    r85190c2 r8678a34  
    33dispersity and possible replacement algorithms. 
    44""" 
     5import sys 
     6 
    57import mpl_toolkits.mplot3d   # Adds projection='3d' option to subplot 
    68import matplotlib.pyplot as plt 
    79from matplotlib.widgets import Slider, CheckButtons 
    810from matplotlib import cm 
    9  
    1011import numpy as np 
    1112from numpy import pi, cos, sin, sqrt, exp, degrees, radians 
    1213 
    13 def draw_beam(ax): 
     14def draw_beam(ax, view=(0, 0)): 
    1415    #ax.plot([0,0],[0,0],[1,-1]) 
    1516    #ax.scatter([0]*100,[0]*100,np.linspace(1, -1, 100), alpha=0.8) 
     
    2223    x = r*np.outer(np.cos(u), np.ones_like(v)) 
    2324    y = r*np.outer(np.sin(u), np.ones_like(v)) 
    24     z = np.outer(np.ones_like(u), v) 
     25    z = 1.3*np.outer(np.ones_like(u), v) 
     26 
     27    theta, phi = view 
     28    shape = x.shape 
     29    points = np.matrix([x.flatten(), y.flatten(), z.flatten()]) 
     30    points = Rz(phi)*Ry(theta)*points 
     31    x, y, z = [v.reshape(shape) for v in points] 
    2532 
    2633    ax.plot_surface(x, y, z, rstride=4, cstride=4, color='y', alpha=0.5) 
    2734 
    28 def draw_shimmy(ax, theta, phi, psi, dtheta, dphi, dpsi): 
    29     size=[0.1, 0.4, 1.0] 
    30     view=[theta, phi, psi] 
    31     shimmy=[0,0,0] 
    32     #draw_shape = draw_parallelepiped 
    33     draw_shape = draw_ellipsoid 
     35def draw_jitter(ax, view, jitter): 
     36    size = [0.1, 0.4, 1.0] 
     37    draw_shape = draw_parallelepiped 
     38    #draw_shape = draw_ellipsoid 
    3439 
    3540    #np.random.seed(10) 
     
    6469        [ 1,  1,  1], 
    6570    ] 
     71    dtheta, dphi, dpsi = jitter 
    6672    if dtheta == 0: 
    6773        cloud = [v for v in cloud if v[0] == 0] 
     
    7076    if dpsi == 0: 
    7177        cloud = [v for v in cloud if v[2] == 0] 
    72     draw_shape(ax, size, view, shimmy, steps=100, alpha=0.8) 
     78    draw_shape(ax, size, view, [0, 0, 0], steps=100, alpha=0.8) 
    7379    for point in cloud: 
    74         shimmy=[dtheta*point[0], dphi*point[1], dpsi*point[2]] 
    75         draw_shape(ax, size, view, shimmy, alpha=0.8) 
     80        delta = [dtheta*point[0], dphi*point[1], dpsi*point[2]] 
     81        draw_shape(ax, size, view, delta, alpha=0.8) 
    7682    for v in 'xyz': 
    7783        a, b, c = size 
     
    8086        getattr(ax, v+'axis').label.set_text(v) 
    8187 
    82 def draw_ellipsoid(ax, size, view, shimmy, steps=25, alpha=1): 
     88def draw_ellipsoid(ax, size, view, jitter, steps=25, alpha=1): 
    8389    a,b,c = size 
    84     theta, phi, psi = view 
    85     dtheta, dphi, dpsi = shimmy 
    86  
    8790    u = np.linspace(0, 2 * np.pi, steps) 
    8891    v = np.linspace(0, np.pi, steps) 
     
    9093    y = b*np.outer(np.sin(u), np.sin(v)) 
    9194    z = c*np.outer(np.ones_like(u), np.cos(v)) 
    92  
    93     shape = x.shape 
    94     points = np.matrix([x.flatten(),y.flatten(),z.flatten()]) 
    95     points = Rz(dpsi)*Ry(dtheta)*Rx(dphi)*points 
    96     points = Rz(phi)*Ry(theta)*Rz(psi)*points 
    97     x,y,z = [v.reshape(shape) for v in points] 
     95    x, y, z = transform_xyz(view, jitter, x, y, z) 
    9896 
    9997    ax.plot_surface(x, y, z, rstride=4, cstride=4, color='w', alpha=alpha) 
    10098 
    101 def draw_parallelepiped(ax, size, view, shimmy, alpha=1): 
     99    draw_labels(ax, view, jitter, [ 
     100         ('c+', [ 0, 0, c], [ 1, 0, 0]), 
     101         ('c-', [ 0, 0,-c], [ 0, 0,-1]), 
     102         ('a+', [ a, 0, 0], [ 0, 0, 1]), 
     103         ('a-', [-a, 0, 0], [ 0, 0,-1]), 
     104         ('b+', [ 0, b, 0], [-1, 0, 0]), 
     105         ('b-', [ 0,-b, 0], [-1, 0, 0]), 
     106    ]) 
     107 
     108def draw_parallelepiped(ax, size, view, jitter, steps=None, alpha=1): 
    102109    a,b,c = size 
    103     theta, phi, psi = view 
    104     dtheta, dphi, dpsi = shimmy 
    105  
    106110    x = a*np.array([ 1,-1, 1,-1, 1,-1, 1,-1]) 
    107111    y = b*np.array([ 1, 1,-1,-1, 1, 1,-1,-1]) 
     
    118122    ]) 
    119123 
    120     points = np.matrix([x,y,z]) 
    121     points = Rz(dpsi)*Ry(dtheta)*Rx(dphi)*points 
    122     points = Rz(phi)*Ry(theta)*Rz(psi)*points 
    123  
    124     x,y,z = [np.array(v).flatten() for v in points] 
     124    x, y, z = transform_xyz(view, jitter, x, y, z) 
    125125    ax.plot_trisurf(x, y, triangles=tri, Z=z, color='w', alpha=alpha) 
    126126 
    127 def draw_sphere(ax, radius=10., steps=100): 
    128     u = np.linspace(0, 2 * np.pi, steps) 
    129     v = np.linspace(0, np.pi, steps) 
    130  
    131     x = radius * np.outer(np.cos(u), np.sin(v)) 
    132     y = radius * np.outer(np.sin(u), np.sin(v)) 
    133     z = radius * np.outer(np.ones(np.size(u)), np.cos(v)) 
    134     ax.plot_surface(x, y, z, rstride=4, cstride=4, color='w') 
    135  
    136 def draw_mesh_new(ax, theta, dtheta, phi, dphi, flow, radius=10., dist='gauss'): 
    137     theta_center = radians(theta) 
    138     phi_center = radians(phi) 
    139     flow_center = radians(flow) 
    140     dtheta = radians(dtheta) 
    141     dphi = radians(dphi) 
    142  
    143     # 10 point 3-sigma gaussian weights 
    144     t = np.linspace(-3., 3., 11) 
     127    draw_labels(ax, view, jitter, [ 
     128         ('c+', [ 0, 0, c], [ 1, 0, 0]), 
     129         ('c-', [ 0, 0,-c], [ 0, 0,-1]), 
     130         ('a+', [ a, 0, 0], [ 0, 0, 1]), 
     131         ('a-', [-a, 0, 0], [ 0, 0,-1]), 
     132         ('b+', [ 0, b, 0], [-1, 0, 0]), 
     133         ('b-', [ 0,-b, 0], [-1, 0, 0]), 
     134    ]) 
     135 
     136def draw_mesh(ax, view, jitter, radius=1.2, n=11, dist='gauss'): 
     137    theta, phi, psi = view 
     138    dtheta, dphi, dpsi = jitter 
    145139    if dist == 'gauss': 
     140        t = np.linspace(-3, 3, n) 
    146141        weights = exp(-0.5*t**2) 
    147142    elif dist == 'rect': 
     143        t = np.linspace(0, 1, n) 
    148144        weights = np.ones_like(t) 
    149145    else: 
    150146        raise ValueError("expected dist to be 'gauss' or 'rect'") 
    151     theta = dtheta*t 
    152     phi = dphi*t 
    153  
    154     x = radius * np.outer(cos(phi), cos(theta)) 
    155     y = radius * np.outer(sin(phi), cos(theta)) 
    156     z = radius * np.outer(np.ones_like(phi), sin(theta)) 
    157     #w = np.outer(weights, weights*abs(cos(dtheta*t))) 
    158     w = np.outer(weights, weights*abs(cos(theta))) 
    159  
    160     x, y, z, w = [v.flatten() for v in (x,y,z,w)] 
    161     x, y, z = rotate(x, y, z, phi_center, theta_center, flow_center) 
    162  
    163     ax.scatter(x, y, z, c=w, marker='o', vmin=0., vmax=1.) 
    164  
    165 def rotate(x, y, z, phi, theta, psi): 
    166     R = Rz(phi)*Ry(theta)*Rz(psi) 
    167     p = np.vstack([x,y,z]) 
    168     return R*p 
     147 
     148    # mesh in theta, phi formed by rotating z 
     149    z = np.matrix([[0], [0], [radius]]) 
     150    points = np.hstack([Rx(phi_i)*Ry(theta_i)*z 
     151                        for theta_i in dtheta*t 
     152                        for phi_i in dphi*t]) 
     153    # rotate relative to beam 
     154    points = orient_relative_to_beam(view, points) 
     155 
     156    w = np.outer(weights, weights) 
     157 
     158    x, y, z = [np.array(v).flatten() for v in points] 
     159    ax.scatter(x, y, z, c=w.flatten(), marker='o', vmin=0., vmax=1.) 
    169160 
    170161def Rx(angle): 
     
    188179         [0., 0., 1.]] 
    189180    return np.matrix(R) 
     181 
     182def transform_xyz(view, jitter, x, y, z): 
     183    x, y, z = [np.asarray(v) for v in (x, y, z)] 
     184    shape = x.shape 
     185    points = np.matrix([x.flatten(),y.flatten(),z.flatten()]) 
     186    points = apply_jitter(jitter, points) 
     187    points = orient_relative_to_beam(view, points) 
     188    x, y, z = [np.array(v).reshape(shape) for v in points] 
     189    return x, y, z 
     190 
     191def apply_jitter(jitter, points): 
     192    dtheta, dphi, dpsi = jitter 
     193    points = Rz(dpsi)*Ry(dtheta)*Rx(dphi)*points 
     194    return points 
     195 
     196def orient_relative_to_beam(view, points): 
     197    theta, phi, psi = view 
     198    points = Rz(phi)*Ry(theta)*Rz(psi)*points 
     199    return points 
     200 
     201def draw_labels(ax, view, jitter, text): 
     202    labels, locations, orientations = zip(*text) 
     203    px, py, pz = zip(*locations) 
     204    dx, dy, dz = zip(*orientations) 
     205 
     206    px, py, pz = transform_xyz(view, jitter, px, py, pz) 
     207    dx, dy, dz = transform_xyz(view, jitter, dx, dy, dz) 
     208 
     209    for label, p, zdir in zip(labels, zip(px, py, pz), zip(dx, dy, dz)): 
     210        zdir = np.asarray(zdir).flatten() 
     211        ax.text(p[0], p[1], p[2], label, zdir=zdir) 
     212 
     213def draw_sphere(ax, radius=10., steps=100): 
     214    u = np.linspace(0, 2 * np.pi, steps) 
     215    v = np.linspace(0, np.pi, steps) 
     216 
     217    x = radius * np.outer(np.cos(u), np.sin(v)) 
     218    y = radius * np.outer(np.sin(u), np.sin(v)) 
     219    z = radius * np.outer(np.ones(np.size(u)), np.cos(v)) 
     220    ax.plot_surface(x, y, z, rstride=4, cstride=4, color='w') 
    190221 
    191222def main(): 
     
    206237 
    207238    axcolor = 'lightgoldenrodyellow' 
     239 
    208240    axtheta  = plt.axes([0.1, 0.15, 0.45, 0.04], axisbg=axcolor) 
    209241    axphi = plt.axes([0.1, 0.1, 0.45, 0.04], axisbg=axcolor) 
     
    212244    sphi = Slider(axphi, 'Phi', -180, 180, valinit=phi) 
    213245    spsi = Slider(axpsi, 'Psi', -180, 180, valinit=psi) 
     246 
    214247    axdtheta  = plt.axes([0.75, 0.15, 0.15, 0.04], axisbg=axcolor) 
    215248    axdphi = plt.axes([0.75, 0.1, 0.15, 0.04], axisbg=axcolor) 
     
    217250    sdtheta = Slider(axdtheta, 'dTheta', 0, 30, valinit=dtheta) 
    218251    sdphi = Slider(axdphi, 'dPhi', 0, 30, valinit=dphi) 
    219     sdpsi = Slider(axdpsi, 'dPsi', 0, 30, valinit=dphi) 
     252    sdpsi = Slider(axdpsi, 'dPsi', 0, 30, valinit=dpsi) 
    220253 
    221254    def update(val, axis=None): 
    222         theta, phi, psi = stheta.val, sphi.val, spsi.val 
    223         dtheta, dphi, dpsi = sdtheta.val, sdphi.val, sdpsi.val 
     255        view = stheta.val, sphi.val, spsi.val 
     256        jitter = sdtheta.val, sdphi.val, sdpsi.val 
    224257        ax.cla() 
    225         draw_beam(ax) 
    226         draw_shimmy(ax, theta, phi, psi, dtheta, dphi, dpsi) 
    227         #if not axis.startswith('d'): 
    228         #    ax.view_init(elev=theta, azim=phi) 
     258        draw_beam(ax, (0, 0)) 
     259        if 0: 
     260            draw_jitter(ax, view, jitter) 
     261        else: 
     262            draw_jitter(ax, view, (0,0,0)) 
     263            draw_mesh(ax, view, jitter) 
    229264        plt.gcf().canvas.draw() 
    230265 
Note: See TracChangeset for help on using the changeset viewer.