Changeset 3157 for trunk/GSASIIpwd.py


Ignore:
Timestamp:
Nov 21, 2017 1:52:20 PM (4 years ago)
Author:
vondreele
Message:

add Lorentzian term 'Z' to CW profile instrument parameters - constant term
change sig-q function to d*sig-q from sig-q/d2 for TOF profile instrument parameters
add filter to SumDialog? for PWDR & IMG data

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/GSASIIpwd.py

    r3136 r3157  
    656656   
    657657    sig = lambda Th,U,V,W: np.sqrt(max(0.001,U*tand(Th)**2+V*tand(Th)+W))
    658     sigTOF = lambda dsp,S0,S1,S2,Sq: np.sqrt(S0+S1*dsp**2+S2*dsp**4+Sq/dsp**2)
    659     gam = lambda Th,X,Y: (X/cosd(Th)+Y*tand(Th))
    660     gamTOF = lambda dsp,X,Y: X*dsp+Y*dsp**2
     658    sigTOF = lambda dsp,S0,S1,S2,Sq: np.sqrt(S0+S1*dsp**2+S2*dsp**4+Sq*dsp)
     659    gam = lambda Th,X,Y,Z: Z+X/cosd(Th)+Y*tand(Th)
     660    gamTOF = lambda dsp,X,Y,Z: Z+X*dsp+Y*dsp**2
    661661    if 'C' in Inst['Type'][0]:
    662662        s = sig(pos/2.,Inst['U'][1],Inst['V'][1],Inst['W'][1])
    663         g = gam(pos/2.,Inst['X'][1],Inst['Y'][1])
     663        g = gam(pos/2.,Inst['X'][1],Inst['Y'][1],Inst['Z'][1])
    664664        return getgamFW(g,s)/100.  #returns FWHM in deg
    665665    else:
    666666        dsp = pos/Inst['difC'][0]
    667667        s = sigTOF(dsp,Inst['sig-0'][1],Inst['sig-1'][1],Inst['sig-2'][1],Inst['sig-q'][1])
    668         g = gamTOF(dsp,Inst['X'][1],Inst['Y'][1])
     668        g = gamTOF(dsp,Inst['X'][1],Inst['Y'][1],Inst['Z'][1])
    669669        return getgamFW(g,s)
    670670   
     
    12111211                if gamName in varyList:
    12121212                    gam = parmDict[gamName]
    1213                     dgdX = dgdY = 0
     1213                    dgdX = dgdY = dgdZ = 0
    12141214                else:
    12151215                    gam = G2mth.getCWgam(parmDict,tth)
    1216                     dgdX,dgdY = G2mth.getCWgamDeriv(tth)
     1216                    dgdX,dgdY,dgdZ = G2mth.getCWgamDeriv(tth)
    12171217                gam = max(gam,0.001)             #avoid neg gamma
    12181218                Wd,fmin,fmax = getWidthsCW(pos,sig,gam,shl)
     
    12571257                if 'Y' in varyList:
    12581258                    dMdv[varyList.index('Y')] += dgdY*dervDict['gam']
     1259                if 'Z' in varyList:
     1260                    dMdv[varyList.index('Z')] += dgdZ*dervDict['gam']
    12591261                if 'SH/L' in varyList:
    12601262                    dMdv[varyList.index('SH/L')] += dervDict['shl']         #problem here
     
    13041306                if gamName in varyList:
    13051307                    gam = parmDict[gamName]
    1306                     dsdX = dsdY = 0
     1308                    dsdX = dsdY = dsdZ = 0
    13071309                else:
    13081310                    gam = G2mth.getTOFgamma(parmDict,dsp)
    1309                     dsdX,dsdY = G2mth.getTOFgammaDeriv(dsp)
     1311                    dsdX,dsdY,dsdZ = G2mth.getTOFgammaDeriv(dsp)
    13101312                gam = max(gam,0.001)             #avoid neg gamma
    13111313                Wd,fmin,fmax = getWidthsTOF(pos,alp,bet,sig,gam)
     
    13541356                    dMdv[varyList.index('X')] += dsdX*dervDict['gam']
    13551357                if 'Y' in varyList:
    1356                     dMdv[varyList.index('Y')] += dsdY*dervDict['gam']         #problem here
     1358                    dMdv[varyList.index('Y')] += dsdY*dervDict['gam']
     1359                if 'Z' in varyList:
     1360                    dMdv[varyList.index('Z')] += dsdZ*dervDict['gam']
    13571361                iPeak += 1
    13581362            except KeyError:        #no more peaks to process
     
    16231627            insNames.append(parm)
    16241628            insVals.append(Inst[parm][1])
    1625             if parm in ['U','V','W','X','Y','SH/L','I(L2)/I(L1)','alpha',
     1629            if parm in ['U','V','W','X','Y','Z','SH/L','I(L2)/I(L1)','alpha',
    16261630                'beta-0','beta-1','beta-q','sig-0','sig-1','sig-2','sig-q',] and Inst[parm][2]:
    16271631                    insVary.append(parm)
    16281632        instDict = dict(zip(insNames,insVals))
    1629         instDict['X'] = max(instDict['X'],0.01)
    1630         instDict['Y'] = max(instDict['Y'],0.01)
     1633#        instDict['X'] = max(instDict['X'],0.01)
     1634#        instDict['Y'] = max(instDict['Y'],0.01)
    16311635        if 'SH/L' in instDict:
    16321636            instDict['SH/L'] = max(instDict['SH/L'],0.002)
     
    16651669        sigstr = 'esds  :'
    16661670        for parm in Inst:
    1667             if parm in  ['U','V','W','X','Y','SH/L','I(L2)/I(L1)','alpha',
     1671            if parm in  ['U','V','W','X','Y','Z','SH/L','I(L2)/I(L1)','alpha',
    16681672                'beta-0','beta-1','beta-q','sig-0','sig-1','sig-2','sig-q',]:
    16691673                ptlbls += "%s" % (parm.center(12))
     
    27822786        'pos2':20.6426,'int2':1573.7,'sig2':1.0,'gam2':1.0,
    27832787        'pos3':26.9568,'int3':925.1,'sig3':1.0,'gam3':1.0,
    2784         'U':1.163,'V':-0.605,'W':0.093,'X':0.0,'Y':2.183,'SH/L':0.002,
     2788        'U':1.163,'V':-0.605,'W':0.093,'X':0.0,'Y':2.183,'Z':0.0,'SH/L':0.002,
    27852789        'Back0':5.384,'Back1':-0.015,'Back2':.004,
    27862790        }
     
    27932797        'pos4':36.1119,'int4':115829.8,'sig4':1.0,'gam4':1.0,
    27942798        'pos5':39.0122,'int5':6916.9,'sig5':1.0,'gam5':1.0,
    2795         'U':22.75,'V':-17.596,'W':10.594,'X':1.577,'Y':5.778,'SH/L':0.002,
     2799        'U':22.75,'V':-17.596,'W':10.594,'X':1.577,'Y':5.778,'Z':0.0,'SH/L':0.002,
    27962800        'Back0':36.897,'Back1':-0.508,'Back2':.006,
    27972801        'Lam1':1.540500,'Lam2':1.544300,'I(L2)/I(L1)':0.5,
     
    28002804    parmDict2 = {
    28012805        'pos0':5.7,'int0':1000.0,'sig0':0.5,'gam0':0.5,
    2802         'U':2.,'V':-2.,'W':5.,'X':0.5,'Y':0.5,'SH/L':0.02,
     2806        'U':2.,'V':-2.,'W':5.,'X':0.5,'Y':0.5,'Z':0.0,'SH/L':0.02,
    28032807        'Back0':5.,'Back1':-0.02,'Back2':.004,
    28042808#        'Lam1':1.540500,'Lam2':1.544300,'I(L2)/I(L1)':0.5,
     
    28532857    plotter = plot.PlotNotebook()
    28542858#    test0()
    2855 #    for name in ['int0','pos0','sig0','gam0','U','V','W','X','Y','SH/L','I(L2)/I(L1)']:
     2859#    for name in ['int0','pos0','sig0','gam0','U','V','W','X','Y','Z','SH/L','I(L2)/I(L1)']:
    28562860    for name,shft in [['int0',0.1],['pos0',0.0001],['sig0',0.01],['gam0',0.00001],
    2857         ['U',0.1],['V',0.01],['W',0.01],['X',0.0001],['Y',0.0001],['SH/L',0.00005]]:
     2861        ['U',0.1],['V',0.01],['W',0.01],['X',0.0001],['Y',0.0001],['Z',0.0001],['SH/L',0.00005]]:
    28582862        test2(name,shft)
    28592863    for name,shft in [['pos',0.0001],['sig',0.01],['gam',0.0001],['shl',0.00005]]:
Note: See TracChangeset for help on using the changeset viewer.