Changeset 4389
- Timestamp:
- Apr 2, 2020 1:44:42 PM (5 years ago)
- Location:
- trunk
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
TabularUnified trunk/GSASIIdataGUI.py ¶
r4379 r4389 391 391 392 392 ############################################################################### 393 # GUI creation393 #### GUI creation 394 394 ############################################################################### 395 395 def GSASIImain(application): … … 441 441 442 442 ################################################################################ 443 # Create main frame (window) for GUI443 #### Create main frame (window) for GUI 444 444 ################################################################################ 445 445 class GSASII(wx.Frame): … … 599 599 if seqSetting: 600 600 for item in self.Refine: 601 item.Set Text('Se&quential refine\tCtrl+R')601 item.SetItemLabel('Se&quential refine\tCtrl+R') #might fail on old wx 602 602 seqMode = True 603 603 else: 604 604 for item in self.Refine: 605 item.Set Text('&Refine\tCtrl+R')605 item.SetItemLabel('&Refine\tCtrl+R') #might fail on old wx 606 606 seqMode = False 607 607 for menu,Id in self.ExportSeq: … … 5835 5835 5836 5836 #Phase / fullrmc & RMCprofile (Reverse Monte Carlo method) tab 5837 G2G.Define_wxId('wxID_SETUPRMC','wxID_ LOADRMC','wxID_SAVERMC','wxID_RUNRMC','wxID_VIEWRMC' )5837 G2G.Define_wxId('wxID_SETUPRMC','wxID_RUNRMC','wxID_VIEWRMC' ) 5838 5838 self.FRMCMenu = wx.MenuBar() 5839 5839 self.PrefillDataMenu(self.FRMCMenu) … … 5842 5842 self.FRMCMenu.Append(menu=self.FRMCDataEdit, title='Operations') 5843 5843 self.FRMCDataEdit.Append(G2G.wxID_SETUPRMC,'Setup RMC','Setup new fullrmc or RMCprofile file') 5844 self.FRMCDataEdit.Append(G2G.wxID_LOADRMC,'Load','Load fullrmc or RMCprofile file')5845 self.FRMCDataEdit.Append(G2G.wxID_SAVERMC,'Save','Save fullrmc or RMCprofile file')5846 5844 self.FRMCDataEdit.Append(G2G.wxID_RUNRMC,'Execute','Run fullrmc or RMCprofile file') 5847 5845 self.FRMCDataEdit.Append(G2G.wxID_VIEWRMC,'View','View fullrmc or RMCprofile results') -
TabularUnified trunk/GSASIIphsGUI.py ¶
r4378 r4389 1089 1089 parent.Raise() 1090 1090 self.EndModal(wx.ID_CANCEL) 1091 1092 1093 class SetUpFullrmcDialog(wx.Dialog):1094 ''' Get from user the super cell size & selected histogram to make various files1095 '''1096 def __init__(self,parent,Name,Phase):1097 title = 'fullrmc setup'1098 wx.Dialog.__init__(self,parent,wx.ID_ANY,title,1099 pos=wx.DefaultPosition,style=wx.DEFAULT_DIALOG_STYLE|wx.RESIZE_BORDER)1100 self.panel = wxscroll.ScrolledPanel(self) #just a dummy - gets destroyed in Draw!1101 self.Name = Name1102 self.Phase = Phase1103 self.SuperCell = [1,1,1]1104 self.aTypes = self.Phase['General']['AtomTypes']1105 self.atSeq = self.aTypes[:]1106 # self.histogram = ''1107 # self.metadata = {'title':'none','owner':'no one','date':str(time.ctime()),1108 # 'material':'nothing','comment':'none ','source':'nowhere'}1109 self.Draw()1110 1111 def Draw(self):1112 1113 # def OnHisto(event):1114 # self.histogram = histo.GetStringSelection()1115 1116 def OnAtSel(event):1117 Obj = event.GetEventObject()1118 itype = Indx[Obj.GetId()]1119 tid = Obj.GetSelection()1120 if itype < nTypes-1:1121 if itype == tid:1122 tid += 11123 self.atSeq = G2lat.SwapItems(self.atSeq,itype,tid)1124 wx.CallAfter(self.Draw)1125 1126 self.panel.Destroy()1127 self.panel = wxscroll.ScrolledPanel(self,style = wx.DEFAULT_DIALOG_STYLE)1128 mainSizer = wx.BoxSizer(wx.VERTICAL)1129 mainSizer.Add(wx.StaticText(self.panel,label=' Setup for: %s'%self.Name),0,WACV)1130 superSizer = wx.BoxSizer(wx.HORIZONTAL)1131 axes = ['X','Y','Z']1132 for i,ax in enumerate(axes):1133 superSizer.Add(wx.StaticText(self.panel,label=' %s-axis: '%ax),0,WACV)1134 superSizer.Add(G2G.ValidatedTxtCtrl(self.panel,self.SuperCell,i,min=1,max=15,size=(50,25)),0,WACV)1135 mainSizer.Add(superSizer,0,WACV)1136 nTypes = len(self.aTypes)1137 atmChoice = wx.BoxSizer(wx.HORIZONTAL)1138 atmChoice.Add(wx.StaticText(self.panel,label=' Set atom ordering: '),0,WACV)1139 Indx = {}1140 for iType in range(nTypes):1141 atChoice = self.atSeq[iType:]1142 atmSel = wx.ComboBox(self.panel,choices=atChoice,style=wx.CB_DROPDOWN|wx.TE_READONLY)1143 atmSel.SetStringSelection(self.atSeq[iType])1144 atmSel.Bind(wx.EVT_COMBOBOX,OnAtSel)1145 Indx[atmSel.GetId()] = iType1146 atmChoice.Add(atmSel,0,WACV)1147 mainSizer.Add(atmChoice,0,WACV)1148 mainSizer.Add(wx.StaticText(self.panel,label=' WARNING: this can take time - be patient'),0,WACV)1149 btnSizer = wx.BoxSizer(wx.HORIZONTAL)1150 OKBtn = wx.Button(self.panel,-1,"OK")1151 OKBtn.Bind(wx.EVT_BUTTON, self.OnOK)1152 btnSizer.Add(OKBtn)1153 1154 mainSizer.Add(btnSizer,0,wx.EXPAND|wx.BOTTOM|wx.TOP, 10)1155 self.panel.SetSizer(mainSizer)1156 size = np.array(self.GetSize())1157 self.panel.SetupScrolling()1158 self.panel.SetAutoLayout(1)1159 size = [size[0]-5,size[1]-20] #this fiddling is needed for older wx!1160 self.panel.SetSize(size)1161 1162 def GetData(self):1163 'Returns the values from the dialog'1164 return self.SuperCell,self.atSeq1165 1166 def OnOK(self,event):1167 parent = self.GetParent()1168 parent.Raise()1169 self.EndModal(wx.ID_OK)1170 1091 1171 1092 ################################################################################ … … 4604 4525 if G2frame.RMCchoice == 'RMCProfile': 4605 4526 G2frame.dataWindow.FRMCDataEdit.Enable(G2G.wxID_SETUPRMC,True) 4606 G2frame.dataWindow.FRMCDataEdit.Enable(G2G.wxID_LOADRMC,False)4607 G2frame.dataWindow.FRMCDataEdit.Enable(G2G.wxID_SAVERMC,False)4608 4527 G2frame.dataWindow.FRMCDataEdit.Enable(G2G.wxID_RUNRMC,True) 4609 4528 G2frame.dataWindow.FRMCDataEdit.Enable(G2G.wxID_VIEWRMC,True) 4610 4529 elif G2frame.RMCchoice == 'fullrmc': 4611 4530 G2frame.dataWindow.FRMCDataEdit.Enable(G2G.wxID_SETUPRMC,False) 4612 G2frame.dataWindow.FRMCDataEdit.Enable(G2G.wxID_LOADRMC,False)4613 G2frame.dataWindow.FRMCDataEdit.Enable(G2G.wxID_SAVERMC,False)4614 4531 G2frame.dataWindow.FRMCDataEdit.Enable(G2G.wxID_RUNRMC,False) 4615 4532 G2frame.dataWindow.FRMCDataEdit.Enable(G2G.wxID_VIEWRMC,False) 4616 wx.MessageBox(''' fullrmc is not correctly installed for use in GSAS-II4617 Install it in your python according to the instructions in4618 https://bachiraoun.github.io/fullrmc/index.html. ''',4619 caption='fullrmc not installed',style=wx.ICON_INFORMATION)4620 4533 if G2frame.FRMC.GetSizer(): 4621 4534 G2frame.FRMC.GetSizer().Clear(True) … … 4632 4545 from fullrmc import Engine 4633 4546 except ModuleNotFoundError: 4547 wx.MessageBox(''' fullrmc is not correctly installed for use in GSAS-II 4548 Install it in your python according to the instructions in 4549 https://bachiraoun.github.io/fullrmc/index.html. ''', 4550 caption='fullrmc not installed',style=wx.ICON_INFORMATION) 4634 4551 return 4552 mainSizer.Add(wx.StaticText(G2frame.FRMC,label=''' "Fullrmc, a Rigid Body Reverse Monte Carlo Modeling Package Enabled with Machine Learning and Artificial Intelligence", 4553 B. Aoun, Jour. Comp. Chem. 2016, 37, 1102-1111. doi: https://doi.org/10.1002/jcc.24304 4554 ''')) 4635 4555 G2frame.dataWindow.FRMCDataEdit.Enable(G2G.wxID_SETUPRMC,True) 4636 G2frame.dataWindow.FRMCDataEdit.Enable(G2G.wxID_LOADRMC,True)4637 G2frame.dataWindow.FRMCDataEdit.Enable(G2G.wxID_SAVERMC,True)4638 4556 G2frame.dataWindow.FRMCDataEdit.Enable(G2G.wxID_RUNRMC,True) 4639 4557 G2frame.dataWindow.FRMCDataEdit.Enable(G2G.wxID_VIEWRMC,True) 4640 4558 mainSizer.Add(wx.StaticText(G2frame.FRMC,label=' fullrmc run.py file preparation:'),0,WACV) 4641 # font1 = wx.Font(12, wx.MODERN, wx.NORMAL, wx.NORMAL, False, u'Consolas')4642 G2frame.runtext = wx.TextCtrl(G2frame.FRMC,style=wx.TE_MULTILINE|wx.TE_DONTWRAP,size=(850,450))4643 # G2frame.runtext.SetFont(font1)4644 mainSizer.Add(G2frame.runtext)4645 4559 elif G2frame.RMCchoice == 'RMCProfile': 4560 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, 4561 Jour. Phys.: Cond. Matter 2007, 19, 335218. doi: https://doi.org/10.1088/0953-8984/19/33/335218 4562 ''')) 4646 4563 mainSizer.Add(wx.StaticText(G2frame.FRMC,label=' RMCProfile setup:')) 4647 4564 if not data['RMC']['RMCProfile']: … … 5203 5120 generalData = data['General'] 5204 5121 pName = generalData['Name'].replace(' ','_') 5122 if not G2frame.GSASprojectfile: #force a project save 5123 G2frame.OnFileSaveas(event) 5205 5124 if G2frame.RMCchoice == 'fullrmc': 5206 dlg = SetUpFullrmcDialog(G2frame,Name=pName,Phase=data) 5207 if dlg.ShowModal() == wx.ID_OK: 5208 superCell,atSeq = dlg.GetData() 5209 # Progress 5210 print(G2pwd.MakePDB(G2frame,pName,data,atSeq,superCell)+ ' written') 5211 print('fullrmc file build completed') 5212 else: 5213 pass 5214 dlg.Destroy() 5215 rundata = ''' 5216 ########################################################################################## 5217 ############################## IMPORTING USEFUL DEFINITIONS ############################ 5218 # standard libraries imports 5219 import os 5220 5221 # external libraries imports 5222 import numpy as np 5223 5224 # fullrmc library imports - these are some examples; others may be needed for your problem 5225 from fullrmc.Globals import LOGGER, FLOAT_TYPE 5226 from fullrmc.Engine import Engine 5227 from fullrmc.Constraints.PairDistributionConstraints import PairDistributionConstraint 5228 from fullrmc.Constraints.PairCorrelationConstraints import PairCorrelationConstraint 5229 from fullrmc.Constraints.DistanceConstraints import InterMolecularDistanceConstraint 5230 from fullrmc.Constraints.BondConstraints import BondConstraint 5231 from fullrmc.Constraints.AngleConstraints import BondsAngleConstraint 5232 from fullrmc.Constraints.ImproperAngleConstraints import ImproperAngleConstraint 5233 from fullrmc.Core.Collection import convert_Gr_to_gr 5234 from fullrmc.Core.MoveGenerator import MoveGeneratorCollector 5235 from fullrmc.Core.GroupSelector import RecursiveGroupSelector 5236 from fullrmc.Selectors.RandomSelectors import RandomSelector 5237 from fullrmc.Selectors.OrderedSelectors import DefinedOrderSelector 5238 from fullrmc.Generators.Translations import TranslationGenerator, TranslationAlongSymmetryAxisGenerator 5239 from fullrmc.Generators.Rotations import RotationGenerator, RotationAboutSymmetryAxisGenerator 5240 from fullrmc.Generators.Agitations import DistanceAgitationGenerator, AngleAgitationGenerator 5241 5242 5243 ########################################################################################## 5244 ##################################### CREATE ENGINE #################################### 5245 # dirname 5246 DIR_PATH = os.path.dirname( os.path.realpath(__file__) ) 5247 5248 # engine file names - replace name with phase name 5249 engineFileName = "name_engine.rmc" 5250 expFileName = "name_pdf.exp" 5251 pdbFileName = "nme.pdb" 5252 freshStart = False #make TRUE for a restart 5253 5254 ''' 5255 G2frame.runtext.SetValue(rundata) 5125 print ('TBD') 5126 return 5127 print('set up rmcfull *.pdb & *.py files TBD') 5128 G2frame.dataWindow.FRMCDataEdit.Enable(G2G.wxID_RUNRMC,True) 5129 RMCPdict = data['RMC']['fullrmc'] 5130 print(G2pwd.MakePDB(pName,data,RMCPdict)+ ' written') 5131 print(G2pwd.MakefullrmcRun(pName,data,RMCPdict)+ ' written') 5132 print('fullrmc file build completed') 5256 5133 else: 5257 5134 G2frame.dataWindow.FRMCDataEdit.Enable(G2G.wxID_RUNRMC,True) … … 5259 5136 PWId = G2gd.GetGPXtreeItemId(G2frame,G2frame.root,RMCPdict['histogram'][0]) 5260 5137 if PWId: 5138 PWDdata = G2frame.GetPWDRdatafromTree(PWId) 5139 histoName = G2frame.GPXtree.GetItemPyData(PWId)[2] 5140 Size = data['Histograms'][histoName]['Size'] 5141 Mustrain = data['Histograms'][histoName]['Mustrain'] 5261 5142 reset = False 5262 print(G2pwd.MakeInst( G2frame,pName,data,RMCPdict['UseSampBrd'],PWId)+ ' written')5263 backfile = G2pwd.MakeBack( G2frame,pName,PWId)5143 print(G2pwd.MakeInst(PWDdata,pName,Size,Mustrain,RMCPdict['UseSampBrd'])+ ' written') 5144 backfile = G2pwd.MakeBack(PWDdata,pName) 5264 5145 if backfile is None: 5265 5146 print(' Chebyschev-1 background not used; no .back file written') … … 5270 5151 else: 5271 5152 print(backfile+ ' written') 5272 print(G2pwd.MakeBragg( G2frame,pName,data,PWId)+ ' written')5153 print(G2pwd.MakeBragg(PWDdata,pName,data)+ ' written') 5273 5154 if RMCPdict['ReStart'][0]: 5274 5155 if os.path.isfile(pName+'.his6f'): 5275 5156 os.remove(pName+'.his6f') 5276 RMC6f,reset = G2pwd.MakeRMC6f( G2frame,pName,data,RMCPdict,PWId)5157 RMC6f,reset = G2pwd.MakeRMC6f(PWDdata,pName,data,RMCPdict) 5277 5158 print(RMC6f+ ' written') 5278 print(G2pwd.MakeRMCPdat( G2frame,pName,data,RMCPdict,PWId)+ ' written')5159 print(G2pwd.MakeRMCPdat(PWDdata,pName,data,RMCPdict)+ ' written') 5279 5160 print('RMCProfile file build completed') 5280 5161 RMCPdict['ReStart'] = [False,False] … … 5287 5168 G2frame.dataWindow.FRMCDataEdit.Enable(G2G.wxID_RUNRMC,False) 5288 5169 5289 def OnLoadRMC(event):5290 global runFile5291 if G2frame.RMCchoice == 'fullrmc':5292 dlg = wx.FileDialog(G2frame, 'Choose fullrmc run file to open', G2G.GetImportPath(G2frame), runFile,5293 wildcard='fullrmc run.py file (*.py)|*.py',style=wx.FD_OPEN| wx.FD_CHANGE_DIR)5294 try:5295 if dlg.ShowModal() == wx.ID_OK:5296 runFile = dlg.GetPath()5297 runpy = open(runFile,'r')5298 G2frame.runtext.SetValue(runpy.read())5299 runpy.close()5300 else:5301 return5302 finally:5303 dlg.Destroy()5304 5305 def OnSaveRMC(event):5306 global runFile5307 if G2frame.RMCchoice == 'fullrmc':5308 dlg = wx.FileDialog(G2frame, 'Choose fullrmc run.py file to save', G2G.GetImportPath(G2frame), runFile,5309 wildcard='fullrmc run.py file (*.py)|*.py',style=wx.FD_SAVE|wx.FD_OVERWRITE_PROMPT)5310 try:5311 if dlg.ShowModal() == wx.ID_OK:5312 runFile = dlg.GetPath()5313 runpy = open(runFile,'w')5314 runpy.write(G2frame.runtext.GetValue())5315 runpy.close()5316 else:5317 return5318 finally:5319 dlg.Destroy()5320 5321 5170 def OnRunRMC(event): 5322 5171 … … 5329 5178 B. Aoun, Jour. Comp. Chem. 2016, 37, 1102-1111. 5330 5179 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 5331 5181 dlg = wx.FileDialog(G2frame, 'Choose fullrmc python file to execute', G2G.GetImportPath(G2frame), 5332 5182 wildcard='fullrmc python file (*.py)|*.py',style=wx.FD_CHANGE_DIR) … … 5336 5186 batch = open('fullrmc.bat','w') 5337 5187 batch.write('run '+sys.exec_prefix+'\\Scripts\\activate\n') 5338 batch.write('SET PYTHONPATH=%s\\fullrmc\n'%GSASIIpath.path2GSAS2)5339 5188 batch.write(sys.exec_prefix+'\\python.exe '+dlg.GetPath()+'\n') 5340 5189 batch.write('pause') … … 5401 5250 def OnViewRMC(event): 5402 5251 if G2frame.RMCchoice == 'fullrmc': 5252 generalData = data['General'] 5253 pName = generalData['Name'].replace(' ','_') 5254 from fullrmc import Engine 5255 # load 5256 engineFilePath = pName+'.rmc' 5257 ENGINE = Engine(path=None) 5403 5258 try: 5404 from fullrmc import Engine 5405 except ModuleNotFoundError: 5406 wx.MessageBox(''' fullrmc is not correctly installed for use in GSAS-II 5407 Install it in your python according to the instructions in 5408 https://bachiraoun.github.io/fullrmc/index.html. ''', 5409 caption='fullrmc not installed',style=wx.ICON_INFORMATION) 5410 return 5411 DIR_PATH = os.path.dirname( os.path.realpath(__file__) ) 5412 engineFilePath = os.path.join(DIR_PATH, "engine.rmc") 5413 5414 # load 5415 ENGINE = Engine(path=None) 5416 result, mes = ENGINE.is_engine(engineFilePath, mes=True) 5417 if result: 5418 ENGINE = ENGINE.load(engineFilePath) 5419 GR, SQ, CN, MD = ENGINE.constraints 5259 if engineFilePath is not None: 5260 result, mes = ENGINE.is_engine(engineFilePath, mes=True) 5261 if result: 5262 ENGINE = ENGINE.load(engineFilePath) 5263 found = False 5264 for frame in list(ENGINE.frames): 5265 ENGINE.set_used_frame(frame) 5266 FRitems = ENGINE.constraints 5267 for item in FRitems: 5268 sitem = str(type(item)) 5269 if 'PairDistribution' in sitem or 'StructureFactor' in sitem or 'PairCorrelation' in sitem: 5270 found = True 5271 Xlab = r'$\mathsf{r,\AA}$' 5272 Ylab = r'$\mathsf{g(r),\AA^{-2}}$' 5273 title = ' g(r) for ' 5274 if 'StructureFactor' in sitem: 5275 Xlab = r'$\mathsf{Q,\AA^{-1}}$' 5276 Ylab = 'S(Q)' 5277 title = ' S(Q) for ' 5278 if frame != '0': 5279 title = frame+title 5280 dataDict= item.get_constraints_properties(frame) 5281 X = dataDict['frames-experimental_x'][0] 5282 Y = dataDict['frames-experimental_y'][0] 5283 rdfDict = item.get_constraint_value() 5284 Z = rdfDict['total'] 5285 XY = [[X,Y],[X,Z]] 5286 Names = ['Obs','Calc'] 5287 G2plt.PlotXY(G2frame,XY,labelX=Xlab, 5288 labelY=Ylab,newPlot=True,Title=title+pName, 5289 lines=True,names=Names) 5290 PXY = [] 5291 PXYT = [] 5292 Names = [] 5293 NamesT = [] 5294 for item in rdfDict: 5295 PXYT.append([X,rdfDict[item]]) 5296 NamesT.append(item) 5297 if 'total' in item: 5298 PXY.append([X,rdfDict[item]]) 5299 Names.append(item) 5300 G2plt.PlotXY(G2frame,PXYT,labelX=Xlab, 5301 labelY=Ylab,newPlot=True,Title=' All partials of '+title+pName, 5302 lines=True,names=NamesT) 5303 G2plt.PlotXY(G2frame,PXY,labelX=Xlab, 5304 labelY=Ylab,newPlot=True,Title=' Total partials of '+title+pName, 5305 lines=True,names=Names) 5306 5307 else: 5308 found = True 5309 if 'BondConstraint' in sitem: 5310 bonds = item.get_constraint_value()['bondsLength'] 5311 bondList = item.bondsList[:2] 5312 atoms = ENGINE.get_original_data("allElements",frame) 5313 bondNames = ['%s-%s'%(atoms[bondList[0][iat]],atoms[bondList[1][iat]]) for iat in range(bonds.shape[0])] 5314 bondSet = list(set(bondNames)) 5315 Bonds = list(zip(bondNames,bonds)) 5316 for Bname in bondSet: 5317 bondLens = [bond[1] for bond in Bonds if bond[0]==Bname] 5318 G2plt.PlotBarGraph(G2frame,bondLens,Xname=r'%s $Bond,\ \AA$'%Bname,Title='%s Bond lengths for %s'%(Bname,pName), 5319 PlotName='%s Bonds for %s'%(Bname,pName),maxBins=20) 5320 elif 'BondsAngleConstraint' in sitem: 5321 angles = 180.*item.get_constraint_value()['angles']/np.pi 5322 angleList = item.anglesList[:3] 5323 atoms = ENGINE.get_original_data("allElements",frame) 5324 angleNames = ['%s-%s-%s'%(atoms[angleList[1][iat]],atoms[angleList[0][iat]],atoms[angleList[2][iat]]) for iat in range(angles.shape[0])] 5325 angleSet = list(set(angleNames)) 5326 Angles = list(zip(angleNames,angles)) 5327 for Aname in angleSet: 5328 bondAngs = [angle[1] for angle in Angles if angle[0]==Aname] 5329 G2plt.PlotBarGraph(G2frame,bondAngs,Xname=r'%s Angle, deg'%Aname,Title='%s Bond angles for %s'%(Aname,pName), 5330 PlotName='%s Angles for %s'%(Aname,pName),maxBins=20) 5331 elif 'ImproperAngleConstraint' in sitem: 5332 impangles = 180.*item.get_constraint_value()['angles']/np.pi 5333 impangleList = item.anglesList[:4] 5334 atoms = ENGINE.get_original_data("allElements",frame) 5335 impangleNames = ['%s-%s-%s-%s'%(atoms[impangleList[0][iat]],atoms[impangleList[1][iat]], 5336 atoms[impangleList[2][iat]],atoms[impangleList[3][iat]]) for iat in range(impangles.shape[0])] 5337 impangleSet = list(set(impangleNames)) 5338 impAngles = list(zip(impangleNames,impangles)) 5339 for Aname in impangleSet: 5340 impAngs = [angle[1] for angle in impAngles if angle[0]==Aname] 5341 G2plt.PlotBarGraph(G2frame,impAngs,Xname=r'%s $Improper Angle, deg$'%Aname,Title='%s Improper angles for %s'%(Aname,pName), 5342 PlotName='%s Improper Angles for %s'%(Aname,pName),maxBins=20) 5343 elif 'AtomicCoordinationNumber' in sitem or 'InterMolecular' in sitem: 5344 print(sitem+' not plotted') 5345 else: 5346 print(sitem) 5347 item.plot(show=True) 5348 pass 5349 if not found: 5350 print(' No saved information yet, wait until fullrms does a Save') 5351 except AssertionError: 5352 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() 5359 start = 0 5360 while True: 5361 line = loglines[start] 5362 if 'Err:' in line: 5363 break 5364 else: 5365 start += 1 5366 Gen = [] 5367 Tr = [] 5368 Acc = [] 5369 Rem = [] 5370 Err = [] 5371 start -= 1 5372 while True: 5373 start += 1 5374 try: 5375 line = loglines[start] 5376 except: 5377 break 5378 if 'Err' not in line: 5379 continue 5380 items = line.split(' - ') 5381 try: # could be a trashed line at end 5382 Err.append(float(items[5][:-1].split('Err:')[1])) 5383 except ValueError: 5384 break 5385 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 5390 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) 5400 5420 5401 else: 5421 5402 generalData = data['General'] … … 11254 11235 FillSelectPageMenu(TabSelectionIdDict, G2frame.dataWindow.FRMCMenu) 11255 11236 G2frame.Bind(wx.EVT_MENU, OnSetupRMC, id=G2G.wxID_SETUPRMC) 11256 G2frame.Bind(wx.EVT_MENU, OnLoadRMC, id=G2G.wxID_LOADRMC)11257 G2frame.Bind(wx.EVT_MENU, OnSaveRMC, id=G2G.wxID_SAVERMC)11258 11237 G2frame.Bind(wx.EVT_MENU, OnRunRMC, id=G2G.wxID_RUNRMC) 11259 11238 G2frame.Bind(wx.EVT_MENU, OnViewRMC, id=G2G.wxID_VIEWRMC) -
TabularUnified trunk/GSASIIplot.py ¶
r4380 r4389 5384 5384 ################################################################################ 5385 5385 5386 def PlotBarGraph(G2frame,Xarray,Xname='',Yname='Number',Title='',PlotName=None,ifBinned=False ):5386 def PlotBarGraph(G2frame,Xarray,Xname='',Yname='Number',Title='',PlotName=None,ifBinned=False,maxBins=None): 5387 5387 'Needs a description' 5388 5388 … … 5415 5415 else: 5416 5416 nBins= max(10,len(Xarray)//10) 5417 if maxBins is not None: 5418 nBins = min(nBins,maxBins) 5417 5419 Bins,Dbins = np.histogram(Xarray,nBins) 5418 5420 wid = Dbins[1]-Dbins[0] … … 8333 8335 if key in ['+','-','=','0']: 8334 8336 if generalData['Modulated']: 8337 tstep = 1./36 #0.05 8335 8338 if key == '0': 8336 8339 G2frame.tau = 0. 8337 8340 elif key in ['+','=']: 8338 G2frame.tau += 0.058341 G2frame.tau += tstep 8339 8342 elif key == '-': 8340 G2frame.tau -= 0.058343 G2frame.tau -= tstep 8341 8344 G2frame.tau %= 1. #force 0-1 range; makes loop 8342 8345 G2frame.G2plotNB.status.SetStatusText('Modulation tau = %.4f'%(G2frame.tau),1) -
TabularUnified trunk/GSASIIpwd.py ¶
r4366 r4389 2107 2107 ################################################################################ 2108 2108 2109 def MakeInst(G2frame,Name,Phase,useSamBrd,PWId): 2110 PWDdata = G2frame.GetPWDRdatafromTree(PWId) 2111 histoName = G2frame.GPXtree.GetItemPyData(PWId)[2] 2112 Size = Phase['Histograms'][histoName]['Size'] 2113 Mustrain = Phase['Histograms'][histoName]['Mustrain'] 2109 def MakeInst(PWDdata,Name,Size,Mustrain,useSamBrd): 2114 2110 inst = PWDdata['Instrument Parameters'][0] 2115 2111 Xsb = 0. … … 2160 2156 return fname 2161 2157 2162 def MakeBack(G2frame,Name,PWId): 2163 PWDdata = G2frame.GetPWDRdatafromTree(PWId) 2158 def MakeBack(PWDdata,Name): 2164 2159 Back = PWDdata['Background'][0] 2165 2160 inst = PWDdata['Instrument Parameters'][0] … … 2179 2174 return fname 2180 2175 2181 def MakeRMC6f( G2frame,Name,Phase,RMCPdict,PWId):2176 def MakeRMC6f(PWDdata,Name,Phase,RMCPdict): 2182 2177 2183 2178 def findDup(Atoms): … … 2199 2194 Atseq = RMCPdict['atSeq'] 2200 2195 Supercell = RMCPdict['SuperCell'] 2201 PWDdata = G2frame.GetPWDRdatafromTree(PWId)2202 2196 generalData = Phase['General'] 2203 2197 Dups,Fracs = findDup(Phase['Atoms']) … … 2279 2273 return fname,reset 2280 2274 2281 def MakeBragg(G2frame,Name,Phase,PWId): 2282 PWDdata = G2frame.GetPWDRdatafromTree(PWId) 2275 def MakeBragg(PWDdata,Name,Phase): 2283 2276 generalData = Phase['General'] 2284 2277 Vol = generalData['Cell'][7] … … 2307 2300 return fname 2308 2301 2309 def MakeRMCPdat( G2frame,Name,Phase,RMCPdict,PWId):2302 def MakeRMCPdat(PWDdata,Name,Phase,RMCPdict): 2310 2303 Meta = RMCPdict['metadata'] 2311 2304 Times = RMCPdict['runTimes'] … … 2315 2308 Files = RMCPdict['files'] 2316 2309 BraggWt = RMCPdict['histogram'][1] 2317 PWDdata = G2frame.GetPWDRdatafromTree(PWId)2318 2310 inst = PWDdata['Instrument Parameters'][0] 2319 2311 refList = PWDdata['Reflection Lists'][Name]['RefList'] … … 2468 2460 fl.write('END ::\n') 2469 2461 fl.close() 2470 return fname2471 2472 def MakePDB(G2frame,Name,Phase,Atseq,Supercell):2473 generalData = Phase['General']2474 Cell = generalData['Cell'][1:7]2475 Trans = np.eye(3)*np.array(Supercell)2476 newPhase = copy.deepcopy(Phase)2477 newPhase['General']['SGData'] = G2spc.SpcGroup('P 1')[1]2478 newPhase['General']['Cell'][1:] = G2lat.TransformCell(Cell,Trans.T)2479 newPhase,Atcodes = G2lat.TransformPhase(Phase,newPhase,Trans,np.zeros(3),np.zeros(3),ifMag=False)2480 Atoms = newPhase['Atoms']2481 Cell = newPhase['General']['Cell'][1:7]2482 A,B = G2lat. cell2AB(Cell)2483 fname = Name+'.pdb'2484 fl = open(fname,'w')2485 fl.write('REMARK this file is generated using GSASII\n')2486 fl.write('CRYST1%9.3f%9.3f%9.3f%7.2f%7.2f%7.2f P 1 1\n'%(2487 Cell[0],Cell[1],Cell[2],Cell[3],Cell[4],Cell[5]))2488 fl.write('ORIGX1 1.000000 0.000000 0.000000 0.00000\n')2489 fl.write('ORIGX2 0.000000 1.000000 0.000000 0.00000\n')2490 fl.write('ORIGX3 0.000000 0.000000 1.000000 0.00000\n')2491 2492 Natm = np.core.defchararray.count(np.array(Atcodes),'+')2493 Natm = np.count_nonzero(Natm-1)2494 nat = 02495 for atm in Atseq:2496 for iat,atom in enumerate(Atoms):2497 if atom[1] == atm:2498 nat += 12499 XYZ = np.inner(A,np.array(atom[3:6])-0.5) #shift origin to middle & make Cartesian2500 #ATOM 1 Ni RMC 1 -22.113 -22.113 -22.113 1.00 0.00 ni2501 fl.write('ATOM %5d %-4s RMC%6d%12.3f%8.3f%8.3f 1.00 0.00 %-2s\n'%(2502 nat,atom[0],nat,XYZ[0],XYZ[1],XYZ[2],atom[1]))2503 fl.close()2504 2462 return fname 2463 2464 def MakefullrmcRun(Name,Phase,RMCPdict): 2465 print(' nothing happened yet') 2466 rname = Name+'-run.py' 2467 rundata = '' 2468 rundata += '#### fullrmc $s file; edit by hand if you so choose #####\n'&rname 2469 rundata += ''' 2470 import numpy as np 2471 2472 # fullrmc library imports 2473 from fullrmc.Globals import LOGGER, FLOAT_TYPE 2474 from fullrmc.Engine import Engine 2475 from fullrmc.Constraints.PairDistributionConstraints import PairDistributionConstraint 2476 from fullrmc.Constraints.PairCorrelationConstraints import PairCorrelationConstraint 2477 from fullrmc.Constraints.DistanceConstraints import InterMolecularDistanceConstraint 2478 from fullrmc.Constraints.BondConstraints import BondConstraint 2479 from fullrmc.Constraints.AngleConstraints import BondsAngleConstraint 2480 from fullrmc.Constraints.ImproperAngleConstraints import ImproperAngleConstraint 2481 from fullrmc.Core.Collection import convert_Gr_to_gr 2482 from fullrmc.Core.MoveGenerator import MoveGeneratorCollector 2483 from fullrmc.Core.GroupSelector import RecursiveGroupSelector 2484 from fullrmc.Selectors.RandomSelectors import RandomSelector 2485 from fullrmc.Selectors.OrderedSelectors import DefinedOrderSelector 2486 from fullrmc.Generators.Translations import TranslationGenerator, TranslationAlongSymmetryAxisGenerator 2487 from fullrmc.Generators.Rotations import RotationGenerator, RotationAboutSymmetryAxisGenerator 2488 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 ''' 2497 rfile = open(rname,'w') 2498 rfile.writelines(rundata) 2499 rfile.close() 2500 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 2505 2535 2506 2536 def GetRMCBonds(general,RMCPdict,Atoms,bondList):
Note: See TracChangeset
for help on using the changeset viewer.