Ignore:
Timestamp:
Apr 2, 2019 3:16:24 PM (4 years ago)
Author:
vondreele
Message:

modulated mag moments now ok; not sf calc

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/GSASIIstrMath.py

    r3865 r3867  
    15091509    if parmDict[pfx+'isMag']:       #This part correct for making modulated mag moments on equiv atoms
    15101510       
    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
    15181513       
    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]
    15231526
    1524 #from #3812
    1525 #1st try at this
    1526 #        GSdata = Gdata.T[:,nxs,:]+Mmod    #Natm,ntau,Mxyz
    1527 #        GSdata = np.inner(GSdata,SGMT).T  #apply sym. ops.--> Mxyz,Nops,Ntau,Natm
    1528 #        if SGData['SGInv'] and not SGData['SGFixed']:
    1529 #            GSdata = np.hstack((GSdata,-GSdata))       #inversion if any
    1530 #        GSdata = np.hstack([GSdata for icen in range(Ncen)])        #dup over cell centering
    1531 #        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 vectors
    1533 #        SMag = np.sqrt(np.sum(Kdata**2,axis=0))         #Nops,Ntau,Natm
    1534 #        Kmean = np.mean(SMag,axis=0)    #normalization --> unit vectors
    1535 #        Kdata /= Kmean[nxs,nxs,:,:]      #mxyz,nops,ntau,natm
    1536        
    15371527    FF = np.zeros(len(Tdata))
    15381528    if 'NC' in calcControls[hfx+'histType']:
     
    16101600            HM = np.inner(Bmat,HP.T)                            #put into cartesian space
    16111601            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,Mxyz
    1614             fbm0 = TMcorr[:,nxs,:,nxs]*GSdata0[nxs,:,:,:]*sinm[:,:,:,nxs]   
    1615                        
    1616             famq0 = np.sum(np.sum(fam0,axis=-2),axis=-2)        #Nref,Mxyz; sum ops & atoms
    1617             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)^2
    1620             fbs0 = np.sum(fbmq0,axis=-1)**2-np.sum(HM.T*fbmq0,axis=-1)**2
     1602
     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
    16211611#for modulated moments --> m != 0 reflections
    16221612#            M = np.array(np.abs(H[3]),dtype=np.int)-1
     
    16331623            mphase = phase[:,:,nxs,:]+D[:,nxs,:,nxs]
    16341624            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,Natm
    1636             sinm = np.swapaxes(np.sin(mphase),2,3)    #--> Nref,Nop,Natm,Ntau
    1637             cosm = np.swapaxes(np.cos(mphase),2,3)                               #ditto
     1625            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
    16381628           
    16391629            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 OK
    1641             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,Natm
     1630            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
    16431633
    1644             fam = (Q*TMcorr[nxs,:,nxs,:,nxs,nxs]*cosm[nxs,:,:,:,:,nxs]*SMag[nxs,nxs,:,:,:,nxs])   #Mxyz,Nref,Nop,Natm,Ntau,ReIm
    1645             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])
    16461636           
    1647             fams = np.sum(np.sum(np.sum(fam,axis=-1),axis=2),axis=2)      #xyz,Nref,ntau; sum ops & atoms
    1648             fbms = np.sum(np.sum(np.sum(fbm,axis=-1),axis=2),axis=2)      #ditto
     1637            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
    16491639           
    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)
    16521642                       
    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])
    16551645           
    16561646        else:
Note: See TracChangeset for help on using the changeset viewer.