Ignore:
Timestamp:
Jun 16, 2020 9:39:08 AM (3 years ago)
Author:
vondreele
Message:

another try at incommensurate magnetic SF; fix bug in plotting mag moments.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/GSASIIstrMath.py

    r4377 r4488  
    15121512    modQ = np.array([parmDict[pfx+'mV0'],parmDict[pfx+'mV1'],parmDict[pfx+'mV2']])
    15131513
    1514     if parmDict[pfx+'isMag']:       #This part correct for making modulated mag moments on equiv atoms
    1515        
     1514    if parmDict[pfx+'isMag']:       #This part correct for making modulated mag moments on equiv atoms - matched drawing & Bilbao drawings
     1515   
     1516        mTau = np.linspace(0,1.,ngl,False)   
    15161517        mXYZ = np.array([[XYZ[0] for XYZ in list(G2spc.GenAtom(xyz,SGData,All=True,Move=True))] for xyz in (Xdata+dXdata).T]) #Natn,Nop,xyz
    15171518        if SGData['SGGray']:
    15181519            mXYZ = np.hstack((mXYZ,mXYZ))
    1519         MmodA,MmodB = G2mth.MagMod(glTau,mXYZ,modQ,MSSdata,SGData,SSGData)  #Ntau,Nops,Natm,Mxyz cos,sim parts sum matches drawing
     1520        MmodA,MmodB = G2mth.MagMod(mTau,mXYZ,modQ,MSSdata,SGData,SSGData)  #Ntau,Nops,Natm,Mxyz cos,sim parts sum matches drawing
    15201521        Mmod = MmodA+MmodB
    15211522       
     
    15291530            Mmod += GSdata[nxs,:,:,:]
    15301531           
    1531 #        Kdata = np.inner(Mmod,uAmat)    #Ntau,Nop,Natm,Mxyz
    1532 #        Mag = np.sqrt(np.sum(Kdata**2,axis=-1))
    1533 #        Kdata /= Mag[:,:,:,nxs]     #Cartesian unit vectors
    1534 #        Kdata = np.nan_to_num(Kdata)    #Ntau,Nops,Natm,Mxyz       
     1532        Kdata = np.inner(Mmod,uAmat)    #Ntau,Nop,Natm,Mxyz
     1533        Mag = np.sqrt(np.sum(Kdata**2,axis=-1)) #ntau,nop,natm
     1534        Kdata /= Mag[:,:,:,nxs]     #Cartesian unit vectors
     1535        Kdata = np.nan_to_num(Kdata)    #Ntau,Nops,Natm,Mxyz checked against drawing   
    15351536
    15361537    FF = np.zeros(len(Tdata))
     
    15991600        Tcorr = np.reshape(Tiso,Tuij.shape)*Tuij*Mdata*Fdata/Uniq.shape[1]  #refBlk x ops x atoms
    16001601
    1601         if 'N' in calcControls[hfx+'histType'] and parmDict[pfx+'isMag']:       #TODO: mag math here??            
     1602        if 'N' in calcControls[hfx+'histType'] and parmDict[pfx+'isMag']:            
    16021603           
    16031604            phasem = twopi*np.inner(mXYZ,HP.T).T    #2pi(Q.r)
    1604             cosm = np.cos(phasem)
     1605            cosm = np.cos(phasem)                   #Nref,nops,natm
    16051606            sinm = np.sin(phasem)
    16061607            MF = refDict['FF']['MF'][iBeg:iFin].T[Tindx].T   #Nref,Natm
    16071608            TMcorr = 0.539*(np.reshape(Tiso,Tuij.shape)*Tuij)[:,0,:]*Mdata*Fdata*MF/(2*Nops)     #Nref,Natm
    1608                      
    1609             HM = np.inner(uBmat.T,HP.T)                            #put into cartesian space X||H,Z||H*L
     1609
     1610#method 1     very wrong                 
     1611            HM = np.inner(uBmat,HP.T)                            #put into cartesian space X||H,Z||H*L
    16101612            eM = (HM/np.sqrt(np.sum(HM**2,axis=0))).T              # normalize  HP  Nref,hkl=Unit vectors || Q
    1611 #for fixed moments --> m=0 reflections
     1613            # edotK = np.sum(eM*HP.T,axis=-1)                                               #nRef
     1614            # Q = edotK[:,nxs,nxs,nxs,nxs]*eM[:,nxs,nxs,nxs,:]-Kdata[nxs,:,:,:,:]           #nRef,ntau,noops,natm,Mxyz     
     1615            # fam = Q*TMcorr[:,nxs,nxs,:,nxs]*cosm[:,nxs,:,:,nxs]*Mag[nxs,:,:,:,nxs]    #nRef,ntau,noops,natm,Mxyz
     1616            # fbm = Q*TMcorr[:,nxs,nxs,:,nxs]*sinm[:,nxs,:,:,nxs]*Mag[nxs,:,:,:,nxs]
     1617            # fama = np.sum(np.sum(fam,axis=2),axis=2)                                      #nRef,ntau,Mxyz; sum natm & nops
     1618            # fbma = np.sum(np.sum(fbm,axis=2),axis=2)
     1619            # fas = np.sum(np.sum(1./ngl*fama**2,axis=1),axis=-1)
     1620            # fbs = np.sum(np.sum(1./ngl*fbma**2,axis=1),axis=-1)
     1621           
     1622#method 2   sort of wrong         
    16121623            fam0 = 0.
    16131624            fbm0 = 0.
     
    16261637                fams += fam0[:,nxs,:,:,:]
    16271638                fbms += fbm0[:,nxs,:,:,:]
    1628             else:
    1629                 fams *= Ncen
    1630                 fbms *= Ncen
     1639            # else:
     1640            #     fams *= Ncen
     1641            #     fbms *= Ncen
    16311642               
    16321643# do sum on ops, atms 1st                       
     
    16341645            fbsm = np.sum(np.sum(fbms,axis=-2),axis=-2)           
    16351646#put into cartesian space
    1636             facm = np.inner(fasm,uAmat.T)
    1637             fbcm = np.inner(fbsm,uAmat.T)
     1647            facm = np.inner(fasm,uAmat)
     1648            fbcm = np.inner(fbsm,uAmat)
    16381649#form e.F dot product
    16391650            eDotFa = np.sum(eM[:,nxs,:]*facm,axis=-1)    #Nref,Ntau       
     
    16441655#do integration
    16451656           
    1646             fas = np.sum(glWt*fass,axis=1)
    1647             fbs = np.sum(glWt*fbss,axis=1)
     1657            fas = np.sum(1./ngl*fass,axis=1)
     1658            fbs = np.sum(1./ngl*fbss,axis=1)
    16481659           
    1649             if SGData['SGInv']:
    1650                 fbs *= 4.
    1651                 fas = 0.
    1652            
     1660            # if SGData['SGInv']:
     1661            #     fbs *= 4.
     1662            #     fas = 0.
     1663               
    16531664            refl.T[10] = fas+fbs   #Sum(fams**2,Mxyz) Re + Im
    16541665            refl.T[11] = atan2d(fbs,fas)
Note: See TracChangeset for help on using the changeset viewer.