Changeset 4aaf89a in sasmodels


Ignore:
Timestamp:
Apr 6, 2017 6:11:41 AM (7 months ago)
Author:
Paul Kienzle <pkienzle@…>
Branches:
master, costrafo411, doc_update, flexible-cylinder, ticket-776-orientation
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

Location:
sasmodels/models
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • sasmodels/models/parallelepiped.py

    red0827a r4aaf89a  
    208208def ER(length_a, length_b, length_c): 
    209209    """ 
    210         Return effective radius (ER) for P(q)*S(q) 
     210    Return effective radius (ER) for P(q)*S(q) 
    211211    """ 
    212  
     212    # now that axes can be in any size order, need to sort a,b,c where a~b and c is either much smaller  
     213    # or much larger 
     214    abc = np.vstack((length_a, length_b, length_c)) 
     215    abc = np.sort(abc, axis=0) 
     216    selector = (abc[1] - abc[0]) > (abc[2] - abc[1]) 
     217    length = np.where(selector, abc[0], abc[2]) 
    213218    # 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)) 
     219    radius = np.sqrt(np.where(~selector, abc[0]*abc[1], abc[1]*abc[2]) / pi) 
     220 
     221    ddd = 0.75 * radius * (2*radius*length + (length + radius)*(length + pi*radius)) 
    217222    return 0.5 * (ddd) ** (1. / 3.) 
    218223 
  • 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.