Changeset 3686


Ignore:
Timestamp:
Oct 22, 2018 8:58:53 AM (4 years ago)
Author:
vondreele
Message:

install new use of Bilbao site - call SUBGROUPS for making subgroup phase selections from parent structure
some modifications to mag subgroup stuff to accommodate

Location:
trunk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/GSASIIdataGUI.py

    r3682 r3686  
    53425342        self.GeneralCalc.Append(G2G.wxID_MULTIMCSA,'Multi MC/SA','Run Monte Carlo - Simulated Annealing on multiprocessors')
    53435343        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')       
    53455345        self.GeneralCalc.Append(G2G.wxID_VALIDPROTEIN,'Protein quality','Protein quality analysis')
    53465346        self.PostfillDataMenu()
  • trunk/GSASIIlattice.py

    r3685 r3686  
    389389    Uvec = Phase['Uvec']
    390390    SGData = Phase['SGData']
    391     MSG = SGData['MagSpGrp'].split(' ',1)
     391    MSG = SGData.get('MagSpGrp',SGData['SpGrp']).split(' ',1)
    392392    MSG[0] += ' '
    393393    bns = ''
    394394    if '_' in MSG[0]:
    395395        bns = MSG[0][2]
    396     spn = SGData['SGSpin']
     396    spn = SGData.get('SGSpin',[])
    397397    if 'ortho' in SGData['SGSys']:
    398398        lattSym = G2spc.getlattSym(Trans)
    399399        SpGrp = SGData['SpGrp']
    400400        NTrans = np.inner(Mats[lattSym].T,Trans.T)        #ok
    401         spn[1:4] = np.inner(np.abs(nl.inv(Mats[lattSym])),spn[1:4])         #ok
     401        if len(spn): spn[1:4] = np.inner(np.abs(nl.inv(Mats[lattSym])),spn[1:4])         #ok
    402402        SGsym = G2spc.getlattSym(nl.inv(Mats[lattSym]))
    403403       
     
    414414                Bns = BNS[bns][lattSym]
    415415                NSG[0] += '_'+Bns+' '
    416             else:
     416            elif len(spn):
    417417                for ifld in [1,2,3]:
    418418                    if spn[ifld] < 0:
     
    450450    return None
    451451       
    452 def makeBilbaoPhase(result,uvec,trans):
     452def makeBilbaoPhase(result,uvec,trans,ifMag=False):
    453453    phase = {}
    454454    phase['Name'] = result[0].strip()
     
    461461    SpGrp = G2spc.StandardizeSpcName(SpGp)
    462462    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'])
    473474    return phase
    474475
  • trunk/GSASIIphsGUI.py

    r3682 r3686  
    590590    '''Get user selected magnetic atoms after cell transformation
    591591    '''
    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,
    594597            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!
    596600        self.Name = Name
    597601        self.Atoms = Atoms
    598602        self.atCodes = atCodes
    599603        self.atMxyz = atMxyz
     604        self.ifMag = ifMag
    600605        self.ifOK = ifOK
    601606        self.ifDelete = ifDelete
     
    612617       
    613618        self.panel.Destroy()
    614         self.panel = wx.Panel(self)
     619        self.panel = wxscroll.ScrolledPanel(self,style = wx.DEFAULT_DIALOG_STYLE)
    615620        Indx = {}
    616621        Mstr = [' Mx',' My',' Mz']
     622        Xstr = ['X','Y','Z']
    617623        mainSizer = wx.BoxSizer(wx.VERTICAL)
    618624        mainSizer.Add(wx.StaticText(self.panel,label='For: %s'%self.Name),0,WACV)
    619625       
    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)
    621630        atmSizer = wx.FlexGridSizer(0,2,5,5)
    622631        for iuse,[use,atom,mxyz] in enumerate(zip(self.Use,self.Atoms,self.atMxyz)):
     
    624633            for i,mx in enumerate(mxyz[1]):
    625634                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)
    632647            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])
    633648            atmSizer.Add(wx.StaticText(self.panel,label=text),0,WACV)
     
    657672        mainSizer.Add(btnSizer,0,wx.EXPAND|wx.BOTTOM|wx.TOP, 10)
    658673        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)
    661679       
    662680    def GetSelection(self):
     
    24422460                    if not '_' in BNSlatt:
    24432461                        SGData['SGSpin'] = G2spc.GetSGSpin(SGData,SGData['MagSpGrp'])
    2444                        
    2445                        
    2446                        
    24472462                else:
    24482463                    return
     
    24632478            else:
    24642479                phaseName = newPhase['General']['Name']
    2465                
    2466                
    24672480                newPhase,atCodes = G2lat.TransformPhase(data,newPhase,Trans,Uvec,Vvec,ifMag)
    24682481                detTrans = np.abs(nl.det(Trans))
     
    25172530        magIds = []
    25182531        magchoices = []
     2532        ifMag = False
    25192533        for mid,magdata in enumerate(magData):
    25202534            if magdata['Keep']:
     2535                if 'magAtms' in magdata:
     2536                    ifMag = True
    25212537                magdata['No.'] = mid+1
    25222538                trans = G2spc.Trans2Text(magdata['Trans'])
     
    25262542                magchoices.append('(%d) %s; (%s) + (%s)'%(mid+1,magdata['Name'],trans,vec))
    25272543        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')
    25292545            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)
    25312550        opt = dlg.ShowModal()
    25322551        if opt == wx.ID_OK:
     
    25342553            magchoice = magKeep[sel]
    25352554            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.'])
    25372559            newPhase = copy.deepcopy(data)
    25382560            newPhase['ranId'] = ran.randint(0,sys.maxsize),
     
    25442566            SGData = generalData['SGData']
    25452567            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)
    25472569            Atoms = newPhase['Atoms']
    25482570            Atms = []
     
    25502572            atMxyz = []
    25512573            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,])):
    25532575                    continue
    25542576                atom[0] += '_%d'%ia
     2577                atom[2] = ''                    #clear away refinement flags
    25552578                SytSym,Mul,Nop,dupDir = G2spc.SytSym(atom[3:6],SGData)
    2556                 CSI = G2spc.GetCSpqinel(SGData['SpnFlp'],dupDir)
    25572579                Atms.append(atom)
    25582580                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)
    25622589            try:
    25632590                opt = dlg.ShowModal()
     
    25882615        G2frame.GPXtree.SetItemPyData(sub,newPhase)
    25892616        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)
    25952623        G2frame.GPXtree.SelectItem(sub)
    25962624       
  • trunk/GSASIIpwdGUI.py

    r3685 r3686  
    31373137        if pNum is None: return
    31383138        Phase = G2frame.GPXtree.GetItemPyData(G2gd.GetGPXtreeItemId(G2frame,pId,Phases[pNum]))
    3139         Phase['magPhases'] = G2frame.GPXtree.GetItemText(G2frame.PatternId)    #use as reference for recovering possible mag phases
     3139        Phase['magPhases'] = G2frame.GPXtree.GetItemText(G2frame.PatternId)    #use as reference for recovering possible phases
    31403140        Cell = Phase['General']['Cell']
    31413141        SGData = Phase['General']['SGData']
     
    31533153        if 'R' in controls[5]: controls[5] = 'R3-H'
    31543154        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']]
    31553157        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] = testAtoms
    31633158            if not ssopt.get('Use',False):
    31643159                G2frame.dataWindow.RunSubGroupsMag.Enable(True)
     
    34203415                phase = magcells[r]
    34213416                mSGData = phase['SGData']
    3422                 msg = 'Magnetic space group information for '+phase['Name']
    34233417                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()
    34293428            elif c == 1:
    34303429                for i in range(len(magcells)):
     
    34483447            elif c ==3:
    34493448                r = event.GetRow()
    3450                 allmom = magcells[0].get('allmom',False)
    3451                 magAtms = magcells[0].get('magAtms','')
    34523449                maxequiv = magcells[0].get('maxequiv',100)
    34533450                phase = magcells[r]
     
    34553452                Uvec = phase['Uvec']
    34563453                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)
    34583462                Atms = []
    34593463                AtCods = []
     
    34623466                    atom[0] += '_%d'%ia
    34633467                    SytSym,Mul,Nop,dupDir = G2spc.SytSym(atom[2:5],mSGData)
    3464                     CSI = G2spc.GetCSpqinel(mSGData['SpnFlp'],dupDir)
    34653468                    Atms.append(atom[:2]+['',]+atom[2:5])
    34663469                    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()
    34703478            data = [controls,bravais,cells,dminx,ssopt,magcells]
    34713479            G2frame.GPXtree.SetItemPyData(UnitCellsId,data)
     
    36313639        return uAtms
    36323640
     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
    36333663    def OnRunSubs(event):
    3634 #        import SUBGROUPS as kSUB
     3664        import kSUBGROUPSMAG as kMAG
    36353665        G2frame.dataWindow.RunSubGroupsMag.Enable(False)
    36363666        pUCid = G2gd.GetGPXtreeItemId(G2frame,G2frame.PatternId, 'Unit Cells List')
    36373667        controls,bravais,cells,dminx,ssopt,magcells = G2frame.GPXtree.GetItemPyData(pUCid)
    36383668        E,SGData = G2spc.SpcGroup(controls[13])
     3669        atoms = list(set([atom[1] for atom in controls[15]]))       
    36393670        Kx = [' ','0','1/2','-1/2','1/3','-1/3','2/3','1']
    36403671        Ky = [' ','0','1/2','1/3','2/3','1']
     
    36433674        dlg = G2G.MultiDataDialog(G2frame,title='SUBGROUPS options',prompts=[' k-vector 1',' k-vector 2',' k-vector 3', \
    36443675            ' Use whole star',' Filter by','preserve axes','max unique'],
    3645             values=kvec+[False,'',True,'',False,100],
     3676            values=kvec+[False,'',True,100],
    36463677            limits=[[Kx[1:],Ky[1:],Kz[1:]],[Kx,Ky,Kz],[Kx,Ky,Kz],[True,False],['',' Landau transition',' Only maximal subgroups',],
    36473678                [True,False],[1,100]],
     
    36493680                    'bool','%d',])
    36503681        if dlg.ShowModal() == wx.ID_OK:
    3651             subcells = []
     3682            magcells = []
    36523683            newVals = dlg.GetValues()
    36533684            kvec[:9] = newVals[0]+newVals[1]+newVals[2]+[' ',]
     
    36743705                    caption='Bilbao SUBGROUPS setup error',style=wx.ICON_EXCLAMATION)
    36753706                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)
    36773757       
    36783758    def OnRunSubsMag(event):
     
    36823762        controls,bravais,cells,dminx,ssopt,magcells = G2frame.GPXtree.GetItemPyData(pUCid)
    36833763        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,]))]
    36853766        Kx = [' ','0','1/2','-1/2','1/3','-1/3','2/3','1']
    36863767        Ky = [' ','0','1/2','1/3','2/3','1']
     
    37543835                Uvec = np.array(numbs[3::4])
    37553836                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)
    37583838                RVT = None
    37593839                if keepaxes:
     
    37613841                if RVT is not None:
    37623842                    result,Uvec,Trans = RVT
    3763                 phase = G2lat.makeBilbaoPhase(result,Uvec,Trans)
     3843                phase = G2lat.makeBilbaoPhase(result,Uvec,Trans,True)
    37643844                phase['Cell'] = G2lat.TransformCell(controls[6:12],Trans)   
    37653845                phase['aType'] = atype
     
    40564136                    gridDisplay.SetReadOnly(r,c,isReadOnly=True)
    40574137        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:       
    40624139        G2frame.dataWindow.CopyCell.Enable(False)
    40634140        kvec1 = ','.join(controls[14][:3])
    40644141        kvec2 = ','.join(controls[14][3:6])
    40654142        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)
    40674149        if ' ' not in kvec2:
    40684150            Label += ', kvec2=(%s)' % kvec2
  • trunk/kSUBGROUPSMAG.py

    r3665 r3686  
    5454   
    5555    def handle_data(self, data):
     56#        print('*',data)
    5657        if self.in_sp:
    57 #            print('*',data)
    5858            if 'No.' in data:
    5959                self.spgp += data.split('(')[0]        #pick up trailing number!
     
    160160    return result
    161161
     162def 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
    162234def test():
    163235    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',' ',' ',' ',' ',' ',' ',' '))
    165237    if results:
    166238        for spgp,bns,mv in results:
     
    168240            print('MV')
    169241            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)
    170248       
    171249
Note: See TracChangeset for help on using the changeset viewer.