Changeset 2500


Ignore:
Timestamp:
Oct 21, 2016 2:58:47 PM (5 years ago)
Author:
vondreele
Message:

protect a dlg in DoIndexPeaks?
fix a lost G2frame.LimitsTable? - need to go back to tree instead
add depVarList to testDeriv file
more work on mag derivs.
modify testDeriv to show depVar derivatives

Location:
trunk
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/GSASIIgrid.py

    r2491 r2500  
    40824082    data = G2frame.PatternTree.GetItemPyData(item)
    40834083#patches
     4084    if not data:
     4085        return
    40844086    if 'wtFactor' not in data[0]:
    40854087        data[0] = {'wtFactor':1.0}
  • trunk/GSASIIindex.py

    r2136 r2500  
    948948            cycle = 0
    949949            while cycle < 5:
    950                 dlg.Update(0,newmsg=tries[cycle]+" cell search for "+bravaisNames[ibrav])
     950                if dlg:
     951                    dlg.Update(0,newmsg=tries[cycle]+" cell search for "+bravaisNames[ibrav])
    951952                try:
    952953                    GoOn = True
  • trunk/GSASIIplot.py

    r2499 r2500  
    20132013                        tip = 'On data point: Lower limit - L MB; Upper limit - R MB. On limit: MB down to move'
    20142014                        Page.canvas.SetToolTipString(tip)
    2015                         data = G2frame.LimitsTable.GetData()
     2015                        data = G2frame.PatternTree.GetItemPyData(G2gd.GetPatternTreeItemId(G2frame,PatternId, 'Limits'))
    20162016                       
    20172017            else:   #not picked
  • trunk/GSASIIstrMain.py

    r2487 r2500  
    233233        cPickle.dump(result[0],fl,1)
    234234        cPickle.dump([Histograms,Phases,restraintDict,rigidbodyDict],fl,1)
    235         cPickle.dump([constrDict,fixedList],fl,1)
     235        cPickle.dump([constrDict,fixedList,G2mv.GetDependentVars()],fl,1)
    236236        cPickle.dump(parmDict,fl,1)
    237237        cPickle.dump(varyList,fl,1)
  • trunk/GSASIIstrMath.py

    r2499 r2500  
    12951295        dfadfr = np.sum(fam/occ,axis=2)        #array(Mxyz,refBlk,nAtom) Fdata != 0 avoids /0. problem
    12961296        dfadx = np.sum(twopi*Uniq[nxs,:,:,nxs,:]*famx[:,:,:,:,nxs],axis=2)
    1297         dfadmx = np.sum(TMcorr[nxs,nxs,:,nxs,:]*cosm[nxs,nxs,:,:,:]*(dqdm[:,:,:,nxs,nxs]+Q[nxs,:,:,:,:]),axis=-2)
     1297        dmx = dqdm[:,:,:,nxs,nxs]*Mag[nxs,nxs,nxs,:,:]+Q[nxs,:,:,:,:]*Gdata[:,nxs,nxs,:,:]
     1298        dfadmx = np.sum(TMcorr[nxs,nxs,:,nxs,:]*cosm[nxs,nxs,:,:,:]*dmx,axis=-2)
    12981299        dfadmx = np.reshape(dfadmx,(3,iFin-iBeg,-1,3))
    12991300        dfadui = np.sum(-SQfactor[:,nxs,nxs]*fam,axis=2) #array(Ops,refBlk,nAtoms)
     
    13021303        dfbdfr = np.sum(fbm/occ,axis=2)        #array(mxyz,refBlk,nAtom) Fdata != 0 avoids /0. problem
    13031304        dfbdx = np.sum(twopi*Uniq[nxs,:,:,nxs,:]*fbmx[:,:,:,:,nxs],axis=2)
    1304         dfbdmx = np.sum(TMcorr[nxs,nxs,:,nxs,:]*sinm[nxs,nxs,:,:,:]*(dqdm[:,:,:,nxs,nxs]+Q[nxs,:,:,:,:]),axis=-2)
     1305        dfbdmx = np.sum(TMcorr[nxs,nxs,:,nxs,:]*sinm[nxs,nxs,:,:,:]*dmx,axis=-2)
    13051306        dfbdmx = np.reshape(dfbdmx,(3,iFin-iBeg,-1,3))
    13061307        dfbdui = np.sum(-SQfactor[:,nxs,nxs]*fbm,axis=2) #array(Ops,refBlk,nAtoms)
     
    13081309        dFdfr[iBeg:iFin] = np.sum(2.*(fams[:,:,nxs]*dfadfr+fbms[:,:,nxs]*dfbdfr)*Mdata/(2*Nops*Ncen),axis=0)
    13091310        dFdx[iBeg:iFin] = np.sum(2.*(fams[:,:,nxs,nxs]*dfadx+fbms[:,:,nxs,nxs]*dfbdx),axis=0)
    1310 #        GSASIIpath.IPyBreak()
    13111311        dFdMx[iBeg:iFin] = np.sum(2.*(fams[:,:,nxs,nxs]*dfadmx+fbms[:,:,nxs,nxs]*dfbdmx),axis=0)
    13121312        dFdui[iBeg:iFin] = 2.*np.sum(fams[:,:,nxs]*dfadui+fbms[:,:,nxs]*dfbdui,axis=0)
     
    13301330        dFdvDict[pfx+'AU13:'+str(i)] = 2.*dFdua.T[4][i]
    13311331        dFdvDict[pfx+'AU23:'+str(i)] = 2.*dFdua.T[5][i]
     1332#    GSASIIpath.IPyBreak()
    13321333    return dFdvDict
    13331334   
     
    38453846                            depDerivDict[phfx+name][iBeg2:iFin2] += parmDict[phfx+'Scale']*dFdvDict[phfx+name][iref]*dervDict2['int']/refl[9+im]                 
    38463847            if not Phase['General'].get('doPawley'):
    3847                 #do atom derivatives -  for RB,F,X & U so far             
    3848                 corr = dervDict['int']/refl[9+im]
    3849                 if Ka2 and iFin2-iBeg2:
    3850                     corr2 = dervDict2['int']/refl[9+im]
     3848                #do atom derivatives -  for RB,F,X & U so far
     3849                corr = 0.
     3850                corr2 = 0.
     3851                if refl[9+im]:             
     3852                    corr = dervDict['int']/refl[9+im]
     3853                    if Ka2 and iFin2-iBeg2:
     3854                        corr2 = dervDict2['int']/refl[9+im]
    38513855                for name in varylist+dependentVars:
    38523856                    if '::RBV;' in name:
  • trunk/testDeriv.py

    r1860 r2500  
    9595                self.values = cPickle.load(file)
    9696                self.HistoPhases = cPickle.load(file)
    97                 (self.constrDict,self.fixedList) = cPickle.load(file)
     97                (self.constrDict,self.fixedList,self.depVarList) = cPickle.load(file)
    9898                self.parmDict = cPickle.load(file)
    9999                self.varylist = cPickle.load(file)
    100100                self.calcControls = cPickle.load(file)
    101101                self.pawleyLookup = cPickle.load(file)
    102                 self.use = [False for i in range(len(self.varylist))]
    103                 self.delt = [max(abs(self.parmDict[name])*0.001,1e-6) for name in self.varylist]
     102                self.use = [False for i in range(len(self.varylist+self.depVarList))]
     103                self.delt = [max(abs(self.parmDict[name])*0.001,1e-6) for name in self.varylist+self.depVarList]
    104104                file.close()
    105105                groups,parmlist = G2mv.GroupConstraints(self.constrDict)
     
    107107                self.UpdateControls(event)
    108108                print G2mv.VarRemapShow(self.varylist)
     109                print 'Dependent Vary List:',self.depVarList
    109110        finally:
    110111            dlg.Destroy()
     
    118119           
    119120        def OnDelValue(event):
     121            event.Skip()
    120122            Obj = event.GetEventObject()
    121123            item = ObjInd[Obj.GetId()]
     
    130132        ObjInd = {}
    131133        varylist = self.varylist
     134        depVarList = self.depVarList
    132135        use = self.use
    133136        delt = self.delt
    134137        mainSizer = wx.FlexGridSizer(0,8,5,5)
    135         for id,[ck,name,d] in enumerate(zip(use,varylist,delt)):
     138        for id,[ck,name,d] in enumerate(zip(use,varylist+depVarList,delt)):
    136139            useVal = wx.CheckBox(self.testDerivPanel,label=name)
    137140            useVal.SetValue(ck)
     
    164167           
    165168            Title = 'derivatives test for '+name
     169            varyList = self.varylist+self.depVarList
    166170            hplot = self.plotNB.add(Title).gca()
    167171            dMdV = G2stMth.dervRefine(self.values,self.HistoPhases,self.parmDict,
    168                 self.varylist,self.calcControls,self.pawleyLookup,None)
    169             hplot.plot(dMdV[self.varylist.index(name)],'b',label='analytic deriv')
    170             if name in self.varylist:
    171                 print 'parameter:',name,self.values[self.varylist.index(name)],delt
    172                 self.values[self.varylist.index(name)] -= delt
     172                varyList,self.calcControls,self.pawleyLookup,None)
     173            hplot.plot(dMdV[varyList.index(name)],'b',label='analytic deriv')
     174            if name in varyList:
     175                mmin = np.min(dMdV[varyList.index(name)])
     176                mmax = np.max(dMdV[varyList.index(name)])
     177                print 'parameter:',name,self.parmDict[name],delt,mmin,mmax
     178                if name in self.varylist:
     179                    self.values[self.varylist.index(name)] -= delt
     180                else:
     181                    self.parmDict[name] -= delt
    173182                M0 = G2stMth.errRefine(self.values,self.HistoPhases,self.parmDict,
    174                     self.varylist,self.calcControls,self.pawleyLookup,None)
    175                 self.values[self.varylist.index(name)] += 2.*delt
     183                    varyList,self.calcControls,self.pawleyLookup,None)
     184                if name in self.varylist:
     185                    self.values[self.varylist.index(name)] += 2.*delt
     186                else:
     187                    self.parmDict[name] += 2.*delt
    176188                M1 = G2stMth.errRefine(self.values,self.HistoPhases,self.parmDict,
    177                     self.varylist,self.calcControls,self.pawleyLookup,None)
    178                 self.values[self.varylist.index(name)] -= delt   
     189                    varyList,self.calcControls,self.pawleyLookup,None)
     190                if name in self.varylist:
     191                    self.values[self.varylist.index(name)] -= delt
     192                else:
     193                    self.parmDict[name] -= delt   
    179194                Mn = (M1-M0)/(2.*delt)
    180195                hplot.plot(Mn,'r',label='numeric deriv')
    181                 hplot.plot(dMdV[self.varylist.index(name)]-Mn,'g',label='diff')
     196                hplot.plot(dMdV[varyList.index(name)]-Mn,'g',label='diff')
     197#            GSASIIpath.IPyBreak()
    182198            hplot.legend(loc='best')           
    183199           
    184200        while self.plotNB.nb.GetPageCount():
    185201            self.plotNB.nb.DeletePage(0)
    186         test1()
    187         for use,name,delt in zip(self.use,self.varylist,self.delt):
     202        for use,name,delt in zip(self.use,self.varylist+self.depVarList,self.delt):
    188203            if use:
    189204                test2(name,delt)
     
    204219   
    205220if __name__ == '__main__':
     221    GSASIIpath.InvokeDebugOpts()
    206222    main()
Note: See TracChangeset for help on using the changeset viewer.