Changeset 4125


Ignore:
Timestamp:
Aug 30, 2019 2:03:45 PM (4 years ago)
Author:
vondreele
Message:

back to incomm. mag. str. fctr.

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/GSASIImath.py

    r4073 r4125  
    13601360    return ngl,nWaves,Fmod,Xmod,Umod,Mmod,glTau,glWt
    13611361
    1362 def MagMod(ngl,XYZ,modQ,MSSdata,SGData,SSGData):
     1362def MagMod(glTau,XYZ,modQ,MSSdata,SGData,SSGData):
    13631363    '''
    13641364    this needs to make magnetic moment modulations & magnitudes as
    1365     fxn of ngl tau points
     1365    fxn of gTau points
    13661366    '''
    13671367    Am = np.array(MSSdata[:3]).T   #atoms x waves x sin pos mods
    13681368    Bm = np.array(MSSdata[3:]).T  #...cos pos mods
    13691369    nWaves = Am.shape[1]
    1370     tau = np.arange(ngl)/ngl
    1371     if not nWaves:
    1372         return 0.0,0.0
    13731370    SGMT = np.array([ops[0] for ops in SGData['SGOps']])        #not .T!!
    13741371    Sinv = np.array([nl.inv(ops[0]) for ops in SSGData['SSGOps']])
     
    13861383    phi = np.inner(XYZ,modQ).T
    13871384    TA = np.sum(mst[nxs,:,:]*(XYZ-SGT[:,:3][nxs,:,:]),axis=-1).T
    1388     tauT =  TA[nxs,:,:] + epsinv[nxs,:,nxs]*(tau[:,nxs,nxs]-SGT[:,3][nxs,:,nxs]+phi[nxs,:,:])
     1385    tauT =  TA[nxs,:,:] + epsinv[nxs,:,nxs]*(glTau[:,nxs,nxs]-SGT[:,3][nxs,:,nxs]+phi[nxs,:,:])
    13891386    modind = np.arange(nWaves)+1.
    13901387    phase = (modind[:,nxs,nxs]*tauT)     #Nops,Natm,Nwave
    13911388    psin = np.sin(twopi*phase)
    13921389    pcos = np.cos(twopi*phase)
    1393     MmodB = np.sum(Bm[nxs,nxs,:,:,:]*pcos[:,:,:,nxs,nxs],axis=3)
    1394     MmodA = np.sum(Am[nxs,nxs,:,:,:]*psin[:,:,:,nxs,nxs],axis=3)
     1390    MmodA = np.sum(Bm[nxs,nxs,:,:,:]*pcos[:,:,:,nxs,nxs],axis=3)
     1391    MmodB = np.sum(Am[nxs,nxs,:,:,:]*psin[:,:,:,nxs,nxs],axis=3)
    13951392    if SGData['SGGray']:
    13961393        MmodA = -np.sum(SGMT[nxs,:,nxs,:,:]*MmodA[:,:,:,nxs,:],axis=-1)*detSM[nxs,:,nxs,nxs]
     
    13991396        MmodA = np.sum(SGMT[nxs,:,nxs,:,:]*MmodA[:,:,:,nxs,:],axis=-1)*SGData['MagMom'][nxs,:,nxs,nxs]
    14001397        MmodB = np.sum(SGMT[nxs,:,nxs,:,:]*MmodB[:,:,:,nxs,:],axis=-1)*SGData['MagMom'][nxs,:,nxs,nxs]
    1401     Mmod = MmodA+MmodB
    1402     return Mmod,MmodA,MmodB    #Ntau,Nops,Natm,,Mxyz; sum,sin & cos parts
     1398    return MmodA,MmodB    #Ntau,Nops,Natm,,Mxyz; cos & sin parts; sum matches drwa
    14031399       
    14041400def MagMod2(XYZ,modQ,MSSdata,SGData,SSGData):
     
    14251421    epsinv = Sinv[:,3,3]            #Nops
    14261422    kdr = np.inner(XYZ,modQ).T      #Nops,Natm
    1427 #    phase = kdr+(epsinv*(np.inner(SGT[:,:3],modQ)-SGT[:,3]))[:,nxs]     #Nops,Natm
    14281423   
    14291424    phase = (np.sum(mst*(XYZ-SGT[nxs,:,:3]),axis=-1)).T+epsinv[:,nxs]*(kdr-SGT[:,nxs,3])
     
    14311426    psin = np.sin(twopi*phase)      #Nops,Natm
    14321427    pcos = np.cos(twopi*phase)
    1433     MmodA = np.sum(Am[nxs,:,:,:]*psin[:,:,nxs,nxs],axis=2)      #Nops,Natm,3
    1434     MmodB = np.sum(Bm[nxs,:,:,:]*pcos[:,:,nxs,nxs],axis=2)
     1428    MmodA = np.sum(Bm[nxs,:,:,:]*pcos[:,:,nxs,nxs],axis=2)
     1429    MmodB = np.sum(Am[nxs,:,:,:]*psin[:,:,nxs,nxs],axis=2)      #Nops,Natm,3
    14351430    MmodA = np.sum(SGMT[:,nxs,:,:]*MmodA[:,:,nxs,:],axis=-1)
    14361431    MmodB = np.sum(SGMT[:,nxs,:,:]*MmodB[:,:,nxs,:],axis=-1)
     
    14421437        MmodB = MmodB*SGData['MagMom'][:,nxs,nxs]
    14431438#MmodA+MmodB matches drawn tau=0 atom moments
    1444     return MmodA,MmodB    #Nops,Natm,Mxyz; sin & cos parts
     1439    return MmodA,MmodB    #Nops,Natm,Mxyz; cos & sin parts
    14451440       
    14461441def Modulation(H,HP,nWaves,Fmod,Xmod,Umod,glTau,glWt):
  • trunk/GSASIIstrMath.py

    r4068 r4125  
    15101510       
    15111511        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         TmagA,TmagB = G2mth.MagMod2(mXYZ,modQ,MSSdata,SGData,SSGData)   #Nops,Natm,Mxyz-Tmag matches drawing moments
     1512#        TmagA,TmagB = G2mth.MagMod2(mXYZ,modQ,MSSdata,SGData,SSGData)   #Nops,Natm,Mxyz-TmagA+TmagB matches drawing moments @ tau=0.
     1513        MmodA,MmodB = G2mth.MagMod(glTau,mXYZ,modQ,MSSdata,SGData,SSGData)  #Ntau,Nops,Natm,Mxyz sum matches drawing
    15131514       
    15141515        if not SGData['SGGray']:    #for fixed Mx,My,Mz
     
    16061607            M = np.array(np.abs(H[3]),dtype=np.int)-1
    16071608       
    1608             fam = .5*TMcorr[:,nxs,:,nxs]*np.array([np.where(M[i]>=0,(TmagB*cosm[i,:,:,nxs]-    \
    1609                 np.sign(H[3,i])*TmagA*sinm[i,:,:,nxs]),0.) for i in range(mRef)])+fam0          #Nref,Nops,Natm,Mxyz
     1609            fams = .5*TMcorr[:,nxs,nxs,:,nxs]*np.array([np.where(M[i]>=0,(MmodA*cosm[i,nxs,:,:,nxs]-    \
     1610                np.sign(H[3,i])*MmodB*sinm[i,nxs,:,:,nxs]),0.) for i in range(mRef)])          #Ntau,Nref,Nops,Natm,Mxyz
     1611                       
     1612            fbms = .5*TMcorr[:,nxs,nxs,:,nxs]*np.array([np.where(M[i]>=0,(MmodA*sinm[i,nxs,:,:,nxs]+    \
     1613                np.sign(H[3,i])*MmodB*cosm[i,nxs,:,:,nxs]),0.) for i in range(mRef)])          #Ntau,Nref,Nops,Natm,Mxyz
    16101614           
    1611             fbm = .5*TMcorr[:,nxs,:,nxs]*np.array([np.where(M[i]>=0,(TmagB*sinm[i,:,:,nxs]+    \
    1612                 np.sign(H[3,i])*TmagA*cosm[i,:,:,nxs]),0.) for i in range(mRef)])+fbm0
    1613                        
    1614             famq = np.sum(np.sum(fam,axis=-2),axis=-2)      #Nref,Mxyz; sum ops & atoms
    1615             fbmq = np.sum(np.sum(fbm,axis=-2),axis=-2)
     1615            if not SGData['SGGray']:
     1616                fams += fam0[:,nxs,:,:,:]
     1617                fbms += fbm0[:,nxs,:,:,:]
     1618                       
     1619            famqs = np.sum(np.sum(fams,axis=-2),axis=-2)      #Ntau,Nref,Mxyz; sum ops & atoms
     1620            fbmqs = np.sum(np.sum(fbms,axis=-2),axis=-2)
    16161621           
    1617             fas = np.sum(famq,axis=-1)**2-np.sum(eM.T*famq,axis=-1)**2      #mag intensity calc F^2-(e.F)^2
    1618             fbs = np.sum(fbmq,axis=-1)**2-np.sum(eM.T*fbmq,axis=-1)**2
     1622            fass = np.sum(famqs,axis=-1)**2-np.sum(eM.T[:,nxs,:]*famqs,axis=-1)**2      #mag intensity calc F^2-(e.F)^2
     1623            fbss = np.sum(fbmqs,axis=-1)**2-np.sum(eM.T[:,nxs,:]*fbmqs,axis=-1)**2
    16191624           
    1620 #            refl.T[10] = np.where(H[3],fas+fbs,fas0+fbs0)
    1621 #            refl.T[11] = np.where(H[3],atan2d(fbs,fas),atan2d(fbs0,fas0))
     1625            fas = np.sum(glWt*fass,axis=1)
     1626            fbs = np.sum(glWt*fbss,axis=1)
     1627           
    16221628            refl.T[10] = fas+fbs
    16231629            refl.T[11] = atan2d(fbs,fas)
Note: See TracChangeset for help on using the changeset viewer.