Ignore:
Timestamp:
Oct 22, 2018 8:58:53 AM (3 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

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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.