Ignore:
Timestamp:
Oct 15, 2013 3:01:21 PM (8 years ago)
Author:
vondreele
Message:

make reflist np.array
fix bug - hfx+'Type' needs to be in parmDict

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/GSASIIstrMath.py

    r1106 r1107  
    529529   
    530530def StructureFactor(refDict,G,hfx,pfx,SGData,calcControls,parmDict):
     531    ''' Compute structure factors for all h,k,l for phase
     532    puts the result, F^2, in each ref[8] in refList
     533    input:
     534   
     535    :param dict refDict: where
     536        'RefList' list where each ref = h,k,l,m,d,...
     537        'Uniq' list of [equiv h,k,l]
     538        'Phi' list of phase[equiv]
     539        'FF' dict of form factors - filed in below
     540    :param np.array G:      reciprocal metric tensor
     541    :param str pfx:    phase id string
     542    :param dict SGData: space group info. dictionary output from SpcGroup
     543    :param dict calcControls:
     544    :param dict ParmDict:
     545
     546    '''       
     547    twopi = 2.0*np.pi
     548    twopisq = 2.0*np.pi**2
     549    phfx = pfx.split(':')[0]+hfx
     550    ast = np.sqrt(np.diag(G))
     551    Mast = twopisq*np.multiply.outer(ast,ast)
     552    FFtables = calcControls['FFtables']
     553    BLtables = calcControls['BLtables']
     554    Tdata,Mdata,Fdata,Xdata,dXdata,IAdata,Uisodata,Uijdata = GetAtomFXU(pfx,calcControls,parmDict)
     555    FF = np.zeros(len(Tdata))
     556    if 'N' in calcControls[hfx+'histType']:
     557        FP,FPP = G2el.BlenRes(Tdata,BLtables,parmDict[hfx+'Lam'])
     558    else:
     559        FP = np.array([FFtables[El][hfx+'FP'] for El in Tdata])
     560        FPP = np.array([FFtables[El][hfx+'FPP'] for El in Tdata])
     561    Uij = np.array(G2lat.U6toUij(Uijdata))
     562    bij = Mast*Uij.T
     563    for iref,refl in enumerate(refDict['RefList']):
     564        fbs = np.array([0,0])
     565        H = refl[:3]
     566        SQ = 1./(2.*refl[4])**2
     567        SQfactor = 4.0*SQ*twopisq
     568        Bab = parmDict[phfx+'BabA']*np.exp(-parmDict[phfx+'BabU']*SQfactor)
     569        if not len(refDict['FF'][iref]):                #no form factors
     570            if 'N' in calcControls[hfx+'histType']:
     571                refDict['FF'][iref] = G2el.getBLvalues(BLtables)
     572            else:       #'X'
     573                refDict['FF'][iref] = G2el.getFFvalues(FFtables,SQ)
     574        for i,El in enumerate(Tdata):
     575            FF[i] = refDict['FF'][iref][El]           
     576        phase = twopi*(np.inner(refDict['Uniq'][iref],(dXdata.T+Xdata.T))+refDict['Phi'][iref][:,np.newaxis])
     577        sinp = np.sin(phase)
     578        cosp = np.cos(phase)
     579        occ = Mdata*Fdata/len(refDict['Uniq'][iref])
     580        biso = -SQfactor*Uisodata
     581        Tiso = np.where(biso<1.,np.exp(biso),1.0)
     582        HbH = np.array([-np.inner(h,np.inner(bij,h)) for h in refDict['Uniq'][iref]])
     583        Tuij = np.where(HbH<1.,np.exp(HbH),1.0)
     584        Tcorr = Tiso*Tuij
     585        fa = np.array([(FF+FP-Bab)*occ*cosp*Tcorr,-FPP*occ*sinp*Tcorr])
     586        fas = np.sum(np.sum(fa,axis=1),axis=1)        #real
     587        if not SGData['SGInv']:
     588            fb = np.array([(FF+FP-Bab)*occ*sinp*Tcorr,FPP*occ*cosp*Tcorr])
     589            fbs = np.sum(np.sum(fb,axis=1),axis=1)
     590        fasq = fas**2
     591        fbsq = fbs**2        #imaginary
     592        refl[9] = np.sum(fasq)+np.sum(fbsq)
     593        refl[10] = atan2d(fbs[0],fas[0])
     594   
     595def StructureFactor2(refDict,G,hfx,pfx,SGData,calcControls,parmDict):
    531596    ''' Compute structure factors for all h,k,l for phase
    532597    puts the result, F^2, in each ref[8] in refList
Note: See TracChangeset for help on using the changeset viewer.