Changeset 2508


Ignore:
Timestamp:
Oct 27, 2016 12:50:38 PM (9 years ago)
Author:
vondreele
Message:

fix move difference curve problem
mag derivs are better but still not right - refinements work (sort of)
fix to testDeriv to show atom pos derivs for depVarList parameters

Location:
trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • TabularUnified trunk/GSASIIplot.py

    r2503 r2508  
    15961596            data = G2frame.PatternTree.GetItemPyData(PickId)
    15971597            ypos = event.ydata
    1598             Pattern[0]['delOffset'] = -ypos/Ymax
     1598            Pattern[0]['delOffset'] = -ypos
    15991599            G2frame.itemPicked = None
    16001600            wx.CallAfter(PlotPatterns,G2frame,plotType=plottype)
  • TabularUnified trunk/GSASIIstrMath.py

    r2506 r2508  
    12221222    Mag = np.sqrt(np.sum(Gdata**2,axis=0))      #magnitude of moments for uniq atoms
    12231223    Gdata = np.where(Mag>0.,Gdata/Mag,0.)       #normalze mag. moments
    1224     dGdM = np.copy(Gdata)
     1224    dGdM = np.repeat(Gdata[:,nxs,:],Nops*Ncen*(1+SGData['SGInv']),axis=1)
    12251225    Gdata = np.inner(Bmat,Gdata.T)              #convert to crystal space
    12261226    Gdata = np.inner(Gdata.T,SGMT).T            #apply sym. ops.
     
    12351235    if SGData['SGInv']:
    12361236        Mag = np.repeat(Mag,2,axis=0)
    1237     dGdm = (1.-Gdata**2)    #1/Mag removed - canceled out in dqmx=sum(dqdm*dGdm)
     1237    dGdm = (1.-Gdata**2)                        #1/Mag removed - canceled out in dqmx=sum(dqdm*dGdm)
    12381238    dFdMx = np.zeros((nRef,mSize,3))
    12391239    Uij = np.array(G2lat.U6toUij(Uijdata))
     
    12841284        cosm = np.cos(mphase)                               #ditto
    12851285        HM = np.inner(Bmat.T,H)                             #put into cartesian space
    1286         HM = HM/np.sqrt(np.sum(HM**2,axis=0))               
     1286        HM = HM/np.sqrt(np.sum(HM**2,axis=0))               #unit vector for H
    12871287        eDotK = np.sum(HM[:,:,nxs,nxs]*Gdata[:,nxs,:,:],axis=0)
    12881288        Q = HM[:,:,nxs,nxs]*eDotK[nxs,:,:,:]-Gdata[:,nxs,:,:] #Mxyz,Nref,Nop,Natm = BPM in magstrfc.for OK
    12891289        dqdm = np.array([np.outer(hm,hm)-np.eye(3) for hm in HM.T]).T   #Mxyz,Mxyz,Nref (3x3 matrix)
    12901290        dqmx = np.sum(dqdm[:,:,:,nxs,nxs]*dGdm[:,nxs,nxs,:,:],axis=0)   #matrix * vector = vector
    1291         dmx = Q*Gdata[:,nxs,:,:]+dqmx      #*Mag canceled out of dqmx term
    1292         fam = Q*TMcorr[nxs,:,nxs,:]*cosm[nxs,:,:,:]*Mag[nxs,nxs,:,:]    #ditto
    1293         fbm = Q*TMcorr[nxs,:,nxs,:]*sinm[nxs,:,:,:]*Mag[nxs,nxs,:,:]    #ditto
    1294         fams = np.sum(np.sum(fam,axis=-1),axis=-1)                          #Mxyz,Nref
    1295         fbms = np.sum(np.sum(fbm,axis=-1),axis=-1)                          #ditto
     1291        dmx = Q*dGdM[:,nxs,:,:]+dqmx                                    #*Mag canceled out of dqmx term
     1292        fam = Q*TMcorr[nxs,:,nxs,:]*cosm[nxs,:,:,:]*Mag[nxs,nxs,:,:]    #Mxyz,Nref,Nop,Natm
     1293        fbm = Q*TMcorr[nxs,:,nxs,:]*sinm[nxs,:,:,:]*Mag[nxs,nxs,:,:]
     1294        fams = np.sum(np.sum(fam,axis=-1),axis=-1)                      #Mxyz,Nref
     1295        fbms = np.sum(np.sum(fbm,axis=-1),axis=-1)
    12961296        famx = Q*TMcorr[nxs,:,nxs,:]*Mag[nxs,nxs,:,:]*sinm[nxs,:,:,:]   #Mxyz,Nref,Nops,Natom
    12971297        fbmx = Q*TMcorr[nxs,:,nxs,:]*Mag[nxs,nxs,:,:]*cosm[nxs,:,:,:]
  • TabularUnified trunk/testDeriv.py

    r2501 r2508  
    8585
    8686    def OnTestRead(self,event):
    87         dlg = wx.FileDialog(self, 'Open testDeriv.dat file', '.', 'testDeriv.dat')
     87        dlg = wx.FileDialog(self, 'Open testDeriv.dat file',defaultFile='testDeriv.dat',
     88            wildcard='testDeriv.dat')
    8889        if self.dirname:
    8990            dlg.SetDirectory(self.dirname)
     
    165166           
    166167        def test2(name,delt):
    167            
    168168            Title = 'derivatives test for '+name
    169169            varyList = self.varylist+self.depVarList
     
    171171            dMdV = G2stMth.dervRefine(self.values,self.HistoPhases,self.parmDict,
    172172                varyList,self.calcControls,self.pawleyLookup,None)
    173             hplot.plot(dMdV[varyList.index(name)],'b',label='analytic deriv')
     173            M2 = dMdV[varyList.index(name)]
     174            hplot.plot(M2,'b',label='analytic deriv')
    174175            if name in varyList:
    175176                mmin = np.min(dMdV[varyList.index(name)])
     
    184185                        varyList,self.calcControls,self.pawleyLookup,None)
    185186                    self.values[self.varylist.index(name)] -= delt
    186                 else:   #in depVarList
     187                elif name in self.depVarList:   #in depVarList
     188                    if 'dA' in name:
     189                        name = name.replace('dA','A')
     190                        delt *= -1
    187191                    self.parmDict[name] -= delt
    188192                    M0 = G2stMth.errRefine(self.values,self.HistoPhases,self.parmDict,
     
    192196                        varyList,self.calcControls,self.pawleyLookup,None)
    193197                    self.parmDict[name] -= delt   
    194                 Mn = (M1-M0)/(2.*delt)
     198                Mn = (M1-M0)/(2.*abs(delt))
    195199                hplot.plot(Mn,'r',label='numeric deriv')
    196                 hplot.plot(dMdV[varyList.index(name)]-Mn,'g',label='diff')
     200                hplot.plot(M2-Mn,'g',label='diff')
    197201#            GSASIIpath.IPyBreak()
    198202            hplot.legend(loc='best')           
Note: See TracChangeset for help on using the changeset viewer.