Changeset 3867 for trunk/GSASIIstrMath.py
- Timestamp:
- Apr 2, 2019 3:16:24 PM (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/GSASIIstrMath.py
r3865 r3867 1509 1509 if parmDict[pfx+'isMag']: #This part correct for making modulated mag moments on equiv atoms 1510 1510 1511 GSdata0 = np.inner(Gdata.T,np.swapaxes(SGMT,1,2)) #apply sym. ops.--> Natm,Nops,Nxyz 1512 if SGData['SGInv'] and not SGData['SGFixed']: #inversion if any 1513 GSdata0 = np.hstack((GSdata0,-GSdata0)) 1514 GSdata0 = np.hstack([GSdata0 for cen in SSCen]) #dup over cell centering - Natm,Nops,Mxyz 1515 GSdata0 = SGData['MagMom'][nxs,:,nxs]*GSdata0 #flip vectors according to spin flip * det(opM) 1516 GSdata0 = np.swapaxes(GSdata0,0,1) #Nop,Natm,Mxyz 1517 GSdata0 = np.inner(GSdata0,uAmat.T) #--> cartesian 1511 mXYZ = np.array([[xyz[0] for xyz in list(G2spc.GenAtom(xyz,SGData,All=True,Move=True))] for xyz in (Xdata+dXdata).T])%1. #Natn,Nop,xyz 1512 Tmag = G2mth.MagMod(ngl,mXYZ,modQ,MSSdata,SGData,SSGData) #Ntau,Nops,Natm,Mxyz 1518 1513 1519 mXYZ = np.array([[xyz[0] for xyz in list(G2spc.GenAtom(xyz,SGData,All=True,Move=True))] for xyz in (Xdata+dXdata).T])%1. #Natn,Nop,xyz 1520 Mmod,SMag = G2mth.MagMod(ngl,mXYZ,modQ,MSSdata,SGData,SSGData) #Re cos/Im sin,Nops,Natm,Nwaves,Mxyz 1521 # MmodA = np.inner(MmodA,uAmat.T) #make cartesian 1522 # MmodB = np.inner(MmodB,uAmat.T) 1514 if not SGData['SGGray']: 1515 GSdata = np.inner(Gdata.T,np.swapaxes(SGMT,1,2)) #apply sym. ops.--> Natm,Nops,Nxyz 1516 if SGData['SGInv'] and not SGData['SGFixed']: #inversion if any 1517 GSdata = np.hstack((GSdata,-GSdata)) 1518 GSdata = np.hstack([GSdata for cen in SSCen]) #dup over cell centering - Natm,Nops,Mxyz 1519 GSdata = SGData['MagMom'][nxs,:,nxs]*GSdata #flip vectors according to spin flip * det(opM) 1520 GSdata = np.swapaxes(GSdata,0,1) #Nop,Natm,Mxyz 1521 Tmag += Gdata.T[nxs,nxs,:,:] 1522 1523 TmagC = np.inner(Tmag,uAmat.T) #make cartesian; Ntau,Nops,Natm,,Mxyz 1524 Smag = np.sqrt(np.sum(TmagC**2,axis=-1)) 1525 Kmag = TmagC/Smag[:,:,:,nxs] 1523 1526 1524 #from #38121525 #1st try at this1526 # GSdata = Gdata.T[:,nxs,:]+Mmod #Natm,ntau,Mxyz1527 # GSdata = np.inner(GSdata,SGMT).T #apply sym. ops.--> Mxyz,Nops,Ntau,Natm1528 # if SGData['SGInv'] and not SGData['SGFixed']:1529 # GSdata = np.hstack((GSdata,-GSdata)) #inversion if any1530 # GSdata = np.hstack([GSdata for icen in range(Ncen)]) #dup over cell centering1531 # GSdata = SGData['MagMom'][nxs,:,nxs,nxs]*GSdata #flip vectors according to spin flip * det(opM)1532 # Kdata = np.inner(GSdata.T,uAmat).T #Cartesian unit vectors1533 # SMag = np.sqrt(np.sum(Kdata**2,axis=0)) #Nops,Ntau,Natm1534 # Kmean = np.mean(SMag,axis=0) #normalization --> unit vectors1535 # Kdata /= Kmean[nxs,nxs,:,:] #mxyz,nops,ntau,natm1536 1537 1527 FF = np.zeros(len(Tdata)) 1538 1528 if 'NC' in calcControls[hfx+'histType']: … … 1610 1600 HM = np.inner(Bmat,HP.T) #put into cartesian space 1611 1601 HM = HM/np.sqrt(np.sum(HM**2,axis=0)) #& normalize 1612 #for fixed moments --> m=0 reflections 1613 fam0 = TMcorr[:,nxs,:,nxs]*GSdata0[nxs,:,:,:]*cosm[:,:,:,nxs] #Nref,Nops,Natm,Mxyz1614 fbm0 = TMcorr[:,nxs,:,nxs]*GSdata0[nxs,:,:,:]*sinm[:,:,:,nxs]1615 1616 famq0 = np.sum(np.sum(fam0,axis=-2),axis=-2) #Nref,Mxyz; sum ops & atoms1617 fbmq0 = np.sum(np.sum(fbm0,axis=-2),axis=-2)1618 1619 fas0 = np.sum(famq0,axis=-1)**2-np.sum(HM.T*famq0,axis=-1)**2 #mag intensity calc F^2-(e.F)^21620 fbs0 = np.sum(fbmq0,axis=-1)**2-np.sum(HM.T*fbmq0,axis=-1)**21602 1603 # fam = TMcorr[:,nxs,nxs,:,nxs]*Tmag[nxs,:,:,:,:]*cosm[:,nxs,:,:,nxs] #Nref,Ntau,Nops,Natm,Mxyz 1604 # fbm = TMcorr[:,nxs,nxs,:,nxs]*Tmag[nxs,:,:,:,:]*sinm[:,nxs,:,:,nxs] 1605 # 1606 # famq = np.sum(np.sum(fam,axis=-2),axis=-2) #Nref,Mxyz; sum ops & atoms 1607 # fbmq = np.sum(np.sum(fbm,axis=-2),axis=-2) 1608 # 1609 # fas = np.sum(famq,axis=-1)**2-np.sum(HM.T[:,nxs,:]*famq,axis=-1)**2 #mag intensity calc F^2-(e.F)^2 1610 # fbs = np.sum(fbmq,axis=-1)**2-np.sum(HM.T[:,nxs,:]*fbmq,axis=-1)**2 1621 1611 #for modulated moments --> m != 0 reflections 1622 1612 # M = np.array(np.abs(H[3]),dtype=np.int)-1 … … 1633 1623 mphase = phase[:,:,nxs,:]+D[:,nxs,:,nxs] 1634 1624 mphase = np.array([mphase+twopi*np.inner(cen,HP.T)[:,nxs,nxs,nxs] for cen in SGData['SGCen']]) 1635 mphase = np.concatenate(mphase,axis=1) #remove extra axis; Nref,Nop,N atm1636 sinm = np.swapaxes(np.sin(mphase), 2,3) #--> Nref,Nop,Natm,Ntau1637 cosm = np.swapaxes(np.cos(mphase), 2,3) #ditto1625 mphase = np.concatenate(mphase,axis=1) #remove extra axis; Nref,Nop,Ntau,Natm 1626 sinm = np.swapaxes(np.sin(mphase),1,2) #--> Nref,Nop,Natm,Ntau 1627 cosm = np.swapaxes(np.cos(mphase),1,2) #ditto 1638 1628 1639 1629 HM = np.inner(Bmat,HP.T) #put into cartesian space 1640 HM = HM/np.sqrt(np.sum(HM**2,axis=0)) # Gdata = MAGS & HM = UVEC in magstrfc.for both OK1641 eDotK = np.sum(HM [:,:,nxs,nxs,nxs]*Kdata[:,nxs,:,:,:],axis=0)1642 Q = HM [:,:,nxs,nxs,nxs,nxs]*eDotK[nxs,:,:,:,:]-Kdata[:,nxs,:,:,:] #Mxyz,Nref,Nop,Ntau,Natm1630 HM = HM/np.sqrt(np.sum(HM**2,axis=0)) #normalize 1631 eDotK = np.sum(HM.T[:,nxs,nxs,nxs,:]*Kmag[nxs,:,:,:,:],axis=-1) 1632 Q = HM.T[:,nxs,nxs,nxs,:]*eDotK[:,:,:,:,nxs]-Kmag[nxs,:,:,:,:] #Nref,Ntau,Nop,Natm,Mxyz 1643 1633 1644 fam = (Q*TMcorr[ nxs,:,nxs,:,nxs,nxs]*cosm[nxs,:,:,:,:,nxs]*SMag[nxs,nxs,:,:,:,nxs]) #Mxyz,Nref,Nop,Natm,Ntau,ReIm1645 fbm = (Q*TMcorr[ nxs,:,nxs,:,nxs,nxs]*sinm[nxs,:,:,:,:,nxs]*SMag[nxs,nxs,:,:,:,nxs])1634 fam = (Q*TMcorr[:,nxs,nxs,:,nxs]*cosm[:,:,:,:,nxs]*Smag[nxs,:,:,:,nxs]) #Nref,Ntau,Nop,Natm,Mxyz 1635 fbm = (Q*TMcorr[:,nxs,nxs,:,nxs]*sinm[:,:,:,:,nxs]*Smag[nxs,:,:,:,nxs]) 1646 1636 1647 fams = np.sum(np.sum( np.sum(fam,axis=-1),axis=2),axis=2) #xyz,Nref,ntau; sum ops & atoms1648 fbms = np.sum(np.sum( np.sum(fbm,axis=-1),axis=2),axis=2) #ditto1637 fams = np.sum(np.sum(fam,axis=2),axis=2) #Nref,ntau,Mxyz; sum ops & atoms 1638 fbms = np.sum(np.sum(fbm,axis=2),axis=2) #ditto 1649 1639 1650 fas = np.sum(fams *glWt[nxs,nxs,:],axis=-1)1651 fbs = np.sum(fbms *glWt[nxs,nxs,:],axis=-1)1640 fas = np.sum(fams/ngl,axis=-1) 1641 fbs = np.sum(fbms/ngl,axis=-1) 1652 1642 1653 refl.T[10] = np. where(H[3],fas+fbs,fas0+fbs0)1654 refl.T[11] = np.where(H[3],atan2d(fas,fbs),atan2d(fas0,fbs0))1643 refl.T[10] = np.sum(fas,axis=-1)**2+np.sum(fbs,axis=-1)**2 1644 refl.T[11] = atan2d(fbs[:,0],fas[:,0]) 1655 1645 1656 1646 else:
Note: See TracChangeset
for help on using the changeset viewer.