Changeset 2d81cfe in sasmodels for sasmodels/models/hardsphere.py
- Timestamp:
- Nov 29, 2017 1:13:23 PM (6 years ago)
- Branches:
- master, core_shell_microgels, magnetic_model, ticket-1257-vesicle-product, ticket_1156, ticket_1265_superball, ticket_822_more_unit_tests
- Children:
- 237b800f
- Parents:
- a839b22
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sasmodels/models/hardsphere.py
r8f04da4 r2d81cfe 42 42 """ 43 43 44 import numpy as np 44 45 from numpy import inf 45 46 … … 77 78 // these are c compiler instructions, can also put normal code inside the "if else" structure 78 79 #if FLOAT_SIZE > 4 79 // double precision orig had 0.2, don't call the variable cutoff as PAK already has one called that! Must use UPPERCASE name please. 80 // 0.05 better, 0.1 OK 80 // double precision 81 // orig had 0.2, don't call the variable cutoff as PAK already has one called that! 82 // Must use UPPERCASE name please. 83 // 0.05 better, 0.1 OK 81 84 #define CUTOFFHS 0.05 82 85 #else … … 90 93 return(HARDSPH); 91 94 } 92 // removing use of pow(xxx,2) and rearranging the calcs of A, B & G cut ~40% off execution time ( 0.5 to 0.3 msec) 95 // removing use of pow(xxx,2) and rearranging the calcs 96 // of A, B & G cut ~40% off execution time ( 0.5 to 0.3 msec) 93 97 X = 1.0/( 1.0 -volfraction); 94 98 D= X*X; … … 110 114 if(X < CUTOFFHS) { 111 115 // RKH Feb 2016, use Taylor series expansion for small X 112 // else no obvious way to rearrange the equations to avoid needing a very high number of significant figures. 113 // Series expansion found using Mathematica software. Numerical test in .xls showed terms to X^2 are sufficient 116 // else no obvious way to rearrange the equations to avoid 117 // needing a very high number of significant figures. 118 // Series expansion found using Mathematica software. Numerical test 119 // in .xls showed terms to X^2 are sufficient 114 120 // for 5 or 6 significant figures, but I put the X^4 one in anyway 115 121 //FF = 8*A +6*B + 4*G - (0.8*A +2.0*B/3.0 +0.5*G)*X2 +(A/35. +B/40. +G/50.)*X4; … … 130 136 SINCOS(X,S,C); 131 137 132 // RKH Feb 2016, use version FISH code as is better than original sasview one at small Q in single precision, and more than twice as fast in double. 138 // RKH Feb 2016, use version FISH code as is better than original sasview one 139 // at small Q in single precision, and more than twice as fast in double. 133 140 //FF=A*(S-X*C)/X + B*(2.*X*S -(X2-2.)*C -2.)/X2 + G*( (4.*X2*X -24.*X)*S -(X4 -12.*X2 +24.)*C +24. )/X4; 134 141 // refactoring the polynomial here & above makes it slightly faster … … 154 161 155 162 def random(): 156 import numpy as np157 163 pars = dict( 158 164 scale=1, background=0, … … 167 173 demo = dict(radius_effective=200, volfraction=0.2, 168 174 radius_effective_pd=0.1, radius_effective_pd_n=40) 169 # Q=0.001 is in the Taylor series, low Q part, so add Q=0.1, assuming double precision sasview is correct 175 # Q=0.001 is in the Taylor series, low Q part, so add Q=0.1, 176 # assuming double precision sasview is correct 170 177 tests = [ 171 [ {'scale': 1.0, 'background' : 0.0, 'radius_effective' : 50.0, 172 'volfraction' : 0.2, 'radius_effective_pd' : 0}, 173 [0.001,0.1], [0.209128,0.930587]], 174 ] 175 # ADDED by: RKH ON: 16Mar2016 using equations from FISH as better than orig sasview, see notes above. Added Taylor expansions at small Q, 178 [{'scale': 1.0, 'background' : 0.0, 'radius_effective' : 50.0, 179 'volfraction' : 0.2, 'radius_effective_pd' : 0}, 180 [0.001, 0.1], [0.209128, 0.930587]], 181 ] 182 # ADDED by: RKH ON: 16Mar2016 using equations from FISH as better than 183 # orig sasview, see notes above. Added Taylor expansions at small Q.
Note: See TracChangeset
for help on using the changeset viewer.