Changeset 1266 for trunk/GSASIIsasd.py


Ignore:
Timestamp:
Mar 28, 2014 11:03:17 AM (8 years ago)
Author:
vondreele
Message:

change some formats in Image Controls
enable insertion of additional points in polygon & frame masks
add code for particle distributions

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/GSASIIsasd.py

    r1263 r1266  
    311311    L,T = arg[:2]
    312312    return CylinderVol(R,[L,])-CylinderVol(R-T,[L,])
     313   
     314################################################################################
     315#### Distribution functions & their cumulative fxns
     316################################################################################
     317
     318def LogNormalDist(x,pos,scale,shape):
     319    ''' Standard LogNormal distribution - numpy friendly on x axis
     320    ref: http://www.itl.nist.gov/div898/handbook/index.htm 1.3.6.6.9
     321    param float x: independent axis (can be numpy array)
     322    param float pos: location of distribution
     323    param float scale: width of distribution (m)
     324    param float shape: shape - (sigma of log(LogNormal))
     325    returns float: LogNormal distribution
     326    '''
     327    return np.exp(-np.log((x-pos)/scale)**2/(2.*shape**2))/(np.sqrt(2.*np.pi)*(x-pos)*shape)
     328   
     329def GaussDist(x,pos,scale,shape):
     330    ''' Standard Normal distribution - numpy friendly on x axis
     331    param float x: independent axis (can be numpy array)
     332    param float pos: location of distribution
     333    param float scale: width of distribution (sigma)
     334    param float shape: not used
     335    returns float: Normal distribution
     336    '''
     337    return (1./scale*np.sqrt(2.*np.pi))*np.exp(-(x-pos)**2/(2.*scale**2))
     338   
     339def LSWDist(x,pos,scale,shape):
     340    ''' Lifshitz-Slyozov-Wagner Ostwald ripening distribution - numpy friendly on x axis
     341    ref:
     342    param float x: independent axis (can be numpy array)
     343    param float pos: location of distribution
     344    param float scale: not used
     345    param float shape: not used
     346    returns float: LSW distribution   
     347    '''
     348    redX = x/pos
     349    result = (81.*2**(-5/3.))*(redX**2*np.exp(-redX/(1.5-redX)))/((1.5-redX)**(11/3.)*(3.-redX)**(7/3.))
     350    return result/pos
     351   
     352def SchulzZimmDist(x,pos,scale,shape):
     353    ''' Schulz-Zimm macromolecule distribution - numpy friendly on x axis
     354    ref: http://goldbook.iupac.org/S05502.html
     355    param float x: independent axis (can be numpy array)
     356    param float pos: location of distribution
     357    param float scale: width of distribution (sigma)
     358    param float shape: not used
     359    returns float: Schulz-Zimm distribution
     360    '''
     361    b = (2.*pos/scale)**2
     362    a = b/pos
     363    if b<70:    #why bother?
     364        return (a**(b+1.))*x**b*np.exp(-a*x)/scsp.gamma(b+1.)
     365    else:
     366        return np.exp((b+1.)*np.log(a)-spsc.gammaln(b+1.)+b*np.log(x)-(a*x))
     367           
     368def LogNormalCume(x,pos,scale,shape):
     369    ''' Standard LogNormal cumulative distribution - numpy friendly on x axis
     370    ref: http://www.itl.nist.gov/div898/handbook/index.htm 1.3.6.6.9
     371    param float x: independent axis (can be numpy array)
     372    param float pos: location of distribution
     373    param float scale: width of distribution (sigma)
     374    param float shape: shape parameter
     375    returns float: LogNormal cumulative distribution
     376    '''
     377    return scsp.erf(np.log((x-pos)/shape)/(np.sqrt(2.)*scale)+1.)/2.
     378   
     379def GaussCume(x,pos,scale,shape):
     380    ''' Standard Normal cumulative distribution - numpy friendly on x axis
     381    param float x: independent axis (can be numpy array)
     382    param float pos: location of distribution
     383    param float scale: width of distribution (sigma)
     384    param float shape: not used
     385    returns float: Normal cumulative distribution
     386    '''
     387    return scsp.erf((x-pos)/(np.sqrt(2.)*scale)+1.)/2.
     388   
     389def LSWCume(x,pos,scale,shape):
     390    ''' Lifshitz-Slyozov-Wagner Ostwald ripening cumulative distribution - numpy friendly on x axis
     391    param float x: independent axis (can be numpy array)
     392    param float pos: location of distribution
     393    param float scale: not used
     394    param float shape: not used
     395    returns float: LSW cumulative distribution
     396    '''
     397    nP = int(np.ceil(x/30+30))
     398    return []
     399   
     400def SchulzZimmCume(x,pos,scale,shape):
     401    ''' Schulz-Zimm cumulative distribution - numpy friendly on x axis
     402    param float x: independent axis (can be numpy array)
     403    param float pos: location of distribution
     404    param float scale: width of distribution (sigma)
     405    param float shape: not used
     406    returns float: Normal distribution
     407    '''
     408    return []
     409   
    313410         
    314411################################################################################
     
    804901def ModelFit(Profile,ProfDict,Limits,Substances,Sample,data):
    805902    print 'do model fit'
     903   
     904def ModelFxn(Q,G,parmDict,SQfxn,args=[]):
     905    return SQfxn(Q,args)
    806906           
    807907   
Note: See TracChangeset for help on using the changeset viewer.