Changeset 5065
- Timestamp:
- Nov 4, 2021 8:09:15 AM (2 years ago)
- Location:
- trunk
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/GSASIIIO.py
r5042 r5065 1504 1504 varyList = covDict.get('varyList') 1505 1505 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 ***') 1509 1510 else: 1510 1511 varyList = list(varyList) -
trunk/GSASIIconstrGUI.py
r5058 r5065 1520 1520 seqhistnum = min(data.get('_seqhist',0),len(seqHistList)-1) 1521 1521 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 1529 1531 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 break1532 # 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 1534 1536 ###### patch: convert old-style (str) variables in constraints to G2VarObj objects ##### 1535 1537 for key,value in data.items(): -
trunk/GSASIIphsGUI.py
r5064 r5065 2922 2922 radio,rundata = ISO.GetISODISTORT(data,parentcif) 2923 2923 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') 2930 2933 else: 2931 2934 G2G.G2MessageBox(G2frame,'ISODISTORT run cancelled') … … 5396 5399 mainSizer.Add((5,5)) 5397 5400 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] 5398 5405 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)5403 5406 oldPairs = data['RMC']['RMCProfile'].get('Pairs',{}) 5404 5407 Pairs = {} … … 5409 5412 else: 5410 5413 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] 5414 5421 BVSpairs = [] 5415 5422 if lenA > 1: … … 5425 5432 metadata = {'title':'none','owner':'no one','date':str(time.ctime()),'temperature':'300K', 5426 5433 '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, 5429 5436 '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,}}) 5432 5439 5433 5440 data['RMC']['RMCProfile']['Isotope'] = copy.copy(data['General']['Isotope']) … … 6690 6697 err = G2mth.ApplyModeDisp(data) 6691 6698 if err: 6692 G2G.G2MessageBox(G2frame,'Do Draw atoms first') 6699 G2G.G2MessageBox(G2frame,'Do Draw atoms first') 6700 FindBondsDraw(data) 6693 6701 G2plt.PlotStructure(G2frame,data) 6694 6702 … … 6699 6707 if err: 6700 6708 G2G.G2MessageBox(G2frame,'Do Draw atoms first') 6709 FindBondsDraw(data) 6701 6710 G2plt.PlotStructure(G2frame,data) 6702 6711 … … 6706 6715 if err: 6707 6716 G2G.G2MessageBox(G2frame,'Do Draw atoms first') 6717 FindBondsDraw(data) 6708 6718 G2plt.PlotStructure(G2frame,data) 6709 6719 UpdateISODISTORT() -
trunk/ISODISTORT.py
r5054 r5065 14 14 ########### SVN repository information ################### 15 15 from __future__ import division, print_function 16 import subprocess as subp 17 import os.path 16 18 import requests 17 19 import copy 18 20 isouploadsite = 'https://stokes.byu.edu/iso/isodistortuploadfile.php' 19 21 isoformsite = 'https://iso.byu.edu/iso/isodistortform.php' 22 23 def 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') 20 33 21 34 def GetISODISTORT(Phase,parentcif): … … 63 76 #recover required info for the distortion search; includes info from cif file (no longer needed) 64 77 65 pos = out2.index('<p><FORM') 78 try: 79 pos = out2.index('<p><FORM') 80 except ValueError: 81 HandleError(out2) 82 return [],[] 66 83 data = {} 67 84 while True: … … 95 112 radio = {} 96 113 num = 0 97 pos = out3.index('RADIO') 114 try: 115 pos = out3.index('RADIO') 116 except ValueError: 117 HandleError(out3) 118 return [],[] 119 98 120 while True: 99 121 try: … … 109 131 110 132 def 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 158 183 159 184 #request a cif file 160 185 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 cifFile186 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 242 242 if SpGrpNorm: 243 243 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) 244 248 # nope, try the space group "out of the Box" 245 249 if E: … … 991 995 head = 20*' ' 992 996 l = '' 993 if k == 0: return997 # if k == 0: return 994 998 if k < 0 and i > 0: 995 999 l += ' - ' … … 1006 1010 line = '' 1007 1011 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) 1009 1013 print(head+line) 1010 1014 … … 1030 1034 head,line = fmtConstr(j,head,line,lbl,k) 1031 1035 print(head+line+') / '+('%.3f'%n)) 1032 breakpoint()1033 1036 print('\nCalculation checks\n') 1034 1037 for i,(row,n) in enumerate(zip(displacivemodeInvmatrix,normlist)):
Note: See TracChangeset
for help on using the changeset viewer.