Changeset c88f983 in sasmodels for sasmodels/models/ellipsoid.py


Ignore:
Timestamp:
Sep 8, 2018 5:29:57 AM (6 years ago)
Author:
Torin Cooper-Bennun <torin.cooper-bennun@…>
Branches:
master, core_shell_microgels, magnetic_model, ticket-1257-vesicle-product, ticket_1156, ticket_1265_superball, ticket_822_more_unit_tests
Children:
c11d09f, 0159b5e
Parents:
84f2962 (diff), 475ff58 (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 'master' into beta_approx

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sasmodels/models/ellipsoid.py

    r71b751d rc88f983  
    125125import numpy as np 
    126126from numpy import inf, sin, cos, pi 
     127 
     128try: 
     129    from numpy import cbrt 
     130except ImportError: 
     131    def cbrt(x): return x ** (1.0/3.0) 
    127132 
    128133name = "ellipsoid" 
     
    172177    idx = radius_polar < radius_equatorial 
    173178    ee[idx] = (radius_equatorial[idx] ** 2 - radius_polar[idx] ** 2) / radius_equatorial[idx] ** 2 
    174     idx = radius_polar == radius_equatorial 
    175     ee[idx] = 2 * radius_polar[idx] 
    176     valid = (radius_polar * radius_equatorial != 0) 
     179    valid = (radius_polar * radius_equatorial != 0) & (radius_polar != radius_equatorial) 
    177180    bd = 1.0 - ee[valid] 
    178181    e1 = np.sqrt(ee[valid]) 
     
    181184    b2 = 1.0 + bd / 2 / e1 * np.log(bL) 
    182185    delta = 0.75 * b1 * b2 
    183  
    184     ddd = np.zeros_like(radius_polar) 
    185     ddd[valid] = 2.0 * (delta + 1.0) * radius_polar * radius_equatorial ** 2 
    186     return 0.5 * ddd ** (1.0 / 3.0) 
     186    ddd = 2.0 * (delta + 1.0) * (radius_polar * radius_equatorial**2)[valid] 
     187 
     188    r = np.zeros_like(radius_polar) 
     189    r[valid] = 0.5 * cbrt(ddd) 
     190    idx = radius_polar == radius_equatorial 
     191    r[idx] = radius_polar[idx] 
     192    return r 
    187193 
    188194def random(): 
Note: See TracChangeset for help on using the changeset viewer.