Changeset 5065


Ignore:
Timestamp:
Nov 4, 2021 8:09:15 AM (2 years ago)
Author:
vondreele
Message:

remove check on Histograms & Phases in beginning of UpdateConstraints? - had prevented viewing constraints when no phases
Always enable SHOWISO - same reason
remove check on length of varyList in LoadParmDict? - prevented export of cif when there was no refinement
checks on failed ISODISTORT runs - now shows resulting html page with error message
fixes to RMCProfile GUI startup
fix distortion mode plotting - now moves bonds & polyhedra
cif importer looks for space group number if symbol not interpretable - i.e. full HM symbol
remove a check on k==0 in line 993 of cif importer; k is always zero in ISODISTORT cifs when there in no preset mode distortion value
fix name bug in line 1008 & remove breakpoint in cif importer
ISODISTORT makes html page & displays it in case of ISODISTORT error

Location:
trunk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/GSASIIIO.py

    r5042 r5065  
    15041504            varyList = covDict.get('varyList')
    15051505        elif varyList is None:
    1506             # old GPX file from before pre-constraint varyList is saved
    1507             print (' *** Old refinement: Please use Calculate/Refine to redo  ***')
    1508             raise Exception(' *** Export aborted ***')
     1506            varyList = []
     1507            # # old GPX file from before pre-constraint varyList is saved
     1508            # print (' *** Old refinement: Please use Calculate/Refine to redo  ***')
     1509            # raise Exception(' *** Export aborted ***')
    15091510        else:
    15101511            varyList = list(varyList)
  • trunk/GSASIIconstrGUI.py

    r5058 r5065  
    15201520        seqhistnum = min(data.get('_seqhist',0),len(seqHistList)-1)
    15211521    Histograms,Phases = G2frame.GetUsedHistogramsAndPhasesfromTree()
    1522     if not len(Phases) or not len(Histograms):
    1523         dlg = wx.MessageDialog(G2frame,'You need both phases and histograms to see Constraints',
    1524             'No phases or histograms')
    1525         dlg.CenterOnParent()
    1526         dlg.ShowModal()
    1527         dlg.Destroy()
    1528         return
     1522    G2frame.dataWindow.ConstraintEdit.Enable(G2G.wxID_SHOWISO,True)
     1523#removed this check as it prevents examination of ISODISTORT constraints without data
     1524    # if not len(Phases) or not len(Histograms):       
     1525    #     dlg = wx.MessageDialog(G2frame,'You need both phases and histograms to see Constraints',
     1526    #         'No phases or histograms')
     1527    #     dlg.CenterOnParent()
     1528    #     dlg.ShowModal()
     1529    #     dlg.Destroy()
     1530    #     return
    15291531    G2obj.IndexAllIds(Histograms,Phases)
    1530     for p in Phases:
    1531         if 'ISODISTORT' in Phases[p] and 'G2VarList' in Phases[p]['ISODISTORT']:
    1532             G2frame.dataWindow.ConstraintEdit.Enable(G2G.wxID_SHOWISO,True)
    1533             break
     1532    # for p in Phases:
     1533    #     if 'ISODISTORT' in Phases[p] and 'G2VarList' in Phases[p]['ISODISTORT']:
     1534    #         G2frame.dataWindow.ConstraintEdit.Enable(G2G.wxID_SHOWISO,True)
     1535    #         break
    15341536    ###### patch: convert old-style (str) variables in constraints to G2VarObj objects #####
    15351537    for key,value in data.items():
  • trunk/GSASIIphsGUI.py

    r5064 r5065  
    29222922            radio,rundata = ISO.GetISODISTORT(data,parentcif)
    29232923            wx.EndBusyCursor()
    2924             data['ISODISTORT']['radio'] = radio
    2925             data['ISODISTORT']['rundata'] = rundata
    2926             data['ISODISTORT']['SGselect'] =  {'Tric':True,'Mono':True,'Orth':True,'Tetr':True,'Trig':True,'Hexa':True,'Cubi':True}
    2927             data['ISODISTORT']['selection'] = None
    2928             print('ISODISTORT run complete')
    2929             UpdateISODISTORT()
     2924            if radio and rundata:
     2925                data['ISODISTORT']['radio'] = radio
     2926                data['ISODISTORT']['rundata'] = rundata
     2927                data['ISODISTORT']['SGselect'] =  {'Tric':True,'Mono':True,'Orth':True,'Tetr':True,'Trig':True,'Hexa':True,'Cubi':True}
     2928                data['ISODISTORT']['selection'] = None
     2929                print('ISODISTORT run complete')
     2930                UpdateISODISTORT()
     2931            else:
     2932                G2G.G2MessageBox(G2frame,'ISODISTORT run failed - see opened web paage')       
    29302933        else:
    29312934            G2G.G2MessageBox(G2frame,'ISODISTORT run cancelled')       
     
    53965399            mainSizer.Add((5,5))
    53975400            Atypes = [atype.split('+')[0].split('-')[0] for atype in data['General']['AtomTypes']]
     5401            aTypes = dict(zip(Atypes,len(Atypes)*[0.10,]))
     5402            atSeq = list(aTypes.keys())
     5403            lenA = len(atSeq)
     5404            atOxid = [[atmdata.BVSoxid[atm][0],0.001] for atm in atSeq]
    53985405            if CheckAtms(Atypes):
    5399                 aTypes = dict(zip(Atypes,len(Atypes)*[0.10,]))
    5400                 atSeq = list(aTypes.keys())
    5401                 atOxid = [[atmdata.BVSoxid[atm][0],0.001] for atm in atSeq]
    5402                 lenA = len(atSeq)
    54035406                oldPairs = data['RMC']['RMCProfile'].get('Pairs',{})
    54045407                Pairs = {}
     
    54095412                        else:
    54105413                            Pairs[pair] = [0.0,0.0,0.0]
    5411                 data['RMC']['RMCProfile'].update({'aTypes':aTypes, 'atSeq':atSeq,'Pairs':Pairs,'Oxid':atOxid,})
    5412                
    5413             if not data['RMC']['RMCProfile']:
     5414                data['RMC']['RMCProfile'].update({'aTypes':aTypes,'atSeq':atSeq,'Pairs':Pairs,'Oxid':atOxid,})
     5415               
     5416            if not data['RMC']['RMCProfile'] or 'metadata' not in RMCPdict:
     5417                Pairs = {}
     5418                for pairs in [[' %s-%s'%(atSeq[i],atSeq[j]) for j in range(i,lenA) if 'Va' not in atSeq[j]] for i in range(lenA) if 'Va' not in atSeq[i]]:
     5419                    for pair in pairs:
     5420                        Pairs[pair] = [0.0,0.0,0.0]
    54145421                BVSpairs = []
    54155422                if lenA > 1:
     
    54255432                metadata = {'title':'none','owner':'no one','date':str(time.ctime()),'temperature':'300K',
    54265433                    'material':'nothing','phase':'vacuum','comment':'none ','source':'nowhere'}
    5427                 data['RMC']['RMCProfile'] = {'SuperCell':[1,1,1],'UseSampBrd':[True,True],'aTypes':aTypes,
    5428                     'atSeq':atSeq,'Pairs':Pairs,'histogram':['',1.0],'files':files,'metadata':metadata,'FitScale':False,
     5434                data['RMC']['RMCProfile'].update({'SuperCell':[1,1,1],'UseSampBrd':[True,True],'aTypes':aTypes,
     5435                    'histogram':['',1.0],'files':files,'metadata':metadata,'FitScale':False,'atSeq':atSeq,
    54295436                    'runTimes':runTimes,'ReStart':[False,False],'BVS':BVS,'Oxid':atOxid,'useBVS':False,'Swaps':[],
    5430                     'AveCN':[],'FxCN':[],'Potentials':{'Angles':[],'Angle search':10.,'Stretch':[],
    5431                     'Stretch search':10.,'Pot. Temp.':300.,'useGPU':False,}}
     5437                    'AveCN':[],'FxCN':[],'Potentials':{'Angles':[],'Angle search':10.,'Stretch':[],'Pairs':Pairs,
     5438                    'Stretch search':10.,'Pot. Temp.':300.,'useGPU':False,}})
    54325439               
    54335440            data['RMC']['RMCProfile']['Isotope'] = copy.copy(data['General']['Isotope'])
     
    66906697            err = G2mth.ApplyModeDisp(data)
    66916698            if err:
    6692                 G2G.G2MessageBox(G2frame,'Do Draw atoms first')               
     6699                G2G.G2MessageBox(G2frame,'Do Draw atoms first')     
     6700            FindBondsDraw(data)               
    66936701            G2plt.PlotStructure(G2frame,data)
    66946702           
     
    66996707            if err:
    67006708                G2G.G2MessageBox(G2frame,'Do Draw atoms first')               
     6709            FindBondsDraw(data)               
    67016710            G2plt.PlotStructure(G2frame,data)
    67026711           
     
    67066715            if err:
    67076716                G2G.G2MessageBox(G2frame,'Do Draw atoms first')               
     6717            FindBondsDraw(data)               
    67086718            G2plt.PlotStructure(G2frame,data)
    67096719            UpdateISODISTORT()                                   
  • trunk/ISODISTORT.py

    r5054 r5065  
    1414########### SVN repository information ###################
    1515from __future__ import division, print_function
     16import subprocess as subp
     17import os.path
    1618import requests
    1719import copy
    1820isouploadsite = 'https://stokes.byu.edu/iso/isodistortuploadfile.php'
    1921isoformsite = 'https://iso.byu.edu/iso/isodistortform.php'
     22
     23def HandleError(out):
     24    open('out.html','wb').write(out.encode("utf-8"))
     25    url = os.path.realpath('out.html')
     26    try:
     27        os.startfile(url)
     28    except AttributeError:
     29        try: # should work on MacOS and most linux versions
     30            subp.call(['open', url])
     31        except:
     32            print('Could not open URL')
    2033
    2134def GetISODISTORT(Phase,parentcif):
     
    6376    #recover required info for the distortion search; includes info from cif file (no longer needed)
    6477   
    65     pos = out2.index('<p><FORM')
     78    try:
     79        pos = out2.index('<p><FORM')
     80    except ValueError:
     81        HandleError(out2)
     82        return [],[]
    6683    data = {}
    6784    while True:
     
    95112    radio = {}
    96113    num = 0
    97     pos = out3.index('RADIO')
     114    try:
     115        pos = out3.index('RADIO')
     116    except ValueError:
     117        HandleError(out3)
     118        return [],[]
     119       
    98120    while True:
    99121        try:
     
    109131
    110132def GetISODISTORTcif(Phase):
    111    '''Run Stokes & Campbell ISODISTORT.
    112    Selection of one of the order parameter disrections is returned to the BYU
    113    form site which returns the text of a cif file to be used to create the new phase
    114    which can apply the distortion mode constraints
    115 
    116    :params dict Phase: GSAS-II phase data; contains result of GetISODISTORT above & selection
    117    
    118    :returns: CIFfile str: name of cif file created by this in local directory
    119    '''
    120    
    121    ISOdata = Phase['ISODISTORT']
    122    data2 = ISOdata['rundata']
    123    #choose one & resubmit
    124    data2['origintype'] = 'method1'
    125    data2['orderparam'] = ISOdata['selection'][1]
    126    data2['input'] = 'distort'
    127    # for item in data2:
    128    #     print(item,data2[item])
    129    out4 = requests.post(isoformsite,data=data2).text
    130    #print(out4)
    131    #open('pyout4.html','wb').write(out4.encode("utf-8"))
    132 
    133    #retrieve data needed for next(last) step
    134 
    135    pos = out4.index('<FORM ACTION')
    136    data3 = {}
    137    while True:
    138        try:
    139            posB = out4[pos:].index('INPUT TYPE')+pos
    140            posF = out4[posB:].index('>')+posB
    141            items = out4[posB:posF].split('=',3)
    142            name = items[2].split()[0].replace('"','')
    143            if 'subsetting' in name:
    144                data3[name] = ''
    145                pos = posF
    146                continue
    147            elif 'atomsfile' in name:
    148                data3[name] = ' '
    149                pos = posF
    150                continue
    151            vals = items[3].replace('"','')
    152            data3[name] = vals
    153            pos = posF
    154            if 'lattparamsub' in name:
    155                break
    156        except ValueError:
    157            break
     133    '''Run Stokes & Campbell ISODISTORT.
     134    Selection of one of the order parameter disrections is returned to the BYU
     135    form site which returns the text of a cif file to be used to create the new phase
     136    which can apply the distortion mode constraints
     137     
     138    :params dict Phase: GSAS-II phase data; contains result of GetISODISTORT above & selection
     139   
     140    :returns: CIFfile str: name of cif file created by this in local directory
     141    '''
     142   
     143    ISOdata = Phase['ISODISTORT']
     144    data2 = ISOdata['rundata']
     145    #choose one & resubmit
     146    data2['origintype'] = 'method1'
     147    data2['orderparam'] = ISOdata['selection'][1]
     148    data2['input'] = 'distort'
     149    # for item in data2:
     150    #     print(item,data2[item])
     151    out4 = requests.post(isoformsite,data=data2).text
     152    #print(out4)
     153    #open('pyout4.html','wb').write(out4.encode("utf-8"))
     154     
     155    #retrieve data needed for next(last) step
     156
     157    try:
     158        pos = out4.index('<FORM ACTION')
     159    except ValueError:
     160        HandleError(out4)
     161    data3 = {}
     162    while True:
     163        try:
     164            posB = out4[pos:].index('INPUT TYPE')+pos
     165            posF = out4[posB:].index('>')+posB
     166            items = out4[posB:posF].split('=',3)
     167            name = items[2].split()[0].replace('"','')
     168            if 'subsetting' in name:
     169                data3[name] = ''
     170                pos = posF
     171                continue
     172            elif 'atomsfile' in name:
     173                data3[name] = ' '
     174                pos = posF
     175                continue
     176            vals = items[3].replace('"','')
     177            data3[name] = vals
     178            pos = posF
     179            if 'lattparamsub' in name:
     180                break
     181        except ValueError:
     182            break
    158183       
    159184   #request a cif file   
    160185       
    161    data3['origintype'] = 'structurefile'
    162    data3['inputvalues'] = 'false'
    163    data3['atomicradius'] = '0.4'
    164    data3['bondlength'] = '2.50'
    165    data3['modeamplitude'] = '1.0'
    166    data3['strainamplitude'] = '0.1'
    167    # for item in data3:
    168    #     print(item,data3[item])
    169    k = requests.post(isoformsite,data=data3)
    170    out5 = k.text   #this is output cif!
    171    #print(out5)
    172    names = ISOdata['selection'][1].split()
    173    cifFile = '%s_%s%s%s.cif'%(Phase['General']['Name'],names[1],names[2].replace('*','_'),names[3])
    174    fl = open(cifFile,'wb')
    175    fl.write(out5.encode("utf-8"))
    176    fl.close()
    177    return cifFile
     186    data3['origintype'] = 'structurefile'
     187    data3['inputvalues'] = 'false'
     188    data3['atomicradius'] = '0.4'
     189    data3['bondlength'] = '2.50'
     190    data3['modeamplitude'] = '1.0'
     191    data3['strainamplitude'] = '0.1'
     192    # for item in data3:
     193    #     print(item,data3[item])
     194    k = requests.post(isoformsite,data=data3)
     195    out5 = k.text   #this is output cif!
     196    #print(out5)
     197    names = ISOdata['selection'][1].split()
     198    cifFile = '%s_%s%s%s.cif'%(Phase['General']['Name'],names[1],names[2].replace('*','_'),names[3])
     199    fl = open(cifFile,'wb')
     200    fl.write(out5.encode("utf-8"))
     201    fl.close()
     202    return cifFile
  • trunk/imports/G2phase_CIF.py

    r5062 r5065  
    242242                if SpGrpNorm:
    243243                    E,SGData = G2spc.SpcGroup(SpGrpNorm)
     244            if E:   #try lookup from number  - found full symbol?               
     245                SpGrpNorm = G2spc.spgbyNum[int(blk.get('_symmetry_Int_Tables_number'))]
     246                if SpGrpNorm:
     247                    E,SGData = G2spc.SpcGroup(SpGrpNorm)
    244248            # nope, try the space group "out of the Box"
    245249            if E:
     
    991995                    head = 20*' '
    992996                    l = ''
    993                 if k == 0: return
     997#                if k == 0: return
    994998                if k < 0 and i > 0:
    995999                    l += '  -  '
     
    10061010                line = ''
    10071011                for j,(lbl,k) in enumerate(zip(coordVarLbl,row)):
    1008                     head,line = fmtConstr(j,head,line,G2varObj[j],k)
     1012                    head,line = fmtConstr(j,head,line,G2varObj[j].name,k)
    10091013                print(head+line)
    10101014
     
    10301034                    head,line = fmtConstr(j,head,line,lbl,k)
    10311035                print(head+line+') / '+('%.3f'%n))
    1032                 breakpoint()
    10331036            print('\nCalculation checks\n')
    10341037            for i,(row,n) in enumerate(zip(displacivemodeInvmatrix,normlist)):
Note: See TracChangeset for help on using the changeset viewer.