Changeset 2182


Ignore:
Timestamp:
Mar 23, 2016 8:56:54 AM (7 years ago)
Author:
vondreele
Message:

change selected area diffr multiplier to be pwrs of 2
change layer width default & ranges to reflect DIFFaX limits
fix some "remaining" bugs in stacking GUI - seems OK now
add CalcStackingSADP for future DIFFaX replacement

Location:
trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/GSASIIgrid.py

    r2177 r2182  
    505505        self.lmax = '2'
    506506        self.lmaxChoice = [str(i+1) for i in range(6)]
    507         self.mult = '2'
    508         self.multChoice = [str(i+1) for i in range(15)]
     507        self.mult = '1'
     508        self.multChoice = [str(2**i) for i in range(10)]
    509509        self.Draw()
    510510       
     
    574574    def GetSelection(self):
    575575        if 'powder' in self.calcType:
    576             return '0\n0\n3\n',''
     576            return '0\n0\n3\n','',''
    577577        elif 'selected' in self.calcType:
    578578            return '0\n0\n4\n1\n%d\n%d\n16\n1\n%d\n0\nend\n'%    \
  • trunk/GSASIIphsGUI.py

    r2181 r2182  
    430430                            if 'Layers' not in data:
    431431                                data['Layers'] = {'Laue':'-1','Cell':[False,1.,1.,1.,90.,90.,90,1.],
    432                                     'Width':[[10.,10.],[False,False]],'Toler':0.01,'AtInfo':{},
     432                                    'Width':[[1.,1.],[False,False]],'Toler':0.01,'AtInfo':{},
    433433                                    'Layers':[],'Stacking':[],'Transitions':[]}
    434434                            G2frame.layerData = wx.ScrolledWindow(G2frame.dataDisplay)
     
    25102510                id = Indx[Obj]
    25112511                try:
    2512                     Layers['Width'][0][id] = float(Obj.GetValue())
     2512                    Layers['Width'][0][id] = max(0.005,min(1.0,float(Obj.GetValue())))
    25132513                except ValueError:
    25142514                    pass
     
    25252525            widthSizer = wx.BoxSizer(wx.HORIZONTAL)
    25262526            for i in range(2):
    2527                 widthSizer.Add(wx.StaticText(layerData,label=' layer width(%s) \xb5m: '%(Labels[i])),0,WACV)
     2527                widthSizer.Add(wx.StaticText(layerData,label=' layer width(%s) (<= 1\xb5m): '%(Labels[i])),0,WACV)
    25282528                widthVal = wx.TextCtrl(layerData,value='%.3f'%(widths[i]),style=wx.TE_PROCESS_ENTER)
    25292529                widthVal.Bind(wx.EVT_TEXT_ENTER,OnWidthChange)       
     
    25512551           
    25522552        def OnImportLayer(event):
     2553            print 'Import atoms for a layer - TBD'
    25532554            #from where? DIFFaX files? other phases? NB: transformation issues
    25542555            event.Skip()
     
    26712672                    rowLabels.append(Xname)
    26722673                    if transArray[Yi][Xi][0] > 0.:
    2673                         allowedTrans.append([str(Yi+1),str(Xi+1)])
     2674                        Layers['allowedTrans'].append([str(Yi+1),str(Xi+1)])
    26742675                transTable = G2G.Table(table,rowLabels=rowLabels,colLabels=transLabels,types=transTypes)
    26752676                transGrid = G2G.GSGrid(layerData)
     
    27922793                if len(Slist) < 2:
    27932794                    stack = 'Error in sequence - too short!'
    2794                 OKlist = [Slist[i:i+2] in allowedTrans for i in range(len(Slist[:-1]))]
     2795                OKlist = [Slist[i:i+2] in Layers['allowedTrans'] for i in range(len(Slist[:-1]))]
    27952796                if all(OKlist):
    27962797                    data['Layers']['Stacking'][2] = stack
     
    28152816                numLayers.Bind(wx.EVT_KILL_FOCUS,OnNumLayers)
    28162817                topLine.Add(numLayers,0,WACV)
     2818                stackSizer.Add(topLine)
    28172819            elif Layers['Stacking'][0] == 'explicit':
    28182820                topLine.Add(wx.StaticText(layerData,label=' layer sequence: '),0,WACV)
     
    28462848        Layers = data['Layers']
    28472849        layerNames = []
    2848         allowedTrans = []
     2850        Layers['allowedTrans'] = []
    28492851        if len(Layers['Layers']):
    28502852            layerNames = [layer['Name'] for layer in Layers['Layers']]
     
    29642966        else:   #selected area
    29652967            G2pwd.StackSim(data['Layers'],ctrls)
     2968#            G2pwd.CalcStackingSADP(data['Layers'])
    29662969        wx.CallAfter(UpdateLayerData)
    29672970       
  • trunk/GSASIIpwd.py

    r2175 r2182  
    17391739
    17401740def StackSim(Layers,ctrls,HistName='',scale=0.,background={},limits=[],inst={},profile=[]):
    1741     '''Simulate powder pattern from stacking faults using DIFFaX
     1741    '''Simulate powder or selected area diffraction pattern from stacking faults using DIFFaX
    17421742   
    17431743    param: Layers dict: 'Laue':'-1','Cell':[False,1.,1.,1.,90.,90.,90,1.],
     
    17581758        if 'bin' in name:
    17591759            DIFFaX = name+'/DIFFaX.exe'
     1760            print ' Execute ',DIFFaX
    17601761            break
    17611762    # make form factor file that DIFFaX wants - atom types are GSASII style
     
    19091910    os.remove('GSASII-DIFFaX.dat')
    19101911   
     1912def CalcStackingSADP(Layers):
     1913   
     1914    def getXY_HK(hk,Layers):
     1915        XY_HK = {}
     1916        for layer in Layers['Layers']:
     1917            if not layer['SameAs']:     #a real layer
     1918                XY_HK[layer['Name']] = np.inner(hk,np.array([atom[2:4] for atom in layer['Atoms']]))*2.*np.pi
     1919        return XY_HK
     1920       
     1921    def getDXY_HK(hk,Trans,detune):
     1922        N = Trans.shape[0]
     1923        DXY_HK = np.zeros((N,N),dtype='cfloat')
     1924        Lphi = np.zeros((N,N),dtype='cfloat')
     1925        for iY in range(N):
     1926            for iX in range(N):
     1927                if [str(iY+1),str(iX+1)] in Layers['allowedTrans']:
     1928                    dot = 2.*np.pi*np.inner(hk,Trans[iY,iX,1:3])
     1929                    Lphi[iY,iX] = complex(np.cos(dot),np.sin(dot))
     1930                    DXY_HK[iY][iX] = detune*Trans[iY,iX,0]*Lphi[iY,iX]
     1931        return DXY_HK,Lphi
     1932                   
     1933                   
     1934   
     1935    sadpSize = 256
     1936    G,g = G2lat.cell2Gmat(Layers['Cell'][1:7])  #recip/real met. tensors
     1937    A = G2lat.Gmat2A(G)
     1938    lmax = float(Layers['Sadp']['Lmax'])
     1939    Smax = G2lat.calc_rDsq([0.,0.,lmax],A)
     1940    plane = Layers['Sadp']['Plane']
     1941    if plane == 'h0l':
     1942        hkmax = int(lmax*np.sqrt(A[2]/A[0]))
     1943    elif plane == '0kl':
     1944        hkmax = int(lmax*np.sqrt(A[2]/A[1]))
     1945    elif plane == 'hhl':
     1946        hkmax = int(lmax*np.sqrt(A[2]/(A[0]+A[1]+A[5])))
     1947    elif plane == 'h-hl':
     1948        hkmax = int(lmax*np.sqrt(A[2]/(A[0]+A[1]-A[5])))
     1949    dl = 2.*lmax/sadpSize
     1950    Trans = []
     1951    for Ytrans in Layers['Transitions']:
     1952        Trans.append([trans[:4] for trans in Ytrans])   #get just the numbers
     1953    Trans = np.array(Trans,dtype='float')
     1954    N = np.sqrt(Trans.shape[0])
     1955    lmax -= 0.5*dl  #shift lmax to avoid l=0
     1956    lmin = -lmax
     1957    sadpBlock = sadpSize
     1958    if Layers['Laue'] not in ['-1','2/m(c)','-3','-3m','axial']:
     1959        lmin = -0.5*dl
     1960        sadpBlock /= 2
     1961#start
     1962    cnt = 0
     1963    Names = [layer['Name'] for layer in Layers['Layers']]
     1964    Nlayers = len(Names)
     1965    detune = 1.0-0.001
     1966    for i in range(hkmax+1):
     1967        if plane == 'h0l':
     1968            hk = np.array([i,0])
     1969        elif plane == '0kl':
     1970            hk = np.array([0,i])
     1971        elif lane == 'hhl':
     1972            hk = np.array([i,i])
     1973        else:
     1974            hk = np.array([i,-i])
     1975        print ' h = %d k = %d'%(hk[0],hk[1])
     1976        XY_HK = getXY_HK(hk,Layers)                 #good
     1977        DXY_HK,Lphi = getDXY_HK(hk,Trans,detune)    #good
     1978             
     1979       
     1980       
     1981   
     1982   
     1983   
    19111984#testing data
    19121985NeedTestData = True
Note: See TracChangeset for help on using the changeset viewer.