Changeset 4404
- Timestamp:
- Apr 19, 2020 11:52:51 AM (3 years ago)
- Location:
- trunk
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/GSASIIphsGUI.py
r4401 r4404 4411 4411 atmChoice.Add(G2G.ValidatedTxtCtrl(G2frame.FRMC,RMCPdict['aTypes'],atId,min=0.,max=1.),0,WACV) 4412 4412 return atmChoice 4413 4414 4413 4414 def FileSizer(RMCdict): 4415 4416 def OnFitScale(event): 4417 RMCPdict['FitScale'] = not RMCPdict['FitScale'] 4418 4419 def OnFileSel(event): 4420 Obj = event.GetEventObject() 4421 fil = Indx[Obj.GetId()] 4422 dlg = wx.FileDialog(G2frame.FRMC, 'Choose '+fil,G2G.GetImportPath(G2frame), 4423 style=wx.FD_OPEN ,wildcard=fil+'(*.*)|*.*') 4424 if dlg.ShowModal() == wx.ID_OK: 4425 fpath,fName = os.path.split(dlg.GetPath()) 4426 if fpath != G2frame.LastGPXdir: 4427 disfile.copy_file(dlg.GetPath(),os.path.join(G2frame.LastGPXdir,fName)) 4428 if os.path.exists(fName): 4429 RMCPdict['files'][fil][0] = fName 4430 G2frame.LastImportDir = fpath #set so next file is found in same place 4431 dlg.Destroy() 4432 else: 4433 dlg.Destroy() 4434 return 4435 wx.CallAfter(UpdateRMC) 4436 4437 def OnFileFormat(event): 4438 Obj = event.GetEventObject() 4439 fil = Indx[Obj.GetId()] 4440 RMCPdict['files'][fil][3] = Obj.GetStringSelection() 4441 4442 def OnPlotBtn(event): 4443 Obj = event.GetEventObject() 4444 fil = Indx[Obj.GetId()] 4445 fileItem = RMCPdict['files'][fil] 4446 start = 0 4447 XY = np.empty((1,2)) 4448 while XY.shape[0] == 1: 4449 try: 4450 XY = np.loadtxt(fileItem[0],skiprows=start) 4451 except ValueError: 4452 start += 1 4453 Xlab = 'Q' 4454 if 'G(R)' in fileItem[2]: 4455 Xlab = 'R' 4456 G2plt.PlotXY(G2frame,[XY.T,],labelX=Xlab, 4457 labelY=fileItem[2],newPlot=True,Title=fileItem[0], 4458 lines=True) 4459 4460 Indx = {} 4461 titleSizer = wx.BoxSizer(wx.HORIZONTAL) 4462 titleSizer.Add(wx.StaticText(G2frame.FRMC,label=' Select data for processing: '),0,WACV) 4463 fitscale = wx.CheckBox(G2frame.FRMC,label=' Fit scale factors?') 4464 fitscale.SetValue(RMCPdict['FitScale']) 4465 fitscale.Bind(wx.EVT_CHECKBOX,OnFitScale) 4466 titleSizer.Add(fitscale,0,WACV) 4467 mainSizer.Add(titleSizer,0,WACV) 4468 ncol= 5 4469 Heads = ['Name','File','Format','Weight','Plot'] 4470 if G2frame.RMCchoice == 'fullrmc': 4471 mainSizer.Add(wx.StaticText(G2frame.FRMC, 4472 label=' NB: fullrmc data files must be 2 columns; all other lines preceeded by "#". Edit before use.'),0,WACV) 4473 ncol = 4 4474 Heads = ['Name','File','Weight','Plot'] 4475 fileSizer = wx.FlexGridSizer(ncol,5,5) 4476 Formats = ['RMC','GUDRUN','STOG'] 4477 for head in Heads: 4478 fileSizer.Add(wx.StaticText(G2frame.FRMC,label=head),0,WACV) 4479 for fil in RMCPdict['files']: 4480 fileSizer.Add(wx.StaticText(G2frame.FRMC,label=fil),0,WACV) 4481 Rfile = RMCPdict['files'][fil][0] 4482 filSel = wx.Button(G2frame.FRMC,label=Rfile) 4483 filSel.Bind(wx.EVT_BUTTON,OnFileSel) 4484 Indx[filSel.GetId()] = fil 4485 fileSizer.Add(filSel,0,WACV) 4486 if Rfile and os.path.exists(Rfile): #incase .gpx file is moved away from G(R), F(Q), etc. files 4487 if G2frame.RMCchoice == 'RMCProfile': 4488 nform = 3 4489 if 'Xray' in fil: nform = 1 4490 fileFormat = wx.ComboBox(G2frame.FRMC,choices=Formats[:nform],style=wx.CB_DROPDOWN|wx.TE_READONLY) 4491 fileFormat.SetStringSelection(RMCPdict['files'][fil][3]) 4492 Indx[fileFormat.GetId()] = fil 4493 fileFormat.Bind(wx.EVT_COMBOBOX,OnFileFormat) 4494 fileSizer.Add(fileFormat,0,WACV) 4495 fileSizer.Add(G2G.ValidatedTxtCtrl(G2frame.FRMC,RMCPdict['files'][fil],1),0,WACV) 4496 plotBtn = wx.Button(G2frame.FRMC,label='Plot?') 4497 plotBtn.Bind(wx.EVT_BUTTON,OnPlotBtn) 4498 Indx[plotBtn.GetId()] = fil 4499 fileSizer.Add(plotBtn,0,WACV) 4500 else: 4501 RMCPdict['files'][fil][0] = 'Select' 4502 fileSizer.Add((5,5),0) 4503 fileSizer.Add((5,5),0) 4504 if G2frame.RMCchoice == 'RMCProfile': 4505 fileSizer.Add((5,5),0) 4506 return fileSizer 4507 4415 4508 G2frame.GetStatusBar().SetStatusText('',1) 4416 4509 if G2frame.RMCchoice == 'RMCProfile': … … 4447 4540 G2frame.dataWindow.FRMCDataEdit.Enable(G2G.wxID_RUNRMC,True) 4448 4541 G2frame.dataWindow.FRMCDataEdit.Enable(G2G.wxID_VIEWRMC,True) 4449 mainSizer.Add(wx.StaticText(G2frame.FRMC,label=' fullrmc run.pyfile preparation:'),0,WACV)4542 mainSizer.Add(wx.StaticText(G2frame.FRMC,label=' fullrmc big box starting pdb file preparation:'),0,WACV) 4450 4543 if not data['RMC']['fullrmc']: 4451 4544 Atypes = data['General']['AtomTypes'] … … 4457 4550 Pairs += pair 4458 4551 Pairs = {pairs:[0.0,0.0,0.0] for pairs in Pairs} 4459 files = {'Neutron real space data; G(r): ':['',0.05,'G(r)','RMC',], 4460 'Neutron reciprocal space data; F(Q): ':['',0.05,'F(Q)','RMC',], 4461 'Neutron reciprocal space data; S(Q): ':['',0.05,'S(Q)','RMC',], 4462 'Xray real space data; G(r): ':['',0.01,'G(r)','RMC',], 4463 'Xray reciprocal space data; F(Q): ':['',0.01,'F(Q)','RMC',],} 4464 data['RMC']['fullrmc'] = {'ifBox':True,'SuperCell':[1,1,1],'Box':[10.,10.,10.],'aTypes':aTypes, 4465 'atSeq':atSeq,'Pairs':Pairs,'files':files,'ReStart':[False,False],'Swaps':[],'useBVS':False, 4466 'AveCN':[],'FxCN':[],'moleculePdb':'Select','targetDensity':1.0,'maxRecursion':10000} 4552 files = {'Neutron real space data; G(r): ':['Select',0.05,'G(r)'], 4553 'Neutron reciprocal space data; F(Q): ':['Select',0.05,'F(Q)'], 4554 'Neutron reciprocal space data; S(Q): ':['Select',0.05,'S(Q)'], 4555 'Xray real space data; G(r): ':['Select',0.01,'G(r)'], 4556 'Xray reciprocal space data; F(Q): ':['Select',0.01,'F(Q)'],} 4557 data['RMC']['fullrmc'] = {'SuperCell':[1,1,1],'Box':[10.,10.,10.],'aTypes':aTypes,'byMolec':False, 4558 'Natoms':1,'atSeq':atSeq,'Pairs':Pairs,'files':files,'ReStart':[False,False], 4559 'Swaps':[],'useBVS':False,'FitScale':False,'AveCN':[],'FxCN':[], 4560 'moleculePdb':'Select','targetDensity':1.0,'maxRecursion':10000, 4561 'atomPDB':''} 4467 4562 RMCPdict = data['RMC']['fullrmc'] 4468 4563 … … 4485 4580 return boxSizer 4486 4581 4487 def OnBoxChoice(event): 4488 RMCPdict['ifBox'] = not RMCPdict['ifBox'] 4489 UpdateRMC() 4490 4582 def OnByMolec(event): 4583 RMCPdict['byMolec'] = bymolec.GetValue() 4584 4491 4585 def OnReStart(event): 4492 4586 RMCPdict['ReStart'][0] = not RMCPdict['ReStart'][0] … … 4501 4595 4502 4596 def OnMakePDB(event): 4597 if not ifBox: 4598 generalData = data['General'] 4599 pName = generalData['Name'].replace(' ','_') 4600 pdbname = G2pwd.MakefullrmcPDB(pName,data,RMCPdict) 4601 RMCPdict['atomPDB'] = pdbname 4602 print(pdbname+ ' written') 4603 return 4604 if RMCPdict['moleculePdb'] == 'Select': 4605 wx.MessageDialog(G2frame,' You must select a source pdb file first','PDB generation error', 4606 wx.ICON_EXCLAMATION).ShowModal() 4607 return 4503 4608 dlg = wx.MessageDialog(G2frame,''' 4504 4609 Warning - this step can take more than an hour; do you want to proceed? … … 4527 4632 if 'moleculePdb' not in RMCPdict: 4528 4633 RMCPdict.update({'moleculePdb':'Select','targetDensity':1.0,'maxRecursion':10000}) 4634 if 'byMolec' not in RMCPdict: 4635 RMCPdict['byMolec'] = False 4636 if 'Natoms' not in RMCPdict: 4637 RMCPdict['Natoms'] = 1 4638 if 'FitScale' not in RMCPdict: 4639 RMCPdict['FitScale'] = False 4640 if 'atomPDB' not in RMCPdict: 4641 RMCPdict['atomPDB'] = '' 4529 4642 #end patches 4530 restart = wx.CheckBox(G2frame.FRMC,label=' Restart fullrmc Engine? (will clear old result!) ') 4531 restart.SetValue(RMCPdict['ReStart'][0])4532 restart.Bind(wx.EVT_CHECKBOX,OnReStart)4533 mainSizer.Add(restart,0,WACV)4534 4643 4644 generalData = data['General'] 4645 ifBox = False 4646 if 'macromolecular' in generalData['Type']: 4647 ifBox = True 4535 4648 lineSizer = wx.BoxSizer(wx.HORIZONTAL) 4536 if RMCPdict['ifBox']:4649 if ifBox: 4537 4650 lineSizer.Add(wx.StaticText(G2frame.FRMC,label=' Big box dimensions, %s:'%Angstr),0,WACV) 4538 4651 lineSizer.Add(GetBoxSizer(),0,WACV) 4539 boxBtn = wx.Button(G2frame.FRMC,label='Use super lattice')4540 4652 else: 4541 4653 lineSizer.Add(wx.StaticText(G2frame.FRMC,label=' Lattice multipliers:'),0,WACV) 4542 4654 lineSizer.Add(GetSuperSizer(),0,WACV) 4543 boxBtn = wx.Button(G2frame.FRMC,label='Use big box dimensions') 4544 boxBtn.Bind(wx.EVT_BUTTON,OnBoxChoice) 4545 lineSizer.Add(boxBtn,0,WACV) 4655 bymolec = wx.CheckBox(G2frame.FRMC,label='Save in molecule order?') 4656 bymolec.SetValue(RMCPdict['byMolec']) 4657 bymolec.Bind(wx.EVT_CHECKBOX,OnByMolec) 4658 lineSizer.Add(bymolec,0,WACV) 4659 lineSizer.Add(wx.StaticText(G2frame.FRMC,label=' Num. atoms per molecule '),0,WACV) 4660 lineSizer.Add(G2G.ValidatedTxtCtrl(G2frame.FRMC,RMCPdict,'Natoms',min=1,size=[40,25]),0,WACV) 4546 4661 mainSizer.Add(lineSizer,0,WACV) 4547 if RMCPdict['ifBox']:4662 if ifBox: 4548 4663 molecSizer = wx.BoxSizer(wx.HORIZONTAL) 4549 4664 molecSizer.Add(wx.StaticText(G2frame.FRMC,label=' Source molecule file '),0,WACV) … … 4559 4674 molecSizer.Add(makePDB,0,WACV) 4560 4675 mainSizer.Add(molecSizer,0,WACV) 4676 else: 4677 makePDB = wx.Button(G2frame.FRMC,label='Make big box PDB') 4678 makePDB.Bind(wx.EVT_BUTTON,OnMakePDB) 4679 mainSizer.Add(makePDB,0,WACV) 4680 4561 4681 G2G.HorizontalLine(mainSizer,G2frame.FRMC) 4562 4682 mainSizer.Add(wx.StaticText(G2frame.FRMC,label=' fullrmc run file preparation:'),0,WACV) 4683 restart = wx.CheckBox(G2frame.FRMC,label=' Restart fullrmc Engine? (will clear old result!) ') 4684 restart.SetValue(RMCPdict['ReStart'][0]) 4685 restart.Bind(wx.EVT_CHECKBOX,OnReStart) 4686 mainSizer.Add(restart,0,WACV) 4687 4688 G2G.HorizontalLine(mainSizer,G2frame.FRMC) 4563 4689 mainSizer.Add(GetAtmChoice(RMCPdict),0,WACV) 4564 4690 4565 4691 G2G.HorizontalLine(mainSizer,G2frame.FRMC) 4692 mainSizer.Add(FileSizer(RMCPdict),0,WACV) 4566 4693 4567 4694 elif G2frame.RMCchoice == 'RMCProfile': … … 4585 4712 BVSpairs += pair 4586 4713 BVS = {pairs:[0.0,0.0,0.0,0.0] for pairs in BVSpairs} 4587 files = {'Neutron real space data; G(r): ':[' ',0.05,'G(r)','RMC',],4588 'Neutron reciprocal space data; F(Q): ':[' ',0.05,'F(Q)','RMC',],4589 'Neutron reciprocal space data; S(Q): ':[' ',0.05,'S(Q)','RMC',],4590 # 'Xray real space data; G(r): ':[' ',0.01,'G(r)','RMC',],4591 'Xray reciprocal space data; F(Q): ':[' ',0.01,'F(Q)','RMC',],}4714 files = {'Neutron real space data; G(r): ':['Select',0.05,'G(r)','RMC',], 4715 'Neutron reciprocal space data; F(Q): ':['Select',0.05,'F(Q)','RMC',], 4716 'Neutron reciprocal space data; S(Q): ':['Select',0.05,'S(Q)','RMC',], 4717 # 'Xray real space data; G(r): ':['Select',0.01,'G(r)','RMC',], 4718 'Xray reciprocal space data; F(Q): ':['Select',0.01,'F(Q)','RMC',],} 4592 4719 runTimes = [10.,1.] 4593 4720 metadata = {'title':'none','owner':'no one','date':str(time.ctime()),'temperature':'300K', 4594 4721 'material':'nothing','phase':'vacuum','comment':'none ','source':'nowhere'} 4595 4722 data['RMC']['RMCProfile'] = {'SuperCell':[1,1,1],'UseSampBrd':[True,True],'aTypes':aTypes, 4596 'atSeq':atSeq,'Pairs':Pairs,'histogram':['',1.0],'files':files,'metadata':metadata, 4723 'atSeq':atSeq,'Pairs':Pairs,'histogram':['',1.0],'files':files,'metadata':metadata,'FitScale':False, 4597 4724 'runTimes':runTimes,'ReStart':[False,False],'BVS':BVS,'Oxid':atOxid,'useBVS':False,'Swaps':[], 4598 4725 'AveCN':[],'FxCN':[],'Potentials':{'Angles':[],'Angle search':10.,'Stretch':[], … … 4615 4742 def OnStrain(event): 4616 4743 RMCPdict['UseSampBrd'][1] = strain.GetValue() 4617 4618 def OnFileSel(event):4619 Obj = event.GetEventObject()4620 fil = Indx[Obj.GetId()]4621 dlg = wx.FileDialog(G2frame.FRMC, 'Choose '+fil,G2G.GetImportPath(G2frame),4622 style=wx.FD_OPEN ,wildcard=fil+'(*.*)|*.*')4623 if dlg.ShowModal() == wx.ID_OK:4624 fpath,fName = os.path.split(dlg.GetPath())4625 if fpath != G2frame.LastGPXdir:4626 disfile.copy_file(dlg.GetPath(),os.path.join(G2frame.LastGPXdir,fName))4627 if os.path.exists(fName):4628 RMCPdict['files'][fil][0] = fName4629 G2frame.LastImportDir = fpath #set so next file is found in same place4630 dlg.Destroy()4631 else:4632 dlg.Destroy()4633 return4634 wx.CallAfter(UpdateRMC)4635 4636 def OnFileFormat(event):4637 Obj = event.GetEventObject()4638 fil = Indx[Obj.GetId()]4639 RMCPdict['files'][fil][3] = Obj.GetStringSelection()4640 4744 4641 4745 def SetRestart(invalid,value,tc): … … 4922 5026 return swapSizer 4923 5027 4924 def OnFitScale(event):4925 RMCPdict['FitScale'] = not RMCPdict['FitScale']4926 4927 5028 Indx = {} 4928 5029 … … 5031 5132 samSizer.Add(strain,0,WACV) 5032 5133 mainSizer.Add(samSizer,0,WACV) 5033 titleSizer = wx.BoxSizer(wx.HORIZONTAL) 5034 titleSizer.Add(wx.StaticText(G2frame.FRMC,label=' Select data for processing: '),0,WACV) 5035 fitscale = wx.CheckBox(G2frame.FRMC,label=' Fit scale factors?') 5036 fitscale.SetValue(RMCPdict['FitScale']) 5037 fitscale.Bind(wx.EVT_CHECKBOX,OnFitScale) 5038 titleSizer.Add(fitscale,0,WACV) 5039 mainSizer.Add(titleSizer,0,WACV) 5040 fileSizer = wx.FlexGridSizer(4,5,5) 5041 Formats = ['RMC','GUDRUN','STOG'] 5042 Heads = [' ','Format','Weight','Name'] 5043 for head in Heads: 5044 fileSizer.Add(wx.StaticText(G2frame.FRMC,label=head),0,WACV) 5045 for fil in RMCPdict['files']: 5046 filSel = wx.Button(G2frame.FRMC,label='Select') 5047 filSel.Bind(wx.EVT_BUTTON,OnFileSel) 5048 Indx[filSel.GetId()] = fil 5049 fileSizer.Add(filSel,0,WACV) 5050 Rfile = RMCPdict['files'][fil][0] 5051 if Rfile and os.path.exists(Rfile): #incase .gpx file is moved away from G(R), F(Q), etc. files 5052 nform = 3 5053 if 'Xray' in fil: nform = 1 5054 fileFormat = wx.ComboBox(G2frame.FRMC,choices=Formats[:nform],style=wx.CB_DROPDOWN|wx.TE_READONLY) 5055 fileFormat.SetStringSelection(RMCPdict['files'][fil][3]) 5056 Indx[fileFormat.GetId()] = fil 5057 fileFormat.Bind(wx.EVT_COMBOBOX,OnFileFormat) 5058 fileSizer.Add(fileFormat,0,WACV) 5059 fileSizer.Add(G2G.ValidatedTxtCtrl(G2frame.FRMC,RMCPdict['files'][fil],1),0,WACV) 5060 else: 5061 RMCPdict['files'][fil][0] = '' 5062 fileSizer.Add((5,5),0) 5063 fileSizer.Add((5,5),0) 5064 fileSizer.Add(wx.StaticText(G2frame.FRMC,label=fil+RMCPdict['files'][fil][0]),0,WACV) 5065 mainSizer.Add(fileSizer,0,WACV) 5134 5135 mainSizer.Add(FileSizer(RMCPdict),0,WACV) 5066 5136 5067 5137 SetPhaseWindow(G2frame.FRMC,mainSizer) … … 5075 5145 G2frame.dataWindow.FRMCDataEdit.Enable(G2G.wxID_RUNRMC,True) 5076 5146 RMCPdict = data['RMC']['fullrmc'] 5077 if RMCPdict['ifBox']: 5078 print(G2pwd.MakepdparserPDB(pName,data,RMCPdict)+ ' written') 5079 else: 5080 print(G2pwd.MakefullrmcPDB(pName,data,RMCPdict)+ ' written') 5081 print('fullrmc file build completed') 5147 fname = G2pwd.MakefullrmcRun(pName,data,RMCPdict) 5148 print('fullrmc file %s build completed'%fname) 5082 5149 else: 5083 5150 G2frame.dataWindow.FRMCDataEdit.Enable(G2G.wxID_RUNRMC,True) … … 5129 5196 doi: https://doi.org/10.1002/jcc.24304''',caption='fullrmc',style=wx.ICON_INFORMATION) 5130 5197 rmcname = pName+'.rmc' 5131 while os.path.isdir(rmcname) and RMCPdict['ReStart'] :5198 while os.path.isdir(rmcname) and RMCPdict['ReStart'][0]: 5132 5199 msg = wx.MessageBox(''' fullrmc will fail to restart if %s exists. You must delete %s by hand now.'''%(rmcname,rmcname), 5133 5200 caption='fullrmc file error',style=wx.ICON_EXCLAMATION|wx.OK|wx.CANCEL) … … 5136 5203 ilog = 0 5137 5204 while True: 5138 logname = ' fullrmc_%d.log'%ilog5205 logname = '%s_%d.log'%(pName,ilog) 5139 5206 if os.path.isfile(logname): 5140 5207 os.remove(logname) … … 5143 5210 ilog += 1 5144 5211 # TBD - remove filedialog & use defined run.py file name here 5212 rname = pName+'-run.py' 5145 5213 dlg = wx.FileDialog(G2frame, 'Choose fullrmc python file to execute', G2G.GetImportPath(G2frame), 5146 5214 wildcard='fullrmc python file (*.py)|*.py',style=wx.FD_CHANGE_DIR) 5147 5215 try: 5148 5216 if dlg.ShowModal() == wx.ID_OK: 5149 import subprocess as sb 5150 batch = open('fullrmc.bat','w') 5151 batch.write('CALL '+sys.exec_prefix+'\\Scripts\\activate\n') 5152 batch.write(sys.exec_prefix+'\\python.exe '+dlg.GetPath()+'\n') 5153 batch.write('pause') 5154 batch.close() 5155 RMCPdict['pid'] = sb.Popen('fullrmc.bat',creationflags=sb.CREATE_NEW_CONSOLE).pid 5217 rname = dlg.GetPath() 5156 5218 else: 5157 5219 return 5158 5220 finally: 5159 5221 dlg.Destroy() 5222 import subprocess as sb 5223 batch = open('fullrmc.bat','w') 5224 batch.write('CALL '+sys.exec_prefix+'\\Scripts\\activate\n') 5225 batch.write(sys.exec_prefix+'\\python.exe '+rname+'\n') 5226 batch.write('pause') 5227 batch.close() 5228 RMCPdict['pid'] = sb.Popen('fullrmc.bat',creationflags=sb.CREATE_NEW_CONSOLE).pid 5160 5229 else: 5161 5230 RMCPdict = data['RMC']['RMCProfile'] … … 5348 5417 ilog = 0 5349 5418 while True: 5350 fname = ' fullrmc_%d.log'%ilog5419 fname = '%s_%d.log'%(pName,ilog) 5351 5420 try: 5352 5421 logfile = open(fname,'r') -
trunk/GSASIIplot.py
r4403 r4404 5253 5253 if np.any(X) and np.any(Y) and np.any(Z): 5254 5254 np.seterr(all='ignore') 5255 try: 5255 if True: 5256 # try: 5256 5257 Plot.plot_surface(X,Y,Z,rstride=1,cstride=1,color='g',linewidth=1) 5257 5258 xyzlim = np.array([Plot.get_xlim3d(),Plot.get_ylim3d(),Plot.get_zlim3d()]).T … … 5265 5266 Plot.set_zlabel(labelZ) 5266 5267 Plot.set_aspect('equal') 5267 except:5268 print('Plot3dXYZ failure')5269 pass5268 # except: 5269 # print('Plot3dXYZ failure') 5270 # pass 5270 5271 Page.canvas.draw() 5271 5272 -
trunk/GSASIIpwd.py
r4400 r4404 2106 2106 #### RMCutilities 2107 2107 ################################################################################ 2108 2108 2109 2109 def MakeInst(PWDdata,Name,Size,Mustrain,useSamBrd): 2110 2110 inst = PWDdata['Instrument Parameters'][0] … … 2423 2423 fl.write(' > CAVSTR%d :: %d %d %.2f %.2f %.2f %.6f\n'%(iav+1,at1+1,at2+1,avcn[2],avcn[3],avcn[4],avcn[5])) 2424 2424 for File in Files: 2425 if Files[File][0] :2425 if Files[File][0] and Files[File][0] != 'Select': 2426 2426 if 'Xray' in File and 'F(Q)' in File: 2427 2427 fqdata = open(Files[File][0],'r') … … 2462 2462 return fname 2463 2463 2464 def MakefullrmcRun( Name,Phase,RMCPdict):2465 print(' nothing happened yet')2466 rname = Name+'-run.py'2464 def MakefullrmcRun(pName,Phase,RMCPdict): 2465 rname = pName+'-run.py' 2466 Files = RMCPdict['files'] 2467 2467 rundata = '' 2468 rundata += '#### fullrmc $s file; edit by hand if you so choose #####\n'&rname2468 rundata += '#### fullrmc %s file; edit by hand if you so choose #####\n'%rname 2469 2469 rundata += ''' 2470 # fullrmc imports (all that are potentially useful) 2470 2471 import numpy as np 2471 2472 # fullrmc library imports 2473 from fullrmc.Globals import LOGGER, FLOAT_TYPE 2472 from fullrmc.Globals import LOGGER 2474 2473 from fullrmc.Engine import Engine 2475 2474 from fullrmc.Constraints.PairDistributionConstraints import PairDistributionConstraint 2476 2475 from fullrmc.Constraints.PairCorrelationConstraints import PairCorrelationConstraint 2476 from fullrmc.Constraints.StructureFactorConstraints import StructureFactorConstraint 2477 2477 from fullrmc.Constraints.DistanceConstraints import InterMolecularDistanceConstraint 2478 2478 from fullrmc.Constraints.BondConstraints import BondConstraint 2479 2479 from fullrmc.Constraints.AngleConstraints import BondsAngleConstraint 2480 2480 from fullrmc.Constraints.ImproperAngleConstraints import ImproperAngleConstraint 2481 from fullrmc.Core.Collection import convert_Gr_to_gr2482 2481 from fullrmc.Core.MoveGenerator import MoveGeneratorCollector 2483 2482 from fullrmc.Core.GroupSelector import RecursiveGroupSelector … … 2485 2484 from fullrmc.Selectors.OrderedSelectors import DefinedOrderSelector 2486 2485 from fullrmc.Generators.Translations import TranslationGenerator, TranslationAlongSymmetryAxisGenerator 2487 from fullrmc.Generators.Rotations import RotationGenerator, RotationAboutSymmetryAxisGenerator2488 2486 from fullrmc.Generators.Agitations import DistanceAgitationGenerator, AngleAgitationGenerator 2489 2490 # engine file names - replace name with phase name 2491 engineFileName = "name_engine.rmc" 2492 expFileName = "name_pdf.exp" 2493 pdbFileName = "nme.pdb" 2494 freshStart = False #make TRUE for a restart 2495 2496 ''' 2487 from fullrmc.Generators.Rotations import RotationGenerator, RotationAboutAxisGenerator 2488 from fullrmc.Core.Collection import get_principal_axis 2489 # engine setup\n''' 2490 rundata += 'LOGGER.set_log_file_basename(%s)\n'%pName 2491 rundata += 'engineFileName = "%s.rmc"\n'%pName 2492 rundata += 'ENGINE = Engine(path=None)\n' 2493 rundata += 'if not ENGINE.is_engine(engineFileName):\n' 2494 # create engine 2495 rundata += ' ENGINE = Engine(path=engineFileName)\n' 2496 rundata += ' ENGINE.set_pdb(%s)\n'%RMCPdict['atomPDB'] 2497 ## create experimental constraints 2498 for File in Files: 2499 filDat = RMCPdict['files'][File] 2500 if filDat[0] != 'Select': 2501 sfwt = 'neutrons' 2502 if 'Xray' in File: 2503 sfwt = 'xrays' 2504 if 'G(r)' in File: 2505 rundata += ' GofR = PairDistributionConstraint(experimentalData=%s, weighting="%s"\n'%(filDat[0],sfwt) 2506 rundata += ' GofR.set_variance_squared(%f)\n'%filDat[1] 2507 rundata += ' ENGINE.add_constraints([GofR])\n' 2508 else: 2509 rundata += ' FofQ = StructureFactorConstraint(experimentalData=%s, weighting="%s"\n'%(filDat[0],sfwt) 2510 rundata += ' FofQ.set_variance_squared(%f)\n'%filDat[1] 2511 rundata += ' ENGINE.add_constraints([FofQ])\n' 2512 rundata += ' ENGINE.save()\n' 2513 2514 2515 2516 rundata += 'else:\n' 2517 rundata += ' ENGINE = ENGINE.load(path=engineFileName)\n' 2518 2519 2497 2520 rfile = open(rname,'w') 2498 2521 rfile.writelines(rundata) 2499 2522 rfile.close() 2523 2524 return rname 2500 2525 2501 2526 … … 2515 2540 Cell = newPhase['General']['Cell'][1:7] 2516 2541 A,B = G2lat. cell2AB(Cell) 2517 fname = Name+' .pdb'2542 fname = Name+'_cbb.pdb' 2518 2543 fl = open(fname,'w') 2519 2544 fl.write('REMARK this file is generated using GSASII\n') … … 2529 2554 Natm = np.count_nonzero(Natm-1) 2530 2555 nat = 0 2531 for atm in Atseq: 2556 if RMCPdict['byMolec']: 2557 NPM = RMCPdict['Natoms'] 2532 2558 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())) 2559 XYZ = np.inner(A,np.array(atom[3:6])-XYZptp) #shift origin to middle & make Cartesian 2560 fl.write('ATOM %5d %-4s RMC%6d%12.3f%8.3f%8.3f 1.00 0.00 %-2s\n'%( 2561 1+nat%NPM,atom[0],1+nat//NPM,XYZ[0],XYZ[1],XYZ[2],atom[1].lower())) 2562 nat += 1 2563 else: 2564 for atm in Atseq: 2565 for iat,atom in enumerate(Atoms): 2566 if atom[1] == atm: 2567 XYZ = np.inner(A,np.array(atom[3:6])-XYZptp) #shift origin to middle & make Cartesian 2568 fl.write('ATOM %5d %-4s RMC%6d%12.3f%8.3f%8.3f 1.00 0.00 %-2s\n'%( 2569 1+nat,atom[0],1+nat,XYZ[0],XYZ[1],XYZ[2],atom[1].lower())) 2570 nat += 1 2538 2571 fl.close() 2539 2572 return fname … … 2542 2575 fname = 'make_pdb.py' 2543 2576 outName = RMCPdict['moleculePdb'].split('.') 2544 outName[0] += ' bb'2577 outName[0] += '_rbb' 2545 2578 outName = '.'.join(outName) 2579 RMCPdict['atomPDB'] = outName #might be empty if pdbparser run fails 2546 2580 fl = open(fname,'w') 2547 2581 fl.write('from pdbparser.pdbparser import pdbparser\n')
Note: See TracChangeset
for help on using the changeset viewer.