Changeset 3830
- Timestamp:
- Feb 27, 2019 10:20:33 AM (5 years ago)
- Location:
- trunk
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/GSASIIimage.py
r3815 r3830 229 229 return 0,0,0,0 230 230 231 def makeRing(dsp,ellipse,pix,reject,scalex,scaley,image ):231 def makeRing(dsp,ellipse,pix,reject,scalex,scaley,image,mul=1): 232 232 'Needs a doc string' 233 233 def ellipseC(): … … 245 245 sphi = sind(phi-90.) 246 246 ring = [] 247 C = int(ellipseC()) #ring circumference247 C = int(ellipseC())*mul #ring circumference in mm 248 248 azm = [] 249 249 for i in range(0,C,1): #step around ring in 1mm increments … … 1129 1129 if len(Ring): 1130 1130 ellipse = FitEllipse(R['ImxyObs'].T) 1131 ringxy,ringazm = makeRing(ring['Dcalc'],ellipse,0,0.,scalex,scaley,Image )1131 ringxy,ringazm = makeRing(ring['Dcalc'],ellipse,0,0.,scalex,scaley,Image,5) 1132 1132 ring['ImxyCalc'] = np.array(ringxy).T[:2] 1133 1133 ringint = np.array([float(Image[int(x*scalex),int(y*scaley)]) for y,x in np.array(ringxy)[:,:2]]) 1134 1134 ringint /= np.mean(ringint) 1135 print (' %s %.3f %s %.3f '%('d-spacing',ring['Dcalc'],'sig(MRD):',np.sqrt(np.var(ringint))))1135 print (' %s %.3f %s %.3f %s %d'%('d-spacing',ring['Dcalc'],'sig(MRD):',np.sqrt(np.var(ringint)),'# points:',len(ringint))) 1136 1136 RingsAI.append(np.array(zip(ringazm,ringint)).T) 1137 1137 return RingsAI -
trunk/GSASIIspc.py
r3795 r3830 1662 1662 for icen,cen in enumerate(SGData['SGCen']): 1663 1663 SSCen[icen,0:3] = cen 1664 SSGData['SSGCen'] = SSCen 1664 if 'BNSlattsym' in SGData and '_' in SGData['BNSlattsym'][0]: 1665 Ncen = len(SGData['SGCen']) 1666 for icen in range(Ncen//2,Ncen): 1667 SSCen[icen,3] = 0.5 1668 SSGData['SSGCen'] = SSCen%1. 1665 1669 SSGData['SSGOps'] = [] 1666 1670 for iop,op in enumerate(SGData['SGOps']): -
trunk/GSASIIstrMath.py
r3825 r3830 1483 1483 ''' 1484 1484 phfx = pfx.split(':')[0]+hfx 1485 g = nl.inv(G)1486 1485 ast = np.sqrt(np.diag(G)) 1487 ainv = np.sqrt(np.diag(g))1488 1486 GS = G/np.outer(ast,ast) 1489 Ginv = g/np.outer(ainv,ainv)1490 1487 uAmat = G2lat.Gmat2AB(GS)[0] 1491 1488 Mast = twopisq*np.multiply.outer(ast,ast) … … 1496 1493 SSGMT = np.array([ops[0].T for ops in SSGData['SSGOps']]) 1497 1494 SSGT = np.array([ops[1] for ops in SSGData['SSGOps']]) 1495 SSCen = SSGData['SSGCen'] 1498 1496 FFtables = calcControls['FFtables'] 1499 1497 BLtables = calcControls['BLtables'] … … 1511 1509 modQ = np.array([parmDict[pfx+'mV0'],parmDict[pfx+'mV1'],parmDict[pfx+'mV2']]) 1512 1510 1513 if parmDict[pfx+'isMag']: #T ODO: fix the math1511 if parmDict[pfx+'isMag']: #This part correct for making modulated mag moments on equiv atoms 1514 1512 GSdata = np.inner(Gdata.T,np.swapaxes(SGMT,1,2)) #apply sym. ops.--> Natm,Nops,Nxyz 1515 MSmod = np.array([np.roll(Mmod ,int(ngl*ssgt[3]),2) for ssgt in SSGT]) #Nops,Natm,Ntau,Mxyz1513 MSmod = np.array([np.roll(Mmod+Gdata.T[:,nxs,:],-int(round(ngl*ssgt[3])),2) for ssgt in SSGT]) #Nops,Natm,Ntau,Mxyz 1516 1514 if SGData['SGInv'] and not SGData['SGFixed']: #inversion if any 1517 1515 GSdata = np.hstack((GSdata,-GSdata)) 1518 1516 MSmod = np.vstack((MSmod,-MSmod)) 1519 GSdata = np.hstack([GSdata for icen in range(Ncen)]) #dup over cell centering1520 MSmod = np.vstack([ MSmod for icen in range(Ncen)]) #dup over cell centering - right??1517 GSdata = np.hstack([GSdata for cen in SSCen]) #dup over cell centering - Natm,Nops,Mxyz 1518 MSmod = np.vstack([np.roll(MSmod,-int(round(ngl*cen[3])),2) for cen in SSCen]) #dup over cell centering - right?? 1521 1519 1522 GSdata = GSdata[:,:,nxs,:]+np.swapaxes(MSmod,0,1) #Natm,Nops,Ntau,Mxyz 1523 GSdata = SGData['MagMom'][nxs,:,nxs,nxs]*GSdata #flip vectors according to spin flip * det(opM) 1524 mXYZ = np.array([[xyz[0] for xyz in list(G2spc.GenAtom(xyz,SGData,All=True,Move=True))] for xyz in (Xdata+dXdata).T]) 1525 mXYZ = np.array(np.inner(mXYZ,modQ)*ngl,dtype=int) 1526 RGSdata = np.array([[np.roll(GSdata[i,j],mXYZ[i,j],0) for j in range(mXYZ.shape[1])] for i in range(mXYZ.shape[0])]) 1527 Kdata = np.inner(RGSdata,uAmat).T #Cartesian unit vectors 1528 SMag = np.sqrt(np.sum(Kdata**2,axis=0)) 1529 Kdata /= SMag #mxyz,ntau,nops,natm 1520 #another try - keep MSmod separated & calc Kdata without modulation 1521 GSdata = SGData['MagMom'][nxs,:,nxs]*GSdata #flip vectors according to spin flip * det(opM) 1522 Kdata = np.inner(GSdata,uAmat).T #Cartesian unit vectors 1523 SMag = np.sqrt(np.sum(Kdata**2,axis=0)) #magnitude of fixed part of moment 1524 Kdata /= SMag #mxyz,nops,natm- unit Cart. vector for fixed component of moment 1525 1526 # GSMdata has modulation 1527 GSMdata = np.swapaxes(MSmod,0,1) #Natm,Nops,Ntau,Mxyz 1528 mXYZ = np.array([[xyz[0] for xyz in list(G2spc.GenAtom(xyz,SGData,All=True,Move=True))] for xyz in (Xdata+dXdata).T])%1. 1529 mXYZ = np.array(np.rint(ngl*np.inner(mXYZ,modQ)),dtype=int) 1530 RGSdata = np.array([[np.roll(GSMdata[i,j],-mXYZ[i,j],0) for j in range(mXYZ.shape[1])] for i in range(mXYZ.shape[0])]) 1531 KMdata = np.inner(RGSdata,uAmat).T #Cartesian unit vectors 1532 SMMag = np.sqrt(np.sum(KMdata**2,axis=0)) 1533 KMdata /= SMMag #mxyz,ntau,nops,natm 1530 1534 1531 1535 FF = np.zeros(len(Tdata)) … … 1603 1607 HM = np.inner(Bmat,HP.T) #put into cartesian space 1604 1608 HM = HM/np.sqrt(np.sum(HM**2,axis=0)) #Gdata = MAGS & HM = UVEC in magstrfc.for both OK 1605 eDotK = np.sum(HM[:,:,nxs,nxs,nxs]*Kdata[:,nxs,:,:,:],axis=0) 1606 Q = HM[:,:,nxs,nxs,nxs]*eDotK[nxs,:,:,:,:]-Kdata[:,nxs,:,:,:] #Mxyz,Nref,Ntau,Nop,Natm 1609 # eDotK = np.sum(HM[:,:,nxs,nxs]*Kdata[:,nxs,:,:],axis=0) 1610 eDotKM = np.sum(HM[:,:,nxs,nxs,nxs]*KMdata[:,nxs,:,:,:],axis=0) 1611 # Q = HM[:,:,nxs,nxs]*eDotK[nxs,:,:,:]-Kdata[:,nxs,:,:] #Mxyz,Nref,Nop,Natm 1612 QM = HM[:,:,nxs,nxs,nxs]*eDotKM[nxs,:,:,:,:]-KMdata[:,nxs,:,:,:] #Mxyz,Nref,Nop,Natm 1607 1613 1608 fam = (Q*TMcorr[nxs,:,nxs,nxs,:]*cosm[nxs,:,nxs,:,:]*SMag[nxs,nxs,:,:,:]) #Mxyz,Nref,Ntau,Nop,Natm1609 fbm = (Q*TMcorr[nxs,:,nxs,nxs,:]*sinm[nxs,:,nxs,:,:]*SMag[nxs,nxs,:,:,:]) 1614 # fam = Q*TMcorr[nxs,:,nxs,:]*cosm[nxs,:,:,:]*SMag[nxs,nxs,:,:] #Mxyz,Nref,Nop,Natm 1615 # fbm = Q*TMcorr[nxs,:,nxs,:]*sinm[nxs,:,:,:]*SMag[nxs,nxs,:,:] 1610 1616 1611 fa s = np.sum(np.sum(fam,axis=-1),axis=-1)/ngl #xyz,Nref,ntau; sum ops & atoms1612 fb s = np.sum(np.sum(fbm,axis=-1),axis=-1)/ngl #ditto1617 fam = QM*TMcorr[nxs,:,nxs,nxs,:]*cosm[nxs,:,nxs,:,:]*SMMag[nxs,nxs,:,:,:]/2. #Mxyz,Nref,Ntau,Nops,Natm 1618 fbm = QM*TMcorr[nxs,:,nxs,nxs,:]*sinm[nxs,:,nxs,:,:]*SMMag[nxs,nxs,:,:,:]/2. 1613 1619 1614 refl.T[10] = np.sum(np.sum(fas,axis=-1),axis=0)**2+np.sum(np.sum(fbs,axis=-1),axis=0)**2 #square of sums 1620 fams = np.sum(fam**2,axis=2)/ngl 1621 fbms = np.sum(fbm**2,axis=2)/ngl 1622 1623 fas = np.sum(np.sum(fams,axis=-1),axis=-1) #xyz,Nref; sum ops & atoms 1624 fbs = np.sum(np.sum(fbms,axis=-1),axis=-1) 1625 1626 refl.T[10] = np.sum(fas,axis=0)**2+np.sum(fbs,axis=0)**2 #square of sums 1615 1627 # refl.T[11] = mphase[:,0,0] #ignore f' & f" 1616 1628
Note: See TracChangeset
for help on using the changeset viewer.