Changeset 3474 for trunk/GSASIIphsGUI.py
- Timestamp:
- Jul 16, 2018 4:07:12 PM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/GSASIIphsGUI.py
r3466 r3474 282 282 #NB: commonNames & commonTrans defined in GSASIIdataGUI = G2gd 283 283 ''' 284 def __init__(self,parent,phase ):284 def __init__(self,parent,phase,Trans=np.eye(3),Uvec=np.zeros(3),Vvec=np.zeros(3),ifMag=False,newSpGrp='',BNSlatt=''): 285 285 wx.Dialog.__init__(self,parent,wx.ID_ANY,'Setup phase transformation', 286 286 pos=wx.DefaultPosition,style=wx.DEFAULT_DIALOG_STYLE) … … 292 292 # self.Vec = np.zeros(4) 293 293 # else: 294 self.Trans = np.eye(3)295 self.Uvec = np.zeros(3)296 self.Vvec = np.zeros(3)294 self.Trans = Trans 295 self.Uvec = Uvec 296 self.Vvec = Vvec 297 297 self.oldSpGrp = phase['General']['SGData']['SpGrp'] 298 298 self.oldSGdata = phase['General']['SGData'] 299 self.newSpGrp = self.Phase['General']['SGData']['SpGrp'] 299 if newSpGrp: 300 self.newSpGrp = newSpGrp 301 else: 302 self.newSpGrp = self.Phase['General']['SGData']['SpGrp'] 300 303 self.oldCell = phase['General']['Cell'][1:8] 301 304 self.newCell = self.Phase['General']['Cell'][1:8] 302 305 self.Common = 'abc' 303 self.ifMag = False 306 self.ifMag = ifMag 307 if ifMag: 308 self.BNSlatt = BNSlatt 304 309 self.ifConstr = True 310 self.Mtrans = False 305 311 self.Draw() 306 312 … … 310 316 Obj = event.GetEventObject() 311 317 self.Common = Obj.GetValue() 318 self.Mtrans = False 312 319 if '*' in self.Common: 313 320 A,B = G2lat.cell2AB(self.oldCell[:6]) … … 366 373 367 374 def OnTest(event): 368 self.newCell = G2lat.TransformCell(self.oldCell[:6],self.Trans) 375 if self.Mtrans: 376 self.newCell = G2lat.TransformCell(self.oldCell[:6],self.Trans.T) 377 else: 378 self.newCell = G2lat.TransformCell(self.oldCell[:6],self.Trans) 369 379 wx.CallAfter(self.Draw) 370 380 … … 386 396 self.Trans = G2spc.ApplyBNSlatt(SGData,SGData['BNSlattsym']) 387 397 wx.CallAfter(self.Draw) 398 399 def OnMtrans(event): 400 Obj = event.GetEventObject() 401 self.Mtrans = Obj.GetValue() 388 402 389 403 SGData = self.Phase['General']['SGData'] … … 391 405 self.panel = wx.Panel(self) 392 406 mainSizer = wx.BoxSizer(wx.VERTICAL) 407 if self.ifMag: 408 if self.BNSlatt != SGData['SGLatt']: 409 GenSym,GenFlg,BNSsym = G2spc.GetGenSym(SGData) 410 SGData['BNSlattsym'] = [self.BNSlatt,BNSsym[self.BNSlatt]] 411 SGData['SGSpin'] = [1,]*len(SGData['SGSpin']) 412 else: 413 mag = wx.Button(self.panel,label='Make new phase magnetic?') 414 mag.Bind(wx.EVT_BUTTON,OnMag) 415 mainSizer.Add(mag,0,WACV) 393 416 MatSizer = wx.BoxSizer(wx.HORIZONTAL) 394 417 transSizer = wx.BoxSizer(wx.VERTICAL) … … 431 454 MatSizer.Add(transSizer) 432 455 mainSizer.Add(MatSizer) 456 if self.ifMag: 457 Mtrans = wx.CheckBox(self.panel,label=' M from Bilbao routine MAXMAGN? Use transform') 458 Mtrans.SetValue(self.Mtrans) 459 Mtrans.Bind(wx.EVT_CHECKBOX,OnMtrans) 460 mainSizer.Add(Mtrans,0,WACV) 433 461 mainSizer.Add(wx.StaticText(self.panel,label=' Old lattice parameters:'),0,WACV) 434 462 mainSizer.Add(wx.StaticText(self.panel,label= … … 444 472 mainSizer.Add(wx.StaticText(self.panel,label=' volume = %.3f'%(self.newCell[6])),0,WACV) 445 473 sgSizer = wx.BoxSizer(wx.HORIZONTAL) 446 sgSizer.Add(wx.StaticText(self.panel,label=' Space group: '),0,WACV)474 sgSizer.Add(wx.StaticText(self.panel,label=' Target space group: '),0,WACV) 447 475 SGTxt = wx.Button(self.panel,wx.ID_ANY,self.newSpGrp,size=(100,-1)) 448 476 SGTxt.Bind(wx.EVT_BUTTON,OnSpaceGroup) … … 460 488 BNSizer.Add(BNS,0,WACV) 461 489 mainSizer.Add(BNSizer,0,WACV) 462 else: 463 mag = wx.Button(self.panel,label='Make new phase magnetic?') 464 mag.Bind(wx.EVT_BUTTON,OnMag) 465 mainSizer.Add(mag,0,WACV) 466 mainSizer.Add(wx.StaticText(self.panel, \ 467 label=' NB: Nonmagnetic atoms will be deleted from new phase'),0,WACV) 490 mainSizer.Add(wx.StaticText(self.panel, \ 491 label=' NB: Nonmagnetic atoms will be deleted from new phase'),0,WACV) 468 492 constr = wx.CheckBox(self.panel,label=' Make constraints between phases?') 469 # mainSizer.Add(wx.StaticText(self.panel, \470 # label=' Constraints not correct for non-diagonal transforms'),0,WACV)471 493 constr.SetValue(self.ifConstr) 472 494 constr.Bind(wx.EVT_CHECKBOX,OnConstr) … … 497 519 else: 498 520 self.Phase['General']['Name'] += ' %s'%(self.Common) 499 self.Phase['General']['Cell'][1:] = G2lat.TransformCell(self.oldCell[:6],self.Trans) 500 return self.Phase,self.Trans,self.Uvec,self.Vvec,self.ifMag,self.ifConstr,self.Common 521 if self.Mtrans: 522 self.Phase['General']['Cell'][1:] = G2lat.TransformCell(self.oldCell[:6],self.Trans.T) 523 return self.Phase,self.Trans.T,self.Uvec,self.Vvec,self.ifMag,self.ifConstr,self.Common 524 else: 525 self.Phase['General']['Cell'][1:] = G2lat.TransformCell(self.oldCell[:6],self.Trans) 526 return self.Phase,self.Trans,self.Uvec,self.Vvec,self.ifMag,self.ifConstr,self.Common 501 527 502 528 def OnOk(self,event): … … 550 576 OkBtn = wx.Button(self.panel,-1,"Ok") 551 577 OkBtn.Bind(wx.EVT_BUTTON, self.OnOk) 552 cancelBtn = wx.Button(self.panel,-1," Use All")578 cancelBtn = wx.Button(self.panel,-1,"Cancel") 553 579 cancelBtn.Bind(wx.EVT_BUTTON, self.OnCancel) 554 580 btnSizer = wx.BoxSizer(wx.HORIZONTAL) … … 1002 1028 Flds = dlg.GetValue().split() 1003 1029 for fld in Flds: fld = fld.strip() 1004 SpcGp = ' '.join(Flds) 1030 SpcGp = ' '.join(Flds).capitalize() 1005 1031 finally: 1006 1032 dlg.Destroy() … … 2294 2320 2295 2321 def OnTransform(event): 2296 dlg = TransformDialog(G2frame,data) 2297 try: 2298 if dlg.ShowModal() == wx.ID_OK: 2299 newPhase,Trans,Uvec,Vvec,ifMag,ifConstr,Common = dlg.GetSelection() 2322 Trans = np.eye(3) 2323 Uvec = np.zeros(3) 2324 Vvec = np.zeros(3) 2325 ifMag = False 2326 newSpGrp = '' 2327 BNSlatt = '' 2328 while True: 2329 dlg = TransformDialog(G2frame,data,Trans,Uvec,Vvec,ifMag,newSpGrp,BNSlatt) 2330 try: 2331 if dlg.ShowModal() == wx.ID_OK: 2332 newPhase,Trans,Uvec,Vvec,ifMag,ifConstr,Common = dlg.GetSelection() 2333 newSpGrp = newPhase['General']['SGData']['SpGrp'] 2334 if ifMag: 2335 BNSlatt = newPhase['General']['SGData']['BNSlattsym'][0] 2336 else: 2337 return 2338 finally: 2339 dlg.Destroy() 2340 if 'setting' in Common: #don't make new phase, Just move atoms! 2341 generalData = data['General'] 2342 cx,ct,cs,cia = generalData['AtomPtrs'] 2343 SGData = generalData['SGData'] 2344 if SGData['SpGrp'] in G2spc.spg2origins: 2345 T = G2spc.spg2origins[SGData['SpGrp']] 2346 Atoms = data['Atoms'] 2347 for atom in Atoms: 2348 for i in [0,1,2]: 2349 atom[cx+i] += T[i] 2350 data['Drawing'] = [] 2351 break 2300 2352 else: 2301 return 2302 finally: 2303 dlg.Destroy() 2304 if 'setting' in Common: #don't make new phase, Just move atoms! 2305 generalData = data['General'] 2306 cx,ct,cs,cia = generalData['AtomPtrs'] 2307 SGData = generalData['SGData'] 2308 if SGData['SpGrp'] in G2spc.spg2origins: 2309 T = G2spc.spg2origins[SGData['SpGrp']] 2310 Atoms = data['Atoms'] 2311 for atom in Atoms: 2312 for i in [0,1,2]: 2313 atom[cx+i] += T[i] 2314 data['Drawing'] = [] 2315 else: 2316 phaseName = newPhase['General']['Name'] 2317 newPhase,atCodes = G2lat.TransformPhase(data,newPhase,Trans,Uvec,Vvec,ifMag) 2318 detTrans = np.abs(nl.det(Trans)) 2319 2320 generalData = newPhase['General'] 2321 SGData = generalData['SGData'] 2322 SGData['fromParent'] = [Trans,Uvec,Vvec] #save these 2323 Atoms = newPhase['Atoms'] 2324 if ifMag: 2325 dlg = UseMagAtomDialog(G2frame,Atoms,atCodes) 2326 try: 2327 if dlg.ShowModal() == wx.ID_OK: 2328 newPhase['Atoms'],atCodes = dlg.GetSelection() 2329 finally: 2330 dlg.Destroy() 2331 SGData['GenSym'],SGData['GenFlg'],BNSsym = G2spc.GetGenSym(SGData) 2332 SGData['MagSpGrp'] = G2spc.MagSGSym(SGData) 2333 SGData['OprNames'],SGData['SpnFlp'] = G2spc.GenMagOps(SGData) 2334 generalData['Lande g'] = len(generalData['AtomTypes'])*[2.,] 2353 phaseName = newPhase['General']['Name'] 2354 newPhase,atCodes = G2lat.TransformPhase(data,newPhase,Trans,Uvec,Vvec,ifMag) 2355 detTrans = np.abs(nl.det(Trans)) 2356 2357 newPhase['ParentId'] = data['ranId'] 2358 generalData = newPhase['General'] 2359 SGData = generalData['SGData'] 2360 SGData['fromParent'] = [Trans,Uvec,Vvec] #save these 2361 Atoms = newPhase['Atoms'] 2362 if ifMag: 2363 dlg = UseMagAtomDialog(G2frame,Atoms,atCodes) 2364 try: 2365 if dlg.ShowModal() == wx.ID_OK: 2366 newPhase['Atoms'],atCodes = dlg.GetSelection() 2367 SGData['GenSym'],SGData['GenFlg'],BNSsym = G2spc.GetGenSym(SGData) 2368 SGData['MagSpGrp'] = G2spc.MagSGSym(SGData) 2369 SGData['OprNames'],SGData['SpnFlp'] = G2spc.GenMagOps(SGData) 2370 generalData['Lande g'] = len(generalData['AtomTypes'])*[2.,] 2371 break 2372 finally: 2373 dlg.Destroy() 2374 else: 2375 break 2335 2376 2336 2337 2338 2339 2340 2341 2342 2343 2344 2345 2346 2347 2348 2349 2350 2351 2377 NShkl = len(G2spc.MustrainNames(SGData)) 2378 NDij = len(G2spc.HStrainNames(SGData)) 2379 UseList = newPhase['Histograms'] 2380 for hist in UseList: 2381 UseList[hist]['Scale'] /= detTrans #scale by 1/volume ratio 2382 UseList[hist]['Mustrain'][4:6] = [NShkl*[0.01,],NShkl*[False,]] 2383 UseList[hist]['HStrain'] = [NDij*[0.0,],NDij*[False,]] 2384 newPhase['General']['Map'] = mapDefault.copy() 2385 sub = G2frame.GPXtree.AppendItem(parent= 2386 G2gd.GetGPXtreeItemId(G2frame,G2frame.root,'Phases'),text=phaseName) 2387 G2frame.GPXtree.SetItemPyData(sub,newPhase) 2388 newPhase['Drawing'] = [] 2389 2390 if ifConstr: 2391 G2cnstG.TransConstraints(G2frame,data,newPhase,Trans,Vvec,atCodes) #data is old phase 2392 G2frame.GPXtree.SelectItem(sub) 2352 2393 2353 2394 ################################################################################
Note: See TracChangeset
for help on using the changeset viewer.