- Timestamp:
- Apr 10, 2020 9:57:11 PM (3 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/GSASIIphsGUI.py
r4389 r4397 4521 4521 G2frame.RMCchoice = RMCsel.GetStringSelection() 4522 4522 UpdateRMC() 4523 4524 def GetAtmChoice(RMCPdict): 4525 4526 Indx = {} 4527 def OnAtSel(event): 4528 Obj = event.GetEventObject() 4529 itype = Indx[Obj.GetId()] 4530 tid = RMCPdict['atSeq'].index(Obj.GetStringSelection()) 4531 if itype < nTypes: 4532 if itype == tid: 4533 tid += 1 4534 RMCPdict['atSeq'] = G2lat.SwapItems(RMCPdict['atSeq'],itype,tid) 4535 Pairs= [] 4536 atSeq = RMCPdict['atSeq'] 4537 lenA = len(atSeq) 4538 for pair in [[' %s-%s'%(atSeq[i],atSeq[j]) for j in range(i,lenA)] for i in range(lenA)]: 4539 Pairs += pair 4540 RMCPdict['Pairs'] = {pairs:[0.0,0.0,0.0] for pairs in Pairs} 4541 if RMCPdict['useBVS']: 4542 BVSpairs = [] 4543 for pair in [[' %s-%s'%(atSeq[i],atSeq[j]) for j in range(i+1,lenA)] for i in range(lenA)]: 4544 BVSpairs += pair 4545 RMCPdict['BVS'] = {pairs:[0.0,0.0,0.0,0.0] for pairs in BVSpairs} 4546 wx.CallAfter(UpdateRMC) 4547 4548 def OnValSel(event): 4549 Obj = event.GetEventObject() 4550 itype = Indx[Obj.GetId()] 4551 RMCPdict['Oxid'][itype][0] = Obj.GetStringSelection() 4552 wx.CallAfter(UpdateRMC) 4553 4554 nTypes = len(RMCPdict['aTypes']) 4555 atmChoice = wx.FlexGridSizer(nTypes+1,5,5) 4556 atmChoice.Add(wx.StaticText(G2frame.FRMC,label=' Set atom ordering: '),0,WACV) 4557 for iType in range(nTypes): 4558 atChoice = RMCPdict['atSeq'][iType:] 4559 atmSel = wx.ComboBox(G2frame.FRMC,choices=atChoice,style=wx.CB_DROPDOWN|wx.TE_READONLY) 4560 atmSel.SetStringSelection(RMCPdict['atSeq'][iType]) 4561 atmSel.Bind(wx.EVT_COMBOBOX,OnAtSel) 4562 Indx[atmSel.GetId()] = iType 4563 atmChoice.Add(atmSel,0,WACV) 4564 if RMCPdict['useBVS']: 4565 atmChoice.Add(wx.StaticText(G2frame.FRMC,label=' Select valence: '),0,WACV) 4566 for itype in range(nTypes): 4567 valChoice = atmdata.BVSoxid[RMCPdict['atSeq'][itype]] 4568 valSel = wx.ComboBox(G2frame.FRMC,choices=valChoice,style=wx.CB_DROPDOWN|wx.TE_READONLY) 4569 try: 4570 valSel.SetStringSelection(RMCPdict['Oxid'][itype][0]) 4571 except IndexError: 4572 RMCPdict['Oxid'].append([RMCPdict['atSeq'][itype],0.0]) 4573 valSel.Bind(wx.EVT_COMBOBOX,OnValSel) 4574 Indx[valSel.GetId()] = itype 4575 atmChoice.Add(valSel,0,WACV) 4576 atmChoice.Add(wx.StaticText(G2frame.FRMC,label=' BVS weight: '),0,WACV) 4577 for itype in range(nTypes): 4578 atmChoice.Add(G2G.ValidatedTxtCtrl(G2frame.FRMC,RMCPdict['Oxid'][itype],1,min=0.),0,WACV) 4579 atmChoice.Add(wx.StaticText(G2frame.FRMC,label=' Set max shift: '),0,WACV) 4580 for iType in range(nTypes): 4581 atId = RMCPdict['atSeq'][iType] 4582 atmChoice.Add(G2G.ValidatedTxtCtrl(G2frame.FRMC,RMCPdict['aTypes'],atId,min=0.,max=1.),0,WACV) 4583 return atmChoice 4584 4523 4585 4524 4586 G2frame.GetStatusBar().SetStatusText('',1) … … 4542 4604 mainSizer.Add((5,5),0,WACV) 4543 4605 if G2frame.RMCchoice == 'fullrmc': 4544 try:4545 from fullrmc import Engine4546 except ModuleNotFoundError:4547 wx.MessageBox(''' fullrmc is not correctly installed for use in GSAS-II4548 Install it in your python according to the instructions in4549 https://bachiraoun.github.io/fullrmc/index.html. ''',4550 caption='fullrmc not installed',style=wx.ICON_INFORMATION)4551 return4606 # try: 4607 # from fullrmc import Engine 4608 # except ModuleNotFoundError: 4609 # wx.MessageBox(''' fullrmc is not correctly installed for use in GSAS-II 4610 # Install it in your python according to the instructions in 4611 # https://bachiraoun.github.io/fullrmc/index.html. ''', 4612 # caption='fullrmc not installed',style=wx.ICON_INFORMATION) 4613 # return 4552 4614 mainSizer.Add(wx.StaticText(G2frame.FRMC,label=''' "Fullrmc, a Rigid Body Reverse Monte Carlo Modeling Package Enabled with Machine Learning and Artificial Intelligence", 4553 4615 B. Aoun, Jour. Comp. Chem. 2016, 37, 1102-1111. doi: https://doi.org/10.1002/jcc.24304 … … 4557 4619 G2frame.dataWindow.FRMCDataEdit.Enable(G2G.wxID_VIEWRMC,True) 4558 4620 mainSizer.Add(wx.StaticText(G2frame.FRMC,label=' fullrmc run.py file preparation:'),0,WACV) 4621 if not data['RMC']['fullrmc']: 4622 Atypes = data['General']['AtomTypes'] 4623 aTypes = dict(zip(Atypes,len(Atypes)*[0.10,])) 4624 atSeq = list(aTypes.keys()) 4625 lenA = len(atSeq) 4626 Pairs= [] 4627 for pair in [[' %s-%s'%(atSeq[i],atSeq[j]) for j in range(i,lenA)] for i in range(lenA)]: 4628 Pairs += pair 4629 Pairs = {pairs:[0.0,0.0,0.0] for pairs in Pairs} 4630 files = {'Neutron real space data; G(r): ':['',0.05,'G(r)','RMC',], 4631 'Neutron reciprocal space data; F(Q): ':['',0.05,'F(Q)','RMC',], 4632 'Neutron reciprocal space data; S(Q): ':['',0.05,'S(Q)','RMC',], 4633 'Xray real space data; G(r): ':['',0.01,'G(r)','RMC',], 4634 'Xray reciprocal space data; F(Q): ':['',0.01,'F(Q)','RMC',],} 4635 data['RMC']['fullrmc'] = {'ifBox':True,'SuperCell':[1,1,1],'Box':[10.,10.,10.],'aTypes':aTypes, 4636 'atSeq':atSeq,'Pairs':Pairs,'files':files,'ReStart':[False,False],'Swaps':[],'useBVS':False, 4637 'AveCN':[],'FxCN':[],} 4638 RMCPdict = data['RMC']['fullrmc'] 4639 4640 def GetSuperSizer(): 4641 superSizer = wx.BoxSizer(wx.HORIZONTAL) 4642 axes = ['X','Y','Z'] 4643 for i,ax in enumerate(axes): 4644 superSizer.Add(wx.StaticText(G2frame.FRMC,label=' %s-axis: '%ax),0,WACV) 4645 superSizer.Add(G2G.ValidatedTxtCtrl(G2frame.FRMC,RMCPdict['SuperCell'], 4646 i,min=1,max=20,size=(50,25)),0,WACV) 4647 return superSizer 4648 4649 def GetBoxSizer(): 4650 boxSizer = wx.BoxSizer(wx.HORIZONTAL) 4651 axes = ['X','Y','Z'] 4652 for i,ax in enumerate(axes): 4653 boxSizer.Add(wx.StaticText(G2frame.FRMC,label=' %s-axis: '%ax),0,WACV) 4654 boxSizer.Add(G2G.ValidatedTxtCtrl(G2frame.FRMC,RMCPdict['Box'], 4655 i,min=10.,max=50.,size=(50,25)),0,WACV) 4656 return boxSizer 4657 4658 def OnBoxChoice(event): 4659 RMCPdict['ifBox'] = not RMCPdict['ifBox'] 4660 UpdateRMC() 4661 4662 def OnReStart(event): 4663 RMCPdict['ReStart'][0] = not RMCPdict['ReStart'][0] 4664 #patches 4665 if 'useBVS' not in RMCPdict: 4666 RMCPdict['useBVS'] = False 4667 #end patches 4668 restart = wx.CheckBox(G2frame.FRMC,label=' Restart fullrmc Engine? (will clear old result!) ') 4669 restart.SetValue(RMCPdict['ReStart'][0]) 4670 restart.Bind(wx.EVT_CHECKBOX,OnReStart) 4671 mainSizer.Add(restart,0,WACV) 4672 4673 lineSizer = wx.BoxSizer(wx.HORIZONTAL) 4674 if RMCPdict['ifBox']: 4675 lineSizer.Add(wx.StaticText(G2frame.FRMC,label=' Big box dimensions:'),0,WACV) 4676 lineSizer.Add(GetBoxSizer(),0,WACV) 4677 boxBtn = wx.Button(G2frame.FRMC,label='Use super lattice') 4678 else: 4679 lineSizer.Add(wx.StaticText(G2frame.FRMC,label=' Lattice multipliers:'),0,WACV) 4680 lineSizer.Add(GetSuperSizer(),0,WACV) 4681 boxBtn = wx.Button(G2frame.FRMC,label='Use big box dimensions') 4682 boxBtn.Bind(wx.EVT_BUTTON,OnBoxChoice) 4683 lineSizer.Add(boxBtn,0,WACV) 4684 mainSizer.Add(lineSizer,0,WACV) 4685 4686 mainSizer.Add(GetAtmChoice(RMCPdict),0,WACV) 4687 4688 4689 4559 4690 elif G2frame.RMCchoice == 'RMCProfile': 4560 4691 mainSizer.Add(wx.StaticText(G2frame.FRMC,label=''' "RMCProfile: Reverse Monte Carlo for polycrystalline materials", M.G. Tucker, D.A. Keen, M.T. Dove, A.L. Goodwin and Q. Hui, … … 4591 4722 'Stretch search':10.,'Pot. Temp.':300., 4592 4723 }} 4724 4593 4725 RMCPdict = data['RMC']['RMCProfile'] 4594 4726 #patches 4595 4727 if 'FitScale' not in RMCPdict: 4596 4728 RMCPdict['FitScale'] = False 4729 4597 4730 #end patches 4598 4731 … … 4680 4813 i,min=1,max=20,size=(50,25),OnLeave=SetRestart),0,WACV) 4681 4814 return superSizer 4682 4683 def GetAtmChoice(): 4684 4685 def OnAtSel(event): 4686 Obj = event.GetEventObject() 4687 itype = Indx[Obj.GetId()] 4688 tid = RMCPdict['atSeq'].index(Obj.GetStringSelection()) 4689 if itype < nTypes: 4690 if itype == tid: 4691 tid += 1 4692 RMCPdict['atSeq'] = G2lat.SwapItems(RMCPdict['atSeq'],itype,tid) 4693 Pairs= [] 4694 atSeq = RMCPdict['atSeq'] 4695 lenA = len(atSeq) 4696 for pair in [[' %s-%s'%(atSeq[i],atSeq[j]) for j in range(i,lenA)] for i in range(lenA)]: 4697 Pairs += pair 4698 RMCPdict['Pairs'] = {pairs:[0.0,0.0,0.0] for pairs in Pairs} 4699 if RMCPdict['useBVS']: 4700 BVSpairs = [] 4701 for pair in [[' %s-%s'%(atSeq[i],atSeq[j]) for j in range(i+1,lenA)] for i in range(lenA)]: 4702 BVSpairs += pair 4703 RMCPdict['BVS'] = {pairs:[0.0,0.0,0.0,0.0] for pairs in BVSpairs} 4704 wx.CallAfter(UpdateRMC) 4705 4706 def OnValSel(event): 4707 Obj = event.GetEventObject() 4708 itype = Indx[Obj.GetId()] 4709 RMCPdict['Oxid'][itype][0] = Obj.GetStringSelection() 4710 wx.CallAfter(UpdateRMC) 4711 4712 nTypes = len(RMCPdict['aTypes']) 4713 atmChoice = wx.FlexGridSizer(nTypes+1,5,5) 4714 atmChoice.Add(wx.StaticText(G2frame.FRMC,label=' Set atom ordering: '),0,WACV) 4715 for iType in range(nTypes): 4716 atChoice = RMCPdict['atSeq'][iType:] 4717 atmSel = wx.ComboBox(G2frame.FRMC,choices=atChoice,style=wx.CB_DROPDOWN|wx.TE_READONLY) 4718 atmSel.SetStringSelection(RMCPdict['atSeq'][iType]) 4719 atmSel.Bind(wx.EVT_COMBOBOX,OnAtSel) 4720 Indx[atmSel.GetId()] = iType 4721 atmChoice.Add(atmSel,0,WACV) 4722 if RMCPdict['useBVS']: 4723 atmChoice.Add(wx.StaticText(G2frame.FRMC,label=' Select valence: '),0,WACV) 4724 for itype in range(nTypes): 4725 valChoice = atmdata.BVSoxid[RMCPdict['atSeq'][itype]] 4726 valSel = wx.ComboBox(G2frame.FRMC,choices=valChoice,style=wx.CB_DROPDOWN|wx.TE_READONLY) 4727 try: 4728 valSel.SetStringSelection(RMCPdict['Oxid'][itype][0]) 4729 except IndexError: 4730 RMCPdict['Oxid'].append([RMCPdict['atSeq'][itype],0.0]) 4731 valSel.Bind(wx.EVT_COMBOBOX,OnValSel) 4732 Indx[valSel.GetId()] = itype 4733 atmChoice.Add(valSel,0,WACV) 4734 atmChoice.Add(wx.StaticText(G2frame.FRMC,label=' BVS weight: '),0,WACV) 4735 for itype in range(nTypes): 4736 atmChoice.Add(G2G.ValidatedTxtCtrl(G2frame.FRMC,RMCPdict['Oxid'][itype],1,min=0.),0,WACV) 4737 atmChoice.Add(wx.StaticText(G2frame.FRMC,label=' Set max shift: '),0,WACV) 4738 for iType in range(nTypes): 4739 atId = RMCPdict['atSeq'][iType] 4740 atmChoice.Add(G2G.ValidatedTxtCtrl(G2frame.FRMC,RMCPdict['aTypes'],atId,min=0.,max=1.),0,WACV) 4741 return atmChoice 4742 4815 4743 4816 def GetPairSizer(): 4744 4817 pairSizer = wx.FlexGridSizer(len(RMCPdict['Pairs'])+1,5,5) … … 4987 5060 4988 5061 mainSizer.Add(wx.StaticText(G2frame.FRMC,label=' NB: be sure to set cations first && anions last in atom ordering'),0,WACV) 4989 mainSizer.Add(GetAtmChoice( ),0,WACV)5062 mainSizer.Add(GetAtmChoice(RMCPdict),0,WACV) 4990 5063 4991 5064 G2G.HorizontalLine(mainSizer,G2frame.FRMC) … … 5123 5196 G2frame.OnFileSaveas(event) 5124 5197 if G2frame.RMCchoice == 'fullrmc': 5125 print ('TBD')5126 return5127 print('set up rmcfull *.pdb & *.py files TBD')5128 5198 G2frame.dataWindow.FRMCDataEdit.Enable(G2G.wxID_RUNRMC,True) 5129 5199 RMCPdict = data['RMC']['fullrmc'] 5130 print(G2pwd.MakePDB(pName,data,RMCPdict)+ ' written') 5131 print(G2pwd.MakefullrmcRun(pName,data,RMCPdict)+ ' written') 5200 if RMCPdict['ifBox']: 5201 print(G2pwd.MakepdparserPDB(pName,data,RMCPdict)+ ' written') 5202 else: 5203 print(G2pwd.MakefullrmcPDB(pName,data,RMCPdict)+ ' written') 5204 #print(G2pwd.MakefullrmcRun(pName,data,RMCPdict)+ ' written') 5132 5205 print('fullrmc file build completed') 5133 5206 else: … … 5173 5246 pName = generalData['Name'].replace(' ','_') 5174 5247 if G2frame.RMCchoice == 'fullrmc': 5248 RMCPdict = data['RMC']['fullrmc'] 5175 5249 wx.MessageBox(''' For use of fullrmc, please cite: 5176 5250 Fullrmc, a Rigid Body Reverse Monte Carlo Modeling Package Enabled with 5177 5251 Machine Learning and Artificial Intelligence, 5178 B. Aoun, Jour. Comp. Chem. 2016, 37, 1102-1111. 5252 B. Aoun, Jour. Comp. Chem. 2016, 37, 1102-1111. 5179 5253 doi: https://doi.org/10.1002/jcc.24304''',caption='fullrmc',style=wx.ICON_INFORMATION) 5180 # TBD - remove filedialog & use defined run.py file name here 5254 rmcname = pName+'.rmc' 5255 while os.path.isdir(rmcname) and RMCPdict['ReStart']: 5256 msg = wx.MessageBox(''' fullrmc will fail to restart if %s exists. You must delete %s by hand now.'''%(rmcname,rmcname), 5257 caption='fullrmc file error',style=wx.ICON_EXCLAMATION|wx.OK|wx.CANCEL) 5258 if msg != wx.OK: 5259 return 5260 ilog = 0 5261 while True: 5262 logname = 'fullrmc_%d.log'%ilog 5263 if os.path.isfile(logname): 5264 os.remove(logname) 5265 else: 5266 break 5267 ilog += 1 5268 # TBD - remove filedialog & use defined run.py file name here 5181 5269 dlg = wx.FileDialog(G2frame, 'Choose fullrmc python file to execute', G2G.GetImportPath(G2frame), 5182 5270 wildcard='fullrmc python file (*.py)|*.py',style=wx.FD_CHANGE_DIR) … … 5185 5273 import subprocess as sb 5186 5274 batch = open('fullrmc.bat','w') 5187 batch.write(' run'+sys.exec_prefix+'\\Scripts\\activate\n')5275 batch.write('CALL '+sys.exec_prefix+'\\Scripts\\activate\n') 5188 5276 batch.write(sys.exec_prefix+'\\python.exe '+dlg.GetPath()+'\n') 5189 5277 batch.write('pause') 5190 5278 batch.close() 5191 sb.Popen('fullrmc.bat',creationflags=sb.CREATE_NEW_CONSOLE)5279 RMCPdict['pid'] = sb.Popen('fullrmc.bat',creationflags=sb.CREATE_NEW_CONSOLE).pid 5192 5280 else: 5193 5281 return … … 5195 5283 dlg.Destroy() 5196 5284 else: 5285 RMCPdict = data['RMC']['RMCProfile'] 5197 5286 rmcfile = G2fl.find('rmcprofile.exe',GSASIIpath.path2GSAS2) 5198 5287 rmcexe = os.path.split(rmcfile)[0] … … 5250 5339 def OnViewRMC(event): 5251 5340 if G2frame.RMCchoice == 'fullrmc': 5341 RMCPdict = data['RMC']['fullrmc'] 5252 5342 generalData = data['General'] 5253 5343 pName = generalData['Name'].replace(' ','_') 5344 import psutil 5345 pid = RMCPdict.get('pid',-1) 5346 Proc = None 5347 if pid and psutil.pid_exists(pid): 5348 proc = psutil.Process(pid).children() 5349 for child in proc: 5350 if 'conhost' in child.name(): #probably very Windows specific 5351 Proc = child 5254 5352 from fullrmc import Engine 5255 5353 # load 5256 5354 engineFilePath = pName+'.rmc' 5257 5355 ENGINE = Engine(path=None) 5356 eNames = ['Total',] 5357 nObs = [0,] 5258 5358 try: 5259 5359 if engineFilePath is not None: 5260 5360 result, mes = ENGINE.is_engine(engineFilePath, mes=True) 5261 5361 if result: 5362 if Proc is not None: 5363 Proc.suspend() 5262 5364 ENGINE = ENGINE.load(engineFilePath) 5263 5365 found = False … … 5273 5375 title = ' g(r) for ' 5274 5376 if 'StructureFactor' in sitem: 5377 eNames.append('S(Q)') 5275 5378 Xlab = r'$\mathsf{Q,\AA^{-1}}$' 5276 5379 Ylab = 'S(Q)' 5277 5380 title = ' S(Q) for ' 5278 if frame != '0': 5381 else: 5382 eNames.append('g(r)') 5279 5383 title = frame+title 5280 5384 dataDict= item.get_constraints_properties(frame) 5281 5385 X = dataDict['frames-experimental_x'][0] 5282 5386 Y = dataDict['frames-experimental_y'][0] 5387 nObs.append(X.shape[0]) 5283 5388 rdfDict = item.get_constraint_value() 5389 if 'total' not in rdfDict: 5390 print('No data yet - wait for a save') 5391 if Proc is not None: 5392 Proc.resume() 5393 return 5284 5394 Z = rdfDict['total'] 5285 5395 XY = [[X,Y],[X,Z]] … … 5308 5418 found = True 5309 5419 if 'BondConstraint' in sitem: 5310 bonds = item.get_constraint_value()['bondsLength'] 5420 try: 5421 bonds = item.get_constraint_value()['bondsLength'] 5422 except TypeError: 5423 break 5311 5424 bondList = item.bondsList[:2] 5312 5425 atoms = ENGINE.get_original_data("allElements",frame) … … 5347 5460 item.plot(show=True) 5348 5461 pass 5462 nObs[0] = np.sum(nObs[1:]) 5349 5463 if not found: 5350 print(' No saved information yet, wait until fullrms does a Save') 5464 print(' No saved information yet, wait until fullrmc does a Save') 5465 eNames = [] 5466 ENGINE.close() #return lock on ENGINE repository & close it 5467 if Proc is not None: 5468 Proc.resume() 5351 5469 except AssertionError: 5352 5470 print("Can't open fullrmc engine while running") 5353 try: 5354 logfile = open('fullrmc.log','r') 5355 except FileNotFoundError: 5356 logfile = open('fullrmc_0.log','r') 5357 loglines = logfile.readlines() 5358 logfile.close() 5471 loglines = [] 5472 ilog = 0 5473 while True: 5474 fname = 'fullrmc_%d.log'%ilog 5475 try: 5476 logfile = open(fname,'r') 5477 loglines += logfile.readlines() 5478 logfile.close() 5479 except FileNotFoundError: 5480 break 5481 ilog += 1 5482 if not len(loglines): 5483 print('no log file found') 5484 return 5359 5485 start = 0 5360 5486 while True: 5487 if start == len(loglines): 5488 print('No log info to plot') 5489 return 5361 5490 line = loglines[start] 5362 5491 if 'Err:' in line: … … 5365 5494 start += 1 5366 5495 Gen = [] 5367 Tr = []5368 Acc = []5369 Rem = []5496 # Tr = [] 5497 # Acc = [] 5498 # Rem = [] 5370 5499 Err = [] 5371 5500 start -= 1 … … 5380 5509 items = line.split(' - ') 5381 5510 try: # could be a trashed line at end 5382 Err.append(float(items[5][:-1].split('Err:')[1])) 5511 errStr = items[5][:-1].split('Err:')[1] 5512 Err.append([float(val) for val in errStr.split(',')]) 5383 5513 except ValueError: 5384 5514 break 5385 5515 Gen.append(int(items[1].split('Gen:')[1])) 5386 Tr.append(float(items[2].split('(')[1].split('%)')[0]))5387 Acc.append(float(items[3].split('(')[1].split('%)')[0]))5388 Rem.append(float(items[4].split('(')[1].split('%)')[0]))5389 5516 5390 5517 Gen = np.array(Gen) 5391 Tr = np.array(Tr) 5392 Acc = np.array(Acc) 5393 Rem = np.array(Rem) 5394 Err = np.log10(np.array(Err)) 5395 Names = ['Tr','Acc','Rem','Err'] 5396 XY = [[Gen,Tr],[Gen,Acc],[Gen,Rem],[Gen,Err]] 5397 G2plt.PlotXY(G2frame,XY,labelX='no. generated', 5398 labelY=r'$log_{10}(Err)\ &\ residuals,\ %$',newPlot=True,Title='fullrmc residuals for '+pName, 5399 lines=True,names=Names) 5518 Err = np.array(Err) 5519 nObs = np.array(nObs) 5520 if np.any(nObs): 5521 Err /= nObs[:Err.shape[1]] 5522 ptstr1 = '' 5523 ptstr2 = '' 5524 for it,item in enumerate(eNames): 5525 ptstr1 += ' %s obs: %d'%(item,nObs[it]) 5526 ptstr2 += ' %s reduced chi^2: %.5f'%(item,Err[-1][it]) 5527 print(ptstr1) 5528 print(ptstr2) 5529 Err = np.log10(Err) 5530 XY = [[Gen,Erri] for Erri in Err.T] 5531 G2plt.PlotXY(G2frame,XY,labelX='no. generated', 5532 labelY=r'$log_{10}$ (reduced $\mathsf{\chi^2})$',newPlot=True,Title='fullrmc residuals for '+pName, 5533 lines=True,names=eNames) 5400 5534 5401 5535 else: … … 10336 10470 startDmin = generalData['Pawley dmin'] 10337 10471 genDlg = wx.Dialog(G2frame,wx.ID_ANY,'Set Pawley Parameters', 10338 10472 style=wx.DEFAULT_DIALOG_STYLE) 10339 10473 mainSizer = wx.BoxSizer(wx.VERTICAL) 10340 10474 mainSizer.Add(wx.StaticText(genDlg,wx.ID_ANY, 10341 'Set Pawley Extraction Parameters for phase '+ 10342 generalData.get('Name','?'))) 10475 'Set Pawley Extraction Parameters for phase '+generalData.get('Name','?'))) 10343 10476 mainSizer.Add([5,10]) 10344 10477 pawleySizer = wx.BoxSizer(wx.HORIZONTAL) 10345 10478 pawleySizer.Add(wx.StaticText(genDlg,label=' Do Pawley refinement?: '),0,WACV) 10346 pawlRef = G2G.G2CheckBox(genDlg,'',generalData,'doPawley', 10347 DisablePawleyOpts) 10479 pawlRef = G2G.G2CheckBox(genDlg,'',generalData,'doPawley',DisablePawleyOpts) 10348 10480 pawleySizer.Add(pawlRef,0,WACV) 10349 10481 mainSizer.Add(pawleySizer) … … 10354 10486 pawlQVal.SetValue(temp['Qmax']) 10355 10487 pawlVal = G2G.ValidatedTxtCtrl(genDlg,generalData,'Pawley dmin', 10356 10488 min=0.25,max=20.,nDig=(10,5),typeHint=float,OnLeave=d2Q) 10357 10489 pawleySizer.Add(pawlVal,0,WACV) 10358 10490 pawleySizer.Add(wx.StaticText(genDlg,label=' Qmax: '),0,WACV) … … 10362 10494 pawlVal.SetValue(generalData['Pawley dmin']) 10363 10495 pawlQVal = G2G.ValidatedTxtCtrl(genDlg,temp,'Qmax', 10364 10496 min=0.314,max=25.,nDig=(10,5),typeHint=float,OnLeave=Q2D) 10365 10497 pawleySizer.Add(pawlQVal,0,WACV) 10366 10498 mainSizer.Add(pawleySizer) … … 10368 10500 pawleySizer.Add(wx.StaticText(genDlg,label=' Pawley neg. wt.: '),0,WACV) 10369 10501 pawlNegWt = G2G.ValidatedTxtCtrl(genDlg,generalData,'Pawley neg wt', 10370 10502 min=0.,max=1.,nDig=(10,4),typeHint=float) 10371 10503 pawleySizer.Add(pawlNegWt,0,WACV) 10372 10504 mainSizer.Add(pawleySizer) -
trunk/GSASIIpwd.py
r4389 r4397 2500 2500 2501 2501 2502 def MakePDB(Name,Phase,RMCPdict): 2503 return None 2504 # generalData = Phase['General'] 2505 # Cell = generalData['Cell'][1:7] 2506 # Trans = np.eye(3)*np.array(Supercell) 2507 # newPhase = copy.deepcopy(Phase) 2508 # newPhase['General']['SGData'] = G2spc.SpcGroup('P 1')[1] 2509 # newPhase['General']['Cell'][1:] = G2lat.TransformCell(Cell,Trans.T) 2510 # newPhase,Atcodes = G2lat.TransformPhase(Phase,newPhase,Trans,np.zeros(3),np.zeros(3),ifMag=False) 2511 # Atoms = newPhase['Atoms'] 2512 # Cell = newPhase['General']['Cell'][1:7] 2513 # A,B = G2lat. cell2AB(Cell) 2514 # fname = Name+'.pdb' 2515 # fl = open(fname,'w') 2516 # fl.write('REMARK this file is generated using GSASII\n') 2517 # fl.write('CRYST1%9.3f%9.3f%9.3f%7.2f%7.2f%7.2f P 1 1\n'%( 2518 # Cell[0],Cell[1],Cell[2],Cell[3],Cell[4],Cell[5])) 2519 # fl.write('ORIGX1 1.000000 0.000000 0.000000 0.00000\n') 2520 # fl.write('ORIGX2 0.000000 1.000000 0.000000 0.00000\n') 2521 # fl.write('ORIGX3 0.000000 0.000000 1.000000 0.00000\n') 2522 2523 # Natm = np.core.defchararray.count(np.array(Atcodes),'+') 2524 # Natm = np.count_nonzero(Natm-1) 2525 # nat = 0 2526 # for atm in Atseq: 2527 # for iat,atom in enumerate(Atoms): 2528 # if atom[1] == atm: 2529 # nat += 1 2530 # XYZ = np.inner(A,np.array(atom[3:6])-0.5) #shift origin to middle & make Cartesian 2531 # fl.write('ATOM %5d %-4s RMC%6d%12.3f%8.3f%8.3f 1.00 0.00 %-2s\n'%( 2532 # nat,atom[0],nat,XYZ[0],XYZ[1],XYZ[2],atom[1])) 2533 # fl.close() 2534 # return fname 2502 def MakefullrmcPDB(Name,Phase,RMCPdict): 2503 generalData = Phase['General'] 2504 Atseq = RMCPdict['atSeq'] 2505 Supercell = RMCPdict['SuperCell'] 2506 Cell = generalData['Cell'][1:7] 2507 Trans = np.eye(3)*np.array(Supercell) 2508 newPhase = copy.deepcopy(Phase) 2509 newPhase['General']['SGData'] = G2spc.SpcGroup('P 1')[1] 2510 newPhase['General']['Cell'][1:] = G2lat.TransformCell(Cell,Trans.T) 2511 newPhase,Atcodes = G2lat.TransformPhase(Phase,newPhase,Trans,np.zeros(3),np.zeros(3),ifMag=False) 2512 Atoms = newPhase['Atoms'] 2513 XYZ = np.array([atom[3:6] for atom in Atoms]).T 2514 XYZptp = np.array([ma.ptp(XYZ[0]),ma.ptp(XYZ[1]),ma.ptp(XYZ[2])])/2. 2515 Cell = newPhase['General']['Cell'][1:7] 2516 A,B = G2lat. cell2AB(Cell) 2517 fname = Name+'.pdb' 2518 fl = open(fname,'w') 2519 fl.write('REMARK this file is generated using GSASII\n') 2520 fl.write('REMARK Boundary Conditions:%6.2f 0.0 0.0 0.0%7.2f 0.0 0.0 0.0%7.2f\n'%( 2521 Cell[0],Cell[1],Cell[2])) 2522 fl.write('CRYST1%9.3f%9.3f%9.3f%7.2f%7.2f%7.2f P 1 1\n'%( 2523 Cell[0],Cell[1],Cell[2],Cell[3],Cell[4],Cell[5])) 2524 fl.write('ORIGX1 1.000000 0.000000 0.000000 0.00000\n') 2525 fl.write('ORIGX2 0.000000 1.000000 0.000000 0.00000\n') 2526 fl.write('ORIGX3 0.000000 0.000000 1.000000 0.00000\n') 2527 2528 Natm = np.core.defchararray.count(np.array(Atcodes),'+') 2529 Natm = np.count_nonzero(Natm-1) 2530 nat = 0 2531 for atm in Atseq: 2532 for iat,atom in enumerate(Atoms): 2533 if atom[1] == atm: 2534 nat += 1 2535 XYZ = np.inner(A,np.array(atom[3:6])-XYZptp) #shift origin to middle & make Cartesian 2536 fl.write('ATOM %5d %-4s RMC%6d%12.3f%8.3f%8.3f 1.00 0.00 %-2s\n'%( 2537 nat,atom[0],nat,XYZ[0],XYZ[1],XYZ[2],atom[1].lower())) 2538 fl.close() 2539 return fname 2540 2541 def MakepdparserPDB(Name,Phase,RMCPdict): 2542 import pdbparser as pdp 2543 fname = Name+'.pdb' 2544 fl = open(fname,'w') 2545 fl.write('REMARK this file to be generated using pdbparser\n') 2546 fl.close() 2547 return fname 2535 2548 2536 2549 def GetRMCBonds(general,RMCPdict,Atoms,bondList):
Note: See TracChangeset
for help on using the changeset viewer.