Changeset 1479


Ignore:
Timestamp:
Aug 26, 2014 4:04:57 PM (7 years ago)
Author:
vondreele
Message:

fix Stephens model for mustrain, fxn & CW derivs are correct

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/GSASIIstrMath.py

    r1478 r1479  
    11571157    return dIdsh,dIdsp,dIdPola,dIdPO,dFdODF,dFdSA,dFdAb,dFdEx
    11581158       
    1159 def GetSampleSigGam(refl,wave,G,GB,hfx,phfx,calcControls,parmDict):
     1159def GetSampleSigGam(refl,wave,G,GB,SGData,hfx,phfx,calcControls,parmDict):
    11601160    'Needs a doc string'
    11611161    if 'C' in calcControls[hfx+'histType']:
     
    11861186            Mgam = 0.018*Si*Sa*tand(refl[5]/2.)/(np.pi*np.sqrt((Si*cosP)**2+(Sa*sinP)**2))
    11871187        else:       #generalized - P.W. Stephens model
    1188             pwrs = calcControls[phfx+'MuPwrs']
    1189             sum = 0
    1190             for i,pwr in enumerate(pwrs):
    1191                 sum += parmDict[phfx+'Mustrain:'+str(i)]*refl[0]**pwr[0]*refl[1]**pwr[1]*refl[2]**pwr[2]
    1192             Mgam = 0.018*refl[4]**2*tand(refl[5]/2.)*sum
     1188            Strms = G2spc.MustrainCoeff(refl[:3],SGData)
     1189            Sum = 0
     1190            for i,strm in enumerate(Strms):
     1191                Sum += parmDict[phfx+'Mustrain:'+str(i)]*strm
     1192            Mgam = refl[4]**2*tand(refl[5]/2.)*np.sqrt(Sum)
    11931193    elif 'T' in calcControls[hfx+'histType']:
    11941194        #crystallite size
     
    12171217            Mgam = 1.e-6*parmDict[hfx+'difC']*refl[4]*Si*Sa/np.sqrt((Si*cosP)**2+(Sa*sinP)**2)
    12181218        else:       #generalized - P.W. Stephens model
    1219             pwrs = calcControls[phfx+'MuPwrs']
    1220             sum = 0
    1221             for i,pwr in enumerate(pwrs):
    1222                 sum += parmDict[phfx+'Mustrain:'+str(i)]*refl[0]**pwr[0]*refl[1]**pwr[1]*refl[2]**pwr[2]
    1223             Mgam = 1.e-6*parmDict[hfx+'difC']*refl[4]**2*sum
     1219            Sum = 0
     1220            Strms = G2spc.MustrainCoeff(refl[:3],SGData)
     1221            for i,strm in enumerate(Strms):
     1222                Sum += parmDict[phfx+'Mustrain:'+str(i)]*strm
     1223            Mgam = 1.e-6*parmDict[hfx+'difC']*refl[4]**2*Sum
    12241224           
    12251225    gam = Sgam*parmDict[phfx+'Size;mx']+Mgam*parmDict[phfx+'Mustrain;mx']
     
    12281228    return sig,gam
    12291229       
    1230 def GetSampleSigGamDerv(refl,wave,G,GB,hfx,phfx,calcControls,parmDict):
     1230def GetSampleSigGamDerv(refl,wave,G,GB,SGData,hfx,phfx,calcControls,parmDict):
    12311231    'Needs a doc string'
    12321232    gamDict = {}
     
    12891289            sigDict[phfx+'Mustrain;a'] = 2*(Mgam/Sa+dsa)*Mgam*(1.-parmDict[phfx+'Mustrain;mx'])**2/ateln2       
    12901290        else:       #generalized - P.W. Stephens model
    1291             pwrs = calcControls[phfx+'MuPwrs']
    1292             const = 0.018*refl[4]**2*tanth
    1293             sum = 0
    1294             for i,pwr in enumerate(pwrs):
    1295                 term = refl[0]**pwr[0]*refl[1]**pwr[1]*refl[2]**pwr[2]
    1296                 sum += parmDict[phfx+'Mustrain:'+str(i)]*term
    1297                 gamDict[phfx+'Mustrain:'+str(i)] = const*term*parmDict[phfx+'Mustrain;mx']
    1298                 sigDict[phfx+'Mustrain:'+str(i)] = \
    1299                     2.*const*term*(1.-parmDict[phfx+'Mustrain;mx'])**2/ateln2
    1300             Mgam = 0.018*refl[4]**2*tand(refl[5]/2.)*sum
    1301             for i in range(len(pwrs)):
    1302                 sigDict[phfx+'Mustrain:'+str(i)] *= Mgam
     1291            const = refl[4]**2*tanth
     1292            Strms = G2spc.MustrainCoeff(refl[:3],SGData)
     1293            Sum = 0
     1294            for i,strm in enumerate(Strms):
     1295                Sum += parmDict[phfx+'Mustrain:'+str(i)]*strm
     1296                gamDict[phfx+'Mustrain:'+str(i)] = strm*parmDict[phfx+'Mustrain;mx']/2.
     1297                sigDict[phfx+'Mustrain:'+str(i)] = strm*(1.-parmDict[phfx+'Mustrain;mx'])**2
     1298            Mgam = const*np.sqrt(Sum)
     1299            for i in range(len(Strms)):
     1300                gamDict[phfx+'Mustrain:'+str(i)] *= Mgam/Sum
     1301                sigDict[phfx+'Mustrain:'+str(i)] *= const**2/ateln2
    13031302        gamDict[phfx+'Mustrain;mx'] = Mgam
    13041303        sigDict[phfx+'Mustrain;mx'] = -2.*Mgam**2*(1.-parmDict[phfx+'Mustrain;mx'])/ateln2
     
    13581357        else:       #generalized - P.W. Stephens model
    13591358            pwrs = calcControls[phfx+'MuPwrs']
     1359            Strms = G2spc.MustrainCoeff(refl[:3],SGData)
    13601360            const = 1.e-6*parmDict[hfx+'difC']*refl[4]**2
    13611361            sum = 0
    1362             for i,pwr in enumerate(pwrs):
    1363                 term = refl[0]**pwr[0]*refl[1]**pwr[1]*refl[2]**pwr[2]
    1364                 sum += parmDict[phfx+'Mustrain:'+str(i)]*term
    1365                 gamDict[phfx+'Mustrain:'+str(i)] = const*term*parmDict[phfx+'Mustrain;mx']
     1362            for i,strm in enumerate(Strms):
     1363                sum += parmDict[phfx+'Mustrain:'+str(i)]*strm
     1364                gamDict[phfx+'Mustrain:'+str(i)] = const*strm*parmDict[phfx+'Mustrain;mx']
    13661365                sigDict[phfx+'Mustrain:'+str(i)] = \
    13671366                    2.*const*term*(1.-parmDict[phfx+'Mustrain;mx'])**2/ateln2
    13681367            Mgam = const*sum
    1369             for i in range(len(pwrs)):
     1368            for i in range(len(Strms)):
    13701369                sigDict[phfx+'Mustrain:'+str(i)] *= Mgam       
    13711370        gamDict[phfx+'Mustrain;mx'] = Mgam
     
    15781577        Y = parmDict[hfx+'Y']
    15791578        tanPos = tand(refl[5]/2.0)
    1580         Ssig,Sgam = GetSampleSigGam(refl,wave,G,GB,hfx,phfx,calcControls,parmDict)
     1579        Ssig,Sgam = GetSampleSigGam(refl,wave,G,GB,SGData,hfx,phfx,calcControls,parmDict)
    15811580        sig = U*tanPos**2+V*tanPos+W+Ssig     #save peak sigma
    15821581        sig = max(0.001,sig)
     
    15891588            parmDict[hfx+'sig-2']*refl[4]**4+parmDict[hfx+'sig-q']/refl[4]**2
    15901589        gam = parmDict[hfx+'X']*refl[4]+parmDict[hfx+'Y']*refl[4]**2
    1591         Ssig,Sgam = GetSampleSigGam(refl,0.0,G,GB,hfx,phfx,calcControls,parmDict)
     1590        Ssig,Sgam = GetSampleSigGam(refl,0.0,G,GB,SGData,hfx,phfx,calcControls,parmDict)
    15921591        sig += Ssig
    15931592        sig = max(0.001,sig)
     
    19221921                        depDerivDict[name][iBeg2:iFin2] += dDijDict[name]*dervDict2['pos']
    19231922            if 'C' in calcControls[hfx+'histType']:
    1924                 sigDict,gamDict = GetSampleSigGamDerv(refl,wave,G,GB,hfx,phfx,calcControls,parmDict)
     1923                sigDict,gamDict = GetSampleSigGamDerv(refl,wave,G,GB,SGData,hfx,phfx,calcControls,parmDict)
    19251924            else:   #'T'OF
    1926                 sigDict,gamDict = GetSampleSigGamDerv(refl,0.0,G,GB,hfx,phfx,calcControls,parmDict)
     1925                sigDict,gamDict = GetSampleSigGamDerv(refl,0.0,G,GB,SGData,hfx,phfx,calcControls,parmDict)
    19271926            for name in gamDict:
    19281927                if name in varylist:
Note: See TracChangeset for help on using the changeset viewer.