Changeset 2508
- Timestamp:
- Oct 27, 2016 12:50:38 PM (9 years ago)
- Location:
- trunk
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
TabularUnified trunk/GSASIIplot.py ¶
r2503 r2508 1596 1596 data = G2frame.PatternTree.GetItemPyData(PickId) 1597 1597 ypos = event.ydata 1598 Pattern[0]['delOffset'] = -ypos /Ymax1598 Pattern[0]['delOffset'] = -ypos 1599 1599 G2frame.itemPicked = None 1600 1600 wx.CallAfter(PlotPatterns,G2frame,plotType=plottype) -
TabularUnified trunk/GSASIIstrMath.py ¶
r2506 r2508 1222 1222 Mag = np.sqrt(np.sum(Gdata**2,axis=0)) #magnitude of moments for uniq atoms 1223 1223 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) 1225 1225 Gdata = np.inner(Bmat,Gdata.T) #convert to crystal space 1226 1226 Gdata = np.inner(Gdata.T,SGMT).T #apply sym. ops. … … 1235 1235 if SGData['SGInv']: 1236 1236 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) 1238 1238 dFdMx = np.zeros((nRef,mSize,3)) 1239 1239 Uij = np.array(G2lat.U6toUij(Uijdata)) … … 1284 1284 cosm = np.cos(mphase) #ditto 1285 1285 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 1287 1287 eDotK = np.sum(HM[:,:,nxs,nxs]*Gdata[:,nxs,:,:],axis=0) 1288 1288 Q = HM[:,:,nxs,nxs]*eDotK[nxs,:,:,:]-Gdata[:,nxs,:,:] #Mxyz,Nref,Nop,Natm = BPM in magstrfc.for OK 1289 1289 dqdm = np.array([np.outer(hm,hm)-np.eye(3) for hm in HM.T]).T #Mxyz,Mxyz,Nref (3x3 matrix) 1290 1290 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 term1292 fam = Q*TMcorr[nxs,:,nxs,:]*cosm[nxs,:,:,:]*Mag[nxs,nxs,:,:] # ditto1293 fbm = Q*TMcorr[nxs,:,nxs,:]*sinm[nxs,:,:,:]*Mag[nxs,nxs,:,:] #ditto1294 fams = np.sum(np.sum(fam,axis=-1),axis=-1) 1295 fbms = np.sum(np.sum(fbm,axis=-1),axis=-1) #ditto1291 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) 1296 1296 famx = Q*TMcorr[nxs,:,nxs,:]*Mag[nxs,nxs,:,:]*sinm[nxs,:,:,:] #Mxyz,Nref,Nops,Natom 1297 1297 fbmx = Q*TMcorr[nxs,:,nxs,:]*Mag[nxs,nxs,:,:]*cosm[nxs,:,:,:] -
TabularUnified trunk/testDeriv.py ¶
r2501 r2508 85 85 86 86 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') 88 89 if self.dirname: 89 90 dlg.SetDirectory(self.dirname) … … 165 166 166 167 def test2(name,delt): 167 168 168 Title = 'derivatives test for '+name 169 169 varyList = self.varylist+self.depVarList … … 171 171 dMdV = G2stMth.dervRefine(self.values,self.HistoPhases,self.parmDict, 172 172 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') 174 175 if name in varyList: 175 176 mmin = np.min(dMdV[varyList.index(name)]) … … 184 185 varyList,self.calcControls,self.pawleyLookup,None) 185 186 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 187 191 self.parmDict[name] -= delt 188 192 M0 = G2stMth.errRefine(self.values,self.HistoPhases,self.parmDict, … … 192 196 varyList,self.calcControls,self.pawleyLookup,None) 193 197 self.parmDict[name] -= delt 194 Mn = (M1-M0)/(2.* delt)198 Mn = (M1-M0)/(2.*abs(delt)) 195 199 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') 197 201 # GSASIIpath.IPyBreak() 198 202 hplot.legend(loc='best')
Note: See TracChangeset
for help on using the changeset viewer.