Changeset 1362


Ignore:
Timestamp:
May 22, 2014 2:09:17 PM (8 years ago)
Author:
vondreele
Message:

mag form factors now modernized; atmdata.dat no longer needed in GSAS-II

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/GSASIIElem.py

    r1360 r1362  
    2121import atmdata
    2222
     23getElSym = lambda sym: sym.split('+')[0].split('-')[0]
    2324def GetFormFactorCoeff(El):
    2425    """Read X-ray form factor coefficients from `atomdata.py` file
     
    3839   
    3940    Els = El.capitalize().strip()
    40     valences = [ky for ky in atmdata.XrayFF.keys() if Els == ky.split('+')[0].split('-')[0]]
     41    valences = [ky for ky in atmdata.XrayFF.keys() if Els == getElSym(ky)]
    4142    FormFactors = [atmdata.XrayFF[val] for val in valences]
    4243    for Sy,FF in zip(valences,FormFactors):
     
    5354    FFtable = {}
    5455    for El in atomTypes:
    55         FFs = GetFormFactorCoeff(El.split('+')[0].split('-')[0])
     56        FFs = GetFormFactorCoeff(getElSym(El))
    5657        for item in FFs:
    5758            if item['Symbol'] == El.upper():
     
    7071    isotope = General['Isotope']
    7172    for El in atomTypes:
    72         ElS = El.split('+')[0].split('-')[0]
     73        ElS = getElSym(El)
    7374        if 'Nat' in isotope[El]:
    7475            BLtable[El] = [isotope[El],atmdata.AtmBlens[ElS+'_']]
     
    154155    Elements = [elem[0][0] for elem in ET.ElTable]
    155156    AtomInfo = {}
    156     ElS = El.split('+')[0].split('-')[0]
     157    ElS = getElSym(El)
    157158    AtomInfo.update(dict(zip(['Drad','Arad','Vdrad','Hbrad'],atmdata.AtmSize[ElS])))
    158159    AtomInfo['Symbol'] = El
     
    272273   
    273274    """
    274     ElS = El.upper()
    275     ElS = ElS.rjust(2)
    276     filename = os.path.join(os.path.split(__file__)[0],'atmdata.dat')
    277     try:
    278         FFdata = open(filename,'Ur')
    279     except:
    280         print '**** ERROR - File atmdata.dat not found in directory %s' % sys.path[0]
    281         sys.exit()
    282     S = '1'
    283275    MagFormFactors = []
    284     while S:
    285         S = FFdata.readline()
    286         if S[3:5] == ElS:
    287             if S[8:9] == 'M':
    288                 SN = FFdata.readline()               #'N' is assumed to follow 'M' in Atomdata.asc
    289                 Z=int(S[:2])
    290                 Symbol = S[3:7]
    291                 S = S[12:]
    292                 SN = SN[12:]
    293                 mfa = (float(S[:7]),float(S[14:21]),float(S[28:35]),float(S[42:49]))
    294                 mfb = (float(S[7:14]),float(S[21:28]),float(S[35:42]),float(S[49:56]))
    295                 nfa = (float(SN[:7]),float(SN[14:21]),float(SN[28:35]),float(SN[42:49]))
    296                 nfb = (float(SN[7:14]),float(SN[21:28]),float(SN[35:42]),float(SN[49:56]))
    297                 FormFac = {'Symbol':Symbol,'Z':Z,'mfa':mfa,'nfa':nfa,'mfb':mfb,'nfb':nfb,
    298                     'mfc':float(S[56:63]),'nfc':float(SN[56:63])}
    299                 MagFormFactors.append(FormFac)
    300     FFdata.close()
     276    mags = [ky for ky in atmdata.MagFF.keys() if El == getElSym(ky)]
     277    for mag in mags:
     278        magData = {}
     279        data = atmdata.MagFF[mag]
     280        magData['Symbol'] = mag
     281        magData['Z'] = atmdata.XrayFF[getElSym(mags)]['Z']
     282        magData['mfa'] = [data['M'][i] for i in [0,2,4,6]]
     283        magdata['mfb'] = [data['M'][i] for i in [1,3,5,7]]
     284        magdata['mfc'] = data['M'][8]
     285        magData['nfa'] = [data['N'][i] for i in [0,2,4,6]]
     286        magdata['nfb'] = [data['N'][i] for i in [1,3,5,7]]
     287        magdata['nfc'] = data['N'][8]
     288        magdata['g-fac'] = data['N'][9]
     289        MagFormFactors.append(magdata)
    301290    return MagFormFactors
    302291
Note: See TracChangeset for help on using the changeset viewer.