Changeset 2d81cfe in sasmodels for sasmodels/models/hardsphere.py


Ignore:
Timestamp:
Nov 29, 2017 1:13:23 PM (6 years ago)
Author:
Paul Kienzle <pkienzle@…>
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
Message:

lint

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sasmodels/models/hardsphere.py

    r8f04da4 r2d81cfe  
    4242""" 
    4343 
     44import numpy as np 
    4445from numpy import inf 
    4546 
     
    7778      // these are c compiler instructions, can also put normal code inside the "if else" structure 
    7879      #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 
    8184      #define CUTOFFHS 0.05 
    8285      #else 
     
    9093               return(HARDSPH); 
    9194      } 
    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) 
    9397      X = 1.0/( 1.0 -volfraction); 
    9498      D= X*X; 
     
    110114      if(X < CUTOFFHS) { 
    111115      // 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 
    114120      // for 5 or 6 significant figures, but I put the X^4 one in anyway 
    115121            //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; 
     
    130136      SINCOS(X,S,C); 
    131137 
    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. 
    133140      //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; 
    134141      // refactoring the polynomial here & above makes it slightly faster 
     
    154161 
    155162def random(): 
    156     import numpy as np 
    157163    pars = dict( 
    158164        scale=1, background=0, 
     
    167173demo = dict(radius_effective=200, volfraction=0.2, 
    168174            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 
    170177tests = [ 
    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.