Changeset 3867
- Timestamp:
- Apr 2, 2019 3:16:24 PM (4 years ago)
- Location:
- trunk
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/GSASIIdataGUI.py
r3863 r3867 6070 6070 event.Skip() 6071 6071 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') 6072 6079 6073 6080 def OnPlotSelSeq(event): … … 7368 7375 else: 7369 7376 G2frame.dataDisplay.Bind(wg.EVT_GRID_CELL_CHANGE, OnCellChange) 7377 # G2frame.dataDisplay.Bind(wx.EVT_KEY_UP,OnKeyUp) 7370 7378 G2frame.dataDisplay.Bind(wg.EVT_GRID_LABEL_LEFT_CLICK, PlotSSelect) 7371 7379 G2frame.dataDisplay.Bind(wg.EVT_GRID_LABEL_LEFT_DCLICK, PlotSelect) 7380 # G2frame.dataDisplay.Bind(wg.EVT_GRID_SELECT_CELL,PlotSSelect) 7372 7381 G2frame.dataDisplay.Bind(wg.EVT_GRID_LABEL_RIGHT_CLICK, SetLabelString) 7373 7382 G2frame.dataDisplay.SetRowLabelSize(8*len(histNames[0])) #pretty arbitrary 8 -
trunk/GSASIImath.py
r3865 r3867 1362 1362 ''' 1363 1363 Bm = np.array(MSSdata[:3]).T #atoms x waves x sin pos mods 1364 Am = np.array(MSSdata[3:]).T 1364 Am = np.array(MSSdata[3:]).T #...cos pos mods 1365 1365 nWaves = Am.shape[1] 1366 ngl = 201367 1366 tau = np.arange(ngl)/ngl 1368 1367 if not nWaves: 1369 1368 return 0.0,0.0 1370 1369 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']]) 1371 1371 SGT = np.array([ops[1] for ops in SSGData['SSGOps']]) 1372 RI = np.array([ops[0][3,3] for ops in SSGData['SSGOps']])1373 1372 if SGData['SGInv']: 1374 1373 SGMT = np.vstack((SGMT,-SGMT)) 1374 Sinv =np.vstack((Sinv,-Sinv)) 1375 1375 SGT = np.vstack((SGT,-SGT)) 1376 RI = np.concatenate((RI,-RI))1377 1376 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']]) 1379 1378 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,:,:]) 1381 1385 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 1387 1387 psin = np.sin(twopi*phase) 1388 1388 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] 1390 1394 return Mmod #Ntau,Nops,Natm,,Mxyz 1391 1392 1393 1394 ##works for DyMn6Ge6 but not MnWO41395 # nCen = len(SSGData['SSGCen'])1396 # nEqv = XYZ.shape[1] #full no. of equivalent pos incl centering1397 # mEqv = nEqv//nCen #no. operators not with centering; includes inversion1398 # MmodAA = 0; MmodBA = 01399 # if nWaves:1400 # phaseA = twopi*(modind[:,nxs,nxs]*(np.inner(XYZ,modQ))).T #= 2pimk.r Nops,Natm,Nwave1401 # if nCen > 0:1402 # phshp = phaseA.shape1403 # 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 ##fails1413 # modQp = np.zeros(4); modQp[:3] = modQ; modQp[3] = -1.1414 # toff = RI*np.inner(modQp,SGT)1415 # MmodA = 0; MmodB = 01416 # if nWaves:1417 # modind = np.arange(nWaves)+1.1418 # phase = twopi*(modind[:,nxs,nxs]*(np.inner(XYZ,modQ)-toff)).T1419 # 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-RBS1426 # MmodB = RAS+RBC1427 # MmodA *= thdetR[:,nxs,nxs,nxs]1428 # MmodB *= thdetR[:,nxs,nxs,nxs]1429 #1430 #from 38121431 # MmodA = 0; MmodB = 01432 # 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,Nwave1436 # 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,Mxyz1439 1395 1440 1396 def Modulation(H,HP,nWaves,Fmod,Xmod,Umod,glTau,glWt): -
trunk/GSASIIstrMath.py
r3865 r3867 1509 1509 if parmDict[pfx+'isMag']: #This part correct for making modulated mag moments on equiv atoms 1510 1510 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 1518 1513 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] 1523 1526 1524 #from #38121525 #1st try at this1526 # GSdata = Gdata.T[:,nxs,:]+Mmod #Natm,ntau,Mxyz1527 # GSdata = np.inner(GSdata,SGMT).T #apply sym. ops.--> Mxyz,Nops,Ntau,Natm1528 # if SGData['SGInv'] and not SGData['SGFixed']:1529 # GSdata = np.hstack((GSdata,-GSdata)) #inversion if any1530 # GSdata = np.hstack([GSdata for icen in range(Ncen)]) #dup over cell centering1531 # 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 vectors1533 # SMag = np.sqrt(np.sum(Kdata**2,axis=0)) #Nops,Ntau,Natm1534 # Kmean = np.mean(SMag,axis=0) #normalization --> unit vectors1535 # Kdata /= Kmean[nxs,nxs,:,:] #mxyz,nops,ntau,natm1536 1537 1527 FF = np.zeros(len(Tdata)) 1538 1528 if 'NC' in calcControls[hfx+'histType']: … … 1610 1600 HM = np.inner(Bmat,HP.T) #put into cartesian space 1611 1601 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,Mxyz1614 fbm0 = TMcorr[:,nxs,:,nxs]*GSdata0[nxs,:,:,:]*sinm[:,:,:,nxs]1615 1616 famq0 = np.sum(np.sum(fam0,axis=-2),axis=-2) #Nref,Mxyz; sum ops & atoms1617 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)^21620 fbs0 = np.sum(fbmq0,axis=-1)**2-np.sum(HM.T*fbmq0,axis=-1)**21602 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 1621 1611 #for modulated moments --> m != 0 reflections 1622 1612 # M = np.array(np.abs(H[3]),dtype=np.int)-1 … … 1633 1623 mphase = phase[:,:,nxs,:]+D[:,nxs,:,nxs] 1634 1624 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,N atm1636 sinm = np.swapaxes(np.sin(mphase), 2,3) #--> Nref,Nop,Natm,Ntau1637 cosm = np.swapaxes(np.cos(mphase), 2,3) #ditto1625 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 1638 1628 1639 1629 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 OK1641 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,Natm1630 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 1643 1633 1644 fam = (Q*TMcorr[ nxs,:,nxs,:,nxs,nxs]*cosm[nxs,:,:,:,:,nxs]*SMag[nxs,nxs,:,:,:,nxs]) #Mxyz,Nref,Nop,Natm,Ntau,ReIm1645 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]) 1646 1636 1647 fams = np.sum(np.sum( np.sum(fam,axis=-1),axis=2),axis=2) #xyz,Nref,ntau; sum ops & atoms1648 fbms = np.sum(np.sum( np.sum(fbm,axis=-1),axis=2),axis=2) #ditto1637 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 1649 1639 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) 1652 1642 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]) 1655 1645 1656 1646 else:
Note: See TracChangeset
for help on using the changeset viewer.