Changeset 4370


Ignore:
Timestamp:
Mar 15, 2020 2:57:46 AM (4 years ago)
Author:
vondreele
Message:

Add new parameter to Data tab - Layer DispSizerThis? is intended to cover multilayered materials of different phases with layers perpendicular to beam - it might have other uses.

Location:
trunk
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/GSASIIddataGUI.py

    r4080 r4370  
    263263        wx.CallLater(100,RepaintHistogramInfo,DData.GetScrollPos(wx.VERTICAL))
    264264           
    265     def OnHstrainRef(event):
    266         Obj = event.GetEventObject()
    267         hist,pid = Indx[Obj.GetId()]
    268         UseList[G2frame.hist]['HStrain'][1][pid] = Obj.GetValue()
    269        
    270     def OnHstrainVal(event):
    271         event.Skip()
    272         Obj = event.GetEventObject()
    273         hist,pid = Indx[Obj.GetId()]
    274         try:
    275             strain = float(Obj.GetValue())
    276             UseList[G2frame.hist]['HStrain'][0][pid] = strain
    277         except ValueError:
    278             pass
    279         Obj.SetValue("%.3g"%(UseList[G2frame.hist]['HStrain'][0][pid]))          #reset in case of error
    280 
    281265    def OnPOAxis(event):
    282266        event.Skip()
     
    477461
    478462    def HstrainSizer():
     463       
     464        def OnHstrainRef(event):
     465            Obj = event.GetEventObject()
     466            hist,pid = Indx[Obj.GetId()]
     467            UseList[G2frame.hist]['HStrain'][1][pid] = Obj.GetValue()
     468           
     469        def OnHstrainVal(event):
     470            event.Skip()
     471            Obj = event.GetEventObject()
     472            hist,pid = Indx[Obj.GetId()]
     473            try:
     474                strain = float(Obj.GetValue())
     475                UseList[G2frame.hist]['HStrain'][0][pid] = strain
     476            except ValueError:
     477                pass
     478            Obj.SetValue("%.3g"%(UseList[G2frame.hist]['HStrain'][0][pid]))          #reset in case of error
     479       
    479480        hstrainSizer = wx.FlexGridSizer(0,6,5,5)
    480481        Hsnames = G2spc.HStrainNames(SGData)
     
    689690        flackSizer.Add(flackVal,0,WACV)
    690691        return flackSizer
     692       
     693    def DispSizer():
     694       
     695        def OnDispRef(event):
     696            Obj = event.GetEventObject()
     697            UseList[G2frame.hist]['Layer Disp'][1] = Obj.GetValue()
     698               
     699        dispSizer = wx.BoxSizer(wx.HORIZONTAL)
     700        dispRef = wx.CheckBox(DData,wx.ID_ANY,label=' Layer displacement (\xb5m): ')
     701        dispRef.SetValue(UseList[G2frame.hist]['Layer Disp'][1])
     702        dispRef.Bind(wx.EVT_CHECKBOX, OnDispRef)
     703        dispSizer.Add(dispRef,0,WACV|wx.LEFT,5)
     704        dispSizer.Add(G2G.ValidatedTxtCtrl(DData,UseList[G2frame.hist]['Layer Disp'],0,nDig=(10,2),typeHint=float),0,WACV)
     705        return dispSizer
    691706       
    692707    def twinSizer():
     
    903918                    G2frame.hist+' not in GSAS-II data tree')
    904919            return
    905         if 'Use' not in UseList[G2frame.hist]:      #patch
     920#patch
     921        if 'Use' not in UseList[G2frame.hist]:
    906922            UseList[G2frame.hist]['Use'] = True
    907923        if 'LeBail' not in UseList[G2frame.hist]:
     
    913929        if 'Fix FXU' not in UseList[G2frame.hist]:
    914930            UseList[G2frame.hist]['Fix FXU'] = ' '
     931        if 'Flack' not in UseList[G2frame.hist]:
     932            UseList[G2frame.hist]['Flack'] = [0.0,False]
     933        if 'Twins' not in UseList[G2frame.hist]:
     934            UseList[G2frame.hist]['Twins'] = [[np.array([[1,0,0],[0,1,0],[0,0,1]]),[1.0,False]],]
     935        if 'Layer Disp' not in UseList[G2frame.hist]:
     936            UseList[G2frame.hist]['Layer Disp'] = [0.0,False]
     937#end patch
    915938        bottomSizer = wx.BoxSizer(wx.VERTICAL)
    916939        useBox = wx.BoxSizer(wx.HORIZONTAL)
     
    10031026            bottomSizer.Add(wx.StaticText(DData,wx.ID_ANY,' Hydrostatic/elastic strain:'))
    10041027            bottomSizer.Add(HstrainSizer())
     1028            bottomSizer.Add(DispSizer())
    10051029               
    10061030            poSizer = wx.BoxSizer(wx.VERTICAL)
     
    10291053                bottomSizer.Add(BabSizer(),0,WACV|wx.BOTTOM,5)
    10301054        elif G2frame.hist[:4] == 'HKLF':
    1031 #patch
    1032             if 'Flack' not in UseList[G2frame.hist]:
    1033                 UseList[G2frame.hist]['Flack'] = [0.0,False]
    1034             if 'Twins' not in UseList[G2frame.hist]:
    1035                 UseList[G2frame.hist]['Twins'] = [[np.array([[1,0,0],[0,1,0],[0,0,1]]),[1.0,False]],]
    1036 #end patch
    10371055            bottomSizer.Add(ExtSizer('HKLF'),0,WACV|wx.BOTTOM,5)
    10381056            bottomSizer.Add(BabSizer(),0,WACV|wx.BOTTOM,5)
  • trunk/GSASIImapvars.py

    r4111 r4370  
    18111811#    if e: print 'error=',e
    18121812#    if w: print 'error=',w
    1813 #    varyList = ['0::A0', '0::AUiso:0', '0::Afrac:1', '0::Afrac:2', '0::Afrac:3', '0::Afrac:4', '0::dAx:5', '0::dAy:5', '0::dAz:5', '0::AUiso:5', ':0:Back;0', ':0:Back;1', ':0:Back;2', ':0:Back;3', ':0:Back;4', ':0:Back;5', ':0:Back;6', ':0:Back;7', ':0:Back;8', ':0:Back;9', ':0:Back;10', ':0:Back;11', ':0:U', ':0:V', ':0:W', ':0:X', ':0:Y', ':0:Scale', ':0:DisplaceX', ':0:DisplaceY']
     1813#    varyList = ['0::A0', '0::AUiso:0', '0::Afrac:1', '0::Afrac:2', '0::Afrac:3', '0::Afrac:4',
     1814#       '0::dAx:5', '0::dAy:5', '0::dAz:5', '0::AUiso:5', ':0:Back;0', ':0:Back;1', ':0:Back;2', ':0:Back;3',
     1815#       ':0:Back;4', ':0:Back;5', ':0:Back;6', ':0:Back;7', ':0:Back;8', ':0:Back;9', ':0:Back;10', ':0:Back;11'
     1816#       :0:U', ':0:V', ':0:W', ':0:X', ':0:Y', ':0:Scale', ':0:DisplaceX', ':0:DisplaceY']
    18141817#    constrDict = [
    18151818#        {'0::Afrac:4': 24.0, '0::Afrac:1': 16.0, '0::Afrac:3': 24.0, '0::Afrac:2': 16.0},
  • trunk/GSASIIobj.py

    r4327 r4370  
    276276                                entries, 'BabA', 'BabU'
    277277\           Extinction          (list of float, bool) Extinction parameter
     278\           Flack               (list of [float, bool]) Flack parameter & refine flag
    278279\           HStrain             (list of two lists) Hydrostatic strain. The first is
    279280                                a list of the HStrain parameters (1, 2, 3, 4, or 6
     
    281282                                refinement parameters (same length)
    282283\           Histogram           (str) The name of the associated histogram
     284\           Layer Disp          (list of [float, bool]) Layer displacement in beam direction & refine flag
    283285\           LeBail              (bool) Flag for LeBail extraction
    284286\           Mustrain            (list) Microstrain parameters, in order:
     
    15851587        'Flack' : 'Flack parameter',
    15861588        'TwinFr' : 'Twin fraction',
     1589        'Layer Disp'  : 'Layer displacement along beam',
    15871590        #Histogram vars (:h:<var>)
    15881591        'Absorption' : 'Absorption coef.',
  • trunk/GSASIIphsGUI.py

    r4366 r4370  
    86308630            copyNames = ['Scale','Extinction','Babinet','Flack','Twins','Fix FXU']
    86318631        else:  #PWDR 
    8632             copyNames = ['Scale','Pref.Ori.','Size','Mustrain','HStrain','Extinction','Babinet','LeBail','newLeBail','Fix FXU']
     8632            copyNames = ['Scale','Pref.Ori.','Size','Mustrain','HStrain','Extinction','Babinet','LeBail','newLeBail','Fix FXU','Layer Disp']
    86338633        copyDict = {}
    86348634        for name in copyNames:
     
    86508650            copyNames = ['Scale','Extinction','Babinet','Flack','Twins','Fix FXU']
    86518651        else:  #PWDR 
    8652             copyNames = ['Scale','Pref.Ori.','Size','Mustrain','HStrain','Extinction','Babinet','Fix FXU']
     8652            copyNames = ['Scale','Pref.Ori.','Size','Mustrain','HStrain','Extinction','Babinet','Fix FXU','Layer Disp']
    86538653        babNames = ['BabA','BabU']
    86548654        for name in copyNames:
    8655             if name in ['Scale','Extinction','HStrain','Flack','Twins']:
     8655            if name in ['Scale','Extinction','HStrain','Flack','Twins','Layer Disp']:
    86568656                if name == 'Extinction' and 'HKLF' in sourceDict['Histogram']:
    86578657                    copyDict[name] = {name:[sourceDict[name][:2]]}
     
    86908690                    item = keyList[sel]
    86918691                    for name in copyNames:
    8692                         if name in ['Scale','Extinction','HStrain','Flack','Twins']:
     8692                        if name in ['Scale','Extinction','HStrain','Flack','Twins','Layer Disp']:
    86938693                            if name == 'Extinction' and 'HKLF' in sourceDict['Histogram']:
    86948694                                data['Histograms'][item][name][:2] = copy.deepcopy(sourceDict[name][:2])
     
    87338733            copyNames = ['Scale','Extinction','Babinet','Flack','Twins','Fix FXU']
    87348734        else:  #PWDR 
    8735             copyNames = ['Scale','Pref.Ori.','Size','Mustrain','HStrain','Extinction','Babinet','LeBail','newLeBail','Fix FXU']
     8735            copyNames = ['Scale','Pref.Ori.','Size','Mustrain','HStrain','Extinction','Babinet','LeBail','newLeBail','Fix FXU','Layer Disp']
    87368736        dlg = G2G.G2MultiChoiceDialog(G2frame,'Select which parameters to copy',
    87378737            'Select phase data parameters', copyNames)
     
    87898789                            'Mustrain':['isotropic',[1000.0,1000.0,1.0],[False,False,False],[0,0,1],
    87908790                                NShkl*[0.01,],NShkl*[False,]],
    8791                             'HStrain':[NDij*[0.0,],NDij*[False,]],                         
     8791                            'HStrain':[NDij*[0.0,],NDij*[False,]],
     8792                            'Layer Disp':[0.0,False],                         
    87928793                            'Extinction':[0.0,False],'Babinet':{'BabA':[0.0,False],'BabU':[0.0,False]},'Fix FXU':' '}
    87938794                        refList = G2frame.GPXtree.GetItemPyData(G2gd.GetGPXtreeItemId(G2frame,Id,'Reflection Lists'))
     
    1047310474                    pos -= const*(4.*Sample['Shift'][0]*cosd(pos/2.0)+ \
    1047410475                        Sample['Transparency'][0]*sind(pos)*100.0)            #trans(=1/mueff) in cm
    10475                 else:               #Debye-Scherrer - simple but maybe not right
     10476                else:               #Debye-Scherrer - simple but maybe not right - +Layer Disp from DData?
    1047610477                    pos -= const*(Sample['DisplaceX'][0]*cosd(pos)+Sample['DisplaceY'][0]*sind(pos))
    1047710478                indx = np.searchsorted(xdata[0],pos)
  • trunk/GSASIIstrIO.py

    r4197 r4370  
    25032503                    HSvals.append(hapDict[pfx+name])
    25042504                    if hapData['HStrain'][1][i]:
    2505 #                    if hapData['HStrain'][1][i] and not hapDict[pfx+'LeBail']:
    25062505                        hapVary.append(pfx+name)
     2506                if 'Layer Disp' in hapData:
     2507                    hapDict[pfx+'LayerDisp'] = hapData['Layer Disp'][0]
     2508                    if hapData['Layer Disp'][1]:
     2509                        hapVary.append(pfx+'LayerDisp')
    25072510                controlDict[pfx+'poType'] = hapData['Pref.Ori.'][0]
    25082511                if hapData['Pref.Ori.'][0] == 'MD':
     
    25792582                    PrintMuStrain(hapData['Mustrain'],SGData)
    25802583                    PrintHStrain(hapData['HStrain'],SGData)
     2584                    if 'Layer Disp' in hapData:
     2585                        pFile.write(' Layer Displacement: %10.3f Refine? %s\n'%(hapData['Layer Disp'][0],hapData['Layer Disp'][1]))
    25812586                    if Phases[phase]['General']['Type'] != 'magnetic':
    25822587                        if hapData['Babinet']['BabA'][0]:
     
    29782983                    if pfx+name in sigDict:
    29792984                        SizeMuStrSig[pfx+'HStrain'][name] = sigDict[pfx+name]
     2985                if 'Layer Disp' in hapData:
     2986                    hapData['Layer Disp'][0] = parmDict[pfx+'LayerDisp']
     2987                    if pfx+'LayerDisp' in sigDict:
     2988                        SizeMuStrSig[pfx+'LayerDisp'] = sigDict[pfx+'LayerDisp']
    29802989                if Phases[phase]['General']['Type'] != 'magnetic':
    29812990                    for name in ['BabA','BabU']:
     
    30613070                    PrintMuStrainAndSig(hapData['Mustrain'],SizeMuStrSig[pfx+'Mustrain'],SGData)
    30623071                    PrintHStrainAndSig(hapData['HStrain'],SizeMuStrSig[pfx+'HStrain'],SGData)
     3072                    if pfx+'LayerDisp' in SizeMuStrSig:
     3073                        pFile.write(' Layer displacement : %10.3f, sig %10.3f\n'%(hapData['Layer Disp'][0],SizeMuStrSig[pfx+'LayerDisp']))           
    30633074                    if Phases[phase]['General']['Type'] != 'magnetic' and not parmDict[pfx+'LeBail']:
    30643075                        if len(BabSig):
  • trunk/GSASIIstrMain.py

    r4289 r4370  
    146146            covMatrix = result[1]*Rvals['GOF']**2
    147147            sig = np.sqrt(np.diag(covMatrix))
    148             Lastshft = result[2]['Xvec']
     148            Lastshft = result[2].get('Xvec',None)
    149149            if Lastshft is None:
    150150                Rvals['Max shft/sig'] = 0.0
  • trunk/GSASIIstrMath.py

    r4344 r4370  
    28682868    return sigDict,gamDict
    28692869       
    2870 def GetReflPos(refl,im,wave,A,pfx,hfx,calcControls,parmDict):
     2870def GetReflPos(refl,im,wave,A,pfx,hfx,phfx,calcControls,parmDict):
    28712871    'Needs a doc string'
    28722872    if im:
     
    28852885                parmDict[hfx+'Transparency']*sind(pos)*100.0)            #trans(=1/mueff) in cm
    28862886        else:               #Debye-Scherrer - simple but maybe not right
    2887             pos -= const*(parmDict[hfx+'DisplaceX']*cosd(pos)+parmDict[hfx+'DisplaceY']*sind(pos))
     2887            pos -= const*(parmDict[hfx+'DisplaceX']*cosd(pos)+(parmDict[hfx+'DisplaceY']+parmDict[phfx+'LayerDisp'])*sind(pos))
    28882888    elif 'T' in calcControls[hfx+'histType']:
    28892889        pos = parmDict[hfx+'difC']*d+parmDict[hfx+'difA']*d**2+parmDict[hfx+'difB']/d+parmDict[hfx+'Zero']
     
    28912891    return pos
    28922892
    2893 def GetReflPosDerv(refl,im,wave,A,pfx,hfx,calcControls,parmDict):
     2893def GetReflPosDerv(refl,im,wave,A,pfx,hfx,phfx,calcControls,parmDict):
    28942894    'Needs a doc string'
    28952895    dpr = 180./np.pi
     
    32423242                    h,k,l = refl[:3]
    32433243                Uniq = np.inner(refl[:3],SGMT)
    3244                 refl[5+im] = GetReflPos(refl,im,wave,A,pfx,hfx,calcControls,parmDict)         #corrected reflection position
     3244                refl[5+im] = GetReflPos(refl,im,wave,A,pfx,hfx,phfx,calcControls,parmDict)         #corrected reflection position
    32453245                Lorenz = 1./(2.*sind(refl[5+im]/2.)**2*cosd(refl[5+im]/2.))           #Lorentz correction
    32463246                refl[6+im:8+im] = GetReflSigGamCW(refl,im,wave,G,GB,phfx,calcControls,parmDict)    #peak sig & gam
     
    32943294                    h,k,l = refl[:3]
    32953295                Uniq = np.inner(refl[:3],SGMT)
    3296                 refl[5+im] = GetReflPos(refl,im,0.0,A,pfx,hfx,calcControls,parmDict)         #corrected reflection position - #TODO - what about tabluated offset?
     3296                refl[5+im] = GetReflPos(refl,im,0.0,A,pfx,hfx,phfx,calcControls,parmDict)         #corrected reflection position - #TODO - what about tabluated offset?
    32973297                Lorenz = sind(abs(parmDict[hfx+'2-theta'])/2)*refl[4+im]**4                                                #TOF Lorentz correction
    32983298#                refl[5+im] += GetHStrainShift(refl,im,SGData,phfx,hfx,calcControls,parmDict)               #apply hydrostatic strain shift
     
    35363536                    pass
    35373537            if 'C' in calcControls[hfx+'histType']:
    3538                 dpdA,dpdw,dpdZ,dpdSh,dpdTr,dpdX,dpdY,dpdV = GetReflPosDerv(refl,im,wave,A,pfx,hfx,calcControls,parmDict)
     3538                dpdA,dpdw,dpdZ,dpdSh,dpdTr,dpdX,dpdY,dpdV = GetReflPosDerv(refl,im,wave,A,pfx,hfx,phfx,calcControls,parmDict)
    35393539                names = {hfx+'Scale':[dIdsh,'int'],hfx+'Polariz.':[dIdpola,'int'],phfx+'Scale':[dIdsp,'int'],
    35403540                    hfx+'U':[tanth**2,'sig'],hfx+'V':[tanth,'sig'],hfx+'W':[1.0,'sig'],
     
    35423542                    hfx+'I(L2)/I(L1)':[1.0,'L1/L2'],hfx+'Zero':[dpdZ,'pos'],hfx+'Lam':[dpdw,'pos'],
    35433543                    hfx+'Shift':[dpdSh,'pos'],hfx+'Transparency':[dpdTr,'pos'],hfx+'DisplaceX':[dpdX,'pos'],
    3544                     hfx+'DisplaceY':[dpdY,'pos'],phfx+'Extinction':[dFdEx,'int'],}
     3544                    hfx+'DisplaceY':[dpdY,'pos'],phfx+'Extinction':[dFdEx,'int'],phfx+'LayerDisp':[dpdY,'pos']}
    35453545                if 'Bragg' in calcControls[hfx+'instType']:
    35463546                    names.update({hfx+'SurfRoughA':[dFdAb[0],'int'],
     
    35493549                    names.update({hfx+'Absorption':[dFdAb,'int'],})
    35503550            else:   #'T'OF
    3551                 dpdA,dpdZ,dpdDC,dpdDA,dpdDB,dpdV = GetReflPosDerv(refl,im,0.0,A,pfx,hfx,calcControls,parmDict)
     3551                dpdA,dpdZ,dpdDC,dpdDA,dpdDB,dpdV = GetReflPosDerv(refl,im,0.0,A,pfx,hfx,phfx,calcControls,parmDict)
    35523552                names = {hfx+'Scale':[dIdsh,'int'],phfx+'Scale':[dIdsp,'int'],
    35533553                    hfx+'difC':[dpdDC,'pos'],hfx+'difA':[dpdDA,'pos'],hfx+'difB':[dpdDB,'pos'],
     
    36153615                    if Ka2 and iFin2-iBeg2:
    36163616                        depDerivDict[name][iBeg2:iFin2] += dDijDict[name]*dervDict2['pos']
     3617#TODO: need Layer Disp deriv here
    36173618            for i,name in enumerate([pfx+'mV0',pfx+'mV1',pfx+'mV2']):
    36183619                if name in varylist:
Note: See TracChangeset for help on using the changeset viewer.