Changeset 3867


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

modulated mag moments now ok; not sf calc

Location:
trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/GSASIIdataGUI.py

    r3863 r3867  
    60706070        event.Skip()
    60716071        wx.CallAfter(PlotSelectedColRow,'double')
     6072       
     6073    def OnKeyUp(event):
     6074        key = event.GetKeyCode()
     6075        rows = G2frame.dataDisplay.GetSelectedRows()
     6076        print(key,rows)
     6077        event.Skip()
     6078        wx.CallAfter(PlotSelectedColRow,'single')
    60726079           
    60736080    def OnPlotSelSeq(event):
     
    73687375    else:
    73697376        G2frame.dataDisplay.Bind(wg.EVT_GRID_CELL_CHANGE, OnCellChange)
     7377#    G2frame.dataDisplay.Bind(wx.EVT_KEY_UP,OnKeyUp)
    73707378    G2frame.dataDisplay.Bind(wg.EVT_GRID_LABEL_LEFT_CLICK, PlotSSelect)
    73717379    G2frame.dataDisplay.Bind(wg.EVT_GRID_LABEL_LEFT_DCLICK, PlotSelect)
     7380#    G2frame.dataDisplay.Bind(wg.EVT_GRID_SELECT_CELL,PlotSSelect)
    73727381    G2frame.dataDisplay.Bind(wg.EVT_GRID_LABEL_RIGHT_CLICK, SetLabelString)
    73737382    G2frame.dataDisplay.SetRowLabelSize(8*len(histNames[0]))       #pretty arbitrary 8
  • trunk/GSASIImath.py

    r3865 r3867  
    13621362    '''
    13631363    Bm = np.array(MSSdata[:3]).T   #atoms x waves x sin pos mods
    1364     Am = np.array(MSSdata[3:]).T   #...cos pos mods
     1364    Am = np.array(MSSdata[3:]).T  #...cos pos mods
    13651365    nWaves = Am.shape[1]
    1366     ngl = 20
    13671366    tau = np.arange(ngl)/ngl
    13681367    if not nWaves:
    13691368        return 0.0,0.0
    13701369    SGMT = np.array([ops[0] for ops in SGData['SGOps']])        #not .T!!
     1370    Sinv = np.array([nl.inv(ops[0]) for ops in SSGData['SSGOps']])
    13711371    SGT = np.array([ops[1] for ops in SSGData['SSGOps']])
    1372     RI = np.array([ops[0][3,3] for ops in SSGData['SSGOps']])
    13731372    if SGData['SGInv']:
    13741373        SGMT = np.vstack((SGMT,-SGMT))
     1374        Sinv =np.vstack((Sinv,-Sinv))
    13751375        SGT = np.vstack((SGT,-SGT))
    1376         RI = np.concatenate((RI,-RI))
    13771376    SGMT = np.vstack([SGMT for cen in SGData['SGCen']])
    1378     thdetR = np.array([nl.det(op) for op in SGMT])*SGData['SpnFlp']
     1377    Sinv = np.vstack([Sinv for cen in SGData['SGCen']])
    13791378    SGT = np.vstack([SGT+cen for cen in SSGData['SSGCen']])%1.
    1380     RI = np.hstack([RI for cen in SSGData['SSGCen']])
     1379    detSM = nl.det(SGMT)
     1380    mst = Sinv[:,3,:3]
     1381    epsinv = Sinv[:,3,3]
     1382    phi = np.inner(XYZ,modQ).T
     1383    TA = np.sum(mst[nxs,:,:]*(XYZ-SGT[:,:3][nxs,:,:]),axis=-1).T
     1384    tauT =  TA[nxs,:,:] + epsinv[nxs,:,nxs]*(tau[:,nxs,nxs]-SGT[:,3][nxs,:,nxs]+phi[nxs,:,:])
    13811385    modind = np.arange(nWaves)+1.
    1382     modQp = np.zeros(4); modQp[:3] = modQ; modQp[3] = -1.
    1383     toff = RI*np.inner(modQp,SGT)
    1384     phase = (modind[:,nxs,nxs]*(np.inner(XYZ,modQ))).T     #Nops,Natm,Nwave
    1385 #    phase = (thdetR[nxs,nxs,:]*(modind[:,nxs,nxs]*np.inner(XYZ,modQ))).T     #Nops,Natm,Nwave
    1386     phase = phase[nxs,:,:,:]+tau[:,nxs,nxs,nxs]                 #Ntau,Nops,Natm,Nwave
     1386    phase = (modind[:,nxs,nxs]*tauT)     #Nops,Natm,Nwave
    13871387    psin = np.sin(twopi*phase)
    13881388    pcos = np.cos(twopi*phase)
    1389     Mmod = np.sum(Am[nxs,nxs,:,:,:]*pcos[:,:,:,:,nxs]+Bm[nxs,nxs,:,:,:]*psin[:,:,:,:,nxs],axis=3)
     1389    Mmod = np.sum(Am[nxs,nxs,:,:,:]*pcos[:,:,:,nxs,nxs]+Bm[nxs,nxs,:,:,:]*psin[:,:,:,nxs,nxs],axis=3)
     1390    if SGData['SGGray']:
     1391        Mmod = -np.sum(SGMT[nxs,:,nxs,:,:]*Mmod[:,:,:,nxs,:],axis=-1)*detSM[nxs,:,nxs,nxs]
     1392    else:
     1393        Mmod = np.sum(SGMT[nxs,:,nxs,:,:]*Mmod[:,:,:,nxs,:],axis=-1)*SGData['MagMom'][nxs,:,nxs,nxs]
    13901394    return Mmod    #Ntau,Nops,Natm,,Mxyz
    1391 
    1392 
    1393 
    1394 ##works for DyMn6Ge6 but not MnWO4
    1395 #    nCen = len(SSGData['SSGCen'])
    1396 #    nEqv = XYZ.shape[1]         #full no. of equivalent pos incl centering
    1397 #    mEqv = nEqv//nCen           #no. operators not with centering; includes inversion
    1398 #    MmodAA = 0; MmodBA = 0
    1399 #    if nWaves:
    1400 #        phaseA = twopi*(modind[:,nxs,nxs]*(np.inner(XYZ,modQ))).T         #= 2pimk.r Nops,Natm,Nwave
    1401 #        if nCen > 0:
    1402 #            phshp = phaseA.shape
    1403 #            phaseA = np.reshape(phaseA,(nCen,mEqv,phshp[1],-1))
    1404 #            for ic,cen in enumerate(SSGData['SSGCen']):
    1405 #                phaseA[ic] += twopi*cen[3]/2.
    1406 #            phaseA = np.reshape(phaseA,phshp)               
    1407 #        psinA = np.sin(phaseA)
    1408 #        pcosA = np.cos(phaseA)
    1409 #        MmodAA = Am[nxs,:,:,:]*pcosA[:,:,:,nxs]-Bm[nxs,:,:,:]*psinA[:,:,:,nxs]
    1410 #        MmodBA = Am[nxs,:,:,:]*psinA[:,:,:,nxs]+Bm[nxs,:,:,:]*pcosA[:,:,:,nxs]   
    1411 #   
    1412 ##fails   
    1413 #    modQp = np.zeros(4); modQp[:3] = modQ; modQp[3] = -1.
    1414 #    toff = RI*np.inner(modQp,SGT)
    1415 #    MmodA = 0; MmodB = 0
    1416 #    if nWaves:
    1417 #        modind = np.arange(nWaves)+1.
    1418 #        phase = twopi*(modind[:,nxs,nxs]*(np.inner(XYZ,modQ)-toff)).T
    1419 #        RAM = np.rollaxis(np.inner(Am,SGMT),2)
    1420 #        RBM = np.rollaxis(np.inner(Bm,SGMT),2)
    1421 #        RAC = RAM*pcos[:,:,:,nxs]
    1422 #        RBS = RBM*psin[:,:,:,nxs]
    1423 #        RAS = RAM*psin[:,:,:,nxs]
    1424 #        RBC = RBM*pcos[:,:,:,nxs]
    1425 #        MmodA = RAC-RBS
    1426 #        MmodB = RAS+RBC
    1427 #        MmodA *= thdetR[:,nxs,nxs,nxs]
    1428 #        MmodB *= thdetR[:,nxs,nxs,nxs]
    1429 #
    1430 #from 3812
    1431 #    MmodA = 0; MmodB = 0
    1432 #    if nWaves:
    1433 #        modind = np.arange(nWaves)+1.
    1434 #        phase = np.sum(twopi*XYZ[:,:,nxs,:]*modind[nxs,nxs,:,nxs]*modQ[nxs,nxs,nxs,:],axis=-1)
    1435 #        phase = np.swapaxes(phase,0,1)  #Nops,Natm,Nwave
    1436 #        MmodA = Am[nxs,:,:,:]*np.cos(phase[:,:,:,nxs])-Bm[nxs,:,:,:]*np.sin(phase[:,:,:,nxs])
    1437 #        MmodB = Am[nxs,:,:,:]*np.sin(phase[:,:,:,nxs])+Bm[nxs,:,:,:]*np.cos(phase[:,:,:,nxs])
    1438 #    return MmodA,MmodB    #cos & sin Nops,Natm,Nwaves,Mxyz
    14391395       
    14401396def Modulation(H,HP,nWaves,Fmod,Xmod,Umod,glTau,glWt):
  • 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.