Changeset 1587


Ignore:
Timestamp:
Nov 27, 2014 9:34:45 AM (7 years ago)
Author:
vondreele
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

Legend:

Unmodified
Added
Removed
  • trunk/GSASIIindex.py

    r1585 r1587  
    244244    return X
    245245               
    246 def sortVolume(cells):
     246def sortCells(cells,col):
    247247    #cells is M20,X20,Bravais,a,b,c,alp,bet,gam,volume
    248     #sort smallest volume 1st
     248    #sort smallest a,b,c,alpha,beta,gamma or volume 1st
    249249    T = []
    250250    for i,M in enumerate(cells):
    251         T.append((M[9],i))
     251        T.append((M[col],i))
    252252    D = dict(zip(T,cells))
    253253    T.sort()
     
    256256        X.append(D[key])
    257257    return X
     258   
     259def findMV(peaks,HKL,ssopt):
     260#    import basinhopping as bh
     261    print ssopt
     262    return ssopt['ModVec']
    258263               
    259264def IndexPeaks(peaks,HKL):
     
    405410        Qc = G2lat.calc_rDsq(H,A)
    406411        return (Qo-Qc)*d**Pwr
     412       
     413    def dervFit(values,ibrav,d,H,Pwr):
     414        if ibrav in [0,1,2]:
     415            derv = [H[0]*H[0]+H[1]*H[1]+H[2]*H[2],]
     416        elif ibrav in [3,4,]:
     417            derv = [H[0]*H[0]+H[1]*H[1]+H[0]*H[1],H[2]*H[2]]
     418        elif ibrav in [5,6]:
     419            derv = [H[0]*H[0]+H[1]*H[1],H[2]*H[2]]
     420        elif ibrav in [7,8,9,10]:
     421            derv = [H[0]*H[0],H[1]*H[1],H[2]*H[2]]
     422        elif ibrav in [11,12]:
     423            derv = [H[0]*H[0],H[1]*H[1],H[2]*H[2],H[0]*H[2]]
     424        else:
     425            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]]
     426        derv = -np.array(derv)
     427        return (derv*d**Pwr).T
    407428   
    408429    Peaks = np.array(peaks).T
    409    
    410430    values = A2values(ibrav,A)
    411     result = so.leastsq(errFit,values,full_output=True,ftol=0.0001,
     431    result = so.leastsq(errFit,values,Dfun=dervFit,full_output=True,ftol=0.000001,
    412432        args=(ibrav,Peaks[7],Peaks[4:7],Pwr))
    413433    A = Values2A(ibrav,result[0])
  • trunk/GSASIIlattice.py

    r1585 r1587  
    418418def Pos2dsp(Inst,pos):
    419419    ''' convert powder pattern position (2-theta or TOF, musec) to d-spacing
    420     ignores secondary effects (e.g. difB in TOF)
    421420    '''
    422421    if 'C' in Inst['Type'][0]:
     
    424423        return wave/(2.0*sind((pos-Inst.get('Zero',[0,0])[1])/2.0))
    425424    else:   #'T'OF - ignore difB
    426 #        return TOF2dsp(Inst,pos)
    427         T = pos-Inst['Zero'][1]
    428         T1 = Inst['difC'][1]**2-4.*Inst['difA'][1]*T
    429         return 2.*T/(Inst['difC'][1]+np.sqrt(T1))
     425        return TOF2dsp(Inst,pos)
    430426       
    431427def TOF2dsp(Inst,Pos):
    432     import scipy.optimize as so
    433    
    434     def func(d,pos,Inst):
    435         return pos-Inst['difC'][1]*d-Inst['difA'][1]*d**2-Inst['Zero'][1]-Inst['difB'][1]/d
    436        
    437     return [so.brentq(func,.01,100.,args=(pos,Inst)) for pos in Pos]
     428    ''' convert powder pattern TOF, musec to d-spacing by successive approximation
     429    Pos can be numpy array
     430    '''
     431    def func(d,pos,Inst):       
     432        return (pos-Inst['difA'][1]*d**2-Inst['Zero'][1]-Inst['difB'][1]/d)/Inst['difC'][1]
     433    dsp0 = np.ones_like(Pos)
     434    while True:      #successive approximations
     435        dsp = func(dsp0,Pos,Inst)
     436        if np.allclose(dsp,dsp0,atol=0.000001):
     437            return dsp
     438        dsp0 = dsp
    438439   
    439440def Dsp2pos(Inst,dsp):
     
    456457    return pos
    457458                   
    458    
    459459def calc_rDsq(H,A):
    460460    'needs doc string'
  • trunk/GSASIIpwdGUI.py

    r1586 r1587  
    22752275       
    22762276    def OnFindMV(event):
    2277         print 'find MV'
     2277        ssopt['ModVec'] = G2indx.findMV(peaks,G2frame.HKL,ssopt)
     2278        OnHklShow(event)
     2279        wx.CallAfter(UpdateUnitCellsGrid,G2frame,data)
    22782280       
    22792281    def OnBravSel(event):
     
    23862388        if colLabels[c] == 'M20':
    23872389            cells = G2indx.sortM20(cells)
    2388         elif colLabels[c] == 'Volume':
    2389             cells = G2indx.sortVolume(cells)
     2390        elif colLabels[c] in ['Bravais','a','b','c','alpha','beta','gamma','Volume']:
     2391            cells = G2indx.sortCells(cells,c-1)     #an extra column (Use) not in cells
    23902392        else:
    23912393            return
  • trunk/GSASIIspc.py

    r1578 r1587  
    19611961        '(00g)','(00g)s00','(1/20g)','(a00)','(a00)00s','(a01/2)',],
    19621962#28       
    1963     'P m a 2':['(00g)','(00g)s0s','(00g)0ss','(00g)ss0','(01/2g)','(01/2g)s0s',
    1964         ],
     1963    'P m a 2':['(00g)','(00g)s0s','(00g)ss0','(00g)0ss','(01/2g)','(01/2g)s0s',
     1964        '(a00)','(a01/2)','(a1/20)','(a1/21/2)','(0b0)','(0b0)s00',],
    19651965    'P 2 m b':[],
    19661966    'P c 2 m':[],
     
    19691969    'P 2 c m':[],
    19701970#29       
    1971     'P c a 21':[],
     1971    'P c a 21':['(00g)','(00g)0ss','(01/2g)','(1/20g)',
     1972        '(a00)','(a00)0s0','(a1/20)','(0b0)','(0b0)s00','(1/2b0)',],
    19721973    'P 21 a b':[],
    19731974    'P c 21 b':[],
Note: See TracChangeset for help on using the changeset viewer.