Changeset 3851


Ignore:
Timestamp:
Mar 13, 2019 4:58:05 PM (3 years ago)
Author:
vondreele
Message:

incommensurate mag. str. fctr. agaiin - now close

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/GSASIImath.py

    r3850 r3851  
    13571357
    13581358def MagMod(XYZ,modQ,MSSdata):
    1359     Am = np.array(MSSdata[:3]).T   #atoms x waves x sin pos mods
    1360     Bm = np.array(MSSdata[3:]).T   #...cos pos mods
     1359    Bm = np.array(MSSdata[:3]).T   #atoms x waves x sin pos mods
     1360    Am = np.array(MSSdata[3:]).T   #...cos pos mods
    13611361    nWaves = Am.shape[1]
    1362     MmodA = 0.
    1363     MmodB = 0.
     1362    MmodA = 0; MmodB = 0
    13641363    if nWaves:
    13651364        modind = np.arange(nWaves)+1.
    1366         phase = twopi*XYZ[:,:,nxs,:]*modind[nxs,nxs,:,nxs]*modQ[nxs,nxs,nxs,:]
    1367         MmodA = np.sum(Bm[:,nxs,:,:]*np.cos(phase),axis=2) #natm,Nops,Mxyz
    1368         MmodB = np.sum(Am[:,nxs,:,:]*np.sin(phase),axis=2)
    1369     return np.swapaxes(MmodA,0,1),np.swapaxes(MmodB,0,1)    #Nops,Natm,Mxyz
     1365        phase = np.sum(twopi*XYZ[:,:,nxs,:]*modind[nxs,nxs,:,nxs]*modQ[nxs,nxs,nxs,:],axis=-1)
     1366        phase = np.swapaxes(phase,0,1)  #Nops,Natm,Nwave
     1367        MmodA = Am[nxs,:,:,:]*np.cos(phase[:,:,:,nxs])-Bm[nxs,:,:,:]*np.sin(phase[:,:,:,nxs])
     1368        MmodB = Am[nxs,:,:,:]*np.sin(phase[:,:,:,nxs])+Bm[nxs,:,:,:]*np.cos(phase[:,:,:,nxs])
     1369    return MmodA,MmodB    #cos & sin Nops,Natm,Nwaves,Mxyz
    13701370       
    13711371def Modulation(H,HP,nWaves,Fmod,Xmod,Umod,glTau,glWt):
  • trunk/GSASIIstrMath.py

    r3850 r3851  
    15181518       
    15191519        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 #        MmodA,MmodB = G2mth.MagMod(mXYZ,modQ,MSSdata)   #Re cos/Im sin,Nops,Natm,Mxyz
    1521 #        MmodA = np.inner(MmodA,uAmat.T)*SGData['SpnFlp']                   #make cartesian
    1522 #        MmodB = np.inner(MmodB,uAmat.T)*SGData['SpnFlp']
    1523         MmodA = np.array(MSSdata[3:]).T         #cos Natm,Nwave,Mxyz
    1524         MmodB = np.array(MSSdata[:3]).T         #sin
     1520        MmodA,MmodB = G2mth.MagMod(mXYZ,modQ,MSSdata)   #Re cos/Im sin,Nops,Natm,Nwaves,Mxyz
     1521        MmodA = np.inner(MmodA,uAmat.T)         #*(SGData['MagMom']/SGData['SpnFlp'])[:,nxs,nxs,nxs]   #make cartesian * apply det(ops)
     1522        MmodB = np.inner(MmodB,uAmat.T)         #*(SGData['MagMom']/SGData['SpnFlp'])[:,nxs,nxs,nxs]
    15251523       
    1526 
    15271524    FF = np.zeros(len(Tdata))
    15281525    if 'NC' in calcControls[hfx+'histType']:
     
    16111608#for modulated moments --> m != 0 reflections
    16121609            M = np.array(np.abs(H[3]),dtype=np.int)-1
    1613             fam = TMcorr[:,nxs,:,nxs]*np.array([np.where(M[i]>=0,(MmodA[nxs,:,M[i],:]*cosm[i,:,:,nxs]-np.sign(H[3])[i,nxs,nxs,nxs]*MmodB[nxs,:,M[i],:]*sinm[i,:,:,nxs]),0.) for i in range(mRef)])
    1614             fbm = TMcorr[:,nxs,:,nxs]*np.array([np.where(M[i]>=0,(MmodA[nxs,:,M[i],:]*sinm[i,:,:,nxs]+np.sign(H[3])[i,nxs,nxs,nxs]*MmodB[nxs,:,M[i],:]*cosm[i,:,:,nxs]),0.) for i in range(mRef)])
     1610            fam = TMcorr[:,nxs,:,nxs]*np.array([np.where(M[i]>=0,(MmodA[:,:,M[i],:]*cosm[i,:,:,nxs]-np.sign(H[3])[i,nxs,nxs,nxs]*MmodB[:,:,M[i],:]*sinm[i,:,:,nxs]),0.) for i in range(mRef)])
     1611            fbm = TMcorr[:,nxs,:,nxs]*np.array([np.where(M[i]>=0,(MmodA[:,:,M[i],:]*sinm[i,:,:,nxs]+np.sign(H[3])[i,nxs,nxs,nxs]*MmodB[:,:,M[i],:]*cosm[i,:,:,nxs]),0.) for i in range(mRef)])
    16151612                       
    1616             famq = np.sum(np.sum(fam,axis=-2),axis=-2)      #Nref,Mxyz; sum ops & atoms
    1617             fbmq = np.sum(np.sum(fbm,axis=-2),axis=-2)
     1613            famq = np.sum(np.sum(fam/2.,axis=-2),axis=-2)      #Nref,Mxyz; sum ops & atoms
     1614            fbmq = np.sum(np.sum(fbm/2.,axis=-2),axis=-2)
    16181615           
    16191616            fas = np.sum(famq,axis=-1)**2-np.sum(HM.T*famq,axis=-1)**2      #mag intensity calc F^2-(e.F)^2
Note: See TracChangeset for help on using the changeset viewer.