Changeset 3686
- Timestamp:
- Oct 22, 2018 8:58:53 AM (4 years ago)
- Location:
- trunk
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/GSASIIdataGUI.py
r3682 r3686 5342 5342 self.GeneralCalc.Append(G2G.wxID_MULTIMCSA,'Multi MC/SA','Run Monte Carlo - Simulated Annealing on multiprocessors') 5343 5343 self.GeneralCalc.Append(G2G.wxID_TRANSFORMSTRUCTURE,'Transform','Transform crystal structure') 5344 self.GeneralCalc.Append(G2G.wxID_USEBILBAOMAG,'Select magnetic phase','If disabled, make in PWDR/Unit Cells')5344 self.GeneralCalc.Append(G2G.wxID_USEBILBAOMAG,'Select magnetic/subgroup phase','If disabled, make in PWDR/Unit Cells') 5345 5345 self.GeneralCalc.Append(G2G.wxID_VALIDPROTEIN,'Protein quality','Protein quality analysis') 5346 5346 self.PostfillDataMenu() -
trunk/GSASIIlattice.py
r3685 r3686 389 389 Uvec = Phase['Uvec'] 390 390 SGData = Phase['SGData'] 391 MSG = SGData ['MagSpGrp'].split(' ',1)391 MSG = SGData.get('MagSpGrp',SGData['SpGrp']).split(' ',1) 392 392 MSG[0] += ' ' 393 393 bns = '' 394 394 if '_' in MSG[0]: 395 395 bns = MSG[0][2] 396 spn = SGData ['SGSpin']396 spn = SGData.get('SGSpin',[]) 397 397 if 'ortho' in SGData['SGSys']: 398 398 lattSym = G2spc.getlattSym(Trans) 399 399 SpGrp = SGData['SpGrp'] 400 400 NTrans = np.inner(Mats[lattSym].T,Trans.T) #ok 401 spn[1:4] = np.inner(np.abs(nl.inv(Mats[lattSym])),spn[1:4]) #ok401 if len(spn): spn[1:4] = np.inner(np.abs(nl.inv(Mats[lattSym])),spn[1:4]) #ok 402 402 SGsym = G2spc.getlattSym(nl.inv(Mats[lattSym])) 403 403 … … 414 414 Bns = BNS[bns][lattSym] 415 415 NSG[0] += '_'+Bns+' ' 416 el se:416 elif len(spn): 417 417 for ifld in [1,2,3]: 418 418 if spn[ifld] < 0: … … 450 450 return None 451 451 452 def makeBilbaoPhase(result,uvec,trans ):452 def makeBilbaoPhase(result,uvec,trans,ifMag=False): 453 453 phase = {} 454 454 phase['Name'] = result[0].strip() … … 461 461 SpGrp = G2spc.StandardizeSpcName(SpGp) 462 462 phase['SGData'] = G2spc.SpcGroup(SpGrp)[1] 463 BNSlatt = phase['SGData']['SGLatt'] 464 if not result[1]: 465 phase['SGData']['SGSpin'] = G2spc.GetSGSpin(phase['SGData'],result[0]) 466 phase['SGData']['GenSym'],phase['SGData']['GenFlg'],BNSsym = G2spc.GetGenSym(phase['SGData']) 467 if result[1]: 468 BNSlatt += '_'+result[1] 469 phase['SGData']['BNSlattsym'] = [BNSlatt,BNSsym[BNSlatt]] 470 G2spc.ApplyBNSlatt(phase['SGData'],phase['SGData']['BNSlattsym']) 471 phase['SGData']['SpnFlp'] = G2spc.GenMagOps(phase['SGData'])[1] 472 phase['SGData']['MagSpGrp'] = G2spc.MagSGSym(phase['SGData']) 463 if ifMag: 464 BNSlatt = phase['SGData']['SGLatt'] 465 if not result[1]: 466 phase['SGData']['SGSpin'] = G2spc.GetSGSpin(phase['SGData'],result[0]) 467 phase['SGData']['GenSym'],phase['SGData']['GenFlg'],BNSsym = G2spc.GetGenSym(phase['SGData']) 468 if result[1]: 469 BNSlatt += '_'+result[1] 470 phase['SGData']['BNSlattsym'] = [BNSlatt,BNSsym[BNSlatt]] 471 G2spc.ApplyBNSlatt(phase['SGData'],phase['SGData']['BNSlattsym']) 472 phase['SGData']['SpnFlp'] = G2spc.GenMagOps(phase['SGData'])[1] 473 phase['SGData']['MagSpGrp'] = G2spc.MagSGSym(phase['SGData']) 473 474 return phase 474 475 -
trunk/GSASIIphsGUI.py
r3682 r3686 590 590 '''Get user selected magnetic atoms after cell transformation 591 591 ''' 592 def __init__(self,parent,Name,Atoms,atCodes,atMxyz,ifOK=False,ifDelete=False): 593 wx.Dialog.__init__(self,parent,wx.ID_ANY,'Magnetic atom selection', 592 def __init__(self,parent,Name,Atoms,atCodes,atMxyz,ifMag=True,ifOK=False,ifDelete=False): 593 title = 'Subgroup atom list' 594 if ifMag: 595 title = 'Magnetic atom selection' 596 wx.Dialog.__init__(self,parent,wx.ID_ANY,title, 594 597 pos=wx.DefaultPosition,style=wx.DEFAULT_DIALOG_STYLE) 595 self.panel = wx.Panel(self) #just a dummy - gets destroyed in Draw! 598 self.panel = wxscroll.ScrolledPanel(self) #just a dummy - gets destroyed in Draw! 599 # self.panel = wx.Panel(self) #just a dummy - gets destroyed in Draw! 596 600 self.Name = Name 597 601 self.Atoms = Atoms 598 602 self.atCodes = atCodes 599 603 self.atMxyz = atMxyz 604 self.ifMag = ifMag 600 605 self.ifOK = ifOK 601 606 self.ifDelete = ifDelete … … 612 617 613 618 self.panel.Destroy() 614 self.panel = wx .Panel(self)619 self.panel = wxscroll.ScrolledPanel(self,style = wx.DEFAULT_DIALOG_STYLE) 615 620 Indx = {} 616 621 Mstr = [' Mx',' My',' Mz'] 622 Xstr = ['X','Y','Z'] 617 623 mainSizer = wx.BoxSizer(wx.VERTICAL) 618 624 mainSizer.Add(wx.StaticText(self.panel,label='For: %s'%self.Name),0,WACV) 619 625 620 mainSizer.Add(wx.StaticText(self.panel,label=' Name, x, y, z, allowed moments, mag. site sym:'),0,WACV) 626 if self.ifMag: 627 mainSizer.Add(wx.StaticText(self.panel,label=' Name, x, y, z, allowed moments, mag. site sym:'),0,WACV) 628 else: 629 mainSizer.Add(wx.StaticText(self.panel,label=' Name, x, y, z, allowed xyz, site sym:'),0,WACV) 621 630 atmSizer = wx.FlexGridSizer(0,2,5,5) 622 631 for iuse,[use,atom,mxyz] in enumerate(zip(self.Use,self.Atoms,self.atMxyz)): … … 624 633 for i,mx in enumerate(mxyz[1]): 625 634 if mx: 626 mstr[i] = Mstr[i] 627 useChk = wx.CheckBox(self.panel,label='Use?') 628 Indx[useChk.GetId()] = iuse 629 useChk.SetValue(use) 630 useChk.Bind(wx.EVT_CHECKBOX, OnUseChk) 631 atmSizer.Add(useChk,0,WACV) 635 if self.ifMag: 636 mstr[i] = Mstr[i] 637 else: 638 mstr[i] = Xstr[i] 639 if self.ifMag: 640 useChk = wx.CheckBox(self.panel,label='Use?') 641 Indx[useChk.GetId()] = iuse 642 useChk.SetValue(use) 643 useChk.Bind(wx.EVT_CHECKBOX, OnUseChk) 644 atmSizer.Add(useChk,0,WACV) 645 else: 646 atmSizer.Add((2,2),0) 632 647 text = ' %5s %10.5f %10.5f %10.5f (%s,%s,%s) %s '%(atom[0],atom[3],atom[4],atom[5],mstr[0],mstr[1],mstr[2],mxyz[0]) 633 648 atmSizer.Add(wx.StaticText(self.panel,label=text),0,WACV) … … 657 672 mainSizer.Add(btnSizer,0,wx.EXPAND|wx.BOTTOM|wx.TOP, 10) 658 673 self.panel.SetSizer(mainSizer) 659 self.panel.Fit() 660 self.Fit() 674 size = np.array(self.GetSize()) 675 self.panel.SetupScrolling() 676 self.panel.SetAutoLayout(1) 677 size = [size[0]-5,size[1]-20] #this fiddling is needed for older wx! 678 self.panel.SetSize(size) 661 679 662 680 def GetSelection(self): … … 2442 2460 if not '_' in BNSlatt: 2443 2461 SGData['SGSpin'] = G2spc.GetSGSpin(SGData,SGData['MagSpGrp']) 2444 2445 2446 2447 2462 else: 2448 2463 return … … 2463 2478 else: 2464 2479 phaseName = newPhase['General']['Name'] 2465 2466 2467 2480 newPhase,atCodes = G2lat.TransformPhase(data,newPhase,Trans,Uvec,Vvec,ifMag) 2468 2481 detTrans = np.abs(nl.det(Trans)) … … 2517 2530 magIds = [] 2518 2531 magchoices = [] 2532 ifMag = False 2519 2533 for mid,magdata in enumerate(magData): 2520 2534 if magdata['Keep']: 2535 if 'magAtms' in magdata: 2536 ifMag = True 2521 2537 magdata['No.'] = mid+1 2522 2538 trans = G2spc.Trans2Text(magdata['Trans']) … … 2526 2542 magchoices.append('(%d) %s; (%s) + (%s)'%(mid+1,magdata['Name'],trans,vec)) 2527 2543 if not len(magKeep): 2528 G2frame.ErrorDialog(' Magnetic phase selection error','No magnetic phases found; be sure to "Keep" some')2544 G2frame.ErrorDialog('Subgroup/magnetic phase selection error','No magnetic phases found; be sure to "Keep" some') 2529 2545 return 2530 dlg = wx.SingleChoiceDialog(G2frame,'Select magnetic space group','Make new magnetic phase',magchoices) 2546 if ifMag: 2547 dlg = wx.SingleChoiceDialog(G2frame,'Select magnetic space group','Make new magnetic phase',magchoices) 2548 else: 2549 dlg = wx.SingleChoiceDialog(G2frame,'Select subgroup','Make new subgroup phase',magchoices) 2531 2550 opt = dlg.ShowModal() 2532 2551 if opt == wx.ID_OK: … … 2534 2553 magchoice = magKeep[sel] 2535 2554 magId = magIds[sel] 2536 phaseName = '%s mag_%d'%(data['General']['Name'],magchoice['No.']) 2555 if ifMag: 2556 phaseName = '%s mag_%d'%(data['General']['Name'],magchoice['No.']) 2557 else: 2558 phaseName = '%s sub_%d'%(data['General']['Name'],magchoice['No.']) 2537 2559 newPhase = copy.deepcopy(data) 2538 2560 newPhase['ranId'] = ran.randint(0,sys.maxsize), … … 2544 2566 SGData = generalData['SGData'] 2545 2567 vvec = np.array([0.,0.,0.]) 2546 newPhase,atCodes = G2lat.TransformPhase(data,newPhase,magchoice['Trans'],magchoice['Uvec'],vvec, True)2568 newPhase,atCodes = G2lat.TransformPhase(data,newPhase,magchoice['Trans'],magchoice['Uvec'],vvec,ifMag) 2547 2569 Atoms = newPhase['Atoms'] 2548 2570 Atms = [] … … 2550 2572 atMxyz = [] 2551 2573 for ia,atom in enumerate(Atoms): 2552 if not len(G2elem.GetMFtable([atom[1],],[2.0,])):2574 if ifMag and not len(G2elem.GetMFtable([atom[1],],[2.0,])): 2553 2575 continue 2554 2576 atom[0] += '_%d'%ia 2577 atom[2] = '' #clear away refinement flags 2555 2578 SytSym,Mul,Nop,dupDir = G2spc.SytSym(atom[3:6],SGData) 2556 CSI = G2spc.GetCSpqinel(SGData['SpnFlp'],dupDir)2557 2579 Atms.append(atom) 2558 2580 AtCods.append(atCodes[ia]) 2559 MagSytSym = G2spc.MagSytSym(SytSym,dupDir,SGData) 2560 atMxyz.append([MagSytSym,CSI[0]]) 2561 dlg = UseMagAtomDialog(G2frame,magchoices[sel],Atms,AtCods,atMxyz,ifDelete=True) 2581 if ifMag: 2582 MagSytSym = G2spc.MagSytSym(SytSym,dupDir,SGData) 2583 CSI = G2spc.GetCSpqinel(SGData['SpnFlp'],dupDir) 2584 atMxyz.append([MagSytSym,CSI[0]]) 2585 else: 2586 CSI = G2spc.GetCSxinel(SytSym) 2587 atMxyz.append([SytSym,CSI[0]]) 2588 dlg = UseMagAtomDialog(G2frame,magchoices[sel],Atms,AtCods,atMxyz,ifMag=ifMag,ifDelete=True) 2562 2589 try: 2563 2590 opt = dlg.ShowModal() … … 2588 2615 G2frame.GPXtree.SetItemPyData(sub,newPhase) 2589 2616 newPhase['Drawing'] = [] 2590 G2cnstG.TransConstraints(G2frame,data,newPhase,magchoice['Trans'],vvec,atCodes) #data is old phase 2591 G2frame.newGPXfile = phaseName+'.gpx' 2592 UCdata[5] = [] #clear away other mag choices from chem phase in new project 2593 G2frame.GPXtree.SetItemPyData(UnitCellsId,UCdata) 2594 G2frame.OnFileSaveas(event) 2617 if ifMag: 2618 G2cnstG.TransConstraints(G2frame,data,newPhase,magchoice['Trans'],vvec,atCodes) #data is old phase 2619 G2frame.newGPXfile = phaseName+'.gpx' 2620 UCdata[5] = [] #clear away other mag choices from chem phase in new project 2621 G2frame.GPXtree.SetItemPyData(UnitCellsId,UCdata) 2622 G2frame.OnFileSaveas(event) 2595 2623 G2frame.GPXtree.SelectItem(sub) 2596 2624 -
trunk/GSASIIpwdGUI.py
r3685 r3686 3137 3137 if pNum is None: return 3138 3138 Phase = G2frame.GPXtree.GetItemPyData(G2gd.GetGPXtreeItemId(G2frame,pId,Phases[pNum])) 3139 Phase['magPhases'] = G2frame.GPXtree.GetItemText(G2frame.PatternId) #use as reference for recovering possible magphases3139 Phase['magPhases'] = G2frame.GPXtree.GetItemText(G2frame.PatternId) #use as reference for recovering possible phases 3140 3140 Cell = Phase['General']['Cell'] 3141 3141 SGData = Phase['General']['SGData'] … … 3153 3153 if 'R' in controls[5]: controls[5] = 'R3-H' 3154 3154 controls[6:13] = Cell[1:8] 3155 cx,ct,cs,cia = Phase['General']['AtomPtrs'] 3156 controls[15] = [atom[:cx+3] for atom in Phase['Atoms']] 3155 3157 if 'N' in Inst['Type'][0]: 3156 testAtoms = []3157 cx,ct,cs,cia = Phase['General']['AtomPtrs']3158 Atoms = Phase['Atoms']3159 for atom in Atoms:3160 if len(G2elem.GetMFtable([atom[ct],],[2.0,])):3161 testAtoms.append(atom[:cx+3])3162 controls[15] = testAtoms3163 3158 if not ssopt.get('Use',False): 3164 3159 G2frame.dataWindow.RunSubGroupsMag.Enable(True) … … 3420 3415 phase = magcells[r] 3421 3416 mSGData = phase['SGData'] 3422 msg = 'Magnetic space group information for '+phase['Name']3423 3417 text,table = G2spc.SGPrint(mSGData,AddInv=True) 3424 text[0] = ' Magnetic Space Group: '+mSGData['MagSpGrp'] 3425 text[3] = ' The magnetic lattice point group is '+mSGData['MagPtGp'] 3426 OprNames,SpnFlp = G2spc.GenMagOps(mSGData) 3427 G2G.SGMagSpinBox(G2frame.dataWindow,msg,text,table,mSGData['SGCen'],OprNames, 3428 mSGData['SpnFlp'],False).Show() 3418 if 'magAtoms' in phase: 3419 msg = 'Magnetic space group information for '+phase['Name'] 3420 text[0] = ' Magnetic Space Group: '+mSGData['MagSpGrp'] 3421 text[3] = ' The magnetic lattice point group is '+mSGData['MagPtGp'] 3422 OprNames,SpnFlp = G2spc.GenMagOps(mSGData) 3423 G2G.SGMagSpinBox(G2frame.dataWindow,msg,text,table,mSGData['SGCen'],OprNames, 3424 mSGData['SpnFlp'],False).Show() 3425 else: 3426 msg = 'Space Group Information' 3427 G2G.SGMessageBox(G2frame.dataWindow,msg,text,table).Show() 3429 3428 elif c == 1: 3430 3429 for i in range(len(magcells)): … … 3448 3447 elif c ==3: 3449 3448 r = event.GetRow() 3450 allmom = magcells[0].get('allmom',False)3451 magAtms = magcells[0].get('magAtms','')3452 3449 maxequiv = magcells[0].get('maxequiv',100) 3453 3450 phase = magcells[r] … … 3455 3452 Uvec = phase['Uvec'] 3456 3453 Trans = phase['Trans'] 3457 mAtoms = TestMagAtoms(phase,magAtms,SGData,Uvec,Trans,allmom,maxequiv) 3454 ifMag = False 3455 if 'magAtms' in magcells[r]: 3456 ifMag = True 3457 allmom = magcells[r].get('allmom',False) 3458 magAtms = magcells[r].get('magAtms','') 3459 mAtoms = TestMagAtoms(phase,magAtms,SGData,Uvec,Trans,allmom,maxequiv) 3460 else: 3461 mAtoms = TestAtoms(phase,controls[15],SGData,Uvec,Trans,maxequiv) 3458 3462 Atms = [] 3459 3463 AtCods = [] … … 3462 3466 atom[0] += '_%d'%ia 3463 3467 SytSym,Mul,Nop,dupDir = G2spc.SytSym(atom[2:5],mSGData) 3464 CSI = G2spc.GetCSpqinel(mSGData['SpnFlp'],dupDir)3465 3468 Atms.append(atom[:2]+['',]+atom[2:5]) 3466 3469 AtCods.append('1') 3467 MagSytSym = G2spc.MagSytSym(SytSym,dupDir,mSGData) 3468 atMxyz.append([MagSytSym,CSI[0]]) 3469 G2phsG.UseMagAtomDialog(G2frame,magcells[r]['Name'],Atms,AtCods,atMxyz,ifOK=True).ShowModal() 3470 if 'magAtms' in magcells[r]: 3471 MagSytSym = G2spc.MagSytSym(SytSym,dupDir,mSGData) 3472 CSI = G2spc.GetCSpqinel(mSGData['SpnFlp'],dupDir) 3473 atMxyz.append([MagSytSym,CSI[0]]) 3474 else: 3475 CSI = G2spc.GetCSxinel(SytSym) 3476 atMxyz.append([SytSym,CSI[0]]) 3477 G2phsG.UseMagAtomDialog(G2frame,magcells[r]['Name'],Atms,AtCods,atMxyz,ifMag=ifMag,ifOK=True).ShowModal() 3470 3478 data = [controls,bravais,cells,dminx,ssopt,magcells] 3471 3479 G2frame.GPXtree.SetItemPyData(UnitCellsId,data) … … 3631 3639 return uAtms 3632 3640 3641 def TestAtoms(phase,magAtms,SGData,Uvec,Trans,maxequiv=100): 3642 phase['Keep'] = False 3643 if not magAtms: 3644 phase['Keep'] = True 3645 return [] 3646 invTrans = nl.inv(Trans) 3647 atCodes = [] 3648 Phase = {'General':{'AtomPtrs':[2,1],'SGData':copy.deepcopy(phase['SGData'])},'Atoms':[]} 3649 for matm in magAtms: 3650 XYZ = G2spc.GenAtom(matm[3:6],SGData,False,Move=True) 3651 xyzs = [xyz[0] for xyz in XYZ] 3652 atCodes += len(xyzs)*['1',] 3653 xyzs,atCodes = G2lat.ExpandCell(xyzs,atCodes,0,Trans) 3654 for ix,x in enumerate(xyzs): 3655 xyz = G2lat.TransformXYZ(x-Uvec,invTrans.T,np.zeros(3))%1. 3656 Phase['Atoms'].append(matm[:2]+list(xyz)) 3657 uAtms = G2lat.GetUnique(Phase,atCodes)[0] 3658 natm = len(uAtms) 3659 if natm > maxequiv: #too many allowed atoms found 3660 phase['Keep'] = False 3661 return uAtms 3662 3633 3663 def OnRunSubs(event): 3634 # import SUBGROUPS as kSUB 3664 import kSUBGROUPSMAG as kMAG 3635 3665 G2frame.dataWindow.RunSubGroupsMag.Enable(False) 3636 3666 pUCid = G2gd.GetGPXtreeItemId(G2frame,G2frame.PatternId, 'Unit Cells List') 3637 3667 controls,bravais,cells,dminx,ssopt,magcells = G2frame.GPXtree.GetItemPyData(pUCid) 3638 3668 E,SGData = G2spc.SpcGroup(controls[13]) 3669 atoms = list(set([atom[1] for atom in controls[15]])) 3639 3670 Kx = [' ','0','1/2','-1/2','1/3','-1/3','2/3','1'] 3640 3671 Ky = [' ','0','1/2','1/3','2/3','1'] … … 3643 3674 dlg = G2G.MultiDataDialog(G2frame,title='SUBGROUPS options',prompts=[' k-vector 1',' k-vector 2',' k-vector 3', \ 3644 3675 ' Use whole star',' Filter by','preserve axes','max unique'], 3645 values=kvec+[False,'',True, '',False,100],3676 values=kvec+[False,'',True,100], 3646 3677 limits=[[Kx[1:],Ky[1:],Kz[1:]],[Kx,Ky,Kz],[Kx,Ky,Kz],[True,False],['',' Landau transition',' Only maximal subgroups',], 3647 3678 [True,False],[1,100]], … … 3649 3680 'bool','%d',]) 3650 3681 if dlg.ShowModal() == wx.ID_OK: 3651 subcells = []3682 magcells = [] 3652 3683 newVals = dlg.GetValues() 3653 3684 kvec[:9] = newVals[0]+newVals[1]+newVals[2]+[' ',] … … 3674 3705 caption='Bilbao SUBGROUPS setup error',style=wx.ICON_EXCLAMATION) 3675 3706 return 3676 print('run Bilbao SUBGROUPS - TBD') 3707 wx.BeginBusyCursor() 3708 wx.MessageBox(''' For use of SUBGROUPS, please cite: 3709 Symmetry-Based Computational Tools for Magnetic Crystallography, 3710 J.M. Perez-Mato, S.V. Gallego, E.S. Tasci, L. Elcoro, G. de la Flor, and M.I. Aroyo 3711 Annu. Rev. Mater. Res. 2015. 45,217-48. 3712 doi: 10.1146/annurev-matsci-070214-021008''',caption='Bilbao SUBGROUPS',style=wx.ICON_INFORMATION) 3713 3714 SUBGROUPS = kMAG.GetNonStdSubgroups(SGData,kvec[:9],star,Landau,maximal) 3715 wx.EndBusyCursor() 3716 if SUBGROUPS is None: 3717 wx.MessageBox('Check your internet connection?',caption='Bilbao SUBGROUPS error',style=wx.ICON_EXCLAMATION) 3718 return 3719 if not SUBGROUPS: 3720 if Landau: 3721 wx.MessageBox('No results from SUBGROUPS, multi k-vectors & Landau not compatible', 3722 caption='Bilbao SUBGROUPS error',style=wx.ICON_EXCLAMATION) 3723 else: 3724 wx.MessageBox('No results from SUBGROUPS, check your propagation vector(s)', 3725 caption='Bilbao SUBGROUPS error',style=wx.ICON_EXCLAMATION) 3726 return 3727 controls[14] = kvec[:9] 3728 dlg = wx.ProgressDialog('SUBGROUPS results','Processing '+SUBGROUPS[0][0],len(SUBGROUPS), 3729 style = wx.PD_ELAPSED_TIME|wx.PD_AUTO_HIDE|wx.PD_REMAINING_TIME) 3730 3731 for ir,result in enumerate(SUBGROUPS): 3732 dlg.Update(ir,newmsg='Processing '+result[0]) 3733 numbs = [eval(item+'.') for item in result[1].split()] 3734 Uvec = np.array(numbs[3::4]) 3735 Trans = np.array([numbs[:3],numbs[4:7],numbs[8:11]]).T #Bilbao gives transpose 3736 phase = G2lat.makeBilbaoPhase(result,Uvec,Trans) 3737 RVT = None 3738 if keepaxes: 3739 RVT = G2lat.FindNonstandard(controls,phase) 3740 if RVT is not None: 3741 result,Uvec,Trans = RVT 3742 phase = G2lat.makeBilbaoPhase(result,Uvec,Trans) 3743 phase['Cell'] = G2lat.TransformCell(controls[6:12],Trans) 3744 phase['maxequiv'] = maxequiv 3745 phase['nAtoms'] = len(TestAtoms(phase,controls[15],SGData,Uvec,Trans,maxequiv)) 3746 magcells.append(phase) 3747 dlg.Destroy() 3748 magcells[0]['Use'] = True 3749 SGData = magcells[0]['SGData'] 3750 A = G2lat.cell2A(magcells[0]['Cell'][:6]) 3751 G2frame.HKL = G2pwd.getHKLpeak(1.0,SGData,A,Inst) 3752 G2plt.PlotPatterns(G2frame,extraKeys=KeyList) 3753 data = [controls,bravais,cells,dmin,ssopt,magcells] 3754 G2frame.GPXtree.SetItemPyData(pUCid,data) 3755 G2frame.OnFileSave(event) 3756 wx.CallAfter(UpdateUnitCellsGrid,G2frame,data) 3677 3757 3678 3758 def OnRunSubsMag(event): … … 3682 3762 controls,bravais,cells,dminx,ssopt,magcells = G2frame.GPXtree.GetItemPyData(pUCid) 3683 3763 E,SGData = G2spc.SpcGroup(controls[13]) 3684 testAtoms = ['',]+list(set([atom[1] for atom in controls[15]])) 3764 atoms = list(set([atom[1] for atom in controls[15]])) 3765 testAtoms = ['',]+[atom for atom in atoms if len(G2elem.GetMFtable([atom,],[2.0,]))] 3685 3766 Kx = [' ','0','1/2','-1/2','1/3','-1/3','2/3','1'] 3686 3767 Ky = [' ','0','1/2','1/3','2/3','1'] … … 3754 3835 Uvec = np.array(numbs[3::4]) 3755 3836 Trans = np.array([numbs[:3],numbs[4:7],numbs[8:11]]).T #Bilbao gives transpose 3756 phase = G2lat.makeBilbaoPhase(result[:2],Uvec,Trans) 3757 3837 phase = G2lat.makeBilbaoPhase(result[:2],Uvec,Trans,True) 3758 3838 RVT = None 3759 3839 if keepaxes: … … 3761 3841 if RVT is not None: 3762 3842 result,Uvec,Trans = RVT 3763 phase = G2lat.makeBilbaoPhase(result,Uvec,Trans )3843 phase = G2lat.makeBilbaoPhase(result,Uvec,Trans,True) 3764 3844 phase['Cell'] = G2lat.TransformCell(controls[6:12],Trans) 3765 3845 phase['aType'] = atype … … 4056 4136 gridDisplay.SetReadOnly(r,c,isReadOnly=True) 4057 4137 mainSizer.Add(gridDisplay,0,WACV) 4058 if magcells and 'N' in Inst['Type'][0]: 4059 if 'N' in Inst['Type'][0]: 4060 if not ssopt.get('Use',False): 4061 G2frame.dataWindow.RunSubGroupsMag.Enable(True) 4138 if magcells: 4062 4139 G2frame.dataWindow.CopyCell.Enable(False) 4063 4140 kvec1 = ','.join(controls[14][:3]) 4064 4141 kvec2 = ','.join(controls[14][3:6]) 4065 4142 kvec3 = ','.join(controls[14][6:]) 4066 Label = '\n Magnetic cells from Bilbao k-SUBGROUPSMAG for %s; kvec1=(%s)'%(controls[13],kvec1) 4143 if 'magAtms' in magcells[0]: 4144 G2frame.dataWindow.RunSubGroupsMag.Enable(True) 4145 Label = '\n Magnetic subgroup cells from Bilbao k-SUBGROUPSMAG for %s; kvec1=(%s)'%(controls[13],kvec1) 4146 else: 4147 G2frame.dataWindow.RunSubGroups.Enable(True) 4148 Label = '\n Subgroup cells from Bilbao SUBGROUPS for %s; kvec1=(%s)'%(controls[13],kvec1) 4067 4149 if ' ' not in kvec2: 4068 4150 Label += ', kvec2=(%s)' % kvec2 -
trunk/kSUBGROUPSMAG.py
r3665 r3686 54 54 55 55 def handle_data(self, data): 56 # print('*',data) 56 57 if self.in_sp: 57 # print('*',data)58 58 if 'No.' in data: 59 59 self.spgp += data.split('(')[0] #pick up trailing number! … … 160 160 return result 161 161 162 def GetNonStdSubgroups(SGData, kvec,star=False,landau=False,maximal=False): 163 '''Run Bilboa's SUBGROUPS for a non-standard space group. 164 This requires doing a post to the Bilboa site, which returns all 165 subgroups of the entered space group as the text of a web page 166 with a table containing the space group symbol, the 167 transformation matrix and index for each subgroup. 168 169 :params list kvec: propogation vector as a list of nine string fractions or blank 170 :params SGData: space group object (see :ref:`Space Group object<SGData_table>`) 171 172 :returns: (error,text) error: if True no error or False; where 173 text containts a possible web page text 174 ''' 175 print(''' 176 For use of SUBGROUPS, please cite: 177 Symmetry-Based Computational Tools for Magnetic Crystallography, 178 J.M. Perez-Mato, S.V. Gallego, E.S. Tasci, L. Elcoro, G. de la Flor, and M.I. Aroyo 179 Annu. Rev. Mater. Res. 2015. 45,217-48. 180 doi: 10.1146/annurev-matsci-070214-021008 181 ''') 182 starmag = 'no' 183 if star: 184 starmag = 'yes' 185 land = 'no' 186 if landau: 187 land = 'yes' 188 celtodas = 'no' 189 limite = 'spgroup' 190 if maximal: 191 limite = 'maximal' 192 postdict = {'centrosymmetry':'0','crystalsystem':'0','landau':land, 193 'eleccion':'subgrmag1_k','inicio':'nostandard','celtodas':celtodas, 194 'limite':limite,'list':'Submit','listado':'lista','starmagnetica':starmag, 195 'pointgroup':'0','polarity':'0','sub':'1', 196 'super':'','tipog':'gesp','wyckoffstrain':''} 197 text,table = G2spc.SGPrint(SGData) 198 OpList = G2spc.TextOps(text,table,reverse=True) 199 # GenList = G2spc.TextGen(SGData,reverse=True) 200 for item in OpList: 201 item += '\n' 202 sym = "" 203 for i in OpList: 204 if sym: sym += '\n' 205 #if sym: sym += ' ' # use this for testing to generate an error in place of previous 206 sym += i.lower() 207 postdict['generators'] = sym 208 for j in [1,2,3]: 209 if kvec[3*j-3] == ' ': 210 break 211 for i,k in zip(('x','y','z'),kvec[3*j-3:3*j]): 212 postdict['knm%d%s'%(j,i)] = k 213 try: 214 r = requests.post(submagSite,postdict) 215 except: #ConnectionError? 216 page = '' 217 print('connection error - not on internet') 218 return None 219 if r.status_code == 200: 220 print('request OK') 221 page = r.text 222 page = page.replace('<font style= "text-decoration: overline;">','<font>-') 223 else: 224 page = '' 225 print('request failed. Reason=',r.reason) 226 return None 227 r.close() 228 229 p = TableParser() 230 p.feed(page) 231 result = list(zip(p.SPGPs,p.MVs)) 232 return result 233 162 234 def test(): 163 235 SGData = G2spc.SpcGroup('p -3 m 1')[1] 164 results = GetNonStdSubgroupsmag(SGData,('1/3','1/3','1/2' ))236 results = GetNonStdSubgroupsmag(SGData,('1/3','1/3','1/2',' ',' ',' ',' ',' ',' ',' ')) 165 237 if results: 166 238 for spgp,bns,mv in results: … … 168 240 print('MV') 169 241 print(mv) 242 results = GetNonStdSubgroups(SGData,('1/3','1/3','1/2',' ',' ',' ',' ',' ',' ',' ')) 243 if results: 244 for spgp,mv in results: 245 print('Space group:',spgp) 246 print('MV') 247 print(mv) 170 248 171 249
Note: See TracChangeset
for help on using the changeset viewer.