Changeset 1362
- Timestamp:
- May 22, 2014 2:09:17 PM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/GSASIIElem.py
r1360 r1362 21 21 import atmdata 22 22 23 getElSym = lambda sym: sym.split('+')[0].split('-')[0] 23 24 def GetFormFactorCoeff(El): 24 25 """Read X-ray form factor coefficients from `atomdata.py` file … … 38 39 39 40 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)] 41 42 FormFactors = [atmdata.XrayFF[val] for val in valences] 42 43 for Sy,FF in zip(valences,FormFactors): … … 53 54 FFtable = {} 54 55 for El in atomTypes: 55 FFs = GetFormFactorCoeff( El.split('+')[0].split('-')[0])56 FFs = GetFormFactorCoeff(getElSym(El)) 56 57 for item in FFs: 57 58 if item['Symbol'] == El.upper(): … … 70 71 isotope = General['Isotope'] 71 72 for El in atomTypes: 72 ElS = El.split('+')[0].split('-')[0]73 ElS = getElSym(El) 73 74 if 'Nat' in isotope[El]: 74 75 BLtable[El] = [isotope[El],atmdata.AtmBlens[ElS+'_']] … … 154 155 Elements = [elem[0][0] for elem in ET.ElTable] 155 156 AtomInfo = {} 156 ElS = El.split('+')[0].split('-')[0]157 ElS = getElSym(El) 157 158 AtomInfo.update(dict(zip(['Drad','Arad','Vdrad','Hbrad'],atmdata.AtmSize[ElS]))) 158 159 AtomInfo['Symbol'] = El … … 272 273 273 274 """ 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'283 275 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) 301 290 return MagFormFactors 302 291
Note: See TracChangeset
for help on using the changeset viewer.