Changeset 265 for trunk/GSASIIElem.py


Ignore:
Timestamp:
Apr 19, 2011 3:12:37 PM (11 years ago)
Author:
vondreele
Message:

further progress on implementing pdf calculations
optionally put legends on the pdf plots
attempt implementation of a rotation of the azimuth ranges for multiazimuth integrations -not fully successful

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/GSASIIElem.py

    r264 r265  
    5353    FFdata.close()
    5454    return FormFactors
     55   
     56def GetFFC5(ElSym):
     57    '''Get 5 term form factor and Compton scattering data
     58    @param ElSym: str(1-2 character element symbol with proper case);
     59    @return El: dictionary with 5 term form factor & compton coefficients
     60    '''
     61    import FormFactors as FF
     62    El = {}
     63    FF5 = FF.FFac5term[ElSym]
     64    El['fa'] = FF5[:5]
     65    El['fc'] = FF5[5]
     66    El['fb'] = FF5[6:]
     67    Cmp5 = FF.Compton[ElSym]
     68    El['cmpz'] = Cmp5[0]
     69    El['cmpa'] = Cmp5[1:6]
     70    El['cmpb'] = Cmp5[6:]
     71    return El
    5572   
    5673def GetAtomInfo(El):
     
    214231    return MagFormFactors
    215232
    216 def ScatFac(FormFac, SQ):
     233def ScatFac(El, SQ):
    217234    """compute value of form factor
    218     @param FormFac: dictionary  defined in GetFormFactorCoeff
     235    @param El: element dictionary  defined in GetFormFactorCoeff
    219236    @param SQ: (sin-theta/lambda)**2
    220     @return: f: real part of form factor
     237    @return: real part of form factor
    221238    """
    222     fa = np.array(FormFac['fa'])
    223     fb = np.array(FormFac['fb'])
    224     t = -fb*SQ
    225     return np.sum(fa*np.exp(t))+FormFac['fc']
    226    
    227 def ComptonFac(ComptonCoeff,SQ):
     239    fa = np.array(El['fa'])
     240    fb = np.array(El['fb'])
     241    t = -fb[:,np.newaxis]*SQ
     242    return np.sum(fa[:,np.newaxis]*np.exp(t)[:],axis=0)+El['fc']
     243   
     244def ComptonFac(El,SQ):
    228245    """compute Compton scattering factor
    229     @param ComptonCoeff: list [Z, a1:a5, b1:b5]
     246    @param El: element dictionary
    230247    @param SQ: (sin-theta/lambda)**2
    231     @return: comp: compton scattering factor
     248    @return: compton scattering factor
    232249    """   
    233     ca = np.array(ComptonCoeff[1:6])
    234     cb = np.array(ComptonCoeff[6:11])
    235     t = -cb*SQ
    236     return ComptonCoeff[0]-np.sum(ca*np.exp(t))
     250    ca = np.array(El['cmpa'])
     251    cb = np.array(El['cmpb'])
     252    t = -cb[:,np.newaxis]*SQ       
     253    return El['cmpz']-np.sum(ca[:,np.newaxis]*np.exp(t),axis=0)
    237254           
    238255def FPcalc(Orbs, KEv):
     
    367384class DeleteElement(wx.Dialog):
    368385    "Delete element from selected set widget"
    369     def _init_ctrls(self, parent):
    370         l = len(DeleteElement.Elems)-1
    371         wx.Dialog.__init__(self, id=-1, name='Delete', parent=parent,
     386    def _init_ctrls(self, parent,choice):
     387        l = len(choice)-1
     388        wx.Dialog.__init__(self, id=-1, name='Delete', parent=parent, 
    372389              pos=wx.DefaultPosition, size=wx.Size(max(128,64+l*24), 87),
    373390              style=wx.DEFAULT_DIALOG_STYLE, title='Delete Element')
     
    379396        i = 0
    380397        Elem = []
    381         for Elem in DeleteElement.Elems:
    382             name = Elem[0].lower().capitalize()
    383             self.ElButton(id=-1,name=name,pos=wx.Point(16+i*24, 16))
     398        for Elem in choice:
     399            self.ElButton(id=-1,name=Elem,pos=wx.Point(16+i*24, 16))
    384400            i+=1
    385401             
    386     def __init__(self, parent):
    387         DeleteElement.Elems = parent.Elems
     402    def __init__(self, parent,choice):
    388403        DeleteElement.El = ' '
    389         self._init_ctrls(parent)
     404        self._init_ctrls(parent,choice)
    390405
    391406    def ElButton(self, id, name, pos):
Note: See TracChangeset for help on using the changeset viewer.