# Changeset 1587

Ignore:
Timestamp:
Nov 27, 2014 9:34:45 AM (7 years ago)
Message:

use successive approx. to get d from TOF
allow sorting on a,b,c,alp,bet,gam, vol & m20 in cell indexed table
put in derivatives for fitCell inside indexing routine - better accuracy & speed
add a couple more orthos to SS table

Location:
trunk
Files:
4 edited

Unmodified
Removed
• ## trunk/GSASIIindex.py

 r1585 return X def sortVolume(cells): def sortCells(cells,col): #cells is M20,X20,Bravais,a,b,c,alp,bet,gam,volume #sort smallest volume 1st #sort smallest a,b,c,alpha,beta,gamma or volume 1st T = [] for i,M in enumerate(cells): T.append((M[9],i)) T.append((M[col],i)) D = dict(zip(T,cells)) T.sort() X.append(D[key]) return X def findMV(peaks,HKL,ssopt): #    import basinhopping as bh print ssopt return ssopt['ModVec'] def IndexPeaks(peaks,HKL): Qc = G2lat.calc_rDsq(H,A) return (Qo-Qc)*d**Pwr def dervFit(values,ibrav,d,H,Pwr): if ibrav in [0,1,2]: derv = [H[0]*H[0]+H[1]*H[1]+H[2]*H[2],] elif ibrav in [3,4,]: derv = [H[0]*H[0]+H[1]*H[1]+H[0]*H[1],H[2]*H[2]] elif ibrav in [5,6]: derv = [H[0]*H[0]+H[1]*H[1],H[2]*H[2]] elif ibrav in [7,8,9,10]: derv = [H[0]*H[0],H[1]*H[1],H[2]*H[2]] elif ibrav in [11,12]: derv = [H[0]*H[0],H[1]*H[1],H[2]*H[2],H[0]*H[2]] else: derv = [H[0]*H[0],H[1]*H[1],H[2]*H[2],H[0]*H[1],H[0]*H[2],H[1]*H[2]] derv = -np.array(derv) return (derv*d**Pwr).T Peaks = np.array(peaks).T values = A2values(ibrav,A) result = so.leastsq(errFit,values,full_output=True,ftol=0.0001, result = so.leastsq(errFit,values,Dfun=dervFit,full_output=True,ftol=0.000001, args=(ibrav,Peaks[7],Peaks[4:7],Pwr)) A = Values2A(ibrav,result[0])
• ## trunk/GSASIIlattice.py

 r1585 def Pos2dsp(Inst,pos): ''' convert powder pattern position (2-theta or TOF, musec) to d-spacing ignores secondary effects (e.g. difB in TOF) ''' if 'C' in Inst['Type'][0]: return wave/(2.0*sind((pos-Inst.get('Zero',[0,0])[1])/2.0)) else:   #'T'OF - ignore difB #        return TOF2dsp(Inst,pos) T = pos-Inst['Zero'][1] T1 = Inst['difC'][1]**2-4.*Inst['difA'][1]*T return 2.*T/(Inst['difC'][1]+np.sqrt(T1)) return TOF2dsp(Inst,pos) def TOF2dsp(Inst,Pos): import scipy.optimize as so def func(d,pos,Inst): return pos-Inst['difC'][1]*d-Inst['difA'][1]*d**2-Inst['Zero'][1]-Inst['difB'][1]/d return [so.brentq(func,.01,100.,args=(pos,Inst)) for pos in Pos] ''' convert powder pattern TOF, musec to d-spacing by successive approximation Pos can be numpy array ''' def func(d,pos,Inst): return (pos-Inst['difA'][1]*d**2-Inst['Zero'][1]-Inst['difB'][1]/d)/Inst['difC'][1] dsp0 = np.ones_like(Pos) while True:      #successive approximations dsp = func(dsp0,Pos,Inst) if np.allclose(dsp,dsp0,atol=0.000001): return dsp dsp0 = dsp def Dsp2pos(Inst,dsp): return pos def calc_rDsq(H,A): 'needs doc string'
• ## trunk/GSASIIpwdGUI.py

 r1586 def OnFindMV(event): print 'find MV' ssopt['ModVec'] = G2indx.findMV(peaks,G2frame.HKL,ssopt) OnHklShow(event) wx.CallAfter(UpdateUnitCellsGrid,G2frame,data) def OnBravSel(event): if colLabels[c] == 'M20': cells = G2indx.sortM20(cells) elif colLabels[c] == 'Volume': cells = G2indx.sortVolume(cells) elif colLabels[c] in ['Bravais','a','b','c','alpha','beta','gamma','Volume']: cells = G2indx.sortCells(cells,c-1)     #an extra column (Use) not in cells else: return
• ## trunk/GSASIIspc.py

 r1578 '(00g)','(00g)s00','(1/20g)','(a00)','(a00)00s','(a01/2)',], #28 'P m a 2':['(00g)','(00g)s0s','(00g)0ss','(00g)ss0','(01/2g)','(01/2g)s0s', ], 'P m a 2':['(00g)','(00g)s0s','(00g)ss0','(00g)0ss','(01/2g)','(01/2g)s0s', '(a00)','(a01/2)','(a1/20)','(a1/21/2)','(0b0)','(0b0)s00',], 'P 2 m b':[], 'P c 2 m':[], 'P 2 c m':[], #29 'P c a 21':[], 'P c a 21':['(00g)','(00g)0ss','(01/2g)','(1/20g)', '(a00)','(a00)0s0','(a1/20)','(0b0)','(0b0)s00','(1/2b0)',], 'P 21 a b':[], 'P c 21 b':[],
Note: See TracChangeset for help on using the changeset viewer.