Changeset 4289


Ignore:
Timestamp:
Feb 5, 2020 7:06:40 AM (21 months ago)
Author:
vondreele
Message:

start on 'Compare' for comparison of bonding polyhedra between phases & within phases
include max shift/esd in cif output - works for Hessian refinement only

Location:
trunk
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/GSASIIdataGUI.py

    r4270 r4289  
    56275627        # Phase / General tab
    56285628        G2G.Define_wxId('wxID_FOURCALC', 'wxID_FOURSEARCH', 'wxID_FOURCLEAR','wxID_CHARGEFLIP','wxID_VALIDPROTEIN',
    5629             'wxID_MULTIMCSA','wxID_SINGLEMCSA', 'wxID_4DCHARGEFLIP', 'wxID_TRANSFORMSTRUCTURE','wxID_USEBILBAOMAG',)
     5629            'wxID_MULTIMCSA','wxID_SINGLEMCSA', 'wxID_4DCHARGEFLIP', 'wxID_TRANSFORMSTRUCTURE','wxID_USEBILBAOMAG',
     5630            'wxID_COMPARESTRUCTURE',)
    56305631        self.DataGeneral = wx.MenuBar()
    56315632        self.PrefillDataMenu(self.DataGeneral)
     
    56425643        self.GeneralCalc.Append(G2G.wxID_MULTIMCSA,'Multi MC/SA','Run Monte Carlo - Simulated Annealing on multiprocessors')
    56435644        self.GeneralCalc.Append(G2G.wxID_TRANSFORMSTRUCTURE,'Transform','Transform crystal structure')
     5645        self.GeneralCalc.Append(G2G.wxID_COMPARESTRUCTURE,'Compare','Compare polyhedra in two structures')
    56445646        self.GeneralCalc.Append(G2G.wxID_USEBILBAOMAG,'Select magnetic/subgroup phase','If disabled, make in PWDR/Unit Cells')       
    56455647        self.GeneralCalc.Append(G2G.wxID_VALIDPROTEIN,'Protein quality','Protein quality analysis')
     
    82098211                text += '\n\tNobs = {}\n\tNvals = {}\n\tSVD zeros = {}'.format(
    82108212                    Rvals['Nobs'],Nvars,Rvals.get('SVD0',0.))
     8213                text += '\n\tmax shift/esd = {:.3f}'.format(Rvals.get('Max shft/sig',0.0))
    82118214                if 'lamMax' in Rvals:
    82128215                    text += '\n\tlog10 MaxLambda = {:.1f}'.format(np.log10(Rvals['lamMax']))
  • trunk/GSASIImath.py

    r4285 r4289  
    232232        if Print: G2fil.G2Print('Found %d SVD zeros'%(Nzero), mode='warn')
    233233        Bmat = Bmat/Anorm
    234         return [x0,Bmat,{'num cyc':icycle,'fvec':M,'nfev':nfev,'lamMax':lamMax,'psing':[],'SVD0':Nzero,'Converged': ifConverged, 'DelChi2':deltaChi2}]
     234        return [x0,Bmat,{'num cyc':icycle,'fvec':M,'nfev':nfev,'lamMax':lamMax,'psing':[],
     235            'SVD0':Nzero,'Converged': ifConverged, 'DelChi2':deltaChi2,'Xvec':Xvec}]
    235236    except nl.LinAlgError:
    236237        G2fil.G2Print('ouch #2 linear algebra error in making v-cov matrix', mode='error')
     
    238239        if maxcyc:
    239240            psing = list(np.where(np.diag(nl.qr(Amat)[1]) < 1.e-14)[0])
    240         return [x0,None,{'num cyc':icycle,'fvec':M,'nfev':nfev,'lamMax':lamMax,'psing':psing,'SVD0':-1}]         
     241        return [x0,None,{'num cyc':icycle,'fvec':M,'nfev':nfev,'lamMax':lamMax,'psing':psing,'SVD0':-1,'Xvec':None}]         
    241242           
    242243def HessianSVD(func,x0,Hess,args=(),ftol=1.49012e-8,xtol=1.e-6, maxcyc=0,lamda=-3,Print=False,refPlotUpdate=None):
     
    673674                dist = np.sqrt(np.sum(dx**2,axis=1))
    674675                IndB = ma.nonzero(ma.masked_greater(dist-radiusFactor*sumR[:,iA],0.))
    675         #        GSASIIpath.IPyBreak()
    676676                for iU in IndB[0]:
    677677                    if AtNames[iA] != notName:
  • trunk/GSASIIphsGUI.py

    r4272 r4289  
    283283        parent.Raise()
    284284        self.EndModal(wx.ID_CANCEL)
     285       
     286################################################################################
     287class CompareDialog(wx.Dialog):
     288    def __init__(self,parent,phase):
     289        wx.Dialog.__init__(self,parent,wx.ID_ANY,'Setup polyhedron comparison',
     290            pos=wx.DefaultPosition,style=wx.DEFAULT_DIALOG_STYLE|wx.RESIZE_BORDER)
     291        self.panel = wxscroll.ScrolledPanel(self)         #just a dummy - gets destroyed in Draw!
     292        self.OPhase = copy.deepcopy(phase)   #will be a new phase!
     293        self.OName = self.OPhase['General']['Name']
     294        self.TPhase = copy.deepcopy(phase)
     295        self.TName = self.OName
     296        self.PhaseNames = parent.GetPhaseNames()
     297        self.PhaseData = parent.GetPhaseData()
     298        self.Oatoms = ['','']
     299        self.Tatoms = ['','']
     300        self.ONeighbors = []
     301        self.Tneighbors = []
     302        self.Draw()
     303           
     304    def Draw(self):
     305       
     306        def OnPhaseSel(event):
     307            self.TName = phasesel.GetStringSelection()
     308            self.Tphase = self.PhaseData[self.TName]
     309            wx.CallAfter(self.Draw)
     310           
     311        def OnOatmOsel(event):
     312            self.Oatoms[0] = oatmosel.GetStringSelection()
     313           
     314        def OnTatmOsel(event):
     315            self.Tatoms[0] = tatmosel.GetStringSelection()
     316            print(G2mth.FindAllNeighbors(self.OPhase,self.Oatoms[0],self.Tatoms[0])[0])
     317
     318        self.panel.Destroy()
     319        self.panel = wxscroll.ScrolledPanel(self,style = wx.DEFAULT_DIALOG_STYLE)
     320        OgeneralData = self.OPhase['General']
     321        OatTypes = OgeneralData['AtomTypes']
     322        TgeneralData = self.OPhase['General']
     323        TatTypes = TgeneralData['AtomTypes']
     324       
     325        mainSizer = wx.BoxSizer(wx.VERTICAL)
     326        mainSizer.Add(wx.StaticText(self.panel,label='Compare polyhedra in %s to target phase %s:(TBD)'%(self.OName,self.TName)),0,WACV)
     327       
     328        Pchoice = self.PhaseNames
     329        phaseselSizer = wx.BoxSizer(wx.HORIZONTAL)
     330        phaseselSizer.Add(wx.StaticText(self.panel,label=' Select target phase: '),0,WACV)
     331        phasesel = wx.ComboBox(self.panel,choices=Pchoice,value=self.OName,
     332            style=wx.CB_READONLY|wx.CB_DROPDOWN)
     333        phasesel.Bind(wx.EVT_COMBOBOX,OnPhaseSel)
     334        phaseselSizer.Add(phasesel,0,WACV)
     335        mainSizer.Add(phaseselSizer,0,WACV)
     336       
     337        mainSizer.Add(wx.StaticText(self.panel,label=' For origin phase %s:'%self.OName),0,WACV)
     338        oatmoselSizer = wx.BoxSizer(wx.HORIZONTAL)
     339        oatmoselSizer.Add(wx.StaticText(self.panel,label=' Select origin atom type: '),0,WACV)
     340        oatmosel = wx.ComboBox(self.panel,choices=OatTypes,style=wx.CB_READONLY|wx.CB_DROPDOWN)
     341        oatmosel.Bind(wx.EVT_COMBOBOX,OnOatmOsel)
     342        oatmoselSizer.Add(oatmosel,0,WACV)
     343        mainSizer.Add(oatmoselSizer,0,WACV)
     344       
     345        tatmoselSizer = wx.BoxSizer(wx.HORIZONTAL)
     346        tatmoselSizer.Add(wx.StaticText(self.panel,label=' Select target atom type: '),0,WACV)
     347        tatmosel = wx.ComboBox(self.panel,choices=OatTypes,style=wx.CB_READONLY|wx.CB_DROPDOWN)
     348        tatmosel.Bind(wx.EVT_COMBOBOX,OnTatmOsel)
     349        tatmoselSizer.Add(tatmosel,0,WACV)
     350        mainSizer.Add(tatmoselSizer,0,WACV)
     351       
     352        mainSizer.Add(wx.StaticText(self.panel,label=' For target phase %s:'%self.TName),0,WACV)
     353       
     354       
     355        OkBtn = wx.Button(self.panel,-1,"Ok")
     356        OkBtn.Bind(wx.EVT_BUTTON, self.OnOk)
     357        cancelBtn = wx.Button(self.panel,-1,"Cancel")
     358        cancelBtn.Bind(wx.EVT_BUTTON, self.OnCancel)
     359        btnSizer = wx.BoxSizer(wx.HORIZONTAL)
     360        btnSizer.Add((20,20),1)
     361        btnSizer.Add(OkBtn)
     362        btnSizer.Add((20,20),1)
     363        btnSizer.Add(cancelBtn)
     364        btnSizer.Add((20,20),1)
     365       
     366        mainSizer.Add(btnSizer,0,wx.EXPAND|wx.BOTTOM|wx.TOP, 10)
     367       
     368        self.panel.SetSizer(mainSizer)
     369        self.panel.SetAutoLayout(1)
     370        self.panel.SetScrollRate(10,10)
     371        size = np.array(self.GetSize())
     372        size = [size[0]-5,size[1]-20]       #this fiddling is needed for older wx!
     373        self.panel.SetSize(size)
     374       
     375    def GetSelection(self):
     376        return None
     377       
     378    def OnOk(self,event):
     379        parent = self.GetParent()
     380        parent.Raise()
     381        self.EndModal(wx.ID_OK)
     382
     383    def OnCancel(self,event):
     384        parent = self.GetParent()
     385        parent.Raise()
     386        self.EndModal(wx.ID_CANCEL)
     387       
    285388
    286389################################################################################
     
    26822785                else:
    26832786                    break
    2684                
     2787                               
    26852788        NShkl = len(G2spc.MustrainNames(SGData))
    26862789        NDij = len(G2spc.HStrainNames(SGData))
     
    26992802        G2frame.GPXtree.SelectItem(sub)
    27002803               
     2804    def OnCompare(event):
     2805        while True:
     2806            dlg = CompareDialog(G2frame,data)
     2807            try:
     2808                if dlg.ShowModal() == wx.ID_OK:
     2809                    print('Compare polyhedra in structures - TBD')
     2810                    return
     2811                else:
     2812                    return
     2813            finally:
     2814                dlg.Destroy()
     2815       
     2816       
    27012817    def OnUseBilbao(event):
    27022818        PatternName = data['magPhases']
     
    44154531        def OnRMCselect(event):
    44164532            G2frame.RMCchoice = RMCsel.GetStringSelection()
    4417             G2frame.runtext.SetValue('')
     4533#            G2frame.runtext.SetValue('')
    44184534            UpdateRMC()
    44194535       
     
    51335249                    import subprocess as sb
    51345250                    batch = open('fullrmc.bat','w')
    5135                     batch.write(sys.exec_prefix+'\\activate\n')
     5251                    batch.write('run '+sys.exec_prefix+'\\Scripts\\activate\n')
     5252                    batch.write('SET PYTHONPATH=%s\\fullrmc\n'%GSASIIpath.path2GSAS2)
    51365253                    batch.write(sys.exec_prefix+'\\python.exe '+dlg.GetPath()+'\n')
    51375254                    batch.write('pause')
     
    1079610913        G2frame.Bind(wx.EVT_MENU, OnRunMultiMCSA, id=G2G.wxID_MULTIMCSA)
    1079710914        G2frame.Bind(wx.EVT_MENU, OnTransform, id=G2G.wxID_TRANSFORMSTRUCTURE)
     10915        G2frame.Bind(wx.EVT_MENU, OnCompare, id=G2G.wxID_COMPARESTRUCTURE)
    1079810916        G2frame.Bind(wx.EVT_MENU, OnUseBilbao, id=G2G.wxID_USEBILBAOMAG)
    1079910917        G2frame.Bind(wx.EVT_MENU, OnValidProtein, id=G2G.wxID_VALIDPROTEIN)
  • trunk/GSASIIstrMain.py

    r4189 r4289  
    146146            covMatrix = result[1]*Rvals['GOF']**2
    147147            sig = np.sqrt(np.diag(covMatrix))
     148            Lastshft = result[2]['Xvec']
     149            if Lastshft is None:
     150                Rvals['Max shft/sig'] = 0.0
     151            else:
     152                Rvals['Max shft/sig'] = np.max(Lastshft/sig)
    148153            if np.any(np.isnan(sig)) or not sig.shape:
    149154                G2fil.G2Print ('*** Least squares aborted - some invalid esds possible ***',mode='error')
     
    505510                rigidbodyDict,parmDict,varyList,calcControls,pawleyLookup,ifSeq,printFile,dlg,
    506511                refPlotUpdate=refPlotUpdate)
    507             G2fil.G2Print ('  wR = %7.2f%%, chi**2 = %12.6g, reduced chi**2 = %6.2f, last delta chi = %.4f'%(
    508                 Rvals['Rwp'],Rvals['chisq'],Rvals['GOF']**2,Rvals['DelChi2']))
     512            G2fil.G2Print ('  wR = %7.2f%%, chi**2 = %12.6g, reduced chi**2 = %6.2f, last delta chi = %.4f, last shft/sig = %.4f'%(
     513                Rvals['Rwp'],Rvals['chisq'],Rvals['GOF']**2,Rvals['DelChi2'],Rvals['Max shft/sig']))
    509514            # add the uncertainties into the esd dictionary (sigDict)
    510515            if not IfOK:
  • trunk/SUBGROUPS.py

    r4060 r4289  
    324324    print('test SUBGROUPSMAG')           
    325325    results,baseList = GetNonStdSubgroupsmag(SGData,('0','0','0',' ',' ',' ',' ',' ',' ',' '))
     326    print(results)
    326327    if results:
    327328        for [spgp,bns,mv,gid,altList,supList] in results:
     
    334335    print('test SUBGROUPS')
    335336    results,baseList = GetNonStdSubgroups(SGData,('1/3','1/3','1/2',' ',' ',' ',' ',' ',' ',' '))
     337    print(results)
    336338    if results:
    337339        for [spgp,mv,gid,altList,supList] in results:
  • trunk/exports/G2export_CIF.py

    r3828 r4289  
    510510                WriteCIFitem(self.fp, '_pd_proc_info_datetime', self.CIFdate)
    511511                WriteCIFitem(self.fp, '_pd_calc_method', 'Rietveld Refinement')
    512             #WriteCIFitem(self.fp, '_refine_ls_shift/su_max',DAT1)
     512               
    513513            #WriteCIFitem(self.fp, '_refine_ls_shift/su_mean',DAT2)
    514514            WriteCIFitem(self.fp, '_computing_structure_refinement','GSAS-II (Toby & Von Dreele, J. Appl. Cryst. 46, 544-549, 2013)')
     
    530530                GOF = '?'
    531531            WriteCIFitem(self.fp, '_refine_ls_goodness_of_fit_all',GOF)
     532            DAT1 = self.OverallParms['Covariance']['Rvals'].get('Max shft/sig',0.0)
     533            if DAT1:
     534                WriteCIFitem(self.fp, '_refine_ls_shift/su_max','%.4f'%DAT1)
    532535
    533536            # get restraint info
  • trunk/kSUBGROUPSMAG.py

    r3716 r4289  
    141141            postdict['km%d%s'%(j,i)] = k
    142142    try:
     143        print(postdict)
    143144        r = requests.post(submagSite,postdict)
     145        print(r)
    144146    except:     #ConnectionError?
    145147        page = ''
     
    214216            postdict['knm%d%s'%(j,i)] = k
    215217    try:
     218        print(postdict)
    216219        r = requests.post(submagSite,postdict)
     220        print(r)
    217221    except:     #ConnectionError?
    218222        page = ''
     
    244248                print('MV')
    245249                print(mv)
    246     results,baseList = GetNonStdSubgroups(SGData,('1/3','1/3','1/2',' ',' ',' ',' ',' ',' ',' '))
     250    results,baseList = GetNonStdSubgroupsmag(SGData,('1/3','1/3','1/2',' ',' ',' ',' ',' ',' ',' '))
    247251    if results:
    248252        for [spgp,mv,gid,altList,supList] in results:
Note: See TracChangeset for help on using the changeset viewer.