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


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

Legend:

Unmodified
Added
Removed
  • sasmodels/models/core_shell_bicelle_elliptical.py

    r15a90c1 r0b56f38  
    8080 
    8181 
    82 .. figure:: img/elliptical_cylinder_angle_definition.png 
     82.. figure:: img/elliptical_cylinder_angle_definition.jpg 
    8383 
    84     Definition of the angles for the oriented core_shell_bicelle_elliptical particles.    
    85  
     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. 
    8686 
    8787 
  • sasmodels/models/core_shell_parallelepiped.py

    r1916c52 rcb0dc22  
    1010 
    1111.. note:: 
    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. 
     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. 
    1414 
    1515The form factor is normalized by the particle volume $V$ such that 
     
    5151 
    5252    F_{a}(Q,\alpha,\beta)= 
    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] 
     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] 
    5757 
    5858.. note:: 
    5959 
    60     Why does t_B not appear in the above equation? 
    6160    For the calculation of the form factor to be valid, the sides of the solid 
    62     MUST (perhaps not any more?) be chosen such that** $A < B < C$. 
     61    MUST be chosen such that** $A < B < C$. 
    6362    If this inequality is not satisfied, the model will not report an error, 
    6463    but the calculation will not be correct and thus the result wrong. 
     
    8180NB: The 2nd virial coefficient of the core_shell_parallelepiped is calculated 
    8281based on the the averaged effective radius $(=\sqrt{(A+2t_A)(B+2t_B)/\pi})$ 
    83 and length $(C+2t_C)$ values, after appropriately 
    84 sorting the three dimensions to give an oblate or prolate particle, to give an  
    85 effective radius, for $S(Q)$ when $P(Q) * S(Q)$ is applied. 
     82and length $(C+2t_C)$ values, and used as the effective radius 
     83for $S(Q)$ when $P(Q) * S(Q)$ is applied. 
    8684 
    8785To provide easy access to the orientation of the parallelepiped, we define the 
     
    9290*x*-axis of the detector. 
    9391 
    94 .. figure:: img/parallelepiped_angle_definition.png 
     92.. figure:: img/parallelepiped_angle_definition.jpg 
    9593 
    9694    Definition of the angles for oriented core-shell parallelepipeds. 
    9795 
    98 .. figure:: img/parallelepiped_angle_projection.png 
     96.. figure:: img/parallelepiped_angle_projection.jpg 
    9997 
    10098    Examples of the angles for oriented core-shell parallelepipeds against the 
     
    121119 
    122120import numpy as np 
    123 from numpy import pi, inf, sqrt, cos, sin 
     121from numpy import pi, inf, sqrt 
    124122 
    125123name = "core_shell_parallelepiped" 
     
    195193            psi_pd=10, psi_pd_n=1) 
    196194 
    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 
    198 qx, qy = 0.2 * cos(pi/6.), 0.2 * sin(pi/6.) 
     195qx, qy = 0.2 * np.cos(2.5), 0.2 * np.sin(2.5) 
    199196tests = [[{}, 0.2, 0.533149288477], 
    200197         [{}, [0.2], [0.533149288477]], 
    201          [{'theta':10.0, 'phi':20.0}, (qx, qy), 0.0853299803222], 
    202          [{'theta':10.0, 'phi':20.0}, [(qx, qy)], [0.0853299803222]], 
     198         [{'theta':10.0, 'phi':10.0}, (qx, qy), 0.032102135569], 
     199         [{'theta':10.0, 'phi':10.0}, [(qx, qy)], [0.032102135569]], 
    203200        ] 
    204201del qx, qy  # not necessary to delete, but cleaner 
  • sasmodels/models/cylinder.py

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

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

    r1916c52 r8e68ea0  
    1515.. _parallelepiped-image: 
    1616 
    17  
    1817.. figure:: img/parallelepiped_geometry.jpg 
    1918 
     
    2221.. note:: 
    2322 
    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.  
     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. 
    2726 
    2827The 1D scattering intensity $I(q)$ is calculated as: 
     
    7271 
    7372NB: The 2nd virial coefficient of the parallelepiped is calculated based on 
    74 the averaged effective radius, after appropriately 
    75 sorting the three dimensions, to give an oblate or prolate particle, $(=\sqrt{A B / \pi})$ and 
     73the averaged effective radius $(=\sqrt{A B / \pi})$ and 
    7674length $(= C)$ values, and used as the effective radius for 
    7775$S(q)$ when $P(q) \cdot S(q)$ is applied. 
     
    104102.. _parallelepiped-orientation: 
    105103 
    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 
     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 
    113111    detector plane. 
    114112 
     
    118116.. math:: 
    119117 
    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 
     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 
    123121 
    124122with 
     
    156154angles. 
    157155 
     156This model is based on form factor calculations implemented in a c-library 
     157provided 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  
    166 Authorship and Verification 
    167 ---------------------------- 
    168  
    169 * **Author:** This model is based on form factor calculations implemented in a c-library 
    170 provided 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  
    174165""" 
    175166 
    176167import numpy as np 
    177 from numpy import pi, inf, sqrt, sin, cos 
     168from numpy import pi, inf, sqrt 
    178169 
    179170name = "parallelepiped" 
     
    217208def ER(length_a, length_b, length_c): 
    218209    """ 
    219     Return effective radius (ER) for P(q)*S(q) 
     210        Return effective radius (ER) for P(q)*S(q) 
    220211    """ 
    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]) 
     212 
    227213    # surface average radius (rough approximation) 
    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)) 
     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)) 
    231217    return 0.5 * (ddd) ** (1. / 3.) 
    232218 
     
    244230            phi_pd=10, phi_pd_n=1, 
    245231            psi_pd=10, psi_pd_n=10) 
    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 
    247 qx, qy = 0.2 * cos(pi/6.), 0.2 * sin(pi/6.) 
     232 
     233qx, qy = 0.2 * np.cos(2.5), 0.2 * np.sin(2.5) 
    248234tests = [[{}, 0.2, 0.17758004974], 
    249235         [{}, [0.2], [0.17758004974]], 
    250          [{'theta':10.0, 'phi':20.0}, (qx, qy), 0.0089517140475], 
    251          [{'theta':10.0, 'phi':20.0}, [(qx, qy)], [0.0089517140475]], 
     236         [{'theta':10.0, 'phi':10.0}, (qx, qy), 0.00560296014], 
     237         [{'theta':10.0, 'phi':10.0}, [(qx, qy)], [0.00560296014]], 
    252238        ] 
    253239del qx, qy  # not necessary to delete, but cleaner 
  • sasmodels/models/triaxial_ellipsoid.py

    r15a90c1 r0b56f38  
    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 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  
     67and $\psi$. These angles are defined on 
     68:numref:`triaxial-ellipsoid-angles` . 
    7469The angle $\psi$ is the rotational angle around its own $c$ axis 
    7570against the $q$ plane. For example, $\psi = 0$ when the 
     
    7873.. _triaxial-ellipsoid-angles: 
    7974 
    80 .. figure:: img/triaxial_ellipsoid_angle_projection.png 
     75.. figure:: img/triaxial_ellipsoid_angle_projection.jpg 
    8176 
    82     Some example angles for oriented ellipsoid. 
     77    The angles for oriented ellipsoid. 
    8378 
    8479The radius-of-gyration for this system is  $R_g^2 = (R_a R_b R_c)^2/5$. 
     
    152147def ER(radius_equat_minor, radius_equat_major, radius_polar): 
    153148    """ 
    154     Returns the effective radius used in the S*P calculation 
     149        Returns the effective radius used in the S*P calculation 
    155150    """ 
    156151    import numpy as np 
    157152    from .ellipsoid import ER as ellipsoid_ER 
    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) 
     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)) 
    167157 
    168158demo = dict(scale=1, background=0, 
     
    176166            phi_pd=15, phi_pd_n=1, 
    177167            psi_pd=15, psi_pd_n=1) 
    178  
    179168q = 0.1 
    180169# 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.