Changeset 2478
- Timestamp:
- Sep 23, 2016 1:43:24 PM (6 years ago)
- Location:
- trunk
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/GSASIIElem.py
r2473 r2478 60 60 return FFtable 61 61 62 def GetMFtable(atomTypes ):62 def GetMFtable(atomTypes,Landeg): 63 63 ''' returns a dictionary of magnetic form factor data for atom types found in atomTypes 64 64 65 65 :param list atomTypes: list of atom types 66 :param list Landeg: Lande g factors for atomTypes 66 67 :return: FFtable, dictionary of form factor data; key is atom type 67 68 68 69 ''' 69 FFtable = {}70 for El in atomTypes:71 FFs = GetMagFormFacCoeff(getElSym(El))72 for item in FFs:70 MFtable = {} 71 for El,gfac in zip(atomTypes,Landeg): 72 MFs = GetMagFormFacCoeff(getElSym(El)) 73 for item in MFs: 73 74 if item['Symbol'] == El.upper(): 74 FFtable[El] = item 75 return FFtable 75 item['gfac'] = gfac 76 MFtable[El] = item 77 return MFtable 76 78 77 79 def GetBLtable(General): … … 122 124 return BLvals 123 125 126 def getMFvalues(MFtables,SQ,ifList=False): 127 'Needs a doc string' 128 if ifList: 129 MFvals = [] 130 for El in MFtables: 131 MFvals.append(MagScatFac(MFtables[El],SQ)[0]) 132 else: 133 MFvals = {} 134 for El in MFtables: 135 MFvals[El] = MagScatFac(MFtables[El],SQ)[0] 136 return MFvals 137 124 138 def GetFFC5(ElSym): 125 139 '''Get 5 term form factor and Compton scattering data … … 327 341 return np.sum(fa[:,np.newaxis]*np.exp(t)[:],axis=0)+El['fc'] 328 342 329 def MagScatFac(El, SQ ,gfac):343 def MagScatFac(El, SQ): 330 344 """compute value of form factor 331 345 … … 343 357 MMF = np.sum(mfa[:,np.newaxis]*np.exp(mt)[:],axis=0)+El['mfc'] 344 358 NMF = np.sum(nfa[:,np.newaxis]*np.exp(nt)[:],axis=0)+El['nfc'] 345 return MMF+(2.0/ gfac-1.0)*NMF359 return MMF+(2.0/El['gfac']-1.0)*NMF 346 360 347 361 def BlenResCW(Els,BLtables,wave): -
trunk/GSASIIstrIO.py
r2474 r2478 190 190 rbIds = rigidbodyDict.get('RBIds',{'Vector':[],'Residue':[]}) 191 191 rbVary,rbDict = GetRigidBodyModels(rigidbodyDict,Print=False) 192 Natoms,atomIndx,phaseVary,phaseDict,pawleyLookup,FFtables,BLtables,maxSSwave = GetPhaseData(Phases,RestraintDict=None,rbIds=rbIds,Print=False) # generates atom symmetry constraints 192 Natoms,atomIndx,phaseVary,phaseDict,pawleyLookup,FFtables,BLtables,MFtables,maxSSwave = \ 193 GetPhaseData(Phases,RestraintDict=None,rbIds=rbIds,Print=False) # generates atom symmetry constraints 193 194 hapVary,hapDict,controlDict = GetHistogramPhaseData(Phases,Histograms,Print=False) 194 195 histVary,histDict,controlDict = GetHistogramData(Histograms,Print=False) … … 1097 1098 FFtables.update(FFtable) 1098 1099 BLtables.update(BLtable) 1100 phaseDict[pfx+'isMag'] = False 1099 1101 if General['Type'] == 'magnetic': 1100 MFtable = G2el.GetMFtable(General['AtomTypes'] )1102 MFtable = G2el.GetMFtable(General['AtomTypes'],General['Lande g']) 1101 1103 MFtables.update(MFtable) 1104 phaseDict[pfx+'isMag'] = True 1102 1105 Atoms = PhaseData[name]['Atoms'] 1103 1106 if Atoms and not General.get('doPawley'): … … 1355 1358 phaseVary += pawleyVary 1356 1359 1357 return Natoms,atomIndx,phaseVary,phaseDict,pawleyLookup,FFtables,BLtables, maxSSwave1360 return Natoms,atomIndx,phaseVary,phaseDict,pawleyLookup,FFtables,BLtables,MFtables,maxSSwave 1358 1361 1359 1362 def cellFill(pfx,SGData,parmDict,sigDict): … … 2276 2279 Uniq = [] 2277 2280 Phi = [] 2281 useExt = 'magnetic' in Phases[phase]['General']['Type'] and 'N' in inst['Type'][0] 2278 2282 if Phases[phase]['General'].get('Modulated',False): 2279 2283 ifSuper = True … … 2283 2287 ext,mul,uniq,phi = G2spc.GenHKLf([h,k,l],SGData) 2284 2288 mul *= 2 # for powder overlap of Friedel pairs 2285 if m or not ext :2289 if m or not ext or useExt: 2286 2290 if 'C' in inst['Type'][0]: 2287 2291 pos = G2lat.Dsp2pos(inst,d) … … 2306 2310 ext,mul,uniq,phi = G2spc.GenHKLf([h,k,l],SGData) 2307 2311 mul *= 2 # for powder overlap of Friedel pairs 2308 if ext :2312 if ext and not useExt: 2309 2313 continue 2310 2314 if 'C' in inst['Type'][0]: -
trunk/GSASIIstrMain.py
r2466 r2478 159 159 rbIds = rigidbodyDict.get('RBIds',{'Vector':[],'Residue':[]}) 160 160 rbVary,rbDict = G2stIO.GetRigidBodyModels(rigidbodyDict,pFile=printFile) 161 Natoms,atomIndx,phaseVary,phaseDict,pawleyLookup,FFtables,BLtables,maxSSwave = G2stIO.GetPhaseData(Phases,restraintDict,rbIds,pFile=printFile) 161 Natoms,atomIndx,phaseVary,phaseDict,pawleyLookup,FFtables,BLtables,MFtables,maxSSwave = \ 162 G2stIO.GetPhaseData(Phases,restraintDict,rbIds,pFile=printFile) 162 163 calcControls['atomIndx'] = atomIndx 163 164 calcControls['Natoms'] = Natoms 164 165 calcControls['FFtables'] = FFtables 165 166 calcControls['BLtables'] = BLtables 167 calcControls['MFtables'] = MFtables 166 168 calcControls['maxSSwave'] = maxSSwave 167 169 hapVary,hapDict,controlDict = G2stIO.GetHistogramPhaseData(Phases,Histograms,pFile=printFile) … … 264 266 rbIds = rigidbodyDict.get('RBIds',{'Vector':[],'Residue':[]}) 265 267 rbVary,rbDict = G2stIO.GetRigidBodyModels(rigidbodyDict,pFile=printFile) 266 Natoms,atomIndx,phaseVary,phaseDict,pawleyLookup,FFtables,BLtables,maxSSwave = G2stIO.GetPhaseData(Phases,restraintDict,rbIds,False,printFile,seqRef=True) 268 Natoms,atomIndx,phaseVary,phaseDict,pawleyLookup,FFtables,BLtables,MFtables,maxSSwave = \ 269 G2stIO.GetPhaseData(Phases,restraintDict,rbIds,False,printFile,seqRef=True) 267 270 for item in phaseVary: 268 271 if '::A0' in item: … … 294 297 calcControls['FFtables'] = FFtables 295 298 calcControls['BLtables'] = BLtables 299 calcControls['MFtables'] = MFtables 296 300 calcControls['maxSSwave'] = maxSSwave 297 301 Histo = {histogram:Histograms[histogram],} -
trunk/GSASIIstrMath.py
r2405 r2478 593 593 Uisodata = np.zeros(Natoms) 594 594 Uijdata = np.zeros((6,Natoms)) 595 Gdata = np.zeros((3,Natoms)) 595 596 keys = {'Atype:':Tdata,'Amul:':Mdata,'Afrac:':Fdata,'AI/A:':IAdata, 596 597 'dAx:':dXdata[0],'dAy:':dXdata[1],'dAz:':dXdata[2], 597 598 'Ax:':Xdata[0],'Ay:':Xdata[1],'Az:':Xdata[2],'AUiso:':Uisodata, 598 599 'AU11:':Uijdata[0],'AU22:':Uijdata[1],'AU33:':Uijdata[2], 599 'AU12:':Uijdata[3],'AU13:':Uijdata[4],'AU23:':Uijdata[5]} 600 'AU12:':Uijdata[3],'AU13:':Uijdata[4],'AU23:':Uijdata[5], 601 'AMx':Gdata[0],'AMy':Gdata[1],'AMz':Gdata[2],} 600 602 for iatm in range(Natoms): 601 603 for key in keys: … … 604 606 keys[key][iatm] = parmDict[parm] 605 607 Fdata = np.where(Fdata,Fdata,1.e-8) #avoid divide by zero in derivative calc. 606 return Tdata,Mdata,Fdata,Xdata,dXdata,IAdata,Uisodata,Uijdata 608 return Tdata,Mdata,Fdata,Xdata,dXdata,IAdata,Uisodata,Uijdata,Gdata 607 609 608 610 def GetAtomSSFXU(pfx,calcControls,parmDict): … … 668 670 FFtables = calcControls['FFtables'] 669 671 BLtables = calcControls['BLtables'] 672 MFtables = calcControls['MFtables'] 670 673 Flack = 1.0 671 674 if not SGData['SGInv'] and 'S' in calcControls[hfx+'histType'] and phfx+'Flack' in parmDict: … … 679 682 TwinFr = np.array([parmDict[phfx+'TwinFr:'+str(i)] for i in range(len(TwinLaw))]) 680 683 TwinInv = list(np.where(calcControls[phfx+'TwinInv'],-1,1)) 681 Tdata,Mdata,Fdata,Xdata,dXdata,IAdata,Uisodata,Uijdata = GetAtomFXU(pfx,calcControls,parmDict)682 FF = np.zeros(len(Tdata))684 Tdata,Mdata,Fdata,Xdata,dXdata,IAdata,Uisodata,Uijdata,Gdata = \ 685 GetAtomFXU(pfx,calcControls,parmDict) 683 686 if 'NC' in calcControls[hfx+'histType']: 684 687 FP,FPP = G2el.BlenResCW(Tdata,BLtables,parmDict[hfx+'Lam']) … … 691 694 nRef = refDict['RefList'].shape[0] 692 695 if not len(refDict['FF']): #no form factors - 1st time thru StructureFactor 696 SQ = 1./(2.*refDict['RefList'].T[4])**2 693 697 if 'N' in calcControls[hfx+'histType']: 694 698 dat = G2el.getBLvalues(BLtables) 695 699 refDict['FF']['El'] = dat.keys() 696 refDict['FF']['FF'] = np.ones((nRef,len(dat)))*dat.values() 700 refDict['FF']['FF'] = np.ones((nRef,len(dat)))*dat.values() 701 refDict['FF']['MF'] = np.zeros((nRef,len(dat))) 702 for iel,El in enumerate(refDict['FF']['El']): 703 if El in MFtables: 704 refDict['FF']['MF'].T[iel] = G2el.MagScatFac(MFtables[El],SQ) 697 705 else: #'X' 698 706 dat = G2el.getFFvalues(FFtables,0.) 699 707 refDict['FF']['El'] = dat.keys() 700 refDict['FF']['FF'] = np.ones((nRef,len(dat))) 701 for iref,ref in enumerate(refDict['RefList']): 702 SQ = 1./(2.*ref[4])**2 703 dat = G2el.getFFvalues(FFtables,SQ) 704 refDict['FF']['FF'][iref] *= dat.values() 708 refDict['FF']['FF'] = np.zeros((nRef,len(dat))) 709 for iel,El in enumerate(refDict['FF']['El']): 710 refDict['FF']['FF'].T[iel] = G2el.ScatFac(FFtables[El],SQ) 711 # GSASIIpath.IPyBreak() 705 712 #reflection processing begins here - big arrays! 706 713 iBeg = 0 … … 731 738 Bab = np.repeat(parmDict[phfx+'BabA']*np.exp(-parmDict[phfx+'BabU']*SQfactor),len(SGT)*len(TwinLaw)) 732 739 Tindx = np.array([refDict['FF']['El'].index(El) for El in Tdata]) 733 FF = np.repeat(refDict['FF']['FF'][iBeg:iFin].T[Tindx].T,len(SGT)*len(TwinLaw),axis=0)734 740 Uniq = np.inner(H,SGMT) 735 741 Phi = np.inner(H,SGT) … … 742 748 Tuij = np.where(HbH<1.,np.exp(HbH),1.0).T 743 749 Tcorr = np.reshape(Tiso,Tuij.shape)*Tuij*Mdata*Fdata/len(SGMT) 750 FF = np.repeat(refDict['FF']['FF'][iBeg:iFin].T[Tindx].T,len(SGT)*len(TwinLaw),axis=0) 751 if 'N' in calcControls[hfx+'histType'] and parmDict[pfx+'isMag']: 752 MF = np.repeat(refDict['FF']['MF'][iBeg:iFin].T[Tindx].T,len(SGT)*len(TwinLaw),axis=0) 753 #calc fam & fbm here 744 754 if 'T' in calcControls[hfx+'histType']: #fa,fb are 2 X blkSize X nTwin X nOps x nAtoms 745 755 fa = np.array([np.reshape(((FF+FP).T-Bab).T,cosp.shape)*cosp*Tcorr,-np.reshape(Flack*FPP,sinp.shape)*sinp*Tcorr]) … … 754 764 fas[1] *= 0. 755 765 if 'PWDR' in calcControls[hfx+'histType']: #PWDR: F^2 = A[0]^2 + A[1]^2 + B[0]^2 + B[1]^2 756 refl.T[9] = np.sum(fas**2,axis=0)+np.sum(fbs**2,axis=0) 766 refl.T[9] = np.sum(fas**2,axis=0)+np.sum(fbs**2,axis=0) #add fam**2 & fbm**2 here 757 767 refl.T[10] = atan2d(fbs[0],fas[0]) #ignore f' & f" 758 768 else: #HKLF: F^2 = (A[0]+A[1])^2 + (B[0]+B[1])^2 … … 805 815 # nTwin = len(TwinLaw) 806 816 # nRef = len(refDict['RefList']) 807 # Tdata,Mdata,Fdata,Xdata,dXdata,IAdata,Uisodata,Uijdata = GetAtomFXU(pfx,calcControls,parmDict) 817 # Tdata,Mdata,Fdata,Xdata,dXdata,IAdata,Uisodata,Uijdata,Gdata = \ 818 # GetAtomFXU(pfx,calcControls,parmDict) 808 819 # mSize = len(Mdata) 809 820 # FF = np.zeros(len(Tdata)) … … 1001 1012 BLtables = calcControls['BLtables'] 1002 1013 nRef = len(refDict['RefList']) 1003 Tdata,Mdata,Fdata,Xdata,dXdata,IAdata,Uisodata,Uijdata = GetAtomFXU(pfx,calcControls,parmDict) 1014 Tdata,Mdata,Fdata,Xdata,dXdata,IAdata,Uisodata,Uijdata,Gdata = \ 1015 GetAtomFXU(pfx,calcControls,parmDict) 1004 1016 mSize = len(Mdata) 1005 1017 FF = np.zeros(len(Tdata)) … … 1171 1183 # nTwin = len(TwinLaw) 1172 1184 # nRef = len(refDict['RefList']) 1173 # Tdata,Mdata,Fdata,Xdata,dXdata,IAdata,Uisodata,Uijdata = GetAtomFXU(pfx,calcControls,parmDict) 1185 # Tdata,Mdata,Fdata,Xdata,dXdata,IAdata,Uisodata,Uijdata,Gdata = \ 1186 # GetAtomFXU(pfx,calcControls,parmDict) 1174 1187 # mSize = len(Mdata) 1175 1188 # FF = np.zeros(len(Tdata)) … … 1317 1330 nTwin = len(TwinLaw) 1318 1331 nRef = len(refDict['RefList']) 1319 Tdata,Mdata,Fdata,Xdata,dXdata,IAdata,Uisodata,Uijdata = GetAtomFXU(pfx,calcControls,parmDict) 1332 Tdata,Mdata,Fdata,Xdata,dXdata,IAdata,Uisodata,Uijdata,Gdata = \ 1333 GetAtomFXU(pfx,calcControls,parmDict) 1320 1334 mSize = len(Mdata) 1321 1335 FF = np.zeros(len(Tdata)) … … 1476 1490 if not SGData['SGInv'] and 'S' in calcControls[hfx+'histType'] and phfx+'Flack' in parmDict: 1477 1491 Flack = 1.-2.*parmDict[phfx+'Flack'] 1478 Tdata,Mdata,Fdata,Xdata,dXdata,IAdata,Uisodata,Uijdata = GetAtomFXU(pfx,calcControls,parmDict) 1492 Tdata,Mdata,Fdata,Xdata,dXdata,IAdata,Uisodata,Uijdata,Gdata = \ 1493 GetAtomFXU(pfx,calcControls,parmDict) 1479 1494 waveTypes,FSSdata,XSSdata,USSdata,MSSdata = GetAtomSSFXU(pfx,calcControls,parmDict) 1480 1495 ngl,nWaves,Fmod,Xmod,Umod,glTau,glWt = G2mth.makeWaves(waveTypes,FSSdata,XSSdata,USSdata,Mast) … … 1491 1506 nRef = refDict['RefList'].shape[0] 1492 1507 if not len(refDict['FF']): 1508 SQ = 1./(2.*refDict['RefList'].T[5])**2 1493 1509 if 'N' in calcControls[hfx+'histType']: 1494 dat = G2el.getBLvalues(BLtables) #will need wave here for anom. neutron b's1510 dat = G2el.getBLvalues(BLtables) 1495 1511 refDict['FF']['El'] = dat.keys() 1496 refDict['FF']['FF'] = np.ones((nRef,len(dat)))*dat.values() 1512 refDict['FF']['FF'] = np.ones((nRef,len(dat)))*dat.values() 1513 refDict['FF']['MF'] = np.zeros((nRef,len(dat))) 1514 for iel,El in enumerate(refDict['FF']['El']): 1515 if El in MFtables: 1516 refDict['FF']['MF'].T[iel] = G2el.MagScatFac(MFtables[El],SQ) 1497 1517 else: 1498 dat = G2el.getFFvalues(FFtables,0.) 1518 dat = G2el.getFFvalues(FFtables,0.) 1499 1519 refDict['FF']['El'] = dat.keys() 1500 refDict['FF']['FF'] = np.ones((nRef,len(dat))) 1501 for iref,ref in enumerate(refDict['RefList']): 1502 SQ = 1./(2.*ref[5])**2 1503 dat = G2el.getFFvalues(FFtables,SQ) 1504 refDict['FF']['FF'][iref] *= dat.values() 1520 refDict['FF']['FF'] = np.zeros((nRef,len(dat))) 1521 for iel,El in enumerate(refDict['FF']['El']): 1522 refDict['FF']['FF'].T[iel] = G2el.ScatFac(FFtables[El],SQ) 1505 1523 time0 = time.time() 1506 1524 #reflection processing begins here - big arrays! … … 1599 1617 TwinFr = np.array([parmDict[phfx+'TwinFr:'+str(i)] for i in range(len(TwinLaw))]) 1600 1618 TwinInv = list(np.where(calcControls[phfx+'TwinInv'],-1,1)) 1601 Tdata,Mdata,Fdata,Xdata,dXdata,IAdata,Uisodata,Uijdata = GetAtomFXU(pfx,calcControls,parmDict) 1619 Tdata,Mdata,Fdata,Xdata,dXdata,IAdata,Uisodata,Uijdata,Gdata = \ 1620 GetAtomFXU(pfx,calcControls,parmDict) 1602 1621 waveTypes,FSSdata,XSSdata,USSdata,MSSdata = GetAtomSSFXU(pfx,calcControls,parmDict) 1603 1622 ngl,nWaves,Fmod,Xmod,Umod,glTau,glWt = G2mth.makeWaves(waveTypes,FSSdata,XSSdata,USSdata,Mast) … … 1613 1632 blkSize = 32 #no. of reflections in a block 1614 1633 nRef = refDict['RefList'].shape[0] 1615 if not len(refDict['FF']): 1634 if not len(refDict['FF']): #no form factors - 1st time thru StructureFactor 1635 SQ = 1./(2.*refDict['RefList'].T[5])**2 1616 1636 if 'N' in calcControls[hfx+'histType']: 1617 dat = G2el.getBLvalues(BLtables) #will need wave here for anom. neutron b's1637 dat = G2el.getBLvalues(BLtables) 1618 1638 refDict['FF']['El'] = dat.keys() 1619 refDict['FF']['FF'] = np.ones((nRef,len(dat)))*dat.values() 1639 refDict['FF']['FF'] = np.ones((nRef,len(dat)))*dat.values() 1640 refDict['FF']['MF'] = np.zeros((nRef,len(dat))) 1641 for iel,El in enumerate(refDict['FF']['El']): 1642 if El in MFtables: 1643 refDict['FF']['MF'].T[iel] = G2el.MagScatFac(MFtables[El],SQ) 1620 1644 else: 1621 dat = G2el.getFFvalues(FFtables,0.) 1645 dat = G2el.getFFvalues(FFtables,0.) 1622 1646 refDict['FF']['El'] = dat.keys() 1623 refDict['FF']['FF'] = np.ones((nRef,len(dat))) 1624 for iref,ref in enumerate(refDict['RefList']): 1625 SQ = 1./(2.*ref[5])**2 1626 dat = G2el.getFFvalues(FFtables,SQ) 1627 refDict['FF']['FF'][iref] *= dat.values() 1647 refDict['FF']['FF'] = np.zeros((nRef,len(dat))) 1648 for iel,El in enumerate(refDict['FF']['El']): 1649 refDict['FF']['FF'].T[iel] = G2el.ScatFac(FFtables[El],SQ) 1628 1650 time0 = time.time() 1629 1651 #reflection processing begins here - big arrays! … … 1725 1747 BLtables = calcControls['BLtables'] 1726 1748 nRef = len(refDict['RefList']) 1727 Tdata,Mdata,Fdata,Xdata,dXdata,IAdata,Uisodata,Uijdata = GetAtomFXU(pfx,calcControls,parmDict) 1749 Tdata,Mdata,Fdata,Xdata,dXdata,IAdata,Uisodata,Uijdata,Gdata = \ 1750 GetAtomFXU(pfx,calcControls,parmDict) 1728 1751 mSize = len(Mdata) #no. atoms 1729 1752 waveTypes,FSSdata,XSSdata,USSdata,MSSdata = GetAtomSSFXU(pfx,calcControls,parmDict) … … 1937 1960 BLtables = calcControls['BLtables'] 1938 1961 nRef = len(refDict['RefList']) 1939 Tdata,Mdata,Fdata,Xdata,dXdata,IAdata,Uisodata,Uijdata = GetAtomFXU(pfx,calcControls,parmDict) 1962 Tdata,Mdata,Fdata,Xdata,dXdata,IAdata,Uisodata,Uijdata,Gdata = \ 1963 GetAtomFXU(pfx,calcControls,parmDict) 1940 1964 mSize = len(Mdata) #no. atoms 1941 1965 waveTypes,FSSdata,XSSdata,USSdata,MSSdata = GetAtomSSFXU(pfx,calcControls,parmDict) … … 2167 2191 nTwin = len(TwinLaw) 2168 2192 nRef = len(refDict['RefList']) 2169 Tdata,Mdata,Fdata,Xdata,dXdata,IAdata,Uisodata,Uijdata = GetAtomFXU(pfx,calcControls,parmDict) 2193 Tdata,Mdata,Fdata,Xdata,dXdata,IAdata,Uisodata,Uijdata,Gdata = \ 2194 GetAtomFXU(pfx,calcControls,parmDict) 2170 2195 mSize = len(Mdata) #no. atoms 2171 2196 waveTypes,FSSdata,XSSdata,USSdata,MSSdata = GetAtomSSFXU(pfx,calcControls,parmDict)
Note: See TracChangeset
for help on using the changeset viewer.