Changeset 2481
- Timestamp:
- Sep 30, 2016 10:33:12 AM (7 years ago)
- Location:
- trunk
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/GSASII.py
r2479 r2481 3656 3656 rbVary,rbDict = G2stIO.GetRigidBodyModels(rigidbodyDict,Print=False) 3657 3657 rbIds = rigidbodyDict.get('RBIds',{'Vector':[],'Residue':[]}) 3658 Natoms,atomIndx,phaseVary,phaseDict,pawleyLookup,FFtable,BLtable, maxSSwave = G2stIO.GetPhaseData(Phases,RestraintDict=None,rbIds=rbIds,Print=False)3658 Natoms,atomIndx,phaseVary,phaseDict,pawleyLookup,FFtable,BLtable,MFtable,maxSSwave = G2stIO.GetPhaseData(Phases,RestraintDict=None,rbIds=rbIds,Print=False) 3659 3659 hapVary,hapDict,controlDict = G2stIO.GetHistogramPhaseData(Phases,Histograms,Print=False) 3660 3660 histVary,histDict,controlDict = G2stIO.GetHistogramData(Histograms,Print=False) -
trunk/GSASIIconstrGUI.py
r2480 r2481 239 239 240 240 # create a list of the phase variables 241 Natoms,atomIndx,phaseVary,phaseDict,pawleyLookup,FFtable,BLtable, maxSSwave = G2stIO.GetPhaseData(Phases,rbIds=rbIds,Print=False)241 Natoms,atomIndx,phaseVary,phaseDict,pawleyLookup,FFtable,BLtable,MFtable,maxSSwave = G2stIO.GetPhaseData(Phases,rbIds=rbIds,Print=False) 242 242 phaseList = [] 243 243 for item in phaseDict: -
trunk/GSASIIlattice.py
r2480 r2481 39 39 import GSASIImath as G2mth 40 40 import GSASIIspc as G2spc 41 import GSASIIElem as G2elem 41 42 GSASIIpath.SetVersionNumber("$Revision$") 42 43 # trig functions in degrees … … 238 239 :param Trans: array transformation matrix 239 240 :param Vec: array transformation vector 240 :param ifMag: bool True if convert to magnetic phase 241 :param ifMag: bool True if convert to magnetic phase; 242 if True all nonmagnetic atoms will be removed 241 243 ''' 242 244 … … 259 261 newPhase['General']['AtomPtrs'] = [cx,ct,cs,cia] 260 262 magAtoms = [] 263 Landeg = 2.0 261 264 for atom in newAtoms: 262 magAtoms.append(atom[:cx+4]+[0.,0.,0.]+atom[cx+4:]) 265 if len(G2elem.GetMFtable([atom[ct],],[Landeg,])): 266 magAtoms.append(atom[:cx+4]+[0.,0.,0.]+atom[cx+4:]) 263 267 newAtoms = magAtoms 264 268 newPhase['Draw Atoms'] = [] -
trunk/GSASIIphsGUI.py
r2480 r2481 1383 1383 dlg.Destroy() 1384 1384 phaseName = newPhase['General']['Name'] 1385 if ifMag: 1386 phaseName += ' mag' 1385 1387 newPhase = G2lat.TransformPhase(data,newPhase,Trans,Vec,ifMag) 1386 1388 newPhase['General']['Map'] = mapDefault.copy() -
trunk/GSASIIpwd.py
r2473 r2481 622 622 key = pfx+'Back;'+str(iBak) 623 623 if bakType == 'chebyschev': 624 ybi = parmDict[key]*( 2.*(xdata-xdata[0])/dt-1.)**iBak624 ybi = parmDict[key]*(-1.+2.*(xdata-xdata[0])/dt)**iBak 625 625 elif bakType == 'cosine': 626 ybi = parmDict[key]*npcosd( xdata*iBak)626 ybi = parmDict[key]*npcosd(180.*xdata*iBak/xdata[-1]) 627 627 yb += ybi 628 628 sumBk[0] = np.sum(yb) … … 744 744 for iBak in range(nBak): 745 745 if bakType == 'chebyschev': 746 dydb[iBak] = ( 2.*(xdata-xdata[0])/dt-1.)**iBak746 dydb[iBak] = (-1.+2.*(xdata-xdata[0])/dt)**iBak 747 747 elif bakType == 'cosine': 748 dydb[iBak] = npcosd( xdata*iBak)748 dydb[iBak] = npcosd(180.*xdata*iBak/xdata[-1]) 749 749 elif bakType in ['Q^2 power series','Q^-2 power series']: 750 750 QT = 1. -
trunk/GSASIIstrIO.py
r2478 r2481 1099 1099 BLtables.update(BLtable) 1100 1100 phaseDict[pfx+'isMag'] = False 1101 SGData = General['SGData'] 1102 SGtext,SGtable = G2spc.SGPrint(SGData) 1101 1103 if General['Type'] == 'magnetic': 1102 1104 MFtable = G2el.GetMFtable(General['AtomTypes'],General['Lande g']) 1103 1105 MFtables.update(MFtable) 1104 1106 phaseDict[pfx+'isMag'] = True 1107 SpnFlp = SGData['SpnFlp'] 1105 1108 Atoms = PhaseData[name]['Atoms'] 1106 1109 if Atoms and not General.get('doPawley'): … … 1108 1111 AtLookup = G2mth.FillAtomLookUp(Atoms,cia+8) 1109 1112 PawleyRef = PhaseData[name].get('Pawley ref',[]) 1110 SGData = General['SGData']1111 SGtext,SGtable = G2spc.SGPrint(SGData)1112 1113 cell = General['Cell'] 1113 1114 A = G2lat.cell2A(cell[1:7]) … … 1208 1209 G2mv.StoreEquivalence(name,equiv[1:]) 1209 1210 if 'M' in at[ct+1]: 1210 pass #magnetic moment vary here 1211 SytSym,Mul,Nop = G2spc.SytSym(at[cx:cx+3],SGData) 1212 if SpnFlp[Nop] > 0.: #black use p 1213 mId,mCoef = G2spc.GetCSpqinel(SytSym)[0] 1214 else: #red use q 1215 mId,mCoef = G2spc.GetCSpqinel(SytSym)[1] 1216 names = [pfx+'AMx:'+str(i),pfx+'AMy:'+str(i),pfx+'AMz:'+str(i)] 1217 equivs = [[],[],[]] 1218 for j in range(3): 1219 if mId[j] > 0: 1220 phaseVary.append(names[j]) 1221 equivs[mId[j]-1].append([names[j],mCoef[j]]) 1222 for equiv in equivs: 1223 if len(equiv) > 1: 1224 name = equiv[0][0] 1225 coef = equiv[0][1] 1226 for eqv in equiv[1:]: 1227 eqv[1] /= coef 1228 G2mv.StoreEquivalence(name,(eqv,)) 1211 1229 if General.get('Modulated',False): 1212 1230 AtomSS = at[-1]['SS1'] … … 1969 1987 names = {cx:pfx+'Ax:'+str(i),cx+1:pfx+'Ay:'+str(i),cx+2:pfx+'Az:'+str(i),cx+3:pfx+'Afrac:'+str(i), 1970 1988 cia+1:pfx+'AUiso:'+str(i),cia+2:pfx+'AU11:'+str(i),cia+3:pfx+'AU22:'+str(i),cia+4:pfx+'AU33:'+str(i), 1971 cia+5:pfx+'AU12:'+str(i),cia+6:pfx+'AU13:'+str(i),cia+7:pfx+'AU23:'+str(i)} 1989 cia+5:pfx+'AU12:'+str(i),cia+6:pfx+'AU13:'+str(i),cia+7:pfx+'AU23:'+str(i), 1990 cx+4:pfx+'AMx:'+str(i),cx+5:pfx+'AMy:'+str(i),cx+6:pfx+'AMz:'+str(i)} 1972 1991 for ind in range(cx,cx+4): 1973 1992 at[ind] = parmDict[names[ind]] … … 1984 2003 else: 1985 2004 for ind in range(cia+2,cia+8): 2005 at[ind] = parmDict[names[ind]] 2006 if names[ind] in sigDict: 2007 atomsSig[str(i)+':'+str(ind)] = sigDict[names[ind]] 2008 if General['Type'] == 'magnetic': 2009 for ind in range(cx+4,cx+7): 1986 2010 at[ind] = parmDict[names[ind]] 1987 2011 if names[ind] in sigDict: -
trunk/GSASIIstrMain.py
r2478 r2481 200 200 print >>printFile,135*'-' 201 201 try: 202 covData = {} 202 203 IfOK,Rvals,result,covMatrix,sig = RefineCore(Controls,Histograms,Phases,restraintDict, 203 204 rigidbodyDict,parmDict,varyList,calcControls,pawleyLookup,ifPrint,printFile,dlg) -
trunk/GSASIIstrMath.py
r2480 r2481 767 767 if 'N' in calcControls[hfx+'histType'] and parmDict[pfx+'isMag']: 768 768 MF = np.repeat(refDict['FF']['MF'][iBeg:iFin].T[Tindx].T,len(TwinLaw),axis=0) #Nref,Natm 769 TMcorr = 0.5 39*Tcorr[:,0,:]*MF#Nref,Natm769 TMcorr = 0.5*0.539*Tcorr[:,0,:]*MF*len(SGMT)/Mdata #Nref,Natm 770 770 if SGData['SGInv']: 771 771 mphase = np.hstack((phase,-phase)) … … 780 780 eDotK = np.sum(HM[:,:,nxs,nxs]*Gdata[:,nxs,:,:],axis=0) 781 781 Q = -HM[:,:,nxs,nxs]*eDotK[nxs,:,:,:]+Gdata[:,nxs,:,:] #xyz,Nref,Nop,Natm = BPM in magstrfc.for OK 782 fam = Q*TMcorr[nxs,:,nxs,:]*SGData['MagMom'][nxs,nxs,:,nxs]*cosm[nxs,:,:,:] #ditto783 fbm = Q*TMcorr[nxs,:,nxs,:]*SGData['MagMom'][nxs,nxs,:,nxs]*sinm[nxs,:,:,:] #ditto782 fam = Q*TMcorr[nxs,:,nxs,:]*SGData['MagMom'][nxs,nxs,:,nxs]*cosm[nxs,:,:,:]*Mag[nxs,nxs,:,:] #ditto 783 fbm = Q*TMcorr[nxs,:,nxs,:]*SGData['MagMom'][nxs,nxs,:,nxs]*sinm[nxs,:,:,:]*Mag[nxs,nxs,:,:] #ditto 784 784 fams = np.sum(np.sum(fam,axis=-1),axis=-1) #xyz,Nref 785 785 fbms = np.sum(np.sum(fbm,axis=-1),axis=-1) #ditto 786 GSASIIpath.IPyBreak()786 # GSASIIpath.IPyBreak() 787 787 if 'T' in calcControls[hfx+'histType']: #fa,fb are 2 X blkSize X nTwin X nOps x nAtoms 788 788 fa = np.array([np.reshape(((FF+FP).T-Bab).T,cosp.shape)*cosp*Tcorr,-np.reshape(Flack*FPP,sinp.shape)*sinp*Tcorr]) … … 800 800 refl.T[10] = atan2d(fbs[0],fas[0]) #ignore f' & f" 801 801 if 'N' in calcControls[hfx+'histType'] and parmDict[pfx+'isMag']: 802 refl.T[9] += np.sum(fams**2,axis=0)+np.sum(fbms**2,axis=0)802 refl.T[9] = np.sum(fams**2,axis=0)+np.sum(fbms**2,axis=0) 803 803 else: #HKLF: F^2 = (A[0]+A[1])^2 + (B[0]+B[1])^2 804 804 if len(TwinLaw) > 1: … … 811 811 refl.T[7] = np.copy(refl.T[9]) 812 812 refl.T[10] = atan2d(fbs[0],fas[0]) #ignore f' & f" 813 if 'N' in calcControls[hfx+'histType'] and parmDict[pfx+'isMag']: 814 refl.T[9] = np.sum(fams**2,axis=0)+np.sum(fbms**2,axis=0) 813 815 # GSASIIpath.IPyBreak() 814 816 # refl.T[10] = atan2d(np.sum(fbs,axis=0),np.sum(fas,axis=0)) #include f' & f" … … 1050 1052 GetAtomFXU(pfx,calcControls,parmDict) 1051 1053 mSize = len(Mdata) 1054 if parmDict[pfx+'isMag']: 1055 Mag = np.sqrt(np.sum(Gdata**2,axis=0)) #magnitude of moments for uniq atoms 1056 Gdata = np.where(Mag>0.,Gdata/Mag,0.) #normalze mag. moments 1057 Gdata = np.inner(Bmat,Gdata.T) #convert to crystal space 1058 Gdata = np.inner(Gdata.T,SGMT).T #apply sym. ops. 1059 if SGData['SGInv']: 1060 Gdata = np.hstack((Gdata,-Gdata)) #inversion if any 1061 Gdata = np.repeat(Gdata,Ncen,axis=1) #dup over cell centering 1062 Gdata = SGData['MagMom'][nxs,:,nxs]*Gdata #flip vectors according to spin flip 1063 Gdata = np.inner(Amat,Gdata.T) #convert back to cart. space MXYZ, Natoms, NOps*Inv*Ncen 1064 Gdata = np.swapaxes(Gdata,1,2) # put Natoms last 1065 # GSASIIpath.IPyBreak() 1066 Mag = np.tile(Mag[:,nxs],len(SGMT)*Ncen).T 1067 if SGData['SGInv']: 1068 Mag = np.repeat(Mag,2,axis=0) #Mag same length as Gdata 1069 dFdMx = np.zeros((nRef,mSize,3)) 1052 1070 FF = np.zeros(len(Tdata)) 1053 1071 if 'NC' in calcControls[hfx+'histType']: … … 1109 1127 else: 1110 1128 fotp = FPP*Tcorr 1129 if 'N' in calcControls[hfx+'histType'] and parmDict[pfx+'isMag']: 1130 MF = np.repeat(refDict['FF']['MF'][iBeg:iFin].T[Tindx].T,len(TwinLaw),axis=0) #Nref,Natm 1131 TMcorr = 0.5*0.539*Tcorr[:,0,:]*MF*len(SGMT)/Mdata #Nref,Natm 1132 if SGData['SGInv']: 1133 mphase = np.hstack((phase,-phase)) 1134 else: 1135 mphase = phase 1136 mphase = np.array([mphase+twopi*np.inner(cen,H)[:,nxs,nxs] for cen in SGData['SGCen']]) 1137 mphase = np.concatenate(mphase,axis=1) #Nref,Nop,Natm 1138 sinm = np.sin(mphase) #ditto - match magstrfc.for 1139 cosm = np.cos(mphase) #ditto 1140 HM = np.inner(Bmat.T,H) #put into cartesian space 1141 HM = HM/np.sqrt(np.sum(HM**2,axis=0)) #Gdata = MAGS & HM = UVEC in magstrfc.for both OK 1142 eDotK = np.sum(HM[:,:,nxs,nxs]*Gdata[:,nxs,:,:],axis=0) 1143 Q = -HM[:,:,nxs,nxs]*eDotK[nxs,:,:,:]+Gdata[:,nxs,:,:] #xyz,Nref,Nop,Natm = BPM in magstrfc.for OK 1144 fam = Q*TMcorr[nxs,:,nxs,:]*SGData['MagMom'][nxs,nxs,:,nxs]*cosm[nxs,:,:,:]*Mag[nxs,nxs,:,:] #ditto 1145 fbm = Q*TMcorr[nxs,:,nxs,:]*SGData['MagMom'][nxs,nxs,:,nxs]*sinm[nxs,:,:,:]*Mag[nxs,nxs,:,:] #ditto 1146 fams = np.sum(np.sum(fam,axis=-1),axis=-1) #xyz,Nref 1147 fbms = np.sum(np.sum(fbm,axis=-1),axis=-1) #ditto 1148 # GSASIIpath.IPyBreak() 1111 1149 if 'T' in calcControls[hfx+'histType']: 1112 1150 fa = np.array([fot*cosp,-np.reshape(Flack*FPP,sinp.shape)*sinp*Tcorr]) … … 1147 1185 if 'P' in calcControls[hfx+'histType']: #checked perfect for centro & noncentro 1148 1186 dFdfr[iBeg:iFin] = 2.*np.sum(fas[:,:,nxs]*dfadfr+fbs[:,:,nxs]*dfbdfr,axis=0)*Mdata/len(SGMT) 1149 # dFdfr[iBeg:iFin] = 2.*(fas[0,:,nxs]*dfadfr[0]+fas[1,:,nxs]*dfadfr[1])*Mdata/len(SGMT)+ \1150 # 2.*(fbs[0,:,nxs]*dfbdfr[0]+fbs[1,:,nxs]*dfbdfr[1])*Mdata/len(SGMT)1151 1187 dFdx[iBeg:iFin] = 2.*np.sum(fas[:,:,nxs,nxs]*dfadx+fbs[:,:,nxs,nxs]*dfbdx,axis=0) 1152 # dFdx[iBeg:iFin] = 2.*(fas[0,:,nxs,nxs]*dfadx[0]+fas[1,:,nxs,nxs]*dfadx[1])+ \1153 # 2.*(fbs[0,:,nxs,nxs]*dfbdx[0]+fbs[1,:,nxs,nxs]*dfbdx[1])1154 1188 dFdui[iBeg:iFin] = 2.*np.sum(fas[:,:,nxs]*dfadui+fbs[:,:,nxs]*dfbdui,axis=0) 1155 # dFdui[iBeg:iFin] = 2.*(fas[0,:,nxs]*dfadui[0]+fas[1,:,nxs]*dfadui[1])+ \1156 # 2.*(fbs[0,:,nxs]*dfbdui[0]+fbs[1,:,nxs]*dfbdui[1])1157 1189 dFdua[iBeg:iFin] = 2.*np.sum(fas[:,:,nxs,nxs]*dfadua+fbs[:,:,nxs,nxs]*dfbdua,axis=0) 1158 # dFdua[iBeg:iFin] = 2.*(fas[0,:,nxs,nxs]*dfadua[0]+fas[1,:,nxs,nxs]*dfadua[1])+ \1159 # 2.*(fbs[0,:,nxs,nxs]*dfbdua[0]+fbs[1,:,nxs,nxs]*dfbdua[1])1160 1190 else: 1161 1191 dFdfr[iBeg:iFin] = (2.*SA[:,nxs]*(dfadfr[0]+dfadfr[1])+2.*SB[:,nxs]*(dfbdfr[0]+dfbdfr[1]))*Mdata/len(SGMT)
Note: See TracChangeset
for help on using the changeset viewer.