Changeset 2c74c11 in sasmodels for sasmodels/models/guinier_porod.py
- Timestamp:
- Jul 24, 2016 10:56:45 PM (8 years ago)
- 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:
- a4280bd
- Parents:
- f1765a2
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sasmodels/models/guinier_porod.py
rec45c4f r2c74c11 63 63 """ 64 64 65 from numpy import inf, sqrt, power, exp65 from numpy import inf, sqrt, exp, errstate 66 66 67 67 name = "guinier_porod" … … 93 93 """ 94 94 n = 3.0 - s 95 ms = 0.5*(m-s) # =(n-3+m)/2 96 97 # preallocate return value 98 iq = 0.0*q 95 99 96 100 # Take care of the singular points 97 if rg <= 0.0: 98 return 0.0 99 if (n-3.0+m) <= 0.0: 100 return 0.0 101 if rg <= 0.0 or ms <= 0.0: 102 return iq 101 103 102 104 # Do the calculation and return the function value 103 q1 = sqrt((n-3.0+m)*n/2.0)/rg 104 if q < q1: 105 iq = (1.0/power(q, (3.0-n)))*exp((-q*q*rg*rg)/n) 106 else: 107 iq = (1.0/power(q, m))*exp(-(n-3.0+m)/2.0)*power(((n-3.0+m)*n/2.0), 108 ((n-3.0+m)/2.0))/power(rg, (n-3.0+m)) 105 idx = q < sqrt(n*ms)/rg 106 with errstate(divide='ignore'): 107 iq[idx] = q[idx]**-s * exp(-(q[idx]*rg)**2/n) 108 iq[~idx] = q[~idx]**-m * (exp(-ms) * (n*ms/rg**2)**ms) 109 109 return iq 110 110 111 Iq.vectorized = False # Iq accepts an array of q values 112 113 def Iqxy(qx, qy, *args): 114 """ 115 @param qx: Input q_x-value 116 @param qy: Input q_y-value 117 @param args: Remaining arguments 118 """ 119 return Iq(sqrt(qx ** 2 + qy ** 2), *args) 120 121 Iqxy.vectorized = False # Iqxy accepts an array of qx, qy values 111 Iq.vectorized = True # Iq accepts an array of q values 122 112 123 113 demo = dict(scale=1.5, background=0.5, rg=60, s=1.0, m=3.0)
Note: See TracChangeset
for help on using the changeset viewer.