Changeset 2473 for trunk/GSASIIElem.py


Ignore:
Timestamp:
Sep 20, 2016 1:58:10 PM (5 years ago)
Author:
vondreele
Message:

work on magnetic structures - import from EXP, plotting, LS refine I/O, mag. form factors, etc.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/GSASIIElem.py

    r1589 r2473  
    5555    for El in atomTypes:
    5656        FFs = GetFormFactorCoeff(getElSym(El))
     57        for item in FFs:
     58            if item['Symbol'] == El.upper():
     59                FFtable[El] = item
     60    return FFtable
     61   
     62def GetMFtable(atomTypes):
     63    ''' returns a dictionary of magnetic form factor data for atom types found in atomTypes
     64
     65    :param list atomTypes: list of atom types
     66    :return: FFtable, dictionary of form factor data; key is atom type
     67
     68    '''
     69    FFtable = {}
     70    for El in atomTypes:
     71        FFs = GetMagFormFacCoeff(getElSym(El))
    5772        for item in FFs:
    5873            if item['Symbol'] == El.upper():
     
    266281   
    267282def GetMagFormFacCoeff(El):
    268     """Read magnetic form factor data from atomdata.asc file
     283    """Read magnetic form factor data from atmdata.py
    269284
    270285    :param El: 2 character element symbol
     
    283298   
    284299    """
     300    Els = El.capitalize().strip()
    285301    MagFormFactors = []
    286     mags = [ky for ky in atmdata.MagFF.keys() if El == getElSym(ky)]
     302    mags = [ky for ky in atmdata.MagFF.keys() if Els == getElSym(ky)]
    287303    for mag in mags:
    288304        magData = {}
    289305        data = atmdata.MagFF[mag]
    290         magData['Symbol'] = mag
    291         magData['Z'] = atmdata.XrayFF[getElSym(mags)]['Z']
     306        magData['Symbol'] = mag.upper()
     307        magData['Z'] = atmdata.XrayFF[getElSym(mag)]['Z']
    292308        magData['mfa'] = [data['M'][i] for i in [0,2,4,6]]
    293         magdata['mfb'] = [data['M'][i] for i in [1,3,5,7]]
    294         magdata['mfc'] = data['M'][8]
     309        magData['mfb'] = [data['M'][i] for i in [1,3,5,7]]
     310        magData['mfc'] = data['M'][8]
    295311        magData['nfa'] = [data['N'][i] for i in [0,2,4,6]]
    296         magdata['nfb'] = [data['N'][i] for i in [1,3,5,7]]
    297         magdata['nfc'] = data['N'][8]
    298         magdata['g-fac'] = data['N'][9]
    299         MagFormFactors.append(magdata)
     312        magData['nfb'] = [data['N'][i] for i in [1,3,5,7]]
     313        magData['nfc'] = data['N'][8]
     314        MagFormFactors.append(magData)
    300315    return MagFormFactors
    301316
     
    311326    t = -fb[:,np.newaxis]*SQ
    312327    return np.sum(fa[:,np.newaxis]*np.exp(t)[:],axis=0)+El['fc']
     328       
     329def MagScatFac(El, SQ,gfac):
     330    """compute value of form factor
     331
     332    :param El: element dictionary defined in GetFormFactorCoeff
     333    :param SQ: (sin-theta/lambda)**2
     334    :param gfac: Lande g factor (normally = 2.0)
     335    :return: real part of form factor
     336    """
     337    mfa = np.array(El['mfa'])
     338    mfb = np.array(El['mfb'])
     339    nfa = np.array(El['nfa'])
     340    nfb = np.array(El['nfb'])
     341    mt = -mfb[:,np.newaxis]*SQ
     342    nt = -nfb[:,np.newaxis]*SQ
     343    MMF = np.sum(mfa[:,np.newaxis]*np.exp(mt)[:],axis=0)+El['mfc']
     344    NMF = np.sum(nfa[:,np.newaxis]*np.exp(nt)[:],axis=0)+El['nfc']
     345    return MMF+(2.0/gfac-1.0)*NMF
    313346       
    314347def BlenResCW(Els,BLtables,wave):
Note: See TracChangeset for help on using the changeset viewer.