Changeset 1360 for trunk/GSASIIElem.py
- Timestamp:
- May 22, 2014 1:07:10 PM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/GSASIIElem.py
r1295 r1360 19 19 GSASIIpath.SetVersionNumber("$Revision$") 20 20 import numpy as np 21 import atmdata 21 22 22 23 def GetFormFactorCoeff(El): 23 """Read X-ray form factor coefficients from `atomdata. asc` file24 """Read X-ray form factor coefficients from `atomdata.py` file 24 25 25 26 :param str El: element 1-2 character symbol, case irrevelant … … 35 36 36 37 """ 37 ElS = El.upper() 38 ElS = ElS.rjust(2) 39 filename = os.path.join(os.path.split(__file__)[0],'atmdata.dat') 40 try: 41 FFdata = open(filename,'Ur') 42 except: 43 print "**** ERROR - File atmdata.dat not found in directory %s" % sys.path[0] 44 sys.exit() 45 S = '1' 46 FormFactors = [] 47 while S: 48 S = FFdata.readline() 49 if S[3:5] == ElS: 50 if S[5:6] != '_' and S[8] not in ['N','M']: 51 Z=int(S[:2]) 52 Symbol = S[3:7].strip() 53 S = S[12:] 54 fa = (float(S[:7]),float(S[14:21]),float(S[28:35]),float(S[42:49])) 55 fb = (float(S[7:14]),float(S[21:28]),float(S[35:42]),float(S[49:56])) 56 FormFac = {'Symbol':Symbol,'Z':Z,'fa':fa,'fb':fb,'fc':float(S[56:63])} 57 FormFactors.append(FormFac) 58 FFdata.close() 38 39 Els = El.capitalize().strip() 40 valences = [ky for ky in atmdata.XrayFF.keys() if Els == ky.split('+')[0].split('-')[0]] 41 FormFactors = [atmdata.XrayFF[val] for val in valences] 42 for Sy,FF in zip(valences,FormFactors): 43 FF.update({'Symbol':Sy.upper()}) 59 44 return FormFactors 60 45 … … 85 70 isotope = General['Isotope'] 86 71 for El in atomTypes: 87 BLtable[El] = [isotope[El],isotopes[El][isotope[El]]] 72 ElS = El.split('+')[0].split('-')[0] 73 if 'Nat' in isotope[El]: 74 BLtable[El] = [isotope[El],atmdata.AtmBlens[ElS+'_']] 75 else: 76 BLtable[El] = [isotope[El],atmdata.AtmBlens[ElS+'_'+isotope[El]]] 88 77 return BLtable 89 78 … … 105 94 BLvals = [] 106 95 for El in BLtables: 107 BLvals.append(BLtables[El][1][ 1])96 BLvals.append(BLtables[El][1]['SL'][0]) 108 97 else: 109 98 BLvals = {} 110 99 for El in BLtables: 111 BLvals[El] = BLtables[El][1][ 1]100 BLvals[El] = BLtables[El][1]['SL'][0] 112 101 return BLvals 113 102 … … 159 148 El = El.split('-0')[0] 160 149 return El 150 151 def GetAtomInfo(El): 152 'reads element information from atmdata.py' 153 import ElementTable as ET 154 Elements = [elem[0][0] for elem in ET.ElTable] 155 AtomInfo = {} 156 ElS = El.split('+')[0].split('-')[0] 157 AtomInfo.update(dict(zip(['Drad','Arad','Vdrad','Hbrad'],atmdata.AtmSize[ElS]))) 158 AtomInfo['Symbol'] = El 159 AtomInfo['Color'] = ET.ElTable[Elements.index(ElS)][6] 160 AtomInfo['Z'] = atmdata.XrayFF[El]['Z'] 161 isotopes = [ky for ky in atmdata.AtmBlens.keys() if ElS == ky.split('_')[0]] 162 isotopes.sort() 163 AtomInfo['Mass'] = atmdata.AtmBlens[isotopes[0]]['Mass'] #default to nat. abund. 164 AtomInfo['Isotopes'] = {} 165 for isotope in isotopes: 166 data = atmdata.AtmBlens[isotope] 167 if isotope == ElS+'_': 168 if data['SL']: 169 AtomInfo['Isotopes']['Nat. Abund.'] = data 170 else: 171 AtomInfo['Isotopes'][isotope.split('_')[1]] = data 172 return AtomInfo 161 173 162 def GetAtomInfo(El):163 'reads element information from file atmdata.dat'164 import ElementTable as ET165 Elements = []166 for elem in ET.ElTable:167 Elements.append(elem[0][0])168 if len(El) in [2,4]:169 ElS = El.upper()[:2].rjust(2)170 else:171 ElS = El.upper()[:1].rjust(2)172 filename = os.path.join(os.path.split(__file__)[0],'atmdata.dat')173 try:174 FFdata = open(filename,'Ur')175 except:176 print '**** ERROR - File atmdata.dat not found in directory %s' % sys.path[0]177 sys.exit()178 S = '1'179 AtomInfo = {}180 Isotopes = {}181 Mass = []182 while S:183 S = FFdata.readline()184 if S[3:5] == ElS:185 if S[5:6] == '_':186 if not Mass: #picks 1st one; natural abundance or 1st isotope187 Mass = float(S[10:19])188 if S[6] in [' ','1','2','3','4','5','6','7','8','9']:189 isoName = S[6:9]190 if isoName == ' ':191 isoName = 'Nat. Abund.' #natural abundance192 if S[76:78] in ['LS','BW']: #special anomalous scattering length info193 St = [S[19:25],S[25:31],S[31:38],S[38:44],S[44:50],194 S[50:56],S[56:62],S[62:68],S[68:74],]195 Vals = []196 for item in St:197 if item.strip():198 Vals.append(float(item.strip()))199 Isotopes[isoName.rstrip()] = Vals200 else:201 Isotopes[isoName.rstrip()] = [float(S[10:19]),float(S[19:25])]202 elif S[5:9] == '_SIZ':203 Z=int(S[:2])204 Symbol = S[3:5].strip().lower().capitalize()205 Drad = float(S[12:22])206 Arad = float(S[22:32])207 Vdrad = float(S[32:38])208 Color = ET.ElTable[Elements.index(Symbol)][6]209 FFdata.close()210 AtomInfo={'Symbol':Symbol,'Isotopes':Isotopes,'Mass':Mass,'Z':Z,'Drad':Drad,'Arad':Arad,'Vdrad':Vdrad,'Color':Color}211 return AtomInfo212 213 174 def GetXsectionCoeff(El): 214 175 """Read atom orbital scattering cross sections for fprime calculations via Cromer-Lieberman algorithm
Note: See TracChangeset
for help on using the changeset viewer.