Changes in / [43ff77c:16a8c63] in sasmodels


Ignore:
Location:
sasmodels/models
Files:
6 added
5 deleted
6 edited

Legend:

Unmodified
Added
Removed
  • sasmodels/models/core_shell_bicelle_elliptical.py

    r0b56f38 r15a90c1  
    8080 
    8181 
    82 .. figure:: img/elliptical_cylinder_angle_definition.jpg 
     82.. figure:: img/elliptical_cylinder_angle_definition.png 
    8383 
    84     Definition of the angles for the oriented core_shell_bicelle_elliptical model. 
    85     Note that *theta* and *phi* are currently defined differently to those for the core_shell_bicelle model. 
     84    Definition of the angles for the oriented core_shell_bicelle_elliptical particles.    
     85 
    8686 
    8787 
  • sasmodels/models/core_shell_parallelepiped.py

    rcb0dc22 r1916c52  
    1010 
    1111.. note:: 
    12    This model was originally ported from NIST IGOR macros. However,t is not 
    13    yet fully understood by the SasView developers and is currently review. 
     12   This model was originally ported from NIST IGOR macros. However, it is not 
     13   yet fully understood by the SasView developers and is currently under review. 
    1414 
    1515The form factor is normalized by the particle volume $V$ such that 
     
    5151 
    5252    F_{a}(Q,\alpha,\beta)= 
    53     \left[\frac{\sin(Q(L_A+2t_A)/2\sin\alpha \sin\beta)}{Q(L_A+2t_A)/2\sin\alpha\sin\beta} 
    54     - \frac{\sin(QL_A/2\sin\alpha \sin\beta)}{QL_A/2\sin\alpha \sin\beta} \right] 
    55     \left[\frac{\sin(QL_B/2\sin\alpha \sin\beta)}{QL_B/2\sin\alpha \sin\beta} \right] 
    56     \left[\frac{\sin(QL_C/2\sin\alpha \sin\beta)}{QL_C/2\sin\alpha \sin\beta} \right] 
     53    \left[\frac{\sin(\tfrac{1}{2}Q(L_A+2t_A)\sin\alpha \sin\beta)}{\tfrac{1}{2}Q(L_A+2t_A)\sin\alpha\sin\beta} 
     54    - \frac{\sin(\tfrac{1}{2}QL_A\sin\alpha \sin\beta)}{\tfrac{1}{2}QL_A\sin\alpha \sin\beta} \right] 
     55    \left[\frac{\sin(\tfrac{1}{2}QL_B\sin\alpha \sin\beta)}{\tfrac{1}{2}QL_B\sin\alpha \sin\beta} \right] 
     56    \left[\frac{\sin(\tfrac{1}{2}QL_C\sin\alpha \sin\beta)}{\tfrac{1}{2}QL_C\sin\alpha \sin\beta} \right] 
    5757 
    5858.. note:: 
    5959 
     60    Why does t_B not appear in the above equation? 
    6061    For the calculation of the form factor to be valid, the sides of the solid 
    61     MUST be chosen such that** $A < B < C$. 
     62    MUST (perhaps not any more?) be chosen such that** $A < B < C$. 
    6263    If this inequality is not satisfied, the model will not report an error, 
    6364    but the calculation will not be correct and thus the result wrong. 
     
    8081NB: The 2nd virial coefficient of the core_shell_parallelepiped is calculated 
    8182based on the the averaged effective radius $(=\sqrt{(A+2t_A)(B+2t_B)/\pi})$ 
    82 and length $(C+2t_C)$ values, and used as the effective radius 
    83 for $S(Q)$ when $P(Q) * S(Q)$ is applied. 
     83and length $(C+2t_C)$ values, after appropriately 
     84sorting the three dimensions to give an oblate or prolate particle, to give an  
     85effective radius, for $S(Q)$ when $P(Q) * S(Q)$ is applied. 
    8486 
    8587To provide easy access to the orientation of the parallelepiped, we define the 
     
    9092*x*-axis of the detector. 
    9193 
    92 .. figure:: img/parallelepiped_angle_definition.jpg 
     94.. figure:: img/parallelepiped_angle_definition.png 
    9395 
    9496    Definition of the angles for oriented core-shell parallelepipeds. 
    9597 
    96 .. figure:: img/parallelepiped_angle_projection.jpg 
     98.. figure:: img/parallelepiped_angle_projection.png 
    9799 
    98100    Examples of the angles for oriented core-shell parallelepipeds against the 
     
    119121 
    120122import numpy as np 
    121 from numpy import pi, inf, sqrt 
     123from numpy import pi, inf, sqrt, cos, sin 
    122124 
    123125name = "core_shell_parallelepiped" 
     
    193195            psi_pd=10, psi_pd_n=1) 
    194196 
    195 qx, qy = 0.2 * np.cos(2.5), 0.2 * np.sin(2.5) 
     197# rkh 7/4/17 add random unit test for 2d, note make all params different, 2d values not tested against other codes or models 
     198qx, qy = 0.2 * cos(pi/6.), 0.2 * sin(pi/6.) 
    196199tests = [[{}, 0.2, 0.533149288477], 
    197200         [{}, [0.2], [0.533149288477]], 
    198          [{'theta':10.0, 'phi':10.0}, (qx, qy), 0.032102135569], 
    199          [{'theta':10.0, 'phi':10.0}, [(qx, qy)], [0.032102135569]], 
     201         [{'theta':10.0, 'phi':20.0}, (qx, qy), 0.0853299803222], 
     202         [{'theta':10.0, 'phi':20.0}, [(qx, qy)], [0.0853299803222]], 
    200203        ] 
    201204del qx, qy  # not necessary to delete, but cleaner 
  • sasmodels/models/cylinder.py

    rb7e8b94 r15a90c1  
    6464 
    6565    Definition of the angles for oriented cylinders. 
     66 
     67.. figure:: img/cylinder_angle_projection.png 
     68 
     69    Examples for oriented cylinders. 
    6670 
    6771The $\theta$ and $\phi$ parameters only appear in the model when fitting 2d data. 
  • sasmodels/models/elliptical_cylinder.py

    r0b56f38 r15a90c1  
    6464oriented system. 
    6565 
    66 .. figure:: img/elliptical_cylinder_angle_definition.jpg 
     66.. figure:: img/elliptical_cylinder_angle_definition.png 
    6767 
    68     Definition of angles for 2D 
     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. 
    6970 
    70 .. figure:: img/cylinder_angle_projection.jpg 
     71.. figure:: img/elliptical_cylinder_angle_projection.png 
    7172 
    7273    Examples of the angles for oriented elliptical cylinders against the 
    73     detector plane. 
     74    detector plane, with $\Psi$ = 0. 
    7475 
    7576NB: The 2nd virial coefficient of the cylinder is calculated based on the 
  • sasmodels/models/parallelepiped.py

    r8e68ea0 r1916c52  
    1515.. _parallelepiped-image: 
    1616 
     17 
    1718.. figure:: img/parallelepiped_geometry.jpg 
    1819 
     
    2122.. note:: 
    2223 
    23    The edge of the solid must satisfy the condition that $A < B < C$. 
    24    This requirement is not enforced in the model, so it is up to the 
    25    user to check this during the analysis. 
     24   The edge of the solid used to have to satisfy the condition that $A < B < C$. 
     25   After some improvements to the effective radius calculation, used with an S(Q), 
     26   it is beleived that this is no longer the case.  
    2627 
    2728The 1D scattering intensity $I(q)$ is calculated as: 
     
    7172 
    7273NB: The 2nd virial coefficient of the parallelepiped is calculated based on 
    73 the averaged effective radius $(=\sqrt{A B / \pi})$ and 
     74the averaged effective radius, after appropriately 
     75sorting the three dimensions, to give an oblate or prolate particle, $(=\sqrt{A B / \pi})$ and 
    7476length $(= C)$ values, and used as the effective radius for 
    7577$S(q)$ when $P(q) \cdot S(q)$ is applied. 
     
    102104.. _parallelepiped-orientation: 
    103105 
    104 .. figure:: img/parallelepiped_angle_definition.jpg 
    105  
    106     Definition of the angles for oriented parallelepipeds. 
    107  
    108 .. figure:: img/parallelepiped_angle_projection.jpg 
    109  
    110     Examples of the angles for oriented parallelepipeds against the 
     106.. figure:: img/parallelepiped_angle_definition.png 
     107 
     108    Definition of the angles for oriented parallelepiped, shown with $A < B < C$. 
     109 
     110.. figure:: img/parallelepiped_angle_projection.png 
     111 
     112    Examples of the angles for an oriented parallelepiped against the 
    111113    detector plane. 
    112114 
     
    116118.. math:: 
    117119 
    118     P(q_x, q_y) = \left[\frac{\sin(qA\cos\alpha/2)}{(qA\cos\alpha/2)}\right]^2 
    119                   \left[\frac{\sin(qB\cos\beta/2)}{(qB\cos\beta/2)}\right]^2 
    120                   \left[\frac{\sin(qC\cos\gamma/2)}{(qC\cos\gamma/2)}\right]^2 
     120    P(q_x, q_y) = \left[\frac{\sin(\tfrac{1}{2}qA\cos\alpha)}{(\tfrac{1}{2}qA\cos\alpha)}\right]^2 
     121                  \left[\frac{\sin(\tfrac{1}{2}qB\cos\beta)}{(\tfrac{1}{2}qB\cos\beta)}\right]^2 
     122                  \left[\frac{\sin(\tfrac{1}{2}qC\cos\gamma)}{(\tfrac{1}{2}qC\cos\gamma)}\right]^2 
    121123 
    122124with 
     
    154156angles. 
    155157 
    156 This model is based on form factor calculations implemented in a c-library 
    157 provided by the NIST Center for Neutron Research (Kline, 2006). 
    158158 
    159159References 
     
    163163 
    164164R Nayuk and K Huber, *Z. Phys. Chem.*, 226 (2012) 837-854 
     165 
     166Authorship and Verification 
     167---------------------------- 
     168 
     169* **Author:** This model is based on form factor calculations implemented in a c-library 
     170provided by the NIST Center for Neutron Research (Kline, 2006). 
     171* **Last Modified by:**  Paul Kienzle **Date:** April 05, 2017 
     172* **Last Reviewed by:**  Richard Heenan **Date:** April 06, 2017 
     173 
    165174""" 
    166175 
    167176import numpy as np 
    168 from numpy import pi, inf, sqrt 
     177from numpy import pi, inf, sqrt, sin, cos 
    169178 
    170179name = "parallelepiped" 
     
    208217def ER(length_a, length_b, length_c): 
    209218    """ 
    210         Return effective radius (ER) for P(q)*S(q) 
     219    Return effective radius (ER) for P(q)*S(q) 
    211220    """ 
    212  
     221    # now that axes can be in any size order, need to sort a,b,c where a~b and c is either much smaller  
     222    # or much larger 
     223    abc = np.vstack((length_a, length_b, length_c)) 
     224    abc = np.sort(abc, axis=0) 
     225    selector = (abc[1] - abc[0]) > (abc[2] - abc[1]) 
     226    length = np.where(selector, abc[0], abc[2]) 
    213227    # surface average radius (rough approximation) 
    214     surf_rad = sqrt(length_a * length_b / pi) 
    215  
    216     ddd = 0.75 * surf_rad * (2 * surf_rad * length_c + (length_c + surf_rad) * (length_c + pi * surf_rad)) 
     228    radius = np.sqrt(np.where(~selector, abc[0]*abc[1], abc[1]*abc[2]) / pi) 
     229 
     230    ddd = 0.75 * radius * (2*radius*length + (length + radius)*(length + pi*radius)) 
    217231    return 0.5 * (ddd) ** (1. / 3.) 
    218232 
     
    230244            phi_pd=10, phi_pd_n=1, 
    231245            psi_pd=10, psi_pd_n=10) 
    232  
    233 qx, qy = 0.2 * np.cos(2.5), 0.2 * np.sin(2.5) 
     246# rkh 7/4/17 add random unit test for 2d, note make all params different, 2d values not tested against other codes or models 
     247qx, qy = 0.2 * cos(pi/6.), 0.2 * sin(pi/6.) 
    234248tests = [[{}, 0.2, 0.17758004974], 
    235249         [{}, [0.2], [0.17758004974]], 
    236          [{'theta':10.0, 'phi':10.0}, (qx, qy), 0.00560296014], 
    237          [{'theta':10.0, 'phi':10.0}, [(qx, qy)], [0.00560296014]], 
     250         [{'theta':10.0, 'phi':20.0}, (qx, qy), 0.0089517140475], 
     251         [{'theta':10.0, 'phi':20.0}, [(qx, qy)], [0.0089517140475]], 
    238252        ] 
    239253del qx, qy  # not necessary to delete, but cleaner 
  • sasmodels/models/triaxial_ellipsoid.py

    r0b56f38 r15a90c1  
    6565To provide easy access to the orientation of the triaxial ellipsoid, 
    6666we define the axis of the cylinder using the angles $\theta$, $\phi$ 
    67 and $\psi$. These angles are defined on 
    68 :numref:`triaxial-ellipsoid-angles` . 
     67and $\psi$. These angles are defined analogously to the elliptical_cylinder below 
     68 
     69.. figure:: img/elliptical_cylinder_angle_definition.png 
     70 
     71    Definition of angles for oriented triaxial ellipsoid, where radii shown here are $a < b << c$ 
     72    and angle $\Psi$ is a rotation around the axis of the particle. 
     73 
    6974The angle $\psi$ is the rotational angle around its own $c$ axis 
    7075against the $q$ plane. For example, $\psi = 0$ when the 
     
    7378.. _triaxial-ellipsoid-angles: 
    7479 
    75 .. figure:: img/triaxial_ellipsoid_angle_projection.jpg 
     80.. figure:: img/triaxial_ellipsoid_angle_projection.png 
    7681 
    77     The angles for oriented ellipsoid. 
     82    Some example angles for oriented ellipsoid. 
    7883 
    7984The radius-of-gyration for this system is  $R_g^2 = (R_a R_b R_c)^2/5$. 
     
    147152def ER(radius_equat_minor, radius_equat_major, radius_polar): 
    148153    """ 
    149         Returns the effective radius used in the S*P calculation 
     154    Returns the effective radius used in the S*P calculation 
    150155    """ 
    151156    import numpy as np 
    152157    from .ellipsoid import ER as ellipsoid_ER 
    153      # now that radii can be in any size order, radii need sorting a,b,c where a~b and c is either much smaller or much larger 
    154      # also need some unit tests! 
    155      
    156     return ellipsoid_ER(radius_polar, np.sqrt(radius_equat_minor * radius_equat_major)) 
     158 
     159    # now that radii can be in any size order, radii need sorting a,b,c where a~b and c is either much smaller 
     160    # or much larger 
     161    radii = np.vstack((radius_equat_major, radius_equat_minor, radius_polar)) 
     162    radii = np.sort(radii, axis=0) 
     163    selector = (radii[1] - radii[0]) > (radii[2] - radii[1]) 
     164    polar = np.where(selector, radii[0], radii[2]) 
     165    equatorial = np.sqrt(np.where(~selector, radii[0]*radii[1], radii[1]*radii[2])) 
     166    return ellipsoid_ER(polar, equatorial) 
    157167 
    158168demo = dict(scale=1, background=0, 
     
    166176            phi_pd=15, phi_pd_n=1, 
    167177            psi_pd=15, psi_pd_n=1) 
     178 
    168179q = 0.1 
    169180# april 6 2017, rkh add unit tests, NOT compared with any other calc method, assume correct! 
Note: See TracChangeset for help on using the changeset viewer.