Changeset 4404


Ignore:
Timestamp:
Apr 19, 2020 11:52:51 AM (3 years ago)
Author:
vondreele
Message:

revise RMCProfile/fullrmc GUI for data files - better interface & has Plot button
continue development of MakefullrmcRun?

Location:
trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/GSASIIphsGUI.py

    r4401 r4404  
    44114411                atmChoice.Add(G2G.ValidatedTxtCtrl(G2frame.FRMC,RMCPdict['aTypes'],atId,min=0.,max=1.),0,WACV)
    44124412            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           
    44154508        G2frame.GetStatusBar().SetStatusText('',1)
    44164509        if G2frame.RMCchoice == 'RMCProfile':
     
    44474540            G2frame.dataWindow.FRMCDataEdit.Enable(G2G.wxID_RUNRMC,True)
    44484541            G2frame.dataWindow.FRMCDataEdit.Enable(G2G.wxID_VIEWRMC,True)
    4449             mainSizer.Add(wx.StaticText(G2frame.FRMC,label=' fullrmc run.py file preparation:'),0,WACV)
     4542            mainSizer.Add(wx.StaticText(G2frame.FRMC,label=' fullrmc big box starting pdb file preparation:'),0,WACV)
    44504543            if not data['RMC']['fullrmc']:
    44514544                Atypes = data['General']['AtomTypes']
     
    44574550                    Pairs += pair
    44584551                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':''}
    44674562            RMCPdict = data['RMC']['fullrmc']
    44684563
     
    44854580                return boxSizer
    44864581           
    4487             def OnBoxChoice(event):
    4488                 RMCPdict['ifBox'] = not RMCPdict['ifBox']
    4489                 UpdateRMC()
    4490                
     4582            def OnByMolec(event):
     4583                RMCPdict['byMolec'] = bymolec.GetValue()
     4584                           
    44914585            def OnReStart(event):
    44924586                RMCPdict['ReStart'][0] = not RMCPdict['ReStart'][0]
     
    45014595                   
    45024596            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
    45034608                dlg = wx.MessageDialog(G2frame,'''
    45044609Warning - this step can take more than an hour; do you want to proceed?
     
    45274632            if 'moleculePdb' not in RMCPdict:
    45284633                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'] = ''
    45294642#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
    45354648            lineSizer = wx.BoxSizer(wx.HORIZONTAL)
    4536             if RMCPdict['ifBox']:
     4649            if ifBox:
    45374650                lineSizer.Add(wx.StaticText(G2frame.FRMC,label=' Big box dimensions, %s:'%Angstr),0,WACV)               
    45384651                lineSizer.Add(GetBoxSizer(),0,WACV)
    4539                 boxBtn = wx.Button(G2frame.FRMC,label='Use super lattice')
    45404652            else:
    45414653                lineSizer.Add(wx.StaticText(G2frame.FRMC,label=' Lattice multipliers:'),0,WACV)
    45424654                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)
    45464661            mainSizer.Add(lineSizer,0,WACV)
    4547             if RMCPdict['ifBox']:
     4662            if ifBox:
    45484663                molecSizer = wx.BoxSizer(wx.HORIZONTAL)
    45494664                molecSizer.Add(wx.StaticText(G2frame.FRMC,label=' Source molecule file '),0,WACV)
     
    45594674                molecSizer.Add(makePDB,0,WACV)               
    45604675                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               
    45614681            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)
    45634689            mainSizer.Add(GetAtmChoice(RMCPdict),0,WACV)
    45644690           
    4565            
     4691            G2G.HorizontalLine(mainSizer,G2frame.FRMC)
     4692            mainSizer.Add(FileSizer(RMCPdict),0,WACV)
    45664693               
    45674694        elif G2frame.RMCchoice ==  'RMCProfile':
     
    45854712                        BVSpairs += pair
    45864713                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',],}
    45924719                runTimes = [10.,1.]
    45934720                metadata = {'title':'none','owner':'no one','date':str(time.ctime()),'temperature':'300K',
    45944721                    'material':'nothing','phase':'vacuum','comment':'none ','source':'nowhere'}
    45954722                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,
    45974724                    'runTimes':runTimes,'ReStart':[False,False],'BVS':BVS,'Oxid':atOxid,'useBVS':False,'Swaps':[],
    45984725                    'AveCN':[],'FxCN':[],'Potentials':{'Angles':[],'Angle search':10.,'Stretch':[],
     
    46154742            def OnStrain(event):
    46164743                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] = fName
    4629                     G2frame.LastImportDir = fpath    #set so next file is found in same place
    4630                     dlg.Destroy()
    4631                 else:
    4632                     dlg.Destroy()
    4633                     return
    4634                 wx.CallAfter(UpdateRMC)
    4635        
    4636             def OnFileFormat(event):
    4637                 Obj = event.GetEventObject()
    4638                 fil = Indx[Obj.GetId()]
    4639                 RMCPdict['files'][fil][3] = Obj.GetStringSelection()
    46404744               
    46414745            def SetRestart(invalid,value,tc):
     
    49225026                return swapSizer
    49235027           
    4924             def OnFitScale(event):
    4925                 RMCPdict['FitScale'] = not RMCPdict['FitScale']
    4926            
    49275028            Indx = {}
    49285029
     
    50315132            samSizer.Add(strain,0,WACV)
    50325133            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)
    50665136   
    50675137        SetPhaseWindow(G2frame.FRMC,mainSizer)
     
    50755145            G2frame.dataWindow.FRMCDataEdit.Enable(G2G.wxID_RUNRMC,True)
    50765146            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)
    50825149        else:
    50835150            G2frame.dataWindow.FRMCDataEdit.Enable(G2G.wxID_RUNRMC,True)
     
    51295196      doi: https://doi.org/10.1002/jcc.24304''',caption='fullrmc',style=wx.ICON_INFORMATION)
    51305197            rmcname = pName+'.rmc'           
    5131             while os.path.isdir(rmcname) and RMCPdict['ReStart']:
     5198            while os.path.isdir(rmcname) and RMCPdict['ReStart'][0]:
    51325199                msg = wx.MessageBox(''' fullrmc will fail to restart if %s exists. You must delete %s by hand now.'''%(rmcname,rmcname),
    51335200                    caption='fullrmc file error',style=wx.ICON_EXCLAMATION|wx.OK|wx.CANCEL)
     
    51365203            ilog = 0
    51375204            while True:
    5138                 logname = 'fullrmc_%d.log'%ilog
     5205                logname = '%s_%d.log'%(pName,ilog)
    51395206                if os.path.isfile(logname):
    51405207                    os.remove(logname)
     
    51435210                ilog += 1
    51445211# TBD - remove filedialog & use defined run.py file name here
     5212            rname = pName+'-run.py'
    51455213            dlg = wx.FileDialog(G2frame, 'Choose fullrmc python file to execute', G2G.GetImportPath(G2frame),
    51465214                wildcard='fullrmc python file (*.py)|*.py',style=wx.FD_CHANGE_DIR)
    51475215            try:
    51485216                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()
    51565218                else:
    51575219                    return
    51585220            finally:
    51595221                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
    51605229        else:
    51615230            RMCPdict = data['RMC']['RMCProfile']
     
    53485417            ilog = 0
    53495418            while True:
    5350                 fname = 'fullrmc_%d.log'%ilog
     5419                fname = '%s_%d.log'%(pName,ilog)
    53515420                try:
    53525421                    logfile = open(fname,'r')
  • trunk/GSASIIplot.py

    r4403 r4404  
    52535253    if np.any(X) and np.any(Y) and np.any(Z):
    52545254        np.seterr(all='ignore')
    5255         try:
     5255        if True:
     5256#        try:
    52565257            Plot.plot_surface(X,Y,Z,rstride=1,cstride=1,color='g',linewidth=1)
    52575258            xyzlim = np.array([Plot.get_xlim3d(),Plot.get_ylim3d(),Plot.get_zlim3d()]).T
     
    52655266            Plot.set_zlabel(labelZ)
    52665267            Plot.set_aspect('equal')
    5267         except:
    5268             print('Plot3dXYZ failure')
    5269             pass
     5268        # except:
     5269        #     print('Plot3dXYZ failure')
     5270        #     pass
    52705271        Page.canvas.draw()
    52715272       
  • trunk/GSASIIpwd.py

    r4400 r4404  
    21062106#### RMCutilities
    21072107################################################################################
    2108     
     2108   
    21092109def MakeInst(PWDdata,Name,Size,Mustrain,useSamBrd):
    21102110    inst = PWDdata['Instrument Parameters'][0]
     
    24232423            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]))
    24242424    for File in Files:
    2425         if Files[File][0]:
     2425        if Files[File][0] and Files[File][0] != 'Select':
    24262426            if 'Xray' in File and 'F(Q)' in File:
    24272427                fqdata = open(Files[File][0],'r')
     
    24622462    return fname
    24632463
    2464 def MakefullrmcRun(Name,Phase,RMCPdict):
    2465     print(' nothing happened yet')
    2466     rname = Name+'-run.py'
     2464def MakefullrmcRun(pName,Phase,RMCPdict):
     2465    rname = pName+'-run.py'
     2466    Files = RMCPdict['files']
    24672467    rundata = ''
    2468     rundata += '#### fullrmc $s file; edit by hand if you so choose #####\n'&rname
     2468    rundata += '#### fullrmc %s file; edit by hand if you so choose #####\n'%rname
    24692469    rundata += '''
     2470# fullrmc imports (all that are potentially useful)
    24702471import numpy as np
    2471 
    2472 # fullrmc library imports
    2473 from fullrmc.Globals import LOGGER, FLOAT_TYPE
     2472from fullrmc.Globals import LOGGER
    24742473from fullrmc.Engine import Engine
    24752474from fullrmc.Constraints.PairDistributionConstraints import PairDistributionConstraint
    24762475from fullrmc.Constraints.PairCorrelationConstraints import PairCorrelationConstraint
     2476from fullrmc.Constraints.StructureFactorConstraints import StructureFactorConstraint
    24772477from fullrmc.Constraints.DistanceConstraints import InterMolecularDistanceConstraint
    24782478from fullrmc.Constraints.BondConstraints import BondConstraint
    24792479from fullrmc.Constraints.AngleConstraints import BondsAngleConstraint
    24802480from fullrmc.Constraints.ImproperAngleConstraints import ImproperAngleConstraint
    2481 from fullrmc.Core.Collection import convert_Gr_to_gr
    24822481from fullrmc.Core.MoveGenerator import MoveGeneratorCollector
    24832482from fullrmc.Core.GroupSelector import RecursiveGroupSelector
     
    24852484from fullrmc.Selectors.OrderedSelectors import DefinedOrderSelector
    24862485from fullrmc.Generators.Translations import TranslationGenerator, TranslationAlongSymmetryAxisGenerator
    2487 from fullrmc.Generators.Rotations import RotationGenerator, RotationAboutSymmetryAxisGenerator
    24882486from 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             '''
     2487from fullrmc.Generators.Rotations import RotationGenerator, RotationAboutAxisGenerator
     2488from 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
    24972520    rfile = open(rname,'w')
    24982521    rfile.writelines(rundata)
    24992522    rfile.close()
     2523   
     2524    return rname
    25002525   
    25012526
     
    25152540    Cell = newPhase['General']['Cell'][1:7]
    25162541    A,B = G2lat. cell2AB(Cell)
    2517     fname = Name+'.pdb'
     2542    fname = Name+'_cbb.pdb'
    25182543    fl = open(fname,'w')
    25192544    fl.write('REMARK    this file is generated using GSASII\n')
     
    25292554    Natm = np.count_nonzero(Natm-1)
    25302555    nat = 0
    2531     for atm in Atseq:
     2556    if RMCPdict['byMolec']:
     2557        NPM = RMCPdict['Natoms']
    25322558        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
    25382571    fl.close()
    25392572    return fname
     
    25422575    fname = 'make_pdb.py'
    25432576    outName = RMCPdict['moleculePdb'].split('.')
    2544     outName[0] += 'bb'
     2577    outName[0] += '_rbb'
    25452578    outName = '.'.join(outName)
     2579    RMCPdict['atomPDB'] = outName   #might be empty if pdbparser run fails
    25462580    fl = open(fname,'w')
    25472581    fl.write('from pdbparser.pdbparser import pdbparser\n')
Note: See TracChangeset for help on using the changeset viewer.