Changeset 3340
- Timestamp:
- Apr 11, 2018 1:32:49 PM (5 years ago)
- Location:
- trunk
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/GSASIIdataGUI.py
r3333 r3340 4306 4306 return 4307 4307 dlg = wx.ProgressDialog('Residual','All data Rw =',101.0, 4308 style = wx.PD_ELAPSED_TIME|wx.PD_AUTO_HIDE|wx.PD_CAN_ABORT|wx.STAY_ON_TOP, 4309 parent=self) 4308 style = wx.PD_ELAPSED_TIME|wx.PD_AUTO_HIDE|wx.PD_CAN_ABORT|wx.STAY_ON_TOP,parent=self) 4310 4309 Size = dlg.GetSize() 4311 4310 if 50 < Size[0] < 500: # sanity check on size, since this fails w/Win & wx3.0 -
trunk/GSASIIspc.py
r3338 r3340 3186 3186 newMom = -(np.inner(Mom,M).T)*nl.det(M) 3187 3187 else: 3188 newMom = -(np.inner(Mom,M).T)*SGData[' SpnFlp'][nA-1]*nl.det(M)3188 newMom = -(np.inner(Mom,M).T)*SGData['MagMom'][nA-1]*nl.det(M) 3189 3189 return newMom 3190 3190 -
trunk/GSASIIstrIO.py
r3311 r3340 1656 1656 1657 1657 def PrintMomentsAndSig(General,Atoms,atomsSig): 1658 cell = General['Cell'][1:7] 1659 G = G2lat.fillgmat(cell) 1660 ast = np.sqrt(np.diag(G)) 1661 GS = G/np.outer(ast,ast) 1658 1662 pFile.write('\n Magnetic Moments:\n') #add magnitude & angle, etc.? TBD 1659 line = ' name Mx My Mz'1663 line = ' name Mx My Mz |Mag|' 1660 1664 cx,ct,cs,cia = General['AtomPtrs'] 1661 1665 cmx = cx+4 … … 1663 1667 pFile.write(line+'\n') 1664 1668 pFile.write(135*'-'+'\n') 1665 fmt = {0:'%7s',ct:'%7s',cmx:'%10. 5f',cmx+1:'%10.5f',cmx+2:'%10.5f'}1669 fmt = {0:'%7s',ct:'%7s',cmx:'%10.3f',cmx+1:'%10.3f',cmx+2:'%10.3f'} 1666 1670 noFXsig = {cmx:[10*' ','%10s'],cmx+1:[10*' ','%10s'],cmx+2:[10*' ','%10s']} 1667 1671 for i,at in enumerate(Atoms): … … 1677 1681 else: 1678 1682 sigstr += noFXsig[ind][1]%(noFXsig[ind][0]) 1683 mag = np.array(at[cmx:cmx+3]) 1684 Mag = np.sqrt(np.inner(mag,np.inner(mag,GS))) 1685 valstr += '%10.3f'%Mag 1686 sigstr += 10*' ' 1679 1687 pFile.write(name+'\n') 1680 1688 pFile.write(valstr+'\n') -
trunk/GSASIIstrMath.py
r3339 r3340 786 786 787 787 ''' 788 # phfx = pfx.split(':')[0]+hfx789 788 ast = np.sqrt(np.diag(G)) 790 789 GS = G/np.outer(ast,ast) 790 uAmat = G2lat.Gmat2AB(GS)[0] 791 791 Mast = twopisq*np.multiply.outer(ast,ast) 792 792 SGMT = np.array([ops[0].T for ops in SGData['SGOps']]) … … 797 797 Nops *= (1+SGData['SGInv']) 798 798 MFtables = calcControls['MFtables'] 799 Amat,Bmat = G2lat.Gmat2AB(G)799 Bmat = G2lat.Gmat2AB(G)[1] 800 800 TwinLaw = np.ones(1) 801 801 # TwinLaw = np.array([[[1,0,0],[0,1,0],[0,0,1]],]) … … 812 812 return 813 813 Mag = np.sqrt(np.array([np.inner(mag,np.inner(mag,GS)) for mag in Gdata.T])) 814 Gdata = np.where(Mag>0.,Gdata/Mag,0.) #normalze mag. moments815 814 Gdata = np.inner(Gdata.T,SGMT).T #apply sym. ops. 816 815 if SGData['SGInv'] and not SGData['SGFixed']: 817 816 Gdata = np.hstack((Gdata,-Gdata)) #inversion if any 818 Gdata = np.hstack([Gdata for icen in range(Ncen)]) #dup over cell centering 817 Gdata = np.hstack([Gdata for icen in range(Ncen)]) #dup over cell centering--> [Mxyz,nops,natms] 819 818 Gdata = SGData['MagMom'][nxs,:,nxs]*Gdata #flip vectors according to spin flip * det(opM) 820 Mag = np.tile(Mag[:,nxs], len(SGMT)*Ncen).T.reshape((len(SGMT),-1))821 if SGData['SGInv'] and not SGData['SGFixed']:822 Mag = np.repeat(Mag,2,axis=0) #Mag same shape as Gdata819 Mag = np.tile(Mag[:,nxs],Nops).T #make Mag same length as Gdata 820 Gdata = Gdata/Mag #normalze mag. moments 821 Gdata = np.inner(Gdata.T,uAmat).T*np.sqrt(nl.det(GS)) 823 822 Uij = np.array(G2lat.U6toUij(Uijdata)) 824 823 bij = Mast*Uij.T … … 1057 1056 1058 1057 def StructureFactorDervMag(refDict,G,hfx,pfx,SGData,calcControls,parmDict): 1059 '''Compute structure factor derivatives on blocks of reflections - for powders/nontwins only1058 '''Compute magnetic structure factor derivatives on blocks of reflections - for powders/nontwins only 1060 1059 input: 1061 1060 … … 1075 1074 ast = np.sqrt(np.diag(G)) 1076 1075 GS = G/np.outer(ast,ast) 1076 uAmat = G2lat.Gmat2AB(GS)[0] 1077 1077 Mast = twopisq*np.multiply.outer(ast,ast) 1078 1078 SGMT = np.array([ops[0].T for ops in SGData['SGOps']]) 1079 1079 SGT = np.array([ops[1] for ops in SGData['SGOps']]) 1080 1080 Ncen = len(SGData['SGCen']) 1081 if SGData['SGFixed']: 1082 Nops = len(SGMT)*Ncen 1083 else: 1084 Nops = len(SGMT)*Ncen*(1+SGData['SGInv']) 1085 Amat,Bmat = G2lat.Gmat2AB(G) 1081 Nops = len(SGMT)*Ncen 1082 if not SGData['SGFixed']: 1083 Nops *= (1+SGData['SGInv']) 1084 Bmat = G2lat.Gmat2AB(G)[1] 1086 1085 nRef = len(refDict['RefList']) 1087 1086 Tdata,Mdata,Fdata,Xdata,dXdata,IAdata,Uisodata,Uijdata,Gdata = \ … … 1098 1097 Gdata = SGData['MagMom'][nxs,:,nxs]*Gdata #flip vectors according to spin flip 1099 1098 Mag = np.tile(Mag[:,nxs],Nops).T #make Mag same length as Gdata 1099 Gdata = Gdata/Mag #normalze mag. moments 1100 Gdata = np.inner(Gdata.T,uAmat).T*np.sqrt(nl.det(GS)) #make unit vectors in Cartesian space 1100 1101 dGdm = (1.-Gdata**2) #1/Mag removed - canceled out in dqmx=sum(dqdm*dGdm) 1101 1102 dFdMx = np.zeros((nRef,mSize,3)) … … 1111 1112 #reflection processing begins here - big arrays! 1112 1113 iBeg = 0 1113 blkSize = 32#no. of reflections in a block - optimized for speed1114 blkSize = 40 #no. of reflections in a block - optimized for speed 1114 1115 while iBeg < nRef: 1115 1116 iFin = min(iBeg+blkSize,nRef) … … 1131 1132 MF = refDict['FF']['MF'][iBeg:iFin].T[Tindx].T #Nref,Natm 1132 1133 TMcorr = 0.539*(np.reshape(Tiso,Tuij.shape)*Tuij)[:,0,:]*Fdata*Mdata*MF/(2*Nops) #Nref,Natm 1133 if SGData['SGInv'] and not SGData['SGFixed']: 1134 mphase = np.hstack((phase,-phase)) 1135 Uniq = np.hstack((Uniq,-Uniq)) #Nref,Nops,hkl 1136 Hij = np.hstack((Hij,Hij)) 1134 if SGData['SGInv']: 1135 if not SGData['SGFixed']: 1136 mphase = np.hstack((phase,-phase)) #OK 1137 Uniq = np.hstack((Uniq,-Uniq)) #Nref,Nops,hkl 1138 Hij = np.hstack((Hij,Hij)) 1139 else: 1140 mphase = phase 1137 1141 else: 1138 mphase = phase 1142 mphase = phase # 1139 1143 Hij = np.concatenate(np.array([Hij for cen in SGData['SGCen']]),axis=1) 1140 1144 Uniq = np.hstack([Uniq for cen in SGData['SGCen']]) … … 1153 1157 dqmx2 = np.sum(dqmx,axis=1) #matrix * vector = vector 1154 1158 # dqmx1 = np.swapaxes(np.swapaxes(np.inner(dqdm.T,dGdm.T),0,1),2,3) 1155 dmx = NQ*Q*dGdM[:,nxs,:,:]-Q*dqmx2#*Mag canceled out of dqmx term1159 dmx = (NQ*Q*dGdM[:,nxs,:,:]-Q*dqmx2)/Mag #*Mag canceled out of dqmx term 1156 1160 1157 1161 fam = Q*TMcorr[nxs,:,nxs,:]*cosm[nxs,:,:,:]*Mag[nxs,nxs,:,:] #Mxyz,Nref,Nop,Natm -
trunk/testDeriv.py
r3232 r3340 22 22 23 23 import sys 24 import cPickle 25 import cProfile,pstats,StringIO 24 import platform 25 if '2' in platform.python_version_tuple()[0]: 26 import cPickle 27 import StringIO 28 else: 29 import _pickle as cPickle 30 import io as StringIO 31 import cProfile,pstats 26 32 import wx 27 33 import numpy as np … … 53 59 self.testDerivMenu = wx.MenuBar() 54 60 self.File = wx.Menu(title='') 55 self.File.Append(help='Open testDeriv.dat', id=wxID_FILEOPEN, 56 kind=wx.ITEM_NORMAL,text='Open testDeriv.dat file') 57 self.File.Append(help='Make derivative plots',id=wxID_MAKEPLOTS, 58 kind=wx.ITEM_NORMAL,text='Make plots') 59 self.File.Append(help='Exit from testDeriv', id=wxID_FILEEXIT, kind=wx.ITEM_NORMAL, 60 text='Exit') 61 self.File.Append(wxID_FILEOPEN,'Open testDeriv.dat file','Open testDeriv.dat') 62 self.File.Append(wxID_MAKEPLOTS,'Make plots','Make derivative plots') 63 self.File.Append(wxID_FILEEXIT,'Exit','Exit from testDeriv') 61 64 self.Bind(wx.EVT_MENU, self.OnTestRead, id=wxID_FILEOPEN) 62 65 self.Bind(wx.EVT_MENU,self.OnMakePlots,id=wxID_MAKEPLOTS) … … 93 96 testFile = dlg.GetPath() 94 97 file = open(testFile,'rb') 95 self.values = cPickle.load(file) 96 self.HistoPhases = cPickle.load(file) 97 (self.constrDict,self.fixedList,self.depVarList) = cPickle.load(file) 98 self.parmDict = cPickle.load(file) 99 self.varylist = cPickle.load(file) 100 self.calcControls = cPickle.load(file) 101 self.pawleyLookup = cPickle.load(file) 98 if '2' in platform.python_version_tuple()[0]: 99 self.values = cPickle.load(file) 100 self.HistoPhases = cPickle.load(file) 101 (self.constrDict,self.fixedList,self.depVarList) = cPickle.load(file) 102 self.parmDict = cPickle.load(file) 103 self.varylist = cPickle.load(file) 104 self.calcControls = cPickle.load(file) 105 self.pawleyLookup = cPickle.load(file) 106 else: 107 self.values = cPickle.load(file,encoding='Latin-1') 108 self.HistoPhases = cPickle.load(file,encoding='Latin-1') 109 (self.constrDict,self.fixedList,self.depVarList) = cPickle.load(file,encoding='Latin-1') 110 self.parmDict = cPickle.load(file,encoding='Latin-1') 111 self.varylist = cPickle.load(file,encoding='Latin-1') 112 self.calcControls = cPickle.load(file,encoding='Latin-1') 113 self.pawleyLookup = cPickle.load(file,encoding='Latin-1') 102 114 self.use = [False for i in range(len(self.varylist+self.depVarList))] 103 115 self.delt = [max(abs(self.parmDict[name])*0.0001,1e-6) for name in self.varylist+self.depVarList]
Note: See TracChangeset
for help on using the changeset viewer.