Changeset 3646
- Timestamp:
- Oct 4, 2018 4:55:17 PM (5 years ago)
- Location:
- trunk
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/GSASIIlattice.py
r3638 r3646 276 276 Uij = np.inner(Trans,np.inner(U6toUij(U6),Trans).T)/nl.det(Trans) 277 277 return UijtoU6(Uij) 278 279 def TransformPhase(oldPhase,newPhase,Trans,Uvec,Vvec,ifMag): 280 '''Transform atoms from oldPhase to newPhase 281 M' is inv(M) 282 does X' = M(X-U)+V transformation for coordinates and U' = MUM/det(M) 283 for anisotropic thermal parameters 284 285 :param oldPhase: dict G2 phase info for old phase 286 :param newPhase: dict G2 phase info for new phase; with new cell & space group 287 atoms are from oldPhase & will be transformed 288 :param Trans: lattice transformation matrix M 289 :param Uvec: array parent coordinates transformation vector U 290 :param Vvec: array child coordinate transformation vector V 291 :param ifMag: bool True if convert to magnetic phase; 292 if True all nonmagnetic atoms will be removed 293 294 ''' 295 296 cx,ct,cs,cia = oldPhase['General']['AtomPtrs'] 297 cm = 0 298 if oldPhase['General']['Type'] == 'magnetic': 299 cm = cx+4 300 oAmat,oBmat = cell2AB(oldPhase['General']['Cell'][1:7]) 301 nAmat,nBmat = cell2AB(newPhase['General']['Cell'][1:7]) 302 SGData = newPhase['General']['SGData'] 303 invTrans = nl.inv(Trans) 304 newAtoms,atCodes = FillUnitCell(oldPhase) 305 Unit =[abs(int(max(unit))-1) for unit in Trans.T] 278 279 def ExpandCell(Atoms,atCodes,cx,Trans): 280 Unit =[int(max(abs(np.array(unit)))-1) for unit in Trans.T] 306 281 for i,unit in enumerate(Unit): 307 282 if unit > 0: 308 283 for j in range(unit): 309 moreAtoms = copy.deepcopy( newAtoms)284 moreAtoms = copy.deepcopy(Atoms) 310 285 moreCodes = [] 311 286 for atom,code in zip(moreAtoms,atCodes): … … 319 294 cell[i] += 1 320 295 moreCodes.append('%s+%d,%d,%d'%(ops,cell[0],cell[1],cell[2])) 321 newAtoms += moreAtoms296 Atoms += moreAtoms 322 297 atCodes += moreCodes 298 return Atoms,atCodes 299 300 def TransformPhase(oldPhase,newPhase,Trans,Uvec,Vvec,ifMag): 301 '''Transform atoms from oldPhase to newPhase 302 M' is inv(M) 303 does X' = M(X-U)+V transformation for coordinates and U' = MUM/det(M) 304 for anisotropic thermal parameters 305 306 :param oldPhase: dict G2 phase info for old phase 307 :param newPhase: dict G2 phase info for new phase; with new cell & space group 308 atoms are from oldPhase & will be transformed 309 :param Trans: lattice transformation matrix M 310 :param Uvec: array parent coordinates transformation vector U 311 :param Vvec: array child coordinate transformation vector V 312 :param ifMag: bool True if convert to magnetic phase; 313 if True all nonmagnetic atoms will be removed 314 315 ''' 316 317 cx,ct,cs,cia = oldPhase['General']['AtomPtrs'] 318 cm = 0 319 if oldPhase['General']['Type'] == 'magnetic': 320 cm = cx+4 321 oAmat,oBmat = cell2AB(oldPhase['General']['Cell'][1:7]) 322 nAmat,nBmat = cell2AB(newPhase['General']['Cell'][1:7]) 323 SGData = newPhase['General']['SGData'] 324 invTrans = nl.inv(Trans) 325 newAtoms,atCodes = FillUnitCell(oldPhase) 326 newAtoms,atCodes = ExpandCell(newAtoms,atCodes,cx,Trans) 323 327 if ifMag: 324 328 cia += 3 -
trunk/GSASIIphsGUI.py
r3638 r3646 590 590 '''Get user selected magnetic atoms after cell transformation 591 591 ''' 592 def __init__(self,parent,Name,Atoms,atCodes,atMxyz,if Delete=False):592 def __init__(self,parent,Name,Atoms,atCodes,atMxyz,ifOK=False,ifDelete=False): 593 593 wx.Dialog.__init__(self,parent,wx.ID_ANY,'Magnetic atom selection', 594 594 pos=wx.DefaultPosition,style=wx.DEFAULT_DIALOG_STYLE) … … 598 598 self.atCodes = atCodes 599 599 self.atMxyz = atMxyz 600 self.ifOK = ifOK 600 601 self.ifDelete = ifDelete 601 602 self.Use = len(self.Atoms)*[True,] … … 633 634 mainSizer.Add(atmSizer) 634 635 635 YesBtn = wx.Button(self.panel,-1,"Yes")636 YesBtn.Bind(wx.EVT_BUTTON, self.OnYes)637 NoBtn = wx.Button(self.panel,-1,"No")638 NoBtn.Bind(wx.EVT_BUTTON, self.OnNo)639 636 btnSizer = wx.BoxSizer(wx.HORIZONTAL) 640 btnSizer.Add((20,20),1) 641 btnSizer.Add(YesBtn) 642 btnSizer.Add((20,20),1) 643 btnSizer.Add(NoBtn) 644 if self.ifDelete: 645 DeleteBtn = wx.Button(self.panel,-1,"Delete") 646 DeleteBtn.Bind(wx.EVT_BUTTON, self.OnDelete) 637 if self.ifOK: 638 OKBtn = wx.Button(self.panel,-1,"OK") 639 OKBtn.Bind(wx.EVT_BUTTON, self.OnNo) 640 btnSizer.Add(OKBtn) 641 else: 642 YesBtn = wx.Button(self.panel,-1,"Yes") 643 YesBtn.Bind(wx.EVT_BUTTON, self.OnYes) 644 NoBtn = wx.Button(self.panel,-1,"No") 645 NoBtn.Bind(wx.EVT_BUTTON, self.OnNo) 647 646 btnSizer.Add((20,20),1) 648 btnSizer.Add(DeleteBtn) 649 btnSizer.Add((20,20),1) 647 btnSizer.Add(YesBtn) 648 btnSizer.Add((20,20),1) 649 btnSizer.Add(NoBtn) 650 if self.ifDelete: 651 DeleteBtn = wx.Button(self.panel,-1,"Delete") 652 DeleteBtn.Bind(wx.EVT_BUTTON, self.OnDelete) 653 btnSizer.Add((20,20),1) 654 btnSizer.Add(DeleteBtn) 655 btnSizer.Add((20,20),1) 650 656 651 657 mainSizer.Add(btnSizer,0,wx.EXPAND|wx.BOTTOM|wx.TOP, 10) -
trunk/GSASIIpwdGUI.py
r3638 r3646 3161 3161 controls[15] = testAtoms 3162 3162 G2frame.dataWindow.RunSubGroupsMag.Enable(True) 3163 G2frame.GPXtree.SetItemPyData(UnitCellsId,data) 3163 3164 G2frame.dataWindow.RefineCell.Enable(True) 3164 3165 OnHklShow(None) … … 3372 3373 r,c = event.GetRow(),event.GetCol() 3373 3374 if magcells: 3374 if c == 1: 3375 if c == 0: 3376 r = event.GetRow() 3377 phase = magcells[r] 3378 mSGData = phase['SGData'] 3379 msg = 'Magnetic space group information for '+phase['Name'] 3380 text,table = G2spc.SGPrint(mSGData,AddInv=True) 3381 text[0] = ' Magnetic Space Group: '+mSGData['MagSpGrp'] 3382 text[3] = ' The magnetic lattice point group is '+mSGData['MagPtGp'] 3383 OprNames,SpnFlp = G2spc.GenMagOps(mSGData) 3384 G2G.SGMagSpinBox(G2frame.dataWindow,msg,text,table,mSGData['SGCen'],OprNames, 3385 mSGData['SpnFlp'],False).Show() 3386 elif c == 1: 3375 3387 for i in range(len(magcells)): 3376 3388 magcells[i]['Use'] = False … … 3379 3391 magDisplay.ForceRefresh() 3380 3392 magcells[r]['Use'] = True 3381 SGData = magcells[r]['SGData']3393 mSGData = magcells[r]['SGData'] 3382 3394 A = G2lat.cell2A(magcells[r]['Cell'][:6]) 3383 G2frame.HKL = G2pwd.getHKLpeak(1.0, SGData,A,Inst)3395 G2frame.HKL = G2pwd.getHKLpeak(1.0,mSGData,A,Inst) 3384 3396 G2plt.PlotPatterns(G2frame) 3385 3397 elif c == 2: … … 3391 3403 MagCellsTable.SetValue(r,c,True) 3392 3404 magDisplay.ForceRefresh() 3405 elif c ==3: 3406 r = event.GetRow() 3407 allmom = magcells[0].get('allmom',False) 3408 magAtms = magcells[0].get('magAtms','') 3409 maxequiv = magcells[0].get('maxequiv',100) 3410 phase = magcells[r] 3411 mSGData = magcells[r]['SGData'] 3412 Uvec = phase['Uvec'] 3413 Trans = phase['Trans'] 3414 mAtoms = TestMagAtoms(phase,magAtms,SGData,Uvec,Trans,allmom,maxequiv) 3415 Atms = [] 3416 AtCods = [] 3417 atMxyz = [] 3418 for ia,atom in enumerate(mAtoms): 3419 atom[0] += '_%d'%ia 3420 SytSym,Mul,Nop,dupDir = G2spc.SytSym(atom[2:5],mSGData) 3421 CSI = G2spc.GetCSpqinel(mSGData['SpnFlp'],dupDir) 3422 Atms.append(atom[:2]+['',]+atom[2:5]) 3423 AtCods.append('1') 3424 MagSytSym = G2spc.MagSytSym(SytSym,dupDir,SGData) 3425 atMxyz.append([MagSytSym,CSI[0]]) 3426 G2phsG.UseMagAtomDialog(G2frame,magcells[r]['Name'],Atms,AtCods,atMxyz,ifOK=True).ShowModal() 3393 3427 data = [controls,bravais,cells,dminx,ssopt,magcells] 3394 3428 G2frame.GPXtree.SetItemPyData(UnitCellsId,data) … … 3402 3436 allmom = magcells[0].get('allmom',False) 3403 3437 magAtms = magcells[0].get('magAtms','') 3404 maxequiv = magcells[0].get('maxequiv',100 0)3438 maxequiv = magcells[0].get('maxequiv',100) 3405 3439 dlg = G2G.MultiDataDialog(G2frame,title='Keep options', 3406 prompts=[' test for mag. atoms','all have moment','max unique'],3407 values=[ '',allmom,maxequiv],limits=[testAtoms,[True,False],[1,100]],3408 formats=[' choice','bool','%d',])3440 prompts=['max unique','test for mag. atoms','all have moment',], 3441 values=[maxequiv,'',allmom],limits=[[1,100],testAtoms,[True,False]], 3442 formats=['%d','choice','bool']) 3409 3443 if dlg.ShowModal() == wx.ID_OK: 3410 atype,allmom,maxequiv= dlg.GetValues()3444 maxequiv,atype,allmom = dlg.GetValues() 3411 3445 magAtms = [atom for atom in controls[15] if atom[1] == atype] 3412 3446 for phase in magcells: 3413 3447 Uvec = phase['Uvec'] 3414 3448 Trans = phase['Trans'] 3415 invTrans = nl.inv(Trans) 3416 phase['nAtoms'] = TestMagAtoms(phase,magAtms,SGData,Uvec,invTrans,allmom,maxequiv) 3449 phase['nAtoms'] = len(TestMagAtoms(phase,magAtms,SGData,Uvec,Trans,allmom,maxequiv)) 3417 3450 data = controls,bravais,cells,dminx,ssopt,magcells 3418 3451 G2frame.GPXtree.SetItemPyData(UnitCellsId,data) 3419 3452 wx.CallAfter(UpdateUnitCellsGrid,G2frame,data) 3420 elif c < 0:3421 r = event.GetRow()3422 phase = magcells[r]3423 SGData = phase['SGData']3424 msg = 'Magnetic space group information for '+phase['Name']3425 text,table = G2spc.SGPrint(SGData,AddInv=True)3426 text[0] = ' Magnetic Space Group: '+SGData['MagSpGrp']3427 text[3] = ' The magnetic lattice point group is '+SGData['MagPtGp']3428 OprNames,SpnFlp = G2spc.GenMagOps(SGData)3429 G2G.SGMagSpinBox(G2frame.dataWindow,msg,text,table,SGData['SGCen'],OprNames,3430 SGData['SpnFlp'],False).Show()3431 3453 3432 3454 def MakeNewPhase(event): … … 3535 3557 wx.CallAfter(UpdateUnitCellsGrid,G2frame,data) 3536 3558 3537 def TestMagAtoms(phase,magAtms,SGData,Uvec, invTrans,allmom,maxequiv=1000):3559 def TestMagAtoms(phase,magAtms,SGData,Uvec,Trans,allmom,maxequiv=1000): 3538 3560 found = False 3539 3561 phase['Keep'] = False … … 3541 3563 phase['Keep'] = True 3542 3564 return 3565 invTrans = nl.inv(Trans) 3566 atCodes = [] 3543 3567 Phase = {'General':{'AtomPtrs':[2,1],'SGData':copy.deepcopy(phase['SGData'])},'Atoms':[]} 3544 3568 for matm in magAtms: 3545 xyzs = G2spc.GenAtom(matm[3:6],SGData,False,Move=True) 3569 XYZ = G2spc.GenAtom(matm[3:6],SGData,False,Move=True) 3570 xyzs = [xyz[0] for xyz in XYZ] 3571 atCodes += len(xyzs)*['1',] 3572 xyzs,atCodes = G2lat.ExpandCell(xyzs,atCodes,0,Trans) 3546 3573 for ix,x in enumerate(xyzs): 3547 xyz = G2lat.TransformXYZ(x [0]-Uvec,invTrans.T,np.zeros(3))%1.3574 xyz = G2lat.TransformXYZ(x-Uvec,invTrans.T,np.zeros(3))%1. 3548 3575 Phase['Atoms'].append(matm[:2]+list(xyz)) 3549 3576 SytSym,Mul,Nop,dupDir = G2spc.SytSym(xyz,phase['SGData']) … … 3552 3579 phase['Keep'] = True 3553 3580 if allmom: 3554 if not any(CSI[0]): #found one - can quit looking3581 if not any(CSI[0]): 3555 3582 phase['Keep'] = False 3556 3583 found = True 3557 atCodes = len(Phase['Atoms'])*['1',]3558 natm = len( G2lat.GetUnique(Phase,atCodes)[0])3584 uAtms = G2lat.GetUnique(Phase,atCodes)[0] 3585 natm = len(uAtms) 3559 3586 if natm > maxequiv or found: #too many allowed atoms found 3560 3587 phase['Keep'] = False 3561 return natm3588 return uAtms 3562 3589 3563 3590 def OnRunSubsMag(event): 3564 3591 import kSUBGROUPSMAG as kMAG 3565 controls,bravais,cells,dminx,ssopt,magcells = G2frame.GPXtree.GetItemPyData(G2gd.GetGPXtreeItemId(G2frame,G2frame.PatternId, 'Unit Cells List')) 3592 pUCid = G2gd.GetGPXtreeItemId(G2frame,G2frame.PatternId, 'Unit Cells List') 3593 controls,bravais,cells,dminx,ssopt,magcells = G2frame.GPXtree.GetItemPyData(pUCid) 3566 3594 E,SGData = G2spc.SpcGroup(controls[13]) 3567 3595 testAtoms = ['',]+list(set([atom[1] for atom in controls[15]])) … … 3621 3649 if RVT is not None: 3622 3650 result,Uvec,Trans = RVT 3623 invTrans = nl.inv(Trans)3624 3651 phase = G2lat.makeBilbaoPhase(result,Uvec,Trans) 3625 3652 phase['Cell'] = G2lat.TransformCell(controls[6:12],Trans) … … 3628 3655 phase['magAtms'] = magAtms 3629 3656 phase['maxequiv'] = maxequiv 3630 phase['nAtoms'] = TestMagAtoms(phase,magAtms,SGData,Uvec,invTrans,allmom,maxequiv)3657 phase['nAtoms'] = len(TestMagAtoms(phase,magAtms,SGData,Uvec,Trans,allmom,maxequiv)) 3631 3658 magcells.append(phase) 3632 3659 magcells[0]['Use'] = True … … 3636 3663 G2plt.PlotPatterns(G2frame) 3637 3664 data = [controls,bravais,cells,dmin,ssopt,magcells] 3638 G2frame.GPXtree.SetItemPyData( G2gd.GetGPXtreeItemId(G2frame,G2frame.PatternId, 'Unit Cells List'),data)3665 G2frame.GPXtree.SetItemPyData(pUCid,data) 3639 3666 G2frame.OnFileSave(event) 3640 3667 wx.CallAfter(UpdateUnitCellsGrid,G2frame,data) … … 3919 3946 G2frame.dataWindow.RunSubGroupsMag.Enable(True) 3920 3947 G2frame.dataWindow.CopyCell.Enable(False) 3921 Label = '\n Magnetic cells from Bilbao k-SUBGROUPSMAG for %s; kvec1: (%s), kvec2: (%s):'%( SGData['SpGrp'],''.join(controls[14][:3]),''.join(controls[14][3:]))3948 Label = '\n Magnetic cells from Bilbao k-SUBGROUPSMAG for %s; kvec1: (%s), kvec2: (%s):'%(controls[13],''.join(controls[14][:3]),''.join(controls[14][3:])) 3922 3949 mainSizer.Add(wx.StaticText(parent=G2frame.dataWindow,label=Label),0,WACV) 3923 3950 rowLabels = [] 3924 3951 for i in range(len(magcells)): rowLabels.append(str(i+1)) 3925 colLabels = ['Space Gp .','Try','Keep','Uniq','Trans','Vec','a','b','c','alpha','beta','gamma','Volume']3952 colLabels = ['Space Gp','Try','Keep','Uniq','Trans','Vec','a','b','c','alpha','beta','gamma','Volume'] 3926 3953 Types = [wg.GRID_VALUE_STRING,wg.GRID_VALUE_BOOL,wg.GRID_VALUE_BOOL,wg.GRID_VALUE_LONG,wg.GRID_VALUE_STRING,wg.GRID_VALUE_STRING,]+ \ 3927 3954 3*[wg.GRID_VALUE_FLOAT+':10,5',]+3*[wg.GRID_VALUE_FLOAT+':10,3',]+[wg.GRID_VALUE_FLOAT+':10,2'] … … 3935 3962 table.append(row) 3936 3963 MagCellsTable = G2G.Table(table,rowLabels=rowLabels,colLabels=colLabels,types=Types) 3937 G2frame.GetStatusBar().SetStatusText('Double click Keep to refresh Keep flags , row no. to see sym. ops.',1)3964 G2frame.GetStatusBar().SetStatusText('Double click Keep to refresh Keep flags; click Space Gp to see sym. ops., Uniq to see unique atoms list',1) 3938 3965 magDisplay = G2G.GSGrid(G2frame.dataWindow) 3939 3966 magDisplay.SetTable(MagCellsTable, True)
Note: See TracChangeset
for help on using the changeset viewer.