Changeset 2767


Ignore:
Timestamp:
Mar 31, 2017 2:41:15 PM (5 years ago)
Author:
vondreele
Message:

make clearer H->R & R->H transformation labels
implement generic unit scatterer for reflectometry (& small angle) modeling
implement plot of scattering contrast with transition markers

Location:
trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/GSASIIgrid.py

    r2763 r2767  
    164164    'ba-c':np.array([[0,1,0],[1,0,0],[0,0,-1]]),'-cba':np.array([[0,0,-1],[0,1,0],[1,0,0]]),
    165165    'bca':np.array([[0,1,0],[0,0,1],[1,0,0]]),'cab':np.array([[0,0,1],[1,0,0],[0,1,0]]),
    166     'P->R':np.array([[1,-1,0],[0,1,-1],[1,1,1]]),'R->P':np.array([[2./3,1./3,1./3],[-1./3,1./3,1./3],[-1./3,-2./3,1./3]]),
     166    'R->H':np.array([[1,-1,0],[0,1,-1],[1,1,1]]),'H->R':np.array([[2./3,1./3,1./3],[-1./3,1./3,1./3],[-1./3,-2./3,1./3]]),
    167167    'P->A':np.array([[-1,0,0],[0,-1,1],[0,1,1]]),'R->O':np.array([[-1,0,0],[0,-1,0],[0,0,1]]),
    168168    'P->B':np.array([[-1,0,1],[0,-1,0],[1,0,1]]),'B->P':np.array([[-.5,0,.5],[0,-1,0],[.5,0,.5]]),
  • trunk/GSASIIpwd.py

    r2763 r2767  
    19321932            name = layer['Name']
    19331933            cid = str(ilay)+';'
    1934             for parm in ['Thick','Rough','DenMul','Mag SLD']:
     1934            parmDict[cid+'Name'] = name
     1935            for parm in ['Thick','Rough','DenMul','Mag SLD','iDenMul']:
    19351936                parmDict[cid+parm] = layer.get(parm,[0.,False])[0]
    19361937                if layer.get(parm,[0.,False])[1]:
     
    19381939                    values.append(layer[parm][0])
    19391940                    bounds.append(Bounds[parm])
    1940             parmDict[cid+'rho'] = Substances[name]['Scatt density']
    1941             parmDict[cid+'irho'] = Substances[name].get('XImag density',0.)
     1941            if name not in ['vacuum','unit scatter']:
     1942                parmDict[cid+'rho'] = Substances[name]['Scatt density']
     1943                parmDict[cid+'irho'] = Substances[name].get('XImag density',0.)
    19421944        return parmDict,varyList,values,bounds
    19431945   
     
    19601962            line2 = ' Scattering density: Real %.5g'%(Substances[name]['Scatt density']*parmDict[cid+'DenMul'])
    19611963            line2 += ' Imag %.5g'%(Substances[name].get('XImag density',0.)**parmDict[cid+'DenMul'])
    1962             for parm in ['Thick','Rough','DenMul','Mag SLD']:
     1964            for parm in ['Thick','Rough','DenMul','Mag SLD','iDenMul']:
    19631965                if parm in layer:
    19641966                    layer[parm][0] = parmDict[cid+parm]
     
    19911993            depth[ilay] = parmDict[cid+'Thick']
    19921994            sigma[ilay] = parmDict[cid+'Rough']
    1993             rho[ilay] = parmDict[cid+'rho']*parmDict[cid+'DenMul']
     1995            if parmDict[cid+'Name'] == u'unit scatter':
     1996                rho[ilay] = parmDict[cid+'DenMul']
     1997                irho[ilay] = parmDict[cid+'iDenMul']
     1998            elif 'vacuum' != parmDict[cid+'Name']:
     1999                rho[ilay] = parmDict[cid+'rho']*parmDict[cid+'DenMul']
     2000                irho[ilay] = parmDict[cid+'irho']*parmDict[cid+'DenMul']
    19942001            if cid+'Mag SLD' in parmDict:
    19952002                rho[ilay] += parmDict[cid+'Mag SLD']
    1996             irho[ilay] = parmDict[cid+'irho']*parmDict[cid+'DenMul']
    1997             A,B = abeles(0.5*Q,depth,rho,irho,sigma[1:])     #Q --> k, offset roughness for abeles
     2003        A,B = abeles(0.5*Q,depth,rho,irho,sigma[1:])     #Q --> k, offset roughness for abeles
    19982004        Ic += (A**2+B**2)*Scale     
    19992005        return Ic
     
    20072013    Ic[:] = 0
    20082014    Bounds = {'Scale':[data['Scale'][0]*.85,data['Scale'][0]/.85],'FltBack':[None,None],
    2009               'DenMul':[0.,None],'Thick':[1.,None],'Rough':[0.,None],'Mag SLD':[-10.,10.]}
     2015              'DenMul':[None,None],'Thick':[1.,None],'Rough':[0.,None],'Mag SLD':[-10.,10.],'iDenMul':[None,None]}
    20102016    parmDict,varyList,values,bounds = GetModelParms()
    20112017    Msg = 'Failed to converge'
     
    21322138        if 'Rough' in layer:    #skips first layer
    21332139            sigma[ilayer] = layer['Rough'][0]
    2134         rho[ilayer] = Substances[name]['Scatt density']*layer['DenMul'][0]
     2140        if 'unit scatter' == name:
     2141            rho[ilayer] = layer['DenMul'][0]
     2142            irho[ilayer] = layer['iDenMul'][0]
     2143        else:
     2144            rho[ilayer] = Substances[name]['Scatt density']*layer['DenMul'][0]
     2145            irho[ilayer] = Substances[name].get('XImag density',0.)*layer['DenMul'][0]
    21352146        if 'Mag SLD' in layer:
    21362147            rho[ilayer] += layer['Mag SLD'][0]
    2137         irho[ilayer] = Substances[name].get('XImag density',0.)*layer['DenMul'][0]
    2138         A,B = abeles(0.5*Q[iBeg:iFin],depth,rho,irho,sigma[1:])     #Q --> k, offset roughness for abeles
     2148    A,B = abeles(0.5*Q[iBeg:iFin],depth,rho,irho,sigma[1:])     #Q --> k, offset roughness for abeles
    21392149    Ic[iBeg:iFin] = (A**2+B**2)*Scale+Ib[iBeg:iFin]
    21402150
  • trunk/GSASIIpwdGUI.py

    r2766 r2767  
    231231    'Fills in default items for the SASD Substances dictionary'
    232232    return {'Substances':{'vacuum':{'Elements':{},'Volume':1.0,'Density':0.0,'Scatt density':0.0,'XImag density':0.0},
    233         'unit scatter':{'Elements':None,'Volume':None,'Density':None,'Scatt density':1.0,'XImag density':0.0}}}
     233        'unit scatter':{'Elements':None,'Volume':None,'Density':None,'Scatt density':1.0,'XImag density':1.0}}}
    234234
    235235def GetFileList(G2frame,fileType):
     
    47404740        SaveState()
    47414741        G2pwd.REFDRefine(Profile,ProfDict,Inst,Limits,Substances,data)
    4742 #        x,xr,y = G2pwd.makeSLDprofile(data,Substances)
    4743 #        ModelPlot(data,x,xr,y)
     4742        x,xr,y = G2pwd.makeSLDprofile(data,Substances)
     4743        ModelPlot(data,x,xr,y)
    47444744        G2plt.PlotPatterns(G2frame,plotType='REFD')
    47454745        wx.CallLater(100,UpdateREFDModelsGrid,G2frame,data)
     
    47474747    def OnModelPlot(event):
    47484748        hst = G2frame.PatternTree.GetItemText(G2frame.PatternId)
    4749         histList = [hst,]
    4750         histList += GetHistsLikeSelected(G2frame)
     4749        histList = GetFileList(G2frame,'REFD')
     4750#        histList = [hst,]
     4751#        histList += GetHistsLikeSelected(G2frame)
    47514752        if not histList:
    47524753            G2frame.ErrorDialog('No match','No histograms match '+hst,G2frame.dataFrame)
     
    47854786        linePos = np.zeros(nLines)
    47864787        for ilay,layer in enumerate(data['Layers'][1:-1]):
    4787             linePos[ilay+1:] += layer['Thick'][0]
     4788            linePos[ilay+1:] += layer.get('Thick',[0.,False])[0]
    47884789        if data['Zero']:
    47894790            XY = [[x,y],]
     
    48014802        G2frame.dataFrame.REFDUndo.Enable(False)
    48024803        G2pwd.REFDModelFxn(Profile,Inst,Limits,Substances,data)
    4803 #        x,xr,y = G2pwd.makeSLDprofile(data,Substances)
    4804 #        ModelPlot(data,x,xr,y)
     4804        x,xr,y = G2pwd.makeSLDprofile(data,Substances)
     4805        ModelPlot(data,x,xr,y)
    48054806        G2plt.PlotPatterns(G2frame,plotType='REFD')
    48064807        wx.CallLater(100,UpdateREFDModelsGrid,G2frame,data)
     
    49034904            if 'N' in Inst['Type'][0]:
    49044905                data['Layers'][item]['Mag SLD'] = [0.,False]
     4906            if Name == 'unit scatter':
     4907                data['Layers'][item]['iDenMul'] = [0.,False]
    49054908            G2pwd.REFDModelFxn(Profile,Inst,Limits,Substances,data)
    49064909            G2plt.PlotPatterns(G2frame,plotType='REFD')
     
    49324935                return
    49334936            G2pwd.REFDModelFxn(Profile,Inst,Limits,Substances,data)
    4934 #            x,xr,y = G2pwd.makeSLDprofile(data,Substances)
    4935 #            ModelPlot(data,x,xr,y)
     4937            x,xr,y = G2pwd.makeSLDprofile(data,Substances)
     4938            ModelPlot(data,x,xr,y)
    49364939            G2plt.PlotPatterns(G2frame,plotType='REFD')
    49374940            wx.CallLater(100,UpdateREFDModelsGrid,G2frame,data)
     
    49564959            midlayer.Add(midSel,0,WACV)
    49574960            if midName != 'vacuum':
    4958                 midlayer.Add(wx.StaticText(G2frame.dataDisplay,label=' Den. Mult.: '),0,WACV)
    4959                 midlayer.Add(G2G.ValidatedTxtCtrl(G2frame.dataDisplay,data['Layers'][ilay]['DenMul'],0,
     4961                if midName != 'unit scatter':
     4962                    midlayer.Add(wx.StaticText(G2frame.dataDisplay,label=' Den. Mult.: '),0,WACV)
     4963                    midlayer.Add(G2G.ValidatedTxtCtrl(G2frame.dataDisplay,data['Layers'][ilay]['DenMul'],0,
     4964                        nDig=(10,4),typeHint=float,OnLeave=Recalculate),0,WACV)
     4965                    varBox = wx.CheckBox(G2frame.dataDisplay,label='Refine?')
     4966                    Indx[varBox.GetId()] = [ilay,'DenMul']
     4967                    varBox.SetValue(data['Layers'][ilay]['DenMul'][1])
     4968                    varBox.Bind(wx.EVT_CHECKBOX, OnCheckBox)
     4969                    midlayer.Add(varBox,0,WACV)
     4970                    realScatt = data['Layers'][ilay]['DenMul'][0]*Substances[midName]['Scatt density']
     4971                    midlayer.Add(wx.StaticText(G2frame.dataDisplay,
     4972                        label=' Real scat. den.: %.4g'%(realScatt)),0,WACV)
     4973                    imagScatt = data['Layers'][ilay]['DenMul'][0]*Substances[midName]['XImag density']
     4974                    midlayer.Add(wx.StaticText(G2frame.dataDisplay,
     4975                        label=' Imag scat. den.: %.4g'%(imagScatt)),0,WACV)
     4976                else:
     4977                    realScatt = data['Layers'][ilay]['DenMul'][0]
     4978                    midlayer.Add(wx.StaticText(G2frame.dataDisplay,
     4979                        label=' Real scat. den.: %.4g'%(realScatt)),0,WACV)
     4980                    imagScatt = data['Layers'][ilay]['iDenMul'][0]
     4981                    midlayer.Add(wx.StaticText(G2frame.dataDisplay,
     4982                        label=' Imag scat. den.: %.4g'%(imagScatt)),0,WACV)                   
     4983            else:
     4984                midlayer.Add(wx.StaticText(G2frame.dataDisplay,label=', air or gas'),0,WACV)
     4985            layerSizer.Add(midlayer)
     4986            if midName == 'unit scatter':
     4987                nxtlayer = wx.BoxSizer(wx.HORIZONTAL)
     4988                nxtlayer.Add(wx.StaticText(G2frame.dataDisplay,label=' Real Den. : '),0,WACV)               
     4989                nxtlayer.Add(G2G.ValidatedTxtCtrl(G2frame.dataDisplay,data['Layers'][ilay]['DenMul'],0,
    49604990                    nDig=(10,4),typeHint=float,OnLeave=Recalculate),0,WACV)
    49614991                varBox = wx.CheckBox(G2frame.dataDisplay,label='Refine?')
     
    49634993                varBox.SetValue(data['Layers'][ilay]['DenMul'][1])
    49644994                varBox.Bind(wx.EVT_CHECKBOX, OnCheckBox)
    4965                 midlayer.Add(varBox,0,WACV)
    4966                 realScatt = data['Layers'][ilay]['DenMul'][0]*Substances[midName]['Scatt density']
    4967                 midlayer.Add(wx.StaticText(G2frame.dataDisplay,
    4968                     label=' Real scat. den.: %.4g'%(realScatt)),0,WACV)
    4969                 if midName != 'unit scatter':
    4970                     midlayer.Add(wx.StaticText(G2frame.dataDisplay,
    4971                         label=' Imag scat. den.: %.4g'%(data['Layers'][ilay]['DenMul'][0]*Substances[midName]['XImag density'])),0,WACV)
    4972             else:
    4973                 midlayer.Add(wx.StaticText(G2frame.dataDisplay,label=', air or gas'),0,WACV)
    4974             layerSizer.Add(midlayer)
     4995                nxtlayer.Add(varBox,0,WACV)
     4996                nxtlayer.Add(wx.StaticText(G2frame.dataDisplay,label=' Imag Den. : '),0,WACV)               
     4997                nxtlayer.Add(G2G.ValidatedTxtCtrl(G2frame.dataDisplay,data['Layers'][ilay]['iDenMul'],0,
     4998                    nDig=(10,4),typeHint=float,OnLeave=Recalculate),0,WACV)
     4999                varBox = wx.CheckBox(G2frame.dataDisplay,label='Refine?')
     5000                Indx[varBox.GetId()] = [ilay,'iDenMul']
     5001                varBox.SetValue(data['Layers'][ilay]['iDenMul'][1])
     5002                varBox.Bind(wx.EVT_CHECKBOX, OnCheckBox)
     5003                nxtlayer.Add(varBox,0,WACV)
     5004                layerSizer.Add(nxtlayer)
    49755005            if midName != 'vacuum':
    49765006                if 'N' in Inst['Type'][0] and midName not in ['vacuum','unit scatter']:
     
    50535083    Size[0] += 25
    50545084    G2frame.dataFrame.setSizePosLeft(Size)
    5055     x,xr,y = G2pwd.makeSLDprofile(data,Substances)
    5056     ModelPlot(data,x,xr,y)
     5085#    x,xr,y = G2pwd.makeSLDprofile(data,Substances)
     5086#    ModelPlot(data,x,xr,y)
    50575087   
    50585088   
Note: See TracChangeset for help on using the changeset viewer.