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

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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'
Note: See TracChangeset for help on using the changeset viewer.