Changeset 3861


Ignore:
Timestamp:
Mar 25, 2019 1:32:58 PM (5 years ago)
Author:
vondreele
Message:

another try at incomm. mag. str. fctr.

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/GSASIImath.py

    r3853 r3861  
    13561356    return ngl,nWaves,Fmod,Xmod,Umod,Mmod,glTau,glWt
    13571357
    1358 def MagMod(XYZ,modQ,MSSdata,SSGData):
     1358def MagMod(XYZ,modQ,MSSdata,SGData,SSGData):
     1359   
     1360    SGMT = np.array([ops[0] for ops in SGData['SGOps']])
     1361    SGT = np.array([ops[1] for ops in SSGData['SSGOps']])
     1362    if SGData['SGInv']:
     1363        SGMT = np.vstack((SGMT,-SGMT))
     1364        SGT = np.vstack((SGT,-SGT))
     1365    SGMT = np.vstack([SGMT for cen in SGData['SGCen']])
     1366    SGT = np.vstack([SGT+cen for cen in SSGData['SSGCen']])%1.
     1367
     1368#works for DyMn6Ge6 but not MnWO4
    13591369    Bm = np.array(MSSdata[:3]).T   #atoms x waves x sin pos mods
    13601370    Am = np.array(MSSdata[3:]).T   #...cos pos mods
     
    13661376    if nWaves:
    13671377        modind = np.arange(nWaves)+1.
    1368         phase = np.sum(twopi*XYZ[:,:,nxs,:]*modind[nxs,nxs,:,nxs]*modQ[nxs,nxs,nxs,:],axis=-1)
    1369         phase = np.swapaxes(phase,0,1)  #Nops,Natm,Nwave
     1378        phaseA = twopi*(modind[:,nxs,nxs]*(np.inner(XYZ,modQ))).T         #= 2pimk.r Nops,Natm,Nwave
    13701379        if nCen > 0:
    1371             phshp = phase.shape
    1372             phase = np.reshape(phase,(nCen,mEqv,phshp[1],-1))
     1380            phshp = phaseA.shape
     1381            phaseA = np.reshape(phaseA,(nCen,mEqv,phshp[1],-1))
    13731382            for ic,cen in enumerate(SSGData['SSGCen']):
    1374                 phase[ic] += twopi*cen[3]/2.
    1375             phase = np.reshape(phase,phshp)               
    1376         MmodA = Am[nxs,:,:,:]*np.cos(phase[:,:,:,nxs])-Bm[nxs,:,:,:]*np.sin(phase[:,:,:,nxs])
    1377         MmodB = Am[nxs,:,:,:]*np.sin(phase[:,:,:,nxs])+Bm[nxs,:,:,:]*np.cos(phase[:,:,:,nxs])
     1383                phaseA[ic] += twopi*cen[3]/2.
     1384            phaseA = np.reshape(phaseA,phshp)               
     1385        MmodAA = Am[nxs,:,:,:]*np.cos(phaseA[:,:,:,nxs])-Bm[nxs,:,:,:]*np.sin(phaseA[:,:,:,nxs])
     1386        MmodBA = Am[nxs,:,:,:]*np.sin(phaseA[:,:,:,nxs])+Bm[nxs,:,:,:]*np.cos(phaseA[:,:,:,nxs])   
     1387   
     1388#fails   
     1389    modQp = np.zeros(4); modQp[:3] = modQ; modQp[3] = 1.
     1390    poff = SGData['SpnFlp']*np.inner(modQp,SGT)
     1391    Bm = np.array(MSSdata[:3]).T   #atoms x waves x sin pos mods
     1392    Am = np.array(MSSdata[3:]).T   #...cos pos mods
     1393    nWaves = Am.shape[1]
     1394    MmodA = 0; MmodB = 0
     1395    if nWaves:
     1396        modind = np.arange(nWaves)+1.
     1397        phase = twopi*(modind[:,nxs,nxs]*(np.inner(XYZ,modQ)+poff)).T
     1398        psin = np.sin(phase)
     1399        pcos = np.cos(phase)
     1400        RAM = np.rollaxis(np.inner(Am,SGMT),2)
     1401        RBM = np.rollaxis(np.inner(Bm,SGMT),2)
     1402        MmodA = SGData['MagMom'][nxs,nxs,:,nxs]*(RAM*pcos[:,:,:,nxs]-RBM*psin[:,:,:,nxs])
     1403        MmodB = SGData['MagMom'][nxs,nxs,:,nxs]*(RAM*psin[:,:,:,nxs]+RBM*pcos[:,:,:,nxs])
     1404#        MmodA = RAM*pcos[:,:,:,nxs]-RBM*psin[:,:,:,nxs]
     1405#        MmodB = RAM*psin[:,:,:,nxs]+RBM*pcos[:,:,:,nxs]   
     1406
    13781407    return MmodA,MmodB    #cos & sin Nops,Natm,Nwaves,Mxyz
    13791408       
  • trunk/GSASIIstrMath.py

    r3859 r3861  
    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,SSGData)   #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]
     1520        MmodA,MmodB = G2mth.MagMod(mXYZ,modQ,MSSdata,SGData,SSGData)   #Re cos/Im sin,Nops,Natm,Nwaves,Mxyz
     1521        MmodA *= (SGData['MagMom']/SGData['SpnFlp'])[:,nxs,nxs,nxs]   #apply det(ops)
     1522        MmodB *= (SGData['MagMom']/SGData['SpnFlp'])[:,nxs,nxs,nxs]
     1523        MmodA = np.inner(MmodA,uAmat.T)   #make cartesian
     1524        MmodB = np.inner(MmodB,uAmat.T)
    15231525       
    15241526    FF = np.zeros(len(Tdata))
     
    15901592            phasem = twopi*np.inner(H.T[:,:3],mXYZ)
    15911593            phasem = np.swapaxes(phasem,1,2)
     1594            cosm = np.cos(phasem)
    15921595            sinm = np.sin(phasem)
    1593             cosm = np.cos(phasem)
    15941596            MF = refDict['FF']['MF'][iBeg:iFin].T[Tindx].T   #Nref,Natm
    15951597            TMcorr = 0.539*(np.reshape(Tiso,Tuij.shape)*Tuij)[:,0,:]*Fdata*Mdata*MF/(2*Nops)     #Nref,Natm
Note: See TracChangeset for help on using the changeset viewer.