Changeset 4aaf89a in sasmodels for sasmodels/models/triaxial_ellipsoid.py


Ignore:
Timestamp:
Apr 6, 2017 4:11:41 AM (7 years ago)
Author:
Paul Kienzle <pkienzle@…>
Branches:
master, core_shell_microgels, costrafo411, magnetic_model, ticket-1257-vesicle-product, ticket_1156, ticket_1265_superball, ticket_822_more_unit_tests
Children:
15a90c1
Parents:
b6e0636
Message:

triaxial ellipsoid/parallelepiped: choose the pair of lengths that are closest to each other as the equatorial plane when computing ER

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sasmodels/models/triaxial_ellipsoid.py

    r4b0a294 r4aaf89a  
    147147def ER(radius_equat_minor, radius_equat_major, radius_polar): 
    148148    """ 
    149         Returns the effective radius used in the S*P calculation 
     149    Returns the effective radius used in the S*P calculation 
    150150    """ 
    151151    import numpy as np 
    152152    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)) 
     153 
     154    # now that radii can be in any size order, radii need sorting a,b,c where a~b and c is either much smaller  
     155    # or much larger 
     156    radii = np.vstack((radius_equat_major, radius_equat_minor, radius_polar)) 
     157    radii = np.sort(radii, axis=0) 
     158    selector = (radii[1] - radii[0]) > (radii[2] - radii[1]) 
     159    polar = np.where(selector, radii[0], radii[2]) 
     160    equatorial = np.sqrt(np.where(~selector, radii[0]*radii[1], radii[1]*radii[2])) 
     161    return ellipsoid_ER(polar, equatorial) 
    157162 
    158163demo = dict(scale=1, background=0, 
     
    166171            phi_pd=15, phi_pd_n=1, 
    167172            psi_pd=15, psi_pd_n=1) 
     173 
     174# TODO: need some unit tests! 
Note: See TracChangeset for help on using the changeset viewer.