Changeset 3372
- Timestamp:
- May 6, 2018 1:42:01 PM (5 years ago)
- Location:
- trunk
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/GSASIIpath.py
r3303 r3372 740 740 741 741 BinaryPathLoaded = False 742 def SetBinaryPath(printInfo= True):742 def SetBinaryPath(printInfo=False): 743 743 ''' 744 744 Add location of GSAS-II shared libraries (binaries: .so or .pyd files) to path -
trunk/GSASIIplot.py
r3366 r3372 6039 6039 except TypeError: 6040 6040 return 6041 if Data['linescan'] :6041 if Data['linescan'][0]: 6042 6042 Page.xlim1 = Plot1.get_xlim() 6043 6043 new,plotNum,Page,Plot,lim = G2frame.G2plotNB.FindPlotTab('2D Powder Image','mpl',newImage=False) -
trunk/GSASIIstrMath.py
r3353 r3372 770 770 # print 'sf time %.4f, nref %d, blkSize %d'%(time.time()-time0,nRef,blkSize) 771 771 772 def MagStructureFactor2(refDict,G,hfx,pfx,SGData,calcControls,parmDict):773 ''' Compute neutron magnetic structure factors for all h,k,l for phase774 puts the result, F^2, in each ref[8] in refList775 operates on blocks of 100 reflections for speed776 input:777 778 :param dict refDict: where779 'RefList' list where each ref = h,k,l,it,d,...780 'FF' dict of form factors - filed in below781 :param np.array G: reciprocal metric tensor782 :param str pfx: phase id string783 :param dict SGData: space group info. dictionary output from SpcGroup784 :param dict calcControls:785 :param dict ParmDict:786 787 '''788 ast = np.sqrt(np.diag(G))789 GS = G/np.outer(ast,ast)790 uAmat = G2lat.Gmat2AB(GS)[0]791 Mast = twopisq*np.multiply.outer(ast,ast)792 SGMT = np.array([ops[0].T for ops in SGData['SGOps']])793 SGT = np.array([ops[1] for ops in SGData['SGOps']])794 Ncen = len(SGData['SGCen'])795 Nops = len(SGMT)*Ncen796 if not SGData['SGFixed']:797 Nops *= (1+SGData['SGInv'])798 MFtables = calcControls['MFtables']799 Bmat = G2lat.Gmat2AB(G)[1]800 TwinLaw = np.ones(1)801 # TwinLaw = np.array([[[1,0,0],[0,1,0],[0,0,1]],])802 # TwDict = refDict.get('TwDict',{})803 # if 'S' in calcControls[hfx+'histType']:804 # NTL = calcControls[phfx+'NTL']805 # NM = calcControls[phfx+'TwinNMN']+1806 # TwinLaw = calcControls[phfx+'TwinLaw']807 # TwinFr = np.array([parmDict[phfx+'TwinFr:'+str(i)] for i in range(len(TwinLaw))])808 # TwinInv = list(np.where(calcControls[phfx+'TwinInv'],-1,1))809 Tdata,Mdata,Fdata,Xdata,dXdata,IAdata,Uisodata,Uijdata,Gdata = \810 GetAtomFXU(pfx,calcControls,parmDict)811 if not Xdata.size: #no atoms in phase!812 return813 Mag = np.sqrt(np.array([np.inner(mag,np.inner(mag,GS)) for mag in Gdata.T]))814 Gdata = np.inner(Gdata.T,SGMT).T #apply sym. ops.815 if SGData['SGInv'] and not SGData['SGFixed']:816 Gdata = np.hstack((Gdata,-Gdata)) #inversion if any817 Gdata = np.hstack([Gdata for icen in range(Ncen)]) #dup over cell centering--> [Mxyz,nops,natms]818 Gdata = SGData['MagMom'][nxs,:,nxs]*Gdata #flip vectors according to spin flip * det(opM)819 Mag = np.tile(Mag[:,nxs],Nops).T #make Mag same length as Gdata820 Gdata = Gdata/Mag #normalze mag. moments821 Gdata = np.inner(Gdata.T,uAmat).T*np.sqrt(nl.det(GS))822 Uij = np.array(G2lat.U6toUij(Uijdata))823 bij = Mast*Uij.T824 blkSize = 100 #no. of reflections in a block - size seems optimal825 nRef = refDict['RefList'].shape[0]826 SQ = 1./(2.*refDict['RefList'].T[4])**2827 refDict['FF']['El'] = list(MFtables.keys())828 refDict['FF']['MF'] = np.zeros((nRef,len(MFtables)))829 for iel,El in enumerate(refDict['FF']['El']):830 refDict['FF']['MF'].T[iel] = G2el.MagScatFac(MFtables[El],SQ)831 #reflection processing begins here - big arrays!832 iBeg = 0833 while iBeg < nRef:834 iFin = min(iBeg+blkSize,nRef)835 refl = refDict['RefList'][iBeg:iFin] #array(blkSize,nItems)836 H = refl.T[:3] #array(blkSize,3)837 # H = np.squeeze(np.inner(H.T,TwinLaw)) #maybe array(blkSize,nTwins,3) or (blkSize,3)838 # TwMask = np.any(H,axis=-1)839 # if TwinLaw.shape[0] > 1 and TwDict: #need np.inner(TwinLaw[?],TwDict[iref][i])*TwinInv[i]840 # for ir in range(blkSize):841 # iref = ir+iBeg842 # if iref in TwDict:843 # for i in TwDict[iref]:844 # for n in range(NTL):845 # H[ir][i+n*NM] = np.inner(TwinLaw[n*NM],np.array(TwDict[iref][i])*TwinInv[i+n*NM])846 # TwMask = np.any(H,axis=-1)847 SQ = 1./(2.*refl.T[4])**2 #array(blkSize)848 SQfactor = 4.0*SQ*twopisq #ditto prev.849 Uniq = np.inner(H.T,SGMT)850 Phi = np.inner(H.T,SGT)851 phase = twopi*(np.inner(Uniq,(dXdata+Xdata).T).T+Phi.T).T852 biso = -SQfactor*Uisodata[:,nxs]853 Tiso = np.repeat(np.where(biso<1.,np.exp(biso),1.0),len(SGT)*len(TwinLaw),axis=1).T854 HbH = -np.sum(Uniq.T*np.swapaxes(np.inner(bij,Uniq),2,-1),axis=1)855 Tuij = np.where(HbH<1.,np.exp(HbH),1.0).T856 Tindx = np.array([refDict['FF']['El'].index(El) for El in Tdata])857 MF = refDict['FF']['MF'][iBeg:iFin].T[Tindx].T #Nref,Natm858 TMcorr = 0.539*(np.reshape(Tiso,Tuij.shape)*Tuij)[:,0,:]*Fdata*Mdata*MF/(2*Nops) #Nref,Natm859 if SGData['SGInv']:860 if not SGData['SGFixed']:861 mphase = np.hstack((phase,-phase)) #OK862 else:863 mphase = phase864 else:865 mphase = phase #866 mphase = np.array([mphase+twopi*np.inner(cen,H.T)[:,nxs,nxs] for cen in SGData['SGCen']])867 mphase = np.concatenate(mphase,axis=1) #Nref,full Nop,Natm868 sinm = np.sin(mphase) #ditto - match magstrfc.for869 cosm = np.cos(mphase) #ditto870 HM = np.inner(Bmat.T,H.T) #put into cartesian space871 HM = HM/np.sqrt(np.sum(HM**2,axis=0)) #Gdata = MAGS & HM = UVEC in magstrfc.for both OK872 eDotK = np.sum(HM[:,:,nxs,nxs]*Gdata[:,nxs,:,:],axis=0)873 Q = HM[:,:,nxs,nxs]*eDotK[nxs,:,:,:]-Gdata[:,nxs,:,:] #xyz,Nref,Nop,Natm = BPM in magstrfc.for OK874 fam = Q*TMcorr[nxs,:,nxs,:]*cosm[nxs,:,:,:]*Mag[nxs,nxs,:,:] #ditto875 fbm = Q*TMcorr[nxs,:,nxs,:]*sinm[nxs,:,:,:]*Mag[nxs,nxs,:,:] #ditto876 fams = np.sum(np.sum(fam,axis=-1),axis=-1) #xyz,Nref877 fbms = np.sum(np.sum(fbm,axis=-1),axis=-1) #ditto878 refl.T[9] = np.sum(fams**2,axis=0)+np.sum(fbms**2,axis=0)879 refl.T[7] = np.copy(refl.T[9])880 refl.T[10] = 0.0 #atan2d(fbs[0],fas[0]) - what is phase for mag refl?881 # if 'P' in calcControls[hfx+'histType']: #PXC, PNC & PNT: F^2 = A[0]^2 + A[1]^2 + B[0]^2 + B[1]^2882 # refl.T[9] = np.sum(fas**2,axis=0)+np.sum(fbs**2,axis=0) #add fam**2 & fbm**2 here883 # refl.T[10] = atan2d(fbs[0],fas[0]) #ignore f' & f"884 # else: #HKLF: F^2 = (A[0]+A[1])^2 + (B[0]+B[1])^2885 # if len(TwinLaw) > 1:886 # refl.T[9] = np.sum(fas[:,:,0],axis=0)**2+np.sum(fbs[:,:,0],axis=0)**2 #FcT from primary twin element887 # refl.T[7] = np.sum(TwinFr*TwMask*np.sum(fas,axis=0)**2,axis=-1)+ \888 # np.sum(TwinFr*TwMask*np.sum(fbs,axis=0)**2,axis=-1) #Fc sum over twins889 # refl.T[10] = atan2d(fbs[0].T[0],fas[0].T[0]) #ignore f' & f" & use primary twin890 # else: # checked correct!!891 # refl.T[9] = np.sum(fas,axis=0)**2+np.sum(fbs,axis=0)**2892 # refl.T[7] = np.copy(refl.T[9])893 # refl.T[10] = atan2d(fbs[0],fas[0]) #ignore f' & f"894 ## refl.T[10] = atan2d(np.sum(fbs,axis=0),np.sum(fas,axis=0)) #include f' & f"895 iBeg += blkSize896 # print 'sf time %.4f, nref %d, blkSize %d'%(time.time()-time0,nRef,blkSize)897 898 772 def StructureFactorDerv2(refDict,G,hfx,pfx,SGData,calcControls,parmDict): 899 773 '''Compute structure factor derivatives on blocks of reflections - for powders/nontwins only … … 1055 929 return dFdvDict 1056 930 1057 def StructureFactorDervMag(refDict,G,hfx,pfx,SGData,calcControls,parmDict): 931 def MagStructureFactor2(refDict,G,hfx,pfx,SGData,calcControls,parmDict): 932 ''' Compute neutron magnetic structure factors for all h,k,l for phase 933 puts the result, F^2, in each ref[8] in refList 934 operates on blocks of 100 reflections for speed 935 input: 936 937 :param dict refDict: where 938 'RefList' list where each ref = h,k,l,it,d,... 939 'FF' dict of form factors - filed in below 940 :param np.array G: reciprocal metric tensor 941 :param str pfx: phase id string 942 :param dict SGData: space group info. dictionary output from SpcGroup 943 :param dict calcControls: 944 :param dict ParmDict: 945 946 ''' 947 g = nl.inv(G) 948 ast = np.sqrt(np.diag(G)) 949 ainv = np.sqrt(np.diag(g)) 950 GS = G/np.outer(ast,ast) 951 Ginv = g/np.outer(ainv,ainv) 952 uAmat = G2lat.Gmat2AB(GS)[0] 953 Mast = twopisq*np.multiply.outer(ast,ast) 954 SGMT = np.array([ops[0].T for ops in SGData['SGOps']]) 955 SGT = np.array([ops[1] for ops in SGData['SGOps']]) 956 Ncen = len(SGData['SGCen']) 957 Nops = len(SGMT)*Ncen 958 if not SGData['SGFixed']: 959 Nops *= (1+SGData['SGInv']) 960 MFtables = calcControls['MFtables'] 961 Bmat = G2lat.Gmat2AB(G)[1] 962 TwinLaw = np.ones(1) 963 # TwinLaw = np.array([[[1,0,0],[0,1,0],[0,0,1]],]) 964 # TwDict = refDict.get('TwDict',{}) 965 # if 'S' in calcControls[hfx+'histType']: 966 # NTL = calcControls[phfx+'NTL'] 967 # NM = calcControls[phfx+'TwinNMN']+1 968 # TwinLaw = calcControls[phfx+'TwinLaw'] 969 # TwinFr = np.array([parmDict[phfx+'TwinFr:'+str(i)] for i in range(len(TwinLaw))]) 970 # TwinInv = list(np.where(calcControls[phfx+'TwinInv'],-1,1)) 971 Tdata,Mdata,Fdata,Xdata,dXdata,IAdata,Uisodata,Uijdata,Gdata = \ 972 GetAtomFXU(pfx,calcControls,parmDict) 973 if not Xdata.size: #no atoms in phase! 974 return 975 Mag = np.array([np.sqrt(np.inner(mag,np.inner(mag,Ginv))) for mag in Gdata.T]) 976 Gdata = np.inner(Gdata.T,SGMT).T #apply sym. ops. 977 if SGData['SGInv'] and not SGData['SGFixed']: 978 Gdata = np.hstack((Gdata,-Gdata)) #inversion if any 979 Gdata = np.hstack([Gdata for icen in range(Ncen)]) #dup over cell centering--> [Mxyz,nops,natms] 980 Gdata = SGData['MagMom'][nxs,:,nxs]*Gdata #flip vectors according to spin flip * det(opM) 981 Mag = np.tile(Mag[:,nxs],Nops).T #make Mag same length as Gdata 982 Kdata = np.inner(Gdata.T,uAmat).T*np.sqrt(nl.det(Ginv))/Mag #Cartesian unit vectors 983 Uij = np.array(G2lat.U6toUij(Uijdata)) 984 bij = Mast*Uij.T 985 blkSize = 100 #no. of reflections in a block - size seems optimal 986 nRef = refDict['RefList'].shape[0] 987 SQ = 1./(2.*refDict['RefList'].T[4])**2 988 refDict['FF']['El'] = list(MFtables.keys()) 989 refDict['FF']['MF'] = np.zeros((nRef,len(MFtables))) 990 for iel,El in enumerate(refDict['FF']['El']): 991 refDict['FF']['MF'].T[iel] = G2el.MagScatFac(MFtables[El],SQ) 992 #reflection processing begins here - big arrays! 993 iBeg = 0 994 while iBeg < nRef: 995 iFin = min(iBeg+blkSize,nRef) 996 refl = refDict['RefList'][iBeg:iFin] #array(blkSize,nItems) 997 H = refl.T[:3].T #array(blkSize,3) 998 # H = np.squeeze(np.inner(H.T,TwinLaw)) #maybe array(blkSize,nTwins,3) or (blkSize,3) 999 # TwMask = np.any(H,axis=-1) 1000 # if TwinLaw.shape[0] > 1 and TwDict: #need np.inner(TwinLaw[?],TwDict[iref][i])*TwinInv[i] 1001 # for ir in range(blkSize): 1002 # iref = ir+iBeg 1003 # if iref in TwDict: 1004 # for i in TwDict[iref]: 1005 # for n in range(NTL): 1006 # H[ir][i+n*NM] = np.inner(TwinLaw[n*NM],np.array(TwDict[iref][i])*TwinInv[i+n*NM]) 1007 # TwMask = np.any(H,axis=-1) 1008 SQ = 1./(2.*refl.T[4])**2 #array(blkSize) 1009 SQfactor = 4.0*SQ*twopisq #ditto prev. 1010 Uniq = np.inner(H,SGMT) 1011 Phi = np.inner(H,SGT) 1012 phase = twopi*(np.inner(Uniq,(dXdata+Xdata).T).T+Phi.T).T 1013 biso = -SQfactor*Uisodata[:,nxs] 1014 Tiso = np.repeat(np.where(biso<1.,np.exp(biso),1.0),len(SGT)*len(TwinLaw),axis=1).T 1015 HbH = -np.sum(Uniq.T*np.swapaxes(np.inner(bij,Uniq),2,-1),axis=1) 1016 Tuij = np.where(HbH<1.,np.exp(HbH),1.0).T 1017 Tindx = np.array([refDict['FF']['El'].index(El) for El in Tdata]) 1018 MF = refDict['FF']['MF'][iBeg:iFin].T[Tindx].T #Nref,Natm 1019 TMcorr = 0.539*(np.reshape(Tiso,Tuij.shape)*Tuij)[:,0,:]*Fdata*Mdata*MF/(2*Nops) #Nref,Natm 1020 if SGData['SGInv']: 1021 if not SGData['SGFixed']: 1022 mphase = np.hstack((phase,-phase)) #OK 1023 else: 1024 mphase = phase 1025 else: 1026 mphase = phase # 1027 mphase = np.array([mphase+twopi*np.inner(cen,H)[:,nxs,nxs] for cen in SGData['SGCen']]) 1028 mphase = np.concatenate(mphase,axis=1) #Nref,full Nop,Natm 1029 sinm = np.sin(mphase) #ditto - match magstrfc.for 1030 cosm = np.cos(mphase) #ditto 1031 HM = np.inner(Bmat.T,H) #put into cartesian space 1032 HM = HM/np.sqrt(np.sum(HM**2,axis=0)) #Kdata = MAGS & HM = UVEC in magstrfc.for both OK 1033 eDotK = np.sum(HM[:,:,nxs,nxs]*Kdata[:,nxs,:,:],axis=0) 1034 Q = HM[:,:,nxs,nxs]*eDotK[nxs,:,:,:]-Kdata[:,nxs,:,:] #xyz,Nref,Nop,Natm = BPM in magstrfc.for OK 1035 fam = Q*TMcorr[nxs,:,nxs,:]*cosm[nxs,:,:,:]*Mag[nxs,nxs,:,:] #ditto 1036 fbm = Q*TMcorr[nxs,:,nxs,:]*sinm[nxs,:,:,:]*Mag[nxs,nxs,:,:] #ditto 1037 fams = np.sum(np.sum(fam,axis=-1),axis=-1) #xyz,Nref 1038 fbms = np.sum(np.sum(fbm,axis=-1),axis=-1) #ditto 1039 refl.T[9] = np.sum(fams**2,axis=0)+np.sum(fbms**2,axis=0) 1040 refl.T[7] = np.copy(refl.T[9]) 1041 refl.T[10] = 0.0 #atan2d(fbs[0],fas[0]) - what is phase for mag refl? 1042 # if 'P' in calcControls[hfx+'histType']: #PXC, PNC & PNT: F^2 = A[0]^2 + A[1]^2 + B[0]^2 + B[1]^2 1043 # refl.T[9] = np.sum(fas**2,axis=0)+np.sum(fbs**2,axis=0) #add fam**2 & fbm**2 here 1044 # refl.T[10] = atan2d(fbs[0],fas[0]) #ignore f' & f" 1045 # else: #HKLF: F^2 = (A[0]+A[1])^2 + (B[0]+B[1])^2 1046 # if len(TwinLaw) > 1: 1047 # refl.T[9] = np.sum(fas[:,:,0],axis=0)**2+np.sum(fbs[:,:,0],axis=0)**2 #FcT from primary twin element 1048 # refl.T[7] = np.sum(TwinFr*TwMask*np.sum(fas,axis=0)**2,axis=-1)+ \ 1049 # np.sum(TwinFr*TwMask*np.sum(fbs,axis=0)**2,axis=-1) #Fc sum over twins 1050 # refl.T[10] = atan2d(fbs[0].T[0],fas[0].T[0]) #ignore f' & f" & use primary twin 1051 # else: # checked correct!! 1052 # refl.T[9] = np.sum(fas,axis=0)**2+np.sum(fbs,axis=0)**2 1053 # refl.T[7] = np.copy(refl.T[9]) 1054 # refl.T[10] = atan2d(fbs[0],fas[0]) #ignore f' & f" 1055 ## refl.T[10] = atan2d(np.sum(fbs,axis=0),np.sum(fas,axis=0)) #include f' & f" 1056 iBeg += blkSize 1057 # print 'sf time %.4f, nref %d, blkSize %d'%(time.time()-time0,nRef,blkSize) 1058 1059 def MagStructureFactorDerv(refDict,G,hfx,pfx,SGData,calcControls,parmDict): 1058 1060 '''Compute magnetic structure factor derivatives on blocks of reflections - for powders/nontwins only 1059 1061 input: … … 1072 1074 ''' 1073 1075 #TODO: fix mag math - moments parallel to crystal axes 1076 g = nl.inv(G) 1074 1077 ast = np.sqrt(np.diag(G)) 1078 ainv = np.sqrt(np.diag(g)) 1075 1079 GS = G/np.outer(ast,ast) 1076 uAmat,uBmat = G2lat.Gmat2AB(GS) 1080 Ginv = g/np.outer(ainv,ainv) 1081 uAmat = G2lat.Gmat2AB(GS)[0] 1077 1082 Mast = twopisq*np.multiply.outer(ast,ast) 1078 1083 SGMT = np.array([ops[0].T for ops in SGData['SGOps']]) … … 1089 1094 return {} 1090 1095 mSize = len(Mdata) 1091 Mag = np.sqrt(np.array([np.inner(mag,np.inner(mag,GS)) for mag in Gdata.T])) 1092 dGdM = np.array([np.inner(mag,GS) for mag in Gdata.T]).T/Mag 1093 1096 Mag = np.array([np.sqrt(np.inner(mag,np.inner(mag,Ginv))) for mag in Gdata.T]) 1097 dMdm = np.inner(Gdata.T,Ginv).T/Mag 1094 1098 Gdata = np.inner(Gdata.T,SGMT).T #apply sym. ops. 1099 dG = np.inner(np.eye(3),SGMT).T 1095 1100 if SGData['SGInv'] and not SGData['SGFixed']: 1096 1101 Gdata = np.hstack((Gdata,-Gdata)) #inversion if any 1102 dG = np.hstack((dG,-dG)) 1097 1103 Gdata = np.hstack([Gdata for icen in range(Ncen)]) #dup over cell centering 1104 dG = np.hstack([dG for icen in range(Ncen)]) 1098 1105 Gdata = SGData['MagMom'][nxs,:,nxs]*Gdata #flip vectors according to spin flip 1099 1106 Mag = np.tile(Mag[:,nxs],Nops).T #make Mag same length as Gdata 1100 Gdata = Gdata/Mag #normalze mag. moments 1101 Gdata = np.inner(Gdata.T,uAmat).T*np.sqrt(nl.det(GS)) #make unit vectors in Cartesian space 1102 # dGdm = (1.-Gdata**2) #1/Mag removed - canceled out in dqmx=sum(dqdm*dGdm) 1107 VGi = np.sqrt(nl.det(Ginv)) 1108 Kdata = np.inner(Gdata.T,uAmat).T*VGi/Mag #make unit vectors in Cartesian space 1109 dG = np.inner(dG.T,uAmat).T*VGi 1110 dkdG = (np.inner(np.ones(3),uAmat)*VGi)[:,nxs,nxs]/Mag[nxs,:,:] 1111 dkdm = dkdG-Kdata*dMdm[:,nxs,:]/Mag[nxs,:,:] 1103 1112 dFdMx = np.zeros((nRef,mSize,3)) 1104 1113 Uij = np.array(G2lat.U6toUij(Uijdata)) … … 1149 1158 cosm = np.cos(mphase) #ditto 1150 1159 HM = np.inner(Bmat.T,H) #put into cartesian space 1151 HM = HM/np.sqrt(np.sum(HM**2,axis=0)) #unit vector for H 1152 eDotK = np.sum(HM[:,:,nxs,nxs]*Gdata[:,nxs,:,:],axis=0) 1153 Q = HM[:,:,nxs,nxs]*eDotK[nxs,:,:,:]-Gdata[:,nxs,:,:] #Mxyz,Nref,Nop,Natm = BPM in magstrfc.for OK 1160 HM = HM/np.sqrt(np.sum(HM**2,axis=0)) #unit cartesian vector for H 1161 eDotK = np.sum(HM[:,:,nxs,nxs]*Kdata[:,nxs,:,:],axis=0) 1162 deDotK = HM.T[nxs,:,nxs,:]*dG.T[:,nxs,:,:] #Mxyz,Nref,Nops 1163 Q = HM[:,:,nxs,nxs]*eDotK[nxs,:,:,:]-Kdata[:,nxs,:,:] #Mxyz,Nref,Nop,Natm = BPM in magstrfc.for OK 1164 dqdk = np.sum(HM[:,:,nxs,nxs]*deDotK-dG.T[:,nxs,:,:],axis=3) #Nref,Nops,Mxyyz 1154 1165 NQ = np.where(np.abs(Q)>0.,1./np.abs(Q),0.) #this sort of works esp for 1 axis moments 1155 # NQ2 = np.where(np.abs(Q)>0.,1./np.sqrt(np.sum(Q**2,axis=0)),0.) 1156 # dqdm = np.array([np.outer(hm,hm)-np.eye(3) for hm in HM.T]).T #Mxyz,Mxyz,Nref (3x3 matrix) 1157 # dqmx = dqdm[:,:,:,nxs,nxs]*dGdm[:,nxs,nxs,:,:] 1158 # dqmx2 = np.sum(dqmx,axis=1) #matrix * vector = vector 1159 # dqmx1 = np.swapaxes(np.swapaxes(np.inner(dqdm.T,dGdm.T),0,1),2,3) 1160 dmx = (NQ*Q*dGdM[:,nxs,nxs,:]) #just use dpdM term & ignore dqdM term(small) 1161 # dmx = (NQ*Q*dGdM[:,nxs,:,:]-Q*dqmx2)/Mag 1166 # dqdk = (HM*HM)-1. 1167 dqdm = dqdk[:,:,:,nxs]*dkdm[:,nxs,:,:] 1168 dmx = Q*dMdm[:,nxs,nxs,:] 1169 dmx += dqdm*Mag[nxs,nxs,:,:] 1162 1170 1163 1171 fam = Q*TMcorr[nxs,:,nxs,:]*cosm[nxs,:,:,:]*Mag[nxs,nxs,:,:] #Mxyz,Nref,Nop,Natm … … 1495 1503 sinm = np.sin(mphase) #ditto - match magstrfc.for 1496 1504 cosm = np.cos(mphase) #ditto 1497 HM = np.inner(Bmat .T,H) #put into cartesian space1505 HM = np.inner(Bmat,H) #put into cartesian space 1498 1506 HM = HM/np.sqrt(np.sum(HM**2,axis=0)) #Gdata = MAGS & HM = UVEC in magstrfc.for both OK 1499 1507 eDotK = np.sum(HM[:,:,nxs,nxs]*Gdata[:,nxs,:,:],axis=0) … … 3832 3840 else: 3833 3841 if Phase['General']['Type'] == 'magnetic': 3834 dFdvDict = StructureFactorDervMag(refDict,G,hfx,pfx,SGData,calcControls,parmDict)3842 dFdvDict = MagStructureFactorDerv(refDict,G,hfx,pfx,SGData,calcControls,parmDict) 3835 3843 else: 3836 3844 dFdvDict = StructureFactorDerv2(refDict,G,hfx,pfx,SGData,calcControls,parmDict) … … 4109 4117 else: #correct!! 4110 4118 if Phase['General']['Type'] == 'magnetic': #is this going to work for single crystal mag data? 4111 dFdvDict = StructureFactorDervMag(refDict,G,hfx,pfx,SGData,calcControls,parmDict)4119 dFdvDict = MagStructureFactorDerv(refDict,G,hfx,pfx,SGData,calcControls,parmDict) 4112 4120 else: 4113 4121 dFdvDict = StructureFactorDerv2(refDict,G,hfx,pfx,SGData,calcControls,parmDict)
Note: See TracChangeset
for help on using the changeset viewer.