Changeset 65279d8 in sasmodels


Ignore:
Timestamp:
Apr 7, 2016 12:05:21 PM (8 years ago)
Author:
Paul Kienzle <pkienzle@…>
Branches:
master, core_shell_microgels, costrafo411, magnetic_model, release_v0.94, release_v0.95, ticket-1257-vesicle-product, ticket_1156, ticket_1265_superball, ticket_822_more_unit_tests
Children:
3a45c2c, 416609b
Parents:
e6408d0
Message:

vectorize poly_gauss_coil

Location:
sasmodels/models
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • sasmodels/models/broad_peak.py

    rec45c4f r65279d8  
    101101    """ 
    102102    return Iq(sqrt(qx ** 2 + qy ** 2), *args) 
    103  
    104103Iqxy.vectorized = True # Iqxy accepts an array of qx, qy values 
    105104 
  • sasmodels/models/poly_gauss_coil.py

    rec45c4f r65279d8  
    5050""" 
    5151 
    52 from numpy import inf, sqrt, exp, power 
     52import numpy as np 
     53from numpy import inf, exp, power, sqrt 
    5354 
    5455name =  "poly_gauss_coil" 
     
    7071    # pylint: disable = missing-docstring 
    7172    u = polydispersity - 1.0 
    72     z = ((q * radius_gyration) * (q * radius_gyration)) / (1.0 + 2.0 * u) 
    73     if (q == 0).any(): 
    74         inten = i_zero 
     73    z = (q*radius_gyration)**2 / (1.0 + 2.0*u) 
     74    # need to trap the case of the polydispersity being 1 (ie, monodispersity!) 
     75    if polydispersity == 1.0: 
     76        inten = i_zero * 2.0 * (exp(-z) + z - 1.0) 
    7577    else: 
    76     # need to trap the case of the polydispersity being 1 (ie, monodispersity!) 
    77         if polydispersity == 1: 
    78             inten = i_zero * 2.0 * (exp(-z) + z - 1.0 ) / (z * z) 
    79         else: 
    80             minusoneonu = -1.0 / u 
    81             inten = i_zero * 2.0 * (power((1.0 + u * z),minusoneonu) + z - 1.0 ) / ((1.0 + u) * (z * z)) 
     78        inten = i_zero * 2.0 * (power(1.0 + u*z, -1.0/u) + z - 1.0) / (1.0 + u) 
     79    index = q != 0. 
     80    inten[~index] = i_zero 
     81    inten[index] /= z[index]**2 
    8282    return inten 
    83 #Iq.vectorized =  True  # Iq accepts an array of q values 
     83Iq.vectorized =  True  # Iq accepts an array of q values 
    8484 
    8585def Iqxy(qx, qy, *args): 
    8686    # pylint: disable = missing-docstring 
    8787    return Iq(sqrt(qx ** 2 + qy ** 2), *args) 
    88 #Iqxy.vectorized = True # Iqxy accepts an array of qx, qy values 
     88Iqxy.vectorized = True # Iqxy accepts an array of qx, qy values 
    8989 
    9090demo =  dict(scale = 1.0, 
Note: See TracChangeset for help on using the changeset viewer.