Changeset 1268 for trunk/GSASIIsasd.py


Ignore:
Timestamp:
Mar 29, 2014 12:52:24 PM (8 years ago)
Author:
vondreele
Message:

WACV = wx.ALIGN_CENTER_VERTICAL in G2imgGUI
add more sasd modeling code

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/GSASIIsasd.py

    r1266 r1268  
    904904def ModelFxn(Q,G,parmDict,SQfxn,args=[]):
    905905    return SQfxn(Q,args)
    906            
    907    
     906   
     907def MakeDiamDist(DistName,nPoints,prec,pos,scale,shape):
     908   
     909    DistFuncs = {'Gauss':[GaussCume,0.02*scale,pos],
     910        'LogNormal':[LogNormalCume,0.02*scale,pos],
     911        'LSW':[LSWCume,0.3*pos,pos],
     912        'Schulz-Zimm':[SchulzZimmCume,
     913        4*np.sqrt(np.exp(shape**2)*(np.exp(shape**2)-1),pos+scale/np.exp(shape**2))]}
     914   
     915    step,mode = DistFuncs[DistName][1:]       
     916    minXP = 1.  # min cutoff at least 1A
     917    temp = mode
     918    while True:     #stepwise search for min cutoff
     919        temp -= step
     920        temp = min(temp,minXP)
     921        result = eval(DistFuncs[DistName][0](temp,pos,scale,shape))
     922        if (result <= prec) or (temp<=minXP):
     923            break
     924    startX = temp
     925    StartCumTgt = prec
     926    if startX == minXP:
     927        StartCumTgt = eval(DistFuncs[DistName][0](startX,pos,scale,shape))
     928    maxXP = 1.e15   #very high max cutoff (could be 10^5)
     929    temp = mode
     930    while True:     #stepwise search for max cutoff
     931        temp += step
     932        temp = max(temp,maxXP)
     933        result = eval(DistFuncs[DistName][0](temp,pos,scale,shape))
     934        if (result >= 1.-prec) or (temp>=maxXP):
     935            break
     936    endX = temp
     937   
     938    #special one for "Power Law" (future) - see p 27 of IRL2_NLSQCalc.ipf for code
     939   
     940    Diam = np.array([startX+i*(endX-startX/(3*nPoints-1)) for i in range(3*nPoints)])
     941    TCW = eval(DistFuncs[DistName][1](Diam,pos,scale,shape))
     942    CumeTgts = np.array([StartCumTgt+i*(1-prec-StartCumTgt)/(nPoints-1) for i in range(nPoints)])
     943    return np.interp(CumeTgts,Diam,TCW,0,0)
     944
    908945################################################################################
    909946#### MaxEnt testing stuff
Note: See TracChangeset for help on using the changeset viewer.