- Timestamp:
- Dec 1, 2015 12:23:23 PM (10 years ago)
- Location:
- trunk
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
TabularUnified trunk/GSASII.py ¶
r2071 r2075 3115 3115 def OnFileExit(self, event): 3116 3116 '''Called in response to the File/Quit menu button''' 3117 if self.G2plotNB: 3118 self.G2plotNB.Destroy() 3117 3119 if self.dataFrame: 3118 3120 self.dataFrame.Clear() -
TabularUnified trunk/GSASIIddataGUI.py ¶
r1922 r2075 43 43 ##### DData routines 44 44 ################################################################################ 45 def UpdateDData(G2frame,DData,data,hist='' ):45 def UpdateDData(G2frame,DData,data,hist='',Scroll=0): 46 46 '''Display the Diffraction Data associated with a phase 47 47 (items where there is a value for each histogram and phase) 48 48 49 49 :param wx.frame G2frame: the main GSAS-II frame object 50 51 50 :param wx.ScrolledWindow DData: notebook page to be used for the display 52 53 51 :param dict data: all the information on the phase in a dictionary 52 :param str hist: histogram name 53 :param int Scroll: previous scroll position 54 54 55 55 ''' … … 171 171 UseList[G2frame.hist]['Size'][0] = Obj.GetValue() 172 172 G2plt.PlotSizeStrainPO(G2frame,data,G2frame.hist) 173 wx.CallLater(100,RepaintHistogramInfo )173 wx.CallLater(100,RepaintHistogramInfo,DData.GetScrollPos(wx.VERTICAL)) 174 174 175 175 def OnSizeRef(event): … … 208 208 UseList[G2frame.hist]['Mustrain'][0] = Obj.GetValue() 209 209 G2plt.PlotSizeStrainPO(G2frame,data,G2frame.hist) 210 wx.CallLater(100,RepaintHistogramInfo )210 wx.CallLater(100,RepaintHistogramInfo,DData.GetScrollPos(wx.VERTICAL)) 211 211 212 212 def OnStrainRef(event): … … 271 271 UseList[item]['Mustrain'][4][i] = vals[i] 272 272 G2plt.PlotSizeStrainPO(G2frame,data,item) 273 wx.CallLater(100,RepaintHistogramInfo )273 wx.CallLater(100,RepaintHistogramInfo,DData.GetScrollPos(wx.VERTICAL)) 274 274 275 275 def OnHstrainRef(event): … … 317 317 UseList[G2frame.hist]['Pref.Ori.'][4] = Order 318 318 UseList[G2frame.hist]['Pref.Ori.'][5] = SetPOCoef(Order,G2frame.hist) 319 wx.CallLater(100,RepaintHistogramInfo )319 wx.CallLater(100,RepaintHistogramInfo,DData.GetScrollPos(wx.VERTICAL)) 320 320 321 321 def OnPOType(event): … … 325 325 else: 326 326 UseList[G2frame.hist]['Pref.Ori.'][0] = 'SH' 327 wx.CallLater(100,RepaintHistogramInfo )327 wx.CallLater(100,RepaintHistogramInfo,DData.GetScrollPos(wx.VERTICAL)) 328 328 329 329 def OnPORef(event): … … 562 562 finally: 563 563 dlg.Destroy() 564 wx.CallLater(100,RepaintHistogramInfo )564 wx.CallLater(100,RepaintHistogramInfo,DData.GetScrollPos(wx.VERTICAL)) 565 565 566 566 def OnshToler(event): … … 594 594 item = Indx[Obj.GetId()] 595 595 UseList[item[0]]['Extinction'][item[1]] = Obj.GetValue() 596 wx.CallLater(100,RepaintHistogramInfo )596 wx.CallLater(100,RepaintHistogramInfo,DData.GetScrollPos(wx.VERTICAL)) 597 597 598 598 def OnTbarVal(event): … … 787 787 UseList[G2frame.hist]['Twins'].append([False,0.0]) 788 788 addtwin.SetValue(False) 789 wx.CallLater(100,RepaintHistogramInfo )789 wx.CallLater(100,RepaintHistogramInfo,DData.GetScrollPos(wx.VERTICAL)) 790 790 791 791 def OnMat(event): … … 815 815 sumTw += twin[1] 816 816 UseList[G2frame.hist]['Twins'][0][1][0] = 1.-sumTw 817 wx.CallLater(100,RepaintHistogramInfo )817 wx.CallLater(100,RepaintHistogramInfo,DData.GetScrollPos(wx.VERTICAL)) 818 818 819 819 def OnTwinRef(event): … … 840 840 if len(UseList[G2frame.hist]['Twins']) == 1: 841 841 UseList[G2frame.hist]['Twins'][0][1][1] = False 842 wx.CallLater(100,RepaintHistogramInfo )842 wx.CallLater(100,RepaintHistogramInfo,DData.GetScrollPos(wx.VERTICAL)) 843 843 844 844 nTwin = len(UseList[G2frame.hist]['Twins']) … … 914 914 wx.CallLater(100,RepaintHistogramInfo) 915 915 916 def RepaintHistogramInfo( ):916 def RepaintHistogramInfo(Scroll=0): 917 917 G2frame.bottomSizer.DeleteWindows() 918 918 Indx.clear() … … 922 922 G2frame.dataFrame.Refresh() 923 923 DData.SetVirtualSize(mainSizer.GetMinSize()) 924 DData.Scroll(0,Scroll) 924 925 G2frame.dataFrame.SendSizeEvent() 925 926 … … 944 945 UseList[item]['Size'][4][i+3] = 0.0 945 946 G2plt.PlotSizeStrainPO(G2frame,data,item) 946 wx.CallLater(100,RepaintHistogramInfo )947 wx.CallLater(100,RepaintHistogramInfo,DData.GetScrollPos(wx.VERTICAL)) 947 948 948 949 def OnSizeAxis(event): … … 1104 1105 0,WACV|wx.TOP,10) 1105 1106 1106 G2phsGUI.SetPhaseWindow(G2frame.dataFrame,DData,mainSizer )1107 G2phsGUI.SetPhaseWindow(G2frame.dataFrame,DData,mainSizer,Scroll) -
TabularUnified trunk/GSASIImath.py ¶
r2074 r2075 936 936 Mast: array orthogonalization matrix for Uij 937 937 ''' 938 glTau,glWt = pwd.pygauleg(0.,1.,32) #get Gauss-Legendre intervals & weights 938 ngl = 32 939 glTau,glWt = pwd.pygauleg(0.,1.,ngl) #get Gauss-Legendre intervals & weights 939 940 Ax = np.array(XSSdata[:3]).T #atoms x waves x sin pos mods 940 941 Bx = np.array(XSSdata[3:]).T #...cos pos mods … … 945 946 nWaves = [Af.shape[1],Ax.shape[1],Au.shape[1]] 946 947 if nWaves[0]: 947 tauF = np.arange(1.,nWaves[0]+1 -nf)[:,nxs]*glTau #Fwaves x 32948 FmodA = Af[:,:,nxs]*np.sin(twopi*tauF[nxs,:,:]) #atoms X Fwaves X 32948 tauF = np.arange(1.,nWaves[0]+1)[:,nxs]*glTau #Fwaves x ngl 949 FmodA = Af[:,:,nxs]*np.sin(twopi*tauF[nxs,:,:]) #atoms X Fwaves X ngl 949 950 FmodB = Bf[:,:,nxs]*np.cos(twopi*tauF[nxs,:,:]) 950 Fmod = np.sum( FmodA+FmodB,axis=1) #atoms X 32; sum waves951 Fmod = np.sum(1.0+FmodA+FmodB,axis=1) #atoms X ngl; sum waves 951 952 else: 952 953 Fmod = 1.0 953 XmodZ = np.zeros((Ax.shape[0],Ax.shape[1],3, 32))954 XmodA = np.zeros((Ax.shape[0],Ax.shape[1],3, 32))955 XmodB = np.zeros((Ax.shape[0],Ax.shape[1],3, 32))954 XmodZ = np.zeros((Ax.shape[0],Ax.shape[1],3,ngl)) 955 XmodA = np.zeros((Ax.shape[0],Ax.shape[1],3,ngl)) 956 XmodB = np.zeros((Ax.shape[0],Ax.shape[1],3,ngl)) 956 957 for iatm in range(Ax.shape[0]): 957 958 nx = 0 … … 966 967 XYZmax = np.array([Ax[iatm][0][2],Bx[iatm][0][0],Bx[iatm][0][1]]) 967 968 XmodZ[iatm][0] += posBlock(glTau,Tmm,XYZmax).T 968 tauX = np.arange(1.,nWaves[1]+1-nx)[:,nxs]*glTau #Xwaves x 32969 tauX = np.arange(1.,nWaves[1]+1-nx)[:,nxs]*glTau #Xwaves x ngl 969 970 if nx: 970 XmodA[iatm][:-nx] = Ax[iatm,nx:,:,nxs]*np.sin(twopi*tauX[nxs,:,nxs,:]) #atoms X waves X 3 X 32971 XmodA[iatm][:-nx] = Ax[iatm,nx:,:,nxs]*np.sin(twopi*tauX[nxs,:,nxs,:]) #atoms X waves X 3 X ngl 971 972 XmodB[iatm][:-nx] = Bx[iatm,nx:,:,nxs]*np.cos(twopi*tauX[nxs,:,nxs,:]) #ditto 972 973 else: 973 XmodA[iatm] = Ax[iatm,:,:,nxs]*np.sin(twopi*tauX[nxs,:,nxs,:]) #atoms X waves X 3 X 32974 XmodA[iatm] = Ax[iatm,:,:,nxs]*np.sin(twopi*tauX[nxs,:,nxs,:]) #atoms X waves X 3 X ngl 974 975 XmodB[iatm] = Bx[iatm,:,:,nxs]*np.cos(twopi*tauX[nxs,:,nxs,:]) #ditto 975 Xmod = np.sum(XmodA+XmodB+XmodZ,axis=1) #atoms X 3 X 32; sum waves976 Xmod = np.sum(XmodA+XmodB+XmodZ,axis=1) #atoms X 3 X ngl; sum waves 976 977 Xmod = np.swapaxes(Xmod,1,2) 977 978 if nWaves[2]: 978 tauU = np.arange(1.,nWaves[2]+1)[:,nxs]*glTau #Uwaves x 32979 UmodA = Au[:,:,:,:,nxs]*np.sin(twopi*tauU[nxs,:,nxs,nxs,:]) #atoms x waves x 3x3 x 32979 tauU = np.arange(1.,nWaves[2]+1)[:,nxs]*glTau #Uwaves x ngl 980 UmodA = Au[:,:,:,:,nxs]*np.sin(twopi*tauU[nxs,:,nxs,nxs,:]) #atoms x waves x 3x3 x ngl 980 981 UmodB = Bu[:,:,:,:,nxs]*np.cos(twopi*tauU[nxs,:,nxs,nxs,:]) #ditto 981 Umod = np.swapaxes(np.sum(UmodA+UmodB,axis=1),1,3) #atoms x 3x3 x 32; sum waves982 Umod = np.swapaxes(np.sum(UmodA+UmodB,axis=1),1,3) #atoms x 3x3 x ngl; sum waves 982 983 else: 983 984 Umod = 1.0 984 985 # GSASIIpath.IPyBreak() 985 return n Waves,Fmod,Xmod,Umod,glTau,glWt986 return ngl,nWaves,Fmod,Xmod,Umod,glTau,glWt 986 987 987 988 def Modulation(H,HP,nWaves,Fmod,Xmod,Umod,glTau,glWt): … … 990 991 HP: array nRefBlk x ops X hklt proj to hkl 991 992 Fmod: array 2 x atoms x waves (sin,cos terms) 992 Xmod: array atoms X 3 X 32993 Umod: array atoms x 3x3 x 32993 Xmod: array atoms X 3 X ngl 994 Umod: array atoms x 3x3 x ngl 994 995 glTau,glWt: arrays Gauss-Lorentzian pos & wts 995 996 ''' 996 997 997 nxs = np.newaxis 998 nxs = np.newaxis 998 999 if nWaves[2]: 999 1000 if len(HP.shape) > 2: 1000 HbH = np.exp(-np.sum(HP[:,:,nxs,nxs,:]*np.inner(HP,Umod),axis=-1)) # refBlk x ops x atoms x 32add Overhauser corr.?1001 HbH = np.exp(-np.sum(HP[:,:,nxs,nxs,:]*np.inner(HP,Umod),axis=-1)) # refBlk x ops x atoms x ngl add Overhauser corr.? 1001 1002 else: 1002 HbH = np.exp(-np.sum(HP[:,nxs,nxs,:]*np.inner(HP,Umod),axis=-1)) # refBlk x ops x atoms x 32add Overhauser corr.?1003 HbH = np.exp(-np.sum(HP[:,nxs,nxs,:]*np.inner(HP,Umod),axis=-1)) # refBlk x ops x atoms x ngl add Overhauser corr.? 1003 1004 else: 1004 1005 HbH = 1.0 1005 HdotX = np.inner(HP,Xmod) #refBlk x ops x atoms X 321006 HdotX = np.inner(HP,Xmod) #refBlk x ops x atoms X ngl 1006 1007 if len(H.shape) > 2: 1007 D = H[:,:,3:]*glTau[nxs,nxs,:] #m*e*tau; refBlk x ops X 321008 D = H[:,:,3:]*glTau[nxs,nxs,:] #m*e*tau; refBlk x ops X ngl 1008 1009 HdotXD = twopi*(HdotX+D[:,:,nxs,:]) 1009 1010 else: 1010 D = H[:,3:]*glTau[nxs,:] #m*e*tau; refBlk x ops X 321011 D = H[:,3:]*glTau[nxs,:] #m*e*tau; refBlk x ops X ngl 1011 1012 HdotXD = twopi*(HdotX+D[:,nxs,:]) 1012 1013 cosHA = np.sum(Fmod*HbH*np.cos(HdotXD)*glWt,axis=-1) #real part; refBlk X ops x atoms; sum for G-L integration … … 1014 1015 return np.array([cosHA,sinHA]) # 2 x refBlk x SGops x atoms 1015 1016 1016 def makeWavesDerv( waveTypes,FSSdata,XSSdata,USSdata,Mast):1017 def makeWavesDerv(ngl,waveTypes,FSSdata,XSSdata,USSdata,Mast): 1017 1018 ''' 1018 1019 FSSdata: array 2 x atoms x waves (sin,cos terms) … … 1021 1022 Mast: array orthogonalization matrix for Uij 1022 1023 ''' 1023 glTau,glWt = pwd.pygauleg(0.,1., 32) #get Gauss-Legendre intervals & weights1024 dT = 1 /32.1024 glTau,glWt = pwd.pygauleg(0.,1.,ngl) #get Gauss-Legendre intervals & weights 1025 dT = 1./ngl 1025 1026 dX = 0.0001 1026 1027 waveShapes = [FSSdata.T.shape,XSSdata.T.shape,USSdata.T.shape] … … 1032 1033 Bu = Mast*np.array(G2lat.U6toUij(USSdata[6:])).T #...cos Uij mods 1033 1034 nWaves = [Af.shape[1],Ax.shape[1],Au.shape[1]] 1034 nx = 0 1035 StauX = np.zeros((Ax.shape[0],Ax.shape[1],3,32)) #atoms x waves x 3 x 32 1036 CtauX = np.zeros((Ax.shape[0],Ax.shape[1],3,32)) 1037 ZtauXx = np.zeros((Ax.shape[0],3,32)) #atoms x XYZmax x 32 1038 ZtauXt = np.zeros((Ax.shape[0],2,32)) #atoms x Tminmax x 32 1035 StauX = np.zeros((Ax.shape[0],Ax.shape[1],3,ngl)) #atoms x waves x 3 x ngl 1036 CtauX = np.zeros((Ax.shape[0],Ax.shape[1],3,ngl)) 1037 ZtauXt = np.zeros((Ax.shape[0],2,ngl)) #atoms x Tminmax x ngl 1038 ZtauXx = np.zeros((Ax.shape[0],3,ngl)) #atoms x XYZmax x ngl 1039 1039 for iatm in range(Ax.shape[0]): 1040 1040 nx = 0 … … 1075 1075 XYZmax[i] += dX 1076 1076 ZtauXx[iatm][i] = (Zp-Zm)[i]/(2.*dX) 1077 tauX = np.arange(1.,nWaves[1]+1-nx)[:,nxs]*glTau #Xwaves x 321077 tauX = np.arange(1.,nWaves[1]+1-nx)[:,nxs]*glTau #Xwaves x ngl 1078 1078 if nx: 1079 StauX[iatm][:-nx] = np.ones_like(Ax)[iatm,nx:,:,nxs]*np.sin(twopi*tauX)[nxs,:,nxs,:] #atoms X waves X 3(xyz) X 321079 StauX[iatm][:-nx] = np.ones_like(Ax)[iatm,nx:,:,nxs]*np.sin(twopi*tauX)[nxs,:,nxs,:] #atoms X waves X 3(xyz) X ngl 1080 1080 CtauX[iatm][:-nx] = np.ones_like(Bx)[iatm,nx:,:,nxs]*np.cos(twopi*tauX)[nxs,:,nxs,:] #ditto 1081 1081 else: 1082 StauX[iatm] = np.ones_like(Ax)[iatm,:,:,nxs]*np.sin(twopi*tauX)[nxs,:,nxs,:] #atoms X waves X 3(xyz) X 321082 StauX[iatm] = np.ones_like(Ax)[iatm,:,:,nxs]*np.sin(twopi*tauX)[nxs,:,nxs,:] #atoms X waves X 3(xyz) X ngl 1083 1083 CtauX[iatm] = np.ones_like(Bx)[iatm,:,:,nxs]*np.cos(twopi*tauX)[nxs,:,nxs,:] #ditto 1084 1084 # GSASIIpath.IPyBreak() 1085 1085 if nWaves[0]: 1086 tauF = np.arange(1.,nWaves[0]+1-nf)[:,nxs]*glTau #Fwaves x 321086 tauF = np.arange(1.,nWaves[0]+1-nf)[:,nxs]*glTau #Fwaves x ngl 1087 1087 StauF = np.ones_like(Af)[:,:,nxs]*np.sin(twopi*tauF)[nxs,:,:] #also dFmod/dAf 1088 1088 CtauF = np.ones_like(Bf)[:,:,nxs]*np.cos(twopi*tauF)[nxs,:,:] #also dFmod/dBf … … 1091 1091 CtauF = 1.0 1092 1092 if nWaves[2]: 1093 tauU = np.arange(1.,nWaves[2]+1)[:,nxs]*glTau #Uwaves x 321093 tauU = np.arange(1.,nWaves[2]+1)[:,nxs]*glTau #Uwaves x ngl 1094 1094 StauU = np.ones_like(Au)[:,:,:,:,nxs]*np.sin(twopi*tauU)[nxs,:,nxs,nxs,:] #also dUmodA/dAu 1095 1095 CtauU = np.ones_like(Bu)[:,:,:,:,nxs]*np.cos(twopi*tauU)[nxs,:,nxs,nxs,:] #also dUmodB/dBu 1096 UmodA = Au[:,:,:,:,nxs]*StauU #atoms x waves x 3x3 x 321096 UmodA = Au[:,:,:,:,nxs]*StauU #atoms x waves x 3x3 x ngl 1097 1097 UmodB = Bu[:,:,:,:,nxs]*CtauU #ditto 1098 #derivs need to be ops x atoms x waves x 6uij; ops x atoms x waves x 32x 6uij before sum1098 #derivs need to be ops x atoms x waves x 6uij; ops x atoms x waves x ngl x 6uij before sum 1099 1099 StauU = np.rollaxis(np.rollaxis(np.swapaxes(StauU,2,4),-1),-1) 1100 1100 CtauU = np.rollaxis(np.rollaxis(np.swapaxes(CtauU,2,4),-1),-1) … … 1123 1123 dGdMuS = np.zeros(Mu) 1124 1124 1125 D = twopi*H[:,3][:,nxs]*glTau[nxs,:] #m*e*tau; ops X 321126 HdotX = twopi*np.inner(HP,Xmod) #ops x atoms X 321125 D = twopi*H[:,3][:,nxs]*glTau[nxs,:] #m*e*tau; ops X ngl 1126 HdotX = twopi*np.inner(HP,Xmod) #ops x atoms X ngl 1127 1127 HdotXD = HdotX+D[:,nxs,:] 1128 1128 if nWaves[2]: 1129 Umod = np.swapaxes((UmodAB),2,4) #atoms x waves x 32x 3x3 (symmetric so I can do this!)1130 HuH = np.sum(HP[:,nxs,nxs,nxs]*np.inner(HP,Umod),axis=-1) #ops x atoms x waves x 321131 HuH = np.sum(HP[:,nxs,nxs,nxs]*np.inner(HP,Umod),axis=-1) #ops x atoms x waves x 321132 HbH = np.exp(-np.sum(HuH,axis=-2)) # ops x atoms x 32; sum waves - OK vs Modulation version1133 part1 = -np.exp(-HuH)*Fmod #ops x atoms x waves x 321134 dUdAu = Hij[:,nxs,nxs,nxs,:]*np.rollaxis(G2lat.UijtoU6(SCtauU[0]),0,4)[nxs,:,:,:,:] #ops x atoms x waves x 32x 6sinUij1135 dUdBu = Hij[:,nxs,nxs,nxs,:]*np.rollaxis(G2lat.UijtoU6(SCtauU[1]),0,4)[nxs,:,:,:,:] #ops x atoms x waves x 32x 6cosUij1129 Umod = np.swapaxes((UmodAB),2,4) #atoms x waves x ngl x 3x3 (symmetric so I can do this!) 1130 HuH = np.sum(HP[:,nxs,nxs,nxs]*np.inner(HP,Umod),axis=-1) #ops x atoms x waves x ngl 1131 HuH = np.sum(HP[:,nxs,nxs,nxs]*np.inner(HP,Umod),axis=-1) #ops x atoms x waves x ngl 1132 HbH = np.exp(-np.sum(HuH,axis=-2)) # ops x atoms x ngl; sum waves - OK vs Modulation version 1133 part1 = -np.exp(-HuH)*Fmod #ops x atoms x waves x ngl 1134 dUdAu = Hij[:,nxs,nxs,nxs,:]*np.rollaxis(G2lat.UijtoU6(SCtauU[0]),0,4)[nxs,:,:,:,:] #ops x atoms x waves x ngl x 6sinUij 1135 dUdBu = Hij[:,nxs,nxs,nxs,:]*np.rollaxis(G2lat.UijtoU6(SCtauU[1]),0,4)[nxs,:,:,:,:] #ops x atoms x waves x ngl x 6cosUij 1136 1136 dGdMuCa = np.sum(part1[:,:,:,:,nxs]*dUdAu*np.cos(HdotXD)[:,:,nxs,:,nxs]*glWt[nxs,nxs,nxs,:,nxs],axis=-2) #ops x atoms x waves x 6uij; G-L sum 1137 1137 dGdMuCb = np.sum(part1[:,:,:,:,nxs]*dUdBu*np.cos(HdotXD)[:,:,nxs,:,nxs]*glWt[nxs,nxs,nxs,:,nxs],axis=-2) … … 1142 1142 else: 1143 1143 HbH = np.ones_like(HdotX) 1144 dHdXA = twopi*HP[:,nxs,nxs,nxs,:]*np.swapaxes(SCtauX[0],-1,-2)[nxs,:,:,:,:] #ops x atoms x sine waves x 32x xyz1144 dHdXA = twopi*HP[:,nxs,nxs,nxs,:]*np.swapaxes(SCtauX[0],-1,-2)[nxs,:,:,:,:] #ops x atoms x sine waves x ngl x xyz 1145 1145 dHdXB = twopi*HP[:,nxs,nxs,nxs,:]*np.swapaxes(SCtauX[1],-1,-2)[nxs,:,:,:,:] #ditto - cos waves 1146 1146 dGdMxCa = -np.sum((Fmod*HbH)[:,:,nxs,:,nxs]*(dHdXA*np.sin(HdotXD)[:,:,nxs,:,nxs])*glWt[nxs,nxs,nxs,:,nxs],axis=-2) … … 1152 1152 dGdMxS = np.concatenate((dGdMxSa,dGdMxSb),axis=-1) 1153 1153 # ZigZag/Block waves 1154 dHdXZt = twopi*np.ones(HP.shape[0])[:,nxs,nxs,nxs]*np.swapaxes(SCtauX[2],-1,-2)[nxs,:,:,:] #??ops x atoms x 32x 3(ZigZag/Block Tminmax)1155 dHdXZx = twopi*HP[:,nxs,nxs,:]*np.swapaxes(SCtauX[3],-1,-2)[nxs,:,:,:] #ops x atoms x 32x 3(ZigZag/Block XYZmax)1154 dHdXZt = twopi*np.ones(HP.shape[0])[:,nxs,nxs,nxs]*np.swapaxes(SCtauX[2],-1,-2)[nxs,:,:,:] #??ops x atoms x ngl x 3(ZigZag/Block Tminmax) 1155 dHdXZx = twopi*HP[:,nxs,nxs,:]*np.swapaxes(SCtauX[3],-1,-2)[nxs,:,:,:] #ops x atoms x ngl x 3(ZigZag/Block XYZmax) 1156 1156 dGdMzCt = -np.sum((Fmod*HbH)[:,:,:,nxs]*(dHdXZt*np.sin(HdotXD)[:,:,:,nxs])*glWt[nxs,nxs,:,nxs],axis=-2) 1157 1157 dGdMzCx = -np.sum((Fmod*HbH)[:,:,:,nxs]*(dHdXZx*np.sin(HdotXD)[:,:,:,nxs])*glWt[nxs,nxs,:,nxs],axis=-2) -
TabularUnified trunk/GSASIIphsGUI.py ¶
r2070 r2075 68 68 atan2d = lambda x,y: 180.*np.arctan2(y,x)/np.pi 69 69 70 def SetPhaseWindow(mainFrame,phasePage,mainSizer ):70 def SetPhaseWindow(mainFrame,phasePage,mainSizer,Scroll=0): 71 71 phasePage.SetSizer(mainSizer) 72 72 Size = mainSizer.GetMinSize() 73 73 Size[0] += 40 74 74 Size[1] = min(Size[1]+ 150,500) 75 phasePage.SetScrollbars(10,10,Size[0]/10-4,Size[1]/10-1) 75 76 phasePage.SetSize(Size) 76 phasePage.S etScrollbars(10,10,Size[0]/10-4,Size[1]/10-1)77 phasePage.Scroll(0,Scroll) 77 78 mainFrame.setSizePosLeft(Size) 78 mainFrame.SendSizeEvent()79 79 80 80 #def FindBondsToo(): #works but slow for large structures - keep as reference … … 319 319 ################################################################################ 320 320 321 def UpdateGeneral( ):321 def UpdateGeneral(Scroll=0): 322 322 '''Draw the controls for the General phase data subpage 323 323 ''' … … 715 715 def ModulatedSizer(name): 716 716 717 def OnSuperGp(event): 717 def OnSuperGp(event): #for HKLF needs to reject SSgps not agreeing with modVec! 718 718 SSymbol = superGp.GetValue() 719 719 E,SSGData = G2spc.SSpcGroup(generalData['SGData'],SSymbol) … … 771 771 superGp.Bind(wx.EVT_TEXT_ENTER,OnSuperGp) 772 772 modSizer.Add(superGp,0,WACV) 773 modSizer.Add(wx.StaticText(General,label=' Max index: '),0,WACV) 774 indChoice = ['1','2','3','4','5','6','7'] 775 Max = wx.ComboBox(General,-1,value='%d'%(generalData['SuperVec'][2]),choices=indChoice, 776 style=wx.CB_READONLY|wx.CB_DROPDOWN) 777 Max.Bind(wx.EVT_COMBOBOX,OnMax) 778 modSizer.Add(Max,0,WACV) 773 if PWDR: 774 modSizer.Add(wx.StaticText(General,label=' Max index: '),0,WACV) 775 indChoice = ['1','2','3','4','5','6','7'] 776 Max = wx.ComboBox(General,-1,value='%d'%(generalData['SuperVec'][2]),choices=indChoice, 777 style=wx.CB_READONLY|wx.CB_DROPDOWN) 778 Max.Bind(wx.EVT_COMBOBOX,OnMax) 779 modSizer.Add(Max,0,WACV) 779 780 ssSizer.Add(modSizer,0,WACV) 780 781 vecSizer = wx.FlexGridSizer(1,5,5,5) … … 796 797 modVal.SetBackgroundColour(VERY_LIGHT_GREY) 797 798 vecSizer.Add(modVal,0,WACV) 798 Ref = wx.CheckBox(General,label='Refine?') 799 Ref.SetValue(generalData['SuperVec'][1]) 800 Ref.Bind(wx.EVT_CHECKBOX, OnVecRef) 801 vecSizer.Add(Ref,0,WACV) 799 if PWDR: 800 Ref = wx.CheckBox(General,label='Refine?') 801 Ref.SetValue(generalData['SuperVec'][1]) 802 Ref.Bind(wx.EVT_CHECKBOX, OnVecRef) 803 vecSizer.Add(Ref,0,WACV) 802 804 ssSizer.Add(vecSizer) 803 805 return ssSizer … … 818 820 finally: 819 821 dlg.Destroy() 820 wx.CallAfter(UpdateGeneral )822 wx.CallAfter(UpdateGeneral,General.GetScrollPos(wx.VERTICAL)) 821 823 822 824 def OnResVal(event): … … 889 891 finally: 890 892 dlg.Destroy() 891 wx.CallAfter(UpdateGeneral )893 wx.CallAfter(UpdateGeneral,General.GetScrollPos(wx.VERTICAL)) 892 894 893 895 def OnNormElem(event): … … 981 983 def OnAlist(event): 982 984 MCSAdata['Algorithm'] = Alist.GetValue() 983 wx.CallAfter(UpdateGeneral )985 wx.CallAfter(UpdateGeneral,General.GetScrollPos(wx.VERTICAL)) 984 986 985 987 def OnSlope(event): … … 1171 1173 mainSizer.Add(MCSASizer()) 1172 1174 G2frame.dataFrame.SetStatusText('') 1173 SetPhaseWindow(G2frame.dataFrame,General,mainSizer )1175 SetPhaseWindow(G2frame.dataFrame,General,mainSizer,Scroll) 1174 1176 1175 1177 ################################################################################ … … 2336 2338 ################################################################################ 2337 2339 2338 def UpdateWavesData( ):2340 def UpdateWavesData(Scroll=0): 2339 2341 2340 2342 generalData = data['General'] … … 2346 2348 atom[-1][SS]['waveType']=waveType.GetValue() 2347 2349 atom[-1][SS]['Spos'] = [] 2348 UpdateWavesData( )2350 UpdateWavesData(G2frame.waveData.GetScrollPos(wx.VERTICAL)) 2349 2351 2350 2352 def OnShowWave(event): … … 2380 2382 nt = numVals[waveType] 2381 2383 atomData[iatm][-1][SS][item].append([[0.0 for i in range(nt)],False]) 2382 UpdateWavesData( )2384 UpdateWavesData(G2frame.waveData.GetScrollPos(wx.VERTICAL)) 2383 2385 2384 2386 def OnWaveVal(event): … … 2406 2408 iatm,item,iwave = Indx[Obj.GetId()] 2407 2409 del atomData[iatm][-1][SS][item][iwave] 2408 UpdateWavesData( )2410 UpdateWavesData(G2frame.waveData.GetScrollPos(wx.VERTICAL)) 2409 2411 2410 2412 waveSizer = wx.BoxSizer(wx.VERTICAL) … … 2509 2511 break 2510 2512 mainSizer.Add(WaveSizer(atm[-1][SS]['waveType'],atm[-1][SS][Stype],Stype,typeNames[Stype],Labels[Stype])) 2511 SetPhaseWindow(G2frame.dataFrame,waveData,mainSizer) 2512 2513 def On4DMapCompute(event): 2514 generalData = data['General'] 2515 mapData = generalData['4DmapData'] 2516 reflNames = mapData['RefList'] 2517 generalData['Map']['Flip'] = False 2518 if not len(reflNames): 2519 G2frame.ErrorDialog('Fourier map error','No reflections defined for Fourier map') 2520 return 2521 phaseName = generalData['Name'] 2522 ReflData = GetReflData(G2frame,phaseName,reflNames) 2523 if ReflData == None: return 2524 G2mth.Fourier4DMap(data,ReflData) 2525 data['Drawing']['contourLevel'] = 1. 2526 data['Drawing']['mapSize'] = 10. 2527 mapSig = np.std(mapData['rho']) 2528 print '4D '+mapData['MapType']+' computed: rhomax = %.3f rhomin = %.3f sigma = %.3f'%(np.max(mapData['rho']),np.min(mapData['rho']),mapSig) 2529 wx.CallAfter(UpdateWavesData) 2530 2513 2514 SetPhaseWindow(G2frame.dataFrame,G2frame.waveData,mainSizer,Scroll) 2515 2531 2516 ################################################################################ 2532 2517 #### Structure drawing GUI stuff … … 4085 4070 ref[4] = np.sqrt(1./G2lat.calc_rDsq2(H,G)) 4086 4071 iabsnt,ref[3],Uniq,phi = G2spc.GenHKLf(H,SGData) 4087 #G2frame.PatternTree.SetItemPyData(Id,[refDict,reflData]) #removed by BHT -- not needed!4088 4072 4089 4073 def OnDataCopy(event): -
TabularUnified trunk/GSASIIspc.py ¶
r2062 r2075 970 970 return SSGText,SSGTable 971 971 972 def SSGModCheck(Vec,modSymb ):972 def SSGModCheck(Vec,modSymb,newMod=True): 973 973 ''' Checks modulation vector compatibility with supersymmetry space group symbol. 974 Superspace group symbol takes precidence & the vector will be modified accordingly974 if newMod: Superspace group symbol takes precidence & the vector will be modified accordingly 975 975 ''' 976 976 Fracs = {'1/2':0.5,'1/3':1./3,'1':1.0,'0':0.,'a':0.,'b':0.,'g':0.} 977 977 modQ = [Fracs[mod] for mod in modSymb] 978 Vec = [0.1 if (vec == 0.0 and mod in ['a','b','g']) else vec for [vec,mod] in zip(Vec,modSymb)] 979 return [Q if mod not in ['a','b','g'] and vec != Q else vec for [vec,mod,Q] in zip(Vec,modSymb,modQ)], \ 980 [True if mod in ['a','b','g'] else False for mod in modSymb] 978 if newMod: 979 newVec = [0.1 if (vec == 0.0 and mod in ['a','b','g']) else vec for [vec,mod] in zip(Vec,modSymb)] 980 return [Q if mod not in ['a','b','g'] and vec != Q else vec for [vec,mod,Q] in zip(newVec,modSymb,modQ)], \ 981 [True if mod in ['a','b','g'] else False for mod in modSymb] 982 else: 983 return Vec,[True if mod in ['a','b','g'] else False for mod in modSymb] 981 984 982 985 def SSMT2text(Opr): -
TabularUnified trunk/GSASIIstrMath.py ¶
r2070 r2075 994 994 Tdata,Mdata,Fdata,Xdata,dXdata,IAdata,Uisodata,Uijdata = GetAtomFXU(pfx,calcControls,parmDict) 995 995 waveTypes,FSSdata,XSSdata,USSdata,MSSdata = GetAtomSSFXU(pfx,calcControls,parmDict) 996 n Waves,Fmod,Xmod,Umod,glTau,glWt = G2mth.makeWaves(waveTypes,FSSdata,XSSdata,USSdata,Mast)996 ngl,nWaves,Fmod,Xmod,Umod,glTau,glWt = G2mth.makeWaves(waveTypes,FSSdata,XSSdata,USSdata,Mast) 997 997 modQ = np.array([parmDict[pfx+'mV0'],parmDict[pfx+'mV1'],parmDict[pfx+'mV2']]) 998 998 FF = np.zeros(len(Tdata)) … … 1121 1121 mSize = len(Mdata) #no. atoms 1122 1122 waveTypes,FSSdata,XSSdata,USSdata,MSSdata = GetAtomSSFXU(pfx,calcControls,parmDict) 1123 n Waves,Fmod,Xmod,Umod,glTau,glWt = G2mth.makeWaves(waveTypes,FSSdata,XSSdata,USSdata,Mast)1124 waveShapes,SCtauF,SCtauX,SCtauU,UmodAB = G2mth.makeWavesDerv( waveTypes,FSSdata,XSSdata,USSdata,Mast)1123 ngl,nWaves,Fmod,Xmod,Umod,glTau,glWt = G2mth.makeWaves(waveTypes,FSSdata,XSSdata,USSdata,Mast) 1124 waveShapes,SCtauF,SCtauX,SCtauU,UmodAB = G2mth.makeWavesDerv(ngl,waveTypes,FSSdata,XSSdata,USSdata,Mast) 1125 1125 modQ = np.array([parmDict[pfx+'mV0'],parmDict[pfx+'mV1'],parmDict[pfx+'mV2']]) 1126 1126 FF = np.zeros(len(Tdata)) … … 1148 1148 dFdfl = np.zeros((nRef,nTwin)) 1149 1149 dFdtw = np.zeros((nRef,nTwin)) 1150 dFdGfA = np.zeros((nRef,nTwin,mSize,FSSdata.shape[1])) 1151 dFdGfB = np.zeros((nRef,nTwin,mSize,FSSdata.shape[1])) 1152 dFdGxA = np.zeros((nRef,nTwin,mSize,XSSdata.shape[1],3)) 1153 dFdGxB = np.zeros((nRef,nTwin,mSize,XSSdata.shape[1],3)) 1154 dFdGuA = np.zeros((nRef,nTwin,mSize,USSdata.shape[1],6)) 1155 dFdGuB = np.zeros((nRef,nTwin,mSize,USSdata.shape[1],6)) 1150 dFdGf = np.zeros((nRef,nTwin,mSize,FSSdata.shape[1])) 1151 dFdGx = np.zeros((nRef,nTwin,mSize,XSSdata.shape[1],3)) 1152 dFdGz = np.zeros((nRef,nTwin,mSize,5)) 1153 dFdGu = np.zeros((nRef,nTwin,mSize,USSdata.shape[1],6)) 1156 1154 else: 1157 1155 dFdfr = np.zeros((nRef,mSize)) … … 1242 1240 dfadGx = np.sum(fa[:,it,:,:,nxs,nxs]*dGdx[0][nxs,nxs,:,:,:,:]-fb[:,it,:,:,nxs,nxs]*dGdx[1][nxs,nxs,:,:,:,:],axis=1) 1243 1241 dfbdGx = np.sum(fb[:,it,:,:,nxs,nxs]*dGdx[0][nxs,nxs,:,:,:,:]+fa[:,it,:,:,nxs,nxs]*dGdx[1][nxs,nxs,:,:,:,:],axis=1) 1244 dfadGz = np.sum(fa[:,it,:,0,nxs,nxs]*dGd x[0][nxs,nxs,:,:,:]-fb[:,it,:,0,nxs,nxs]*dGdx[1][nxs,nxs,:,:,:],axis=1)1245 dfbdGz = np.sum(fb[:,it,:,0,nxs,nxs]*dGd x[0][nxs,nxs,:,:,:]+fa[:,it,:,0,nxs,nxs]*dGdx[1][nxs,nxs,:,:,:],axis=1)1242 dfadGz = np.sum(fa[:,it,:,0,nxs,nxs]*dGdz[0][nxs,nxs,:,:,:]-fb[:,it,:,0,nxs,nxs]*dGdz[1][nxs,nxs,:,:,:],axis=1) 1243 dfbdGz = np.sum(fb[:,it,:,0,nxs,nxs]*dGdz[0][nxs,nxs,:,:,:]+fa[:,it,:,0,nxs,nxs]*dGdz[1][nxs,nxs,:,:,:],axis=1) 1246 1244 dfadGu = np.sum(fa[:,it,:,:,nxs,nxs]*dGdu[0][nxs,nxs,:,:,:,:]-fb[:,it,:,:,nxs,nxs]*dGdu[1][nxs,nxs,:,:,:,:],axis=1) 1247 1245 dfbdGu = np.sum(fb[:,it,:,:,nxs,nxs]*dGdu[0][nxs,nxs,:,:,:,:]+fa[:,it,:,:,nxs,nxs]*dGdu[1][nxs,nxs,:,:,:,:],axis=1) … … 1278 1276 dFdGf[iref] = 2.*(SA*dfadGf[0]+SB*dfbdGf[1]) #array(nRef,natom,nwave,2) 1279 1277 dFdGx[iref] = 2.*(SA*dfadGx[0]+SB*dfbdGx[1]) #array(nRef,natom,nwave,6) 1278 dFdGz[iref] = 2.*(SA*dfadGz[0]+SB*dfbdGz[1]) #array(nRef,natom,5) 1280 1279 dFdGu[iref] = 2.*(SA*dfadGu[0]+SB*dfbdGu[1]) #array(nRef,natom,nwave,12) 1281 1280 # dFdfr[iref] = 2.*(fas[0]*dfadfr[0]+fas[1]*dfadfr[1])*Mdata/len(Uniq)+ \ … … 1303 1302 dFdGf[iref] = [2.*TwMask[it]*(SA[it]*dfadGf[1]+SB[it]*dfbdGf[1]) for it in range(nTwin)] 1304 1303 dFdGx[iref] = [2.*TwMask[it]*(SA[it]*dfadGx[1]+SB[it]*dfbdGx[1]) for it in range(nTwin)] 1305 dFdGz[iref] = [2.*TwMask[it]*(SA[it]*dfadG x[1]+SB[it]*dfbdGx[1]) for it in range(nTwin)]1304 dFdGz[iref] = [2.*TwMask[it]*(SA[it]*dfadGz[1]+SB[it]*dfbdGz[1]) for it in range(nTwin)] 1306 1305 dFdGu[iref] = [2.*TwMask[it]*(SA[it]*dfadGu[1]+SB[it]*dfbdGu[1]) for it in range(nTwin)] 1307 1306 else: #these are good for no twin single crystals … … 1319 1318 2.*fbs[0]*np.array([np.sum(dfbdba*dBabdA),np.sum(-dfbdba*parmDict[phfx+'BabA']*SQfactor*dBabdA)]).T 1320 1319 #loop over atoms - each dict entry is list of derivatives for all the reflections 1321 # GSASIIpath.IPyBreak()1322 1320 if not iref%100 : 1323 1321 print ' %d derivative time %.4f\r'%(iref,time.time()-time0), 1324 for i in range(len(Mdata)): #loop over atoms 1322 for i in range(len(Mdata)): #loop over atoms 1325 1323 dFdvDict[pfx+'Afrac:'+str(i)] = dFdfr.T[i] 1326 1324 dFdvDict[pfx+'dAx:'+str(i)] = dFdx.T[0][i] … … 1337 1335 dFdvDict[pfx+'Fsin:'+str(i)+':'+str(j)] = dFdGf.T[0][j][i] 1338 1336 dFdvDict[pfx+'Fcos:'+str(i)+':'+str(j)] = dFdGf.T[1][j][i] 1339 for j in range(XSSdata.shape[1]): #loop over waves 1340 dFdvDict[pfx+'Xsin:'+str(i)+':'+str(j)] = dFdGx.T[0][j][i] 1341 dFdvDict[pfx+'Ysin:'+str(i)+':'+str(j)] = dFdGx.T[1][j][i] 1342 dFdvDict[pfx+'Zsin:'+str(i)+':'+str(j)] = dFdGx.T[2][j][i] 1343 dFdvDict[pfx+'Xcos:'+str(i)+':'+str(j)] = dFdGx.T[3][j][i] 1344 dFdvDict[pfx+'Ycos:'+str(i)+':'+str(j)] = dFdGx.T[4][j][i] 1345 dFdvDict[pfx+'Zcos:'+str(i)+':'+str(j)] = dFdGx.T[5][j][i] 1346 dFdvDict[pfx+'Tmin:'+str(i)+':0'] = dFdGz.T[0][i] 1347 dFdvDict[pfx+'Tmax:'+str(i)+':0'] = dFdGz.T[0][i] 1348 dFdvDict[pfx+'Xmax:'+str(i)+':0'] = dFdGz.T[0][i] 1349 dFdvDict[pfx+'Ymax:'+str(i)+':0'] = dFdGz.T[0][i] 1350 dFdvDict[pfx+'Zmax:'+str(i)+':0'] = dFdGz.T[0][i] 1337 nx = 0 1338 if waveTypes[i] in ['Block','ZigZag']: 1339 nx = 1 1340 dFdvDict[pfx+'Tmin:'+str(i)+':0'] = dFdGz.T[0][i] #ZigZag/Block waves (if any) 1341 dFdvDict[pfx+'Tmax:'+str(i)+':0'] = dFdGz.T[1][i] 1342 dFdvDict[pfx+'Xmax:'+str(i)+':0'] = dFdGz.T[2][i] 1343 dFdvDict[pfx+'Ymax:'+str(i)+':0'] = dFdGz.T[3][i] 1344 dFdvDict[pfx+'Zmax:'+str(i)+':0'] = dFdGz.T[4][i] 1345 for j in range(XSSdata.shape[1]-nx): #loop over waves 1346 dFdvDict[pfx+'Xsin:'+str(i)+':'+str(j+nx)] = dFdGx.T[0][j][i] 1347 dFdvDict[pfx+'Ysin:'+str(i)+':'+str(j+nx)] = dFdGx.T[1][j][i] 1348 dFdvDict[pfx+'Zsin:'+str(i)+':'+str(j+nx)] = dFdGx.T[2][j][i] 1349 dFdvDict[pfx+'Xcos:'+str(i)+':'+str(j+nx)] = dFdGx.T[3][j][i] 1350 dFdvDict[pfx+'Ycos:'+str(i)+':'+str(j+nx)] = dFdGx.T[4][j][i] 1351 dFdvDict[pfx+'Zcos:'+str(i)+':'+str(j+nx)] = dFdGx.T[5][j][i] 1351 1352 for j in range(USSdata.shape[1]): #loop over waves 1352 1353 dFdvDict[pfx+'U11sin:'+str(i)+':'+str(j)] = dFdGu.T[0][j][i] … … 1363 1364 dFdvDict[pfx+'U23cos:'+str(i)+':'+str(j)] = 2.*dFdGu.T[11][j][i] 1364 1365 1366 # GSASIIpath.IPyBreak() 1365 1367 dFdvDict[phfx+'BabA'] = dFdbab.T[0] 1366 1368 dFdvDict[phfx+'BabU'] = dFdbab.T[1] … … 2644 2646 try: 2645 2647 aname = name.split(pfx)[1][:2] 2646 if aname not in ['Af','dA','AU','RB','Xs','Xc','Ys','Yc','Zs','Zc',' U1','U2','U3']: continue # skip anything not an atom or rigid body param2648 if aname not in ['Af','dA','AU','RB','Xs','Xc','Ys','Yc','Zs','Zc','Tm','Xm','Ym','Zm','U1','U2','U3']: continue # skip anything not an atom or rigid body param 2647 2649 except IndexError: 2648 2650 continue
Note: See TracChangeset
for help on using the changeset viewer.