Changeset 432 for trunk/GSASIIstruct.py


Ignore:
Timestamp:
Dec 5, 2011 4:00:00 PM (10 years ago)
Author:
vondreele
Message:

remove test prints from GSASIIIO
new Gmat2AB routine
work on the DData GUI bug - doesn't crash but bad GUI shown
work on ellipsoidal crystallites - all now work.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/GSASIIstruct.py

    r429 r432  
    18951895    return dIdsh,dIdsp,dIdPola,dIdPO,dFdODF,dFdSA
    18961896       
    1897 def GetSampleGam(refl,wave,G,phfx,calcControls,parmDict,sizeEllipse):
     1897def GetSampleGam(refl,wave,G,GB,phfx,calcControls,parmDict):
    18981898    costh = cosd(refl[5]/2.)
    18991899    #crystallite size
     
    19061906        gam = (1.8*wave/np.pi)/(parmDict[phfx+'Size:0']*parmDict[phfx+'Size:1']*costh)
    19071907        gam *= np.sqrt((cosP*parmDict[phfx+'Size:1'])**2+(sinP*parmDict[phfx+'Size:0'])**2)
    1908     else:           #ellipsoidal crystallites - wrong not make sense
     1908    else:           #ellipsoidal crystallites
     1909        Sij =[parmDict[phfx+'Size:%d'%(i)] for i in range(6)]
    19091910        H = np.array(refl[:3])
    1910         gam += 1.8*wave/(np.pi*costh*np.inner(H,np.inner(sizeEllipse,H)))
     1911        lenR = G2pwd.ellipseSize(H,Sij,GB)
     1912        gam = 1.8*wave/(np.pi*costh*lenR)
    19111913    #microstrain               
    19121914    if calcControls[phfx+'MustrainType'] == 'isotropic':
     
    19271929    return gam
    19281930       
    1929 def GetSampleGamDerv(refl,wave,G,phfx,calcControls,parmDict,sizeEllipse):
     1931def GetSampleGamDerv(refl,wave,G,GB,phfx,calcControls,parmDict):
    19301932    gamDict = {}
    19311933    costh = cosd(refl[5]/2.)
     
    19401942        Si = parmDict[phfx+'Size:0']
    19411943        Sa = parmDict[phfx+'Size:1']
    1942         gami = (1.80*wave/np.pi)/(Si*Sa)
     1944        gami = (1.8*wave/np.pi)/(Si*Sa)
    19431945        sqtrm = np.sqrt((cosP*Sa)**2+(sinP*Si)**2)
    19441946        gam = gami*sqtrm/costh           
    19451947        gamDict[phfx+'Size:0'] = gami*Si*sinP**2/(sqtrm*costh)-gam/Si
    19461948        gamDict[phfx+'Size:1'] = gami*Sa*cosP**2/(sqtrm*costh)-gam/Sa         
    1947     else:           #ellipsoidal crystallites - do numerically? - not right not make sense
     1949    else:           #ellipsoidal crystallites
     1950        const = 1.8*wave/(np.pi*costh)
     1951        Sij =[parmDict[phfx+'Size:%d'%(i)] for i in range(6)]
    19481952        H = np.array(refl[:3])
    1949         gam = 1.8*wave/(np.pi*costh*np.inner(H,np.inner(sizeEllipse,H)))
     1953        R,dRdS = G2pwd.ellipseSizeDerv(H,Sij,GB)
     1954        for i,item in enumerate([phfx+'Size:%d'%(j) for j in range(6)]):
     1955            gamDict[item] = -(const/R**2)*dRdS[i]
    19501956    #microstrain derivatives               
    19511957    if calcControls[phfx+'MustrainType'] == 'isotropic':
     
    20822088def getPowderProfile(parmDict,x,varylist,Histogram,Phases,calcControls,pawleyLookup):
    20832089   
    2084     def GetReflSIgGam(refl,wave,G,hfx,phfx,calcControls,parmDict,sizeEllipse):
     2090    def GetReflSIgGam(refl,wave,G,GB,hfx,phfx,calcControls,parmDict):
    20852091        U = parmDict[hfx+'U']
    20862092        V = parmDict[hfx+'V']
     
    20912097        sig = U*tanPos**2+V*tanPos+W        #save peak sigma
    20922098        sig = max(0.001,sig)
    2093         gam = X/cosd(refl[5]/2.0)+Y*tanPos+GetSampleGam(refl,wave,G,phfx,calcControls,parmDict,sizeEllipse) #save peak gamma
     2099        gam = X/cosd(refl[5]/2.0)+Y*tanPos+GetSampleGam(refl,wave,G,GB,phfx,calcControls,parmDict) #save peak gamma
    20942100        gam = max(0.001,gam)
    20952101        return sig,gam
     
    21242130        A = [parmDict[pfx+'A%d'%(i)] for i in range(6)]
    21252131        G,g = G2lat.A2Gmat(A)       #recip & real metric tensors
     2132        GA,GB = G2lat.Gmat2AB(G)    #Orthogonalization matricies
    21262133        Vst = np.sqrt(nl.det(G))    #V*
    21272134        if 'Pawley' not in Phase['General']['Type']:
    21282135            refList = StructureFactor(refList,G,hfx,pfx,SGData,calcControls,parmDict)
    2129         sizeEllipse = []
    2130         if calcControls[phfx+'SizeType'] == 'ellipsoidal':
    2131             sizeEllipse = G2lat.U6toUij([parmDIct[phfx+'Size:%d'%(i)] for i in range(6)])
    21322136        for refl in refList:
    21332137            if 'C' in calcControls[hfx+'histType']:
     
    21362140                Lorenz = 1./(2.*sind(refl[5]/2.)**2*cosd(refl[5]/2.))           #Lorentz correction
    21372141                refl[5] += GetHStrainShift(refl,SGData,phfx,parmDict)               #apply hydrostatic strain shift
    2138                 refl[6:8] = GetReflSIgGam(refl,wave,G,hfx,phfx,calcControls,parmDict,sizeEllipse)    #peak sig & gam
     2142                refl[6:8] = GetReflSIgGam(refl,wave,G,GB,hfx,phfx,calcControls,parmDict)    #peak sig & gam
    21392143                GetIntensityCorr(refl,G,g,pfx,phfx,hfx,SGData,calcControls,parmDict)    #puts corrections in refl[13]
    21402144                refl[13] *= Vst*Lorenz
     
    22912295        A = [parmDict[pfx+'A%d'%(i)] for i in range(6)]
    22922296        G,g = G2lat.A2Gmat(A)       #recip & real metric tensors
     2297        GA,GB = G2lat.Gmat2AB(G)    #Orthogonalization matricies
    22932298        if 'Pawley' not in Phase['General']['Type']:
    22942299            dFdvDict = StructureFactorDerv(refList,G,hfx,pfx,SGData,calcControls,parmDict)
    2295         sizeEllipse = []
    2296         if calcControls[phfx+'SizeType'] == 'ellipsoidal':
    2297             sizeEllipse = G2lat.U6toUij([parmDIct[phfx+'Size:%d'%(i)] for i in range(6)])
    22982300        for iref,refl in enumerate(refList):
    22992301            if 'C' in calcControls[hfx+'histType']:        #CW powder
     
    23842386                    elif name in dependentVars:
    23852387                        depDerivDict[name] += dDijDict[name]*dervDict['pos']
    2386                 gamDict = GetSampleGamDerv(refl,wave,G,phfx,calcControls,parmDict,sizeEllipse)
     2388                gamDict = GetSampleGamDerv(refl,wave,G,GB,phfx,calcControls,parmDict)
    23872389                for name in gamDict:
    23882390                    if name in varylist:
     
    25952597    SetUsedHistogramsAndPhases(GPXfile,Histograms,Phases,covData)
    25962598#for testing purposes!!!
    2597 #    file = open('structTestdata.dat','wb')
    2598 #    cPickle.dump(parmDict,file,1)
    2599 #    cPickle.dump(varyList,file,1)
    2600 #    for histogram in Histograms:
    2601 #        if 'PWDR' in histogram[:4]:
    2602 #            Histogram = Histograms[histogram]
    2603 #    cPickle.dump(Histogram,file,1)
    2604 #    cPickle.dump(Phases,file,1)
    2605 #    cPickle.dump(calcControls,file,1)
    2606 #    cPickle.dump(pawleyLookup,file,1)
    2607 #    file.close()
     2599    file = open('structTestdata.dat','wb')
     2600    cPickle.dump(parmDict,file,1)
     2601    cPickle.dump(varyList,file,1)
     2602    for histogram in Histograms:
     2603        if 'PWDR' in histogram[:4]:
     2604            Histogram = Histograms[histogram]
     2605    cPickle.dump(Histogram,file,1)
     2606    cPickle.dump(Phases,file,1)
     2607    cPickle.dump(calcControls,file,1)
     2608    cPickle.dump(pawleyLookup,file,1)
     2609    file.close()
    26082610
    26092611def SeqRefine(GPXfile,dlg):
Note: See TracChangeset for help on using the changeset viewer.