Changeset 5054


Ignore:
Timestamp:
Oct 27, 2021 2:18:24 PM (2 years ago)
Author:
vondreele
Message:

place run ISODISTORT in General/Compute? menu
Create interface to ISODISTORT - displacements & strains only - to obtain distortin mode list
distortion list in new phase tab (ISODISTORT) to all ow selection & make cif file
new code ISODISTORT.py for interface to BYU server.
More changes to PDFfit interface - not done yet; needs atom constraints.

Location:
trunk
Files:
1 added
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/GSASIIdataGUI.py

    r5051 r5054  
    63166316        G2G.Define_wxId('wxID_FOURCALC', 'wxID_FOURSEARCH', 'wxID_FOURCLEAR','wxID_CHARGEFLIP','wxID_VALIDPROTEIN',
    63176317            'wxID_MULTIMCSA','wxID_SINGLEMCSA', 'wxID_4DCHARGEFLIP', 'wxID_TRANSFORMSTRUCTURE','wxID_USEBILBAOMAG',
    6318             'wxID_COMPARESTRUCTURE',)
     6318            'wxID_COMPARESTRUCTURE','wxID_ISODISTORT')
    63196319        self.DataGeneral = wx.MenuBar()
    63206320        self.PrefillDataMenu(self.DataGeneral)
     
    63316331        self.GeneralCalc.Append(G2G.wxID_MULTIMCSA,'Multi MC/SA','Run Monte Carlo - Simulated Annealing on multiprocessors')
    63326332        self.GeneralCalc.Append(G2G.wxID_TRANSFORMSTRUCTURE,'Transform','Transform crystal structure')
     6333        self.GeneralCalc.Append(G2G.wxID_ISODISTORT,'Run ISODISTORT','Run ISODISTORT for PDFfit constraints')
    63336334        self.GeneralCalc.Append(G2G.wxID_COMPARESTRUCTURE,'Compare','Compare polyhedra to ideal octahedra/tetrahedra')
    63346335        self.GeneralCalc.Enable(G2G.wxID_COMPARESTRUCTURE,False)   
     
    64336434       
    64346435        #Phase / fullrmc & RMCprofile (Reverse Monte Carlo method) tab
    6435         G2G.Define_wxId('wxID_SETUPRMC','wxID_RUNRMC','wxID_VIEWRMC',
    6436                             'wxID_STOPRMC', 'wxID_ISODISTORT')       
     6436        G2G.Define_wxId('wxID_SETUPRMC','wxID_RUNRMC','wxID_VIEWRMC','wxID_STOPRMC', )       
    64376437        self.FRMCMenu = wx.MenuBar()
    64386438        self.PrefillDataMenu(self.FRMCMenu)
     
    64446444        self.FRMCDataEdit.Append(G2G.wxID_STOPRMC,'Stop run','Stop fullrmc run')
    64456445        self.FRMCDataEdit.Append(G2G.wxID_VIEWRMC,'Plot','View fullrmc or RMCprofile results')
    6446         self.FRMCDataEdit.Append(G2G.wxID_ISODISTORT,'Run ISODISTORT','Run ISODISTORT for PDFfit constraints')
    64476446        self.PostfillDataMenu()
    64486447       
     6448        # Phase/ ISODISTORT tab
     6449        G2G.Define_wxId('wxID_ISODNEWPHASE',)       
     6450        self.ISODData = wx.MenuBar()
     6451        self.PrefillDataMenu(self.ISODData)
     6452        self.ISODData.Append(menu=wx.Menu(title=''),title='Select tab')
     6453        self.ISODDataEdit = wx.Menu(title='')
     6454        self.ISODData.Append(menu=self.ISODDataEdit, title='Operations')
     6455        self.ISODDataEdit.Append(G2G.wxID_ISODNEWPHASE,'Make new phase','From ISODISTORT cif file')
     6456        self.PostfillDataMenu()
     6457
    64496458        # Phase / Layer tab
    64506459        G2G.Define_wxId('wxID_LOADDIFFAX', 'wxID_LAYERSIMULATE', 'wxID_SEQUENCESIMULATE', 'wxID_LAYERSFIT', 'wxID_COPYPHASE',)       
  • trunk/GSASIIphsGUI.py

    r5050 r5054  
    29122912            G2cnstG.TransConstraints(G2frame,data,newPhase,Trans,Vvec,atCodes)     #data is old phase
    29132913        G2frame.GPXtree.SelectItem(sub)
     2914       
     2915    def OnRunISODISTORT(event):
     2916        import ISODISTORT as ISO
     2917        dlg = wx.FileDialog(General, 'Choose parent cif file for ISODISTORT',G2G.GetImportPath(G2frame),
     2918            style=wx.FD_OPEN ,wildcard='(*.cif)|*.cif')
     2919        if dlg.ShowModal() == wx.ID_OK:
     2920            fpath,parentcif = os.path.split(dlg.GetPath())
     2921            radio,rundata = ISO.GetISODISTORT(data,parentcif)
     2922            data['ISODISTORT']['radio'] = radio
     2923            data['ISODISTORT']['rundata'] = rundata
     2924            data['ISODISTORT']['SGselect'] =  {'Tric':True,'Mono':True,'Orth':True,'Tetr':True,'Trig':True,'Hexa':True,'Cubi':True}
     2925            data['ISODISTORT']['selection'] = None
     2926            print('ISODISTORT run complete')
     2927            UpdateISODISTORT()
     2928        else:
     2929            print('ISODISTORT run cancelled')
    29142930               
    29152931    def OnCompare(event):
     
    57975813                return parmSizer
    57985814           
     5815            def OnSpaceGroup(event):
     5816                # try a lookup on the user-supplied name
     5817                SpcGp = GetSpGrpfromUser(G2frame.FRMC,SpGrp)
     5818                SGErr,SGData = G2spc.SpcGroup(SpcGp)
     5819                if SGErr:
     5820                    text = [G2spc.SGErrors(SGErr)+'\nSpace Group set to previous']
     5821                    SGTxt.SetLabel(RMCPdict.get('Target SpGrp','P 1'))
     5822                    msg = 'Space Group Error'
     5823                    Text = '\n'.join(text)
     5824                    wx.MessageBox(Text,caption=msg,style=wx.ICON_EXCLAMATION)
     5825                else:
     5826                    text,table = G2spc.SGPrint(SGData)
     5827                    RMCPdict['SGData'] = SGData
     5828                    SGTxt.SetLabel(RMCPdict['SGData']['SpGrp'])
     5829                    msg = 'Target Space Group Information'
     5830                    G2G.SGMessageBox(G2frame.FRMC,msg,text,table).Show()
     5831                G2spc.UpdateSytSym(data)
     5832               
     5833            def OnCellRef(event):
     5834                RMCPdict['cellref'] = not RMCPdict['cellref']
     5835               
     5836            def AtomSizer():
     5837                return None
     5838               
     5839
    57995840            subSizer = wx.BoxSizer(wx.HORIZONTAL)
    58005841            subSizer.Add((-1,-1),1,wx.EXPAND)
     
    58105851            mainSizer.Add((5,5))
    58115852            if 'PDFfit' not in data['RMC']:
    5812                 Atypes = [atype.split('+')[0].split('-')[0] for atype in data['General']['AtomTypes']]
    5813                 aTypes = dict(zip(Atypes,len(Atypes)*[0.10,]))
     5853                SGData = G2spc.SpcGroup('P 1')[1]
    58145854                metadata = {'title':'none','date':str(time.ctime()),'temperature':'300K',
    58155855                    'doping':0}
     
    58185858                data['RMC']['PDFfit'] = {'files':files,'ReStart':[False,False],'metadata':metadata,
    58195859                'delta1':[0.,False],'delta2':[0.,False],'spdiameter':[0.,False],
    5820                 'sratio':[1.,False],'rcut':0.0,'stepcut':0.0,'shape':'sphere',         
     5860                'sratio':[1.,False],'rcut':0.0,'stepcut':0.0,'shape':'sphere','SGData':SGData,'cellref':False,       
    58215861                'Xdata':{'dscale':[1.0,False],'Datarange':[0.,30.],'Fitrange':[0.,30.],'qdamp':[0.03,False],'qbroad':[0,False]},
    58225862                'Ndata':{'dscale':[1.0,False],'Datarange':[0.,30.],'Fitrange':[0.,30.],'qdamp':[0.03,False],'qbroad':[0,False]},}
    58235863               
    58245864            RMCPdict = data['RMC']['PDFfit']
     5865#patch
     5866            if 'SGData' not in RMCPdict:
     5867                RMCPdict['SGData'] = G2spc.SpcGroup('P 1')[1]
     5868            if 'cellref' not in RMCPdict:
     5869                RMCPdict['cellref'] = False
     5870#end patch
    58255871            mainSizer.Add(wx.StaticText(G2frame.FRMC,label=' Enter metadata items:'),0)
    58265872            mainSizer.Add(GetMetaSizer(RMCPdict,['title','date','temperature','doping']),0)
    58275873           
    58285874            G2G.HorizontalLine(mainSizer,G2frame.FRMC)
    5829             mainSizer.Add(wx.StaticText(G2frame.FRMC,label=' PDF phase profile coefficients:'),0,WACV)
     5875            SgSizer = wx.BoxSizer(wx.HORIZONTAL)
     5876            SgSizer.Add(wx.StaticText(G2frame.FRMC,label=' Target space group: '),0,WACV)
     5877           
     5878            mainSizer.Add(wx.StaticText(G2frame.FRMC,label='PDFfit phase structure parameters:'),0,WACV)
     5879           
     5880            SpGrp = RMCPdict['SGData']['SpGrp']
     5881            SGTxt = wx.Button(G2frame.FRMC,wx.ID_ANY,SpGrp,size=(100,-1))
     5882            SGTxt.Bind(wx.EVT_BUTTON,OnSpaceGroup)
     5883            SgSizer.Add(SGTxt,0,WACV)
     5884            mainSizer.Add(SgSizer,0,WACV)
     5885           
     5886            cellref = wx.CheckBox(G2frame.FRMC,label=' Refine unit cell?')
     5887            cellref.SetValue(RMCPdict['cellref'])
     5888            cellref.Bind(wx.EVT_CHECKBOX,OnCellRef)
     5889            mainSizer.Add(cellref,0,WACV)
     5890                       
     5891            mainSizer.Add(wx.StaticText(G2frame.FRMC,label='PDFfit atom parameters:'),0,WACV)
     5892            mainSizer.Add(AtomSizer())
     5893           
     5894            mainSizer.Add(wx.StaticText(G2frame.FRMC,label=' PDFfit phase profile coefficients:'),0,WACV)
    58305895            mainSizer.Add(PDFParmSizer(),0)
    58315896           
     
    59466011            G2frame.dataWindow.FRMCDataEdit.Enable(G2G.wxID_RUNRMC,True)
    59476012            RMCPdict = data['RMC']['PDFfit']
    5948             title = RMCPdict['metadata']['title']
    59496013            G2pwd.MakePDFfitAtomsFile(data,RMCPdict)
    59506014            G2pwd.MakePDFfitRunFile(data,RMCPdict)
     
    65476611                        lines=False,names=['G(R) obs','G(R) calc','diff',])
    65486612           
    6549     def OnRunISODISTORT(event):
     6613       
     6614#### ISOTDISTORT results tab ###############################################################################
     6615
     6616    def UpdateISODISTORT(Scroll=0):
     6617        ''' Present the results of an ISODISTORT run & allow selection of a distortion model for PDFfit
     6618        & refinement constraints
     6619        '''
     6620        def OnLaue(event):
     6621            Obj = event.GetEventObject()
     6622            name = Indx[Obj.GetId()]
     6623            data['ISODISTORT']['SGselect'][name[:4]] = not data['ISODISTORT']['SGselect'][name[:4]]
     6624            data['ISODISTORT']['selection'] = None
     6625            UpdateISODISTORT()
     6626           
     6627        def OnAllBtn(event):
     6628            for item in data['ISODISTORT']['SGselect']:
     6629                data['ISODISTORT']['SGselect'][item] = not data['ISODISTORT']['SGselect'][item]
     6630            data['ISODISTORT']['selection'] = None
     6631            UpdateISODISTORT()
     6632           
     6633        def CheckItem(item):
     6634            SGnum = int(item.split()[1].split('*')[0])
     6635            for SGtype in data['ISODISTORT']['SGselect']:
     6636                if data['ISODISTORT']['SGselect'][SGtype] and SGnum in SGrange[SGtype]:
     6637                    return True
     6638            return False
     6639       
     6640        def OnSelect(event):
     6641            r,c = event.GetRow(),event.GetCol()
     6642            if c == 0:
     6643                data['ISODISTORT']['selection'] = [r,isoTable.GetValue(r,1)]
     6644                for row in range(isoGrid.GetNumberRows()):
     6645                    isoTable.SetValue(row,c,False)
     6646                isoTable.SetValue(r,c,True)
     6647                isoGrid.ForceRefresh()
     6648               
     6649        if not data['ISODISTORT']:
     6650            return
     6651        if ISODIST.GetSizer():
     6652            ISODIST.GetSizer().Clear(True)
     6653        SGrange = {'Cubi':np.arange(195,231),'Hexa':np.arange(168,195),'Trig':np.arange(143,168),'Tetr':np.arange(75,143),
     6654                   'Orth':np.arange(16,75),'Mono':np.arange(3,16),'Tric':np.arange(1,3)}       
     6655        colLabels = ['select',' ISODISTORT order parameter direction description']
     6656        colTypes = [wg.GRID_VALUE_BOOL,wg.GRID_VALUE_STRING,]
     6657        mainSizer = wx.BoxSizer(wx.VERTICAL)
     6658        topSizer = wx.BoxSizer(wx.VERTICAL)   
     6659        bottomSizer = wx.BoxSizer(wx.VERTICAL)
     6660        topSizer.Add(wx.StaticText(ISODIST,label=' ISODISTORT distortion search results:'),0,WACV)
     6661        topSizer.Add(wx.StaticText(ISODIST,label='''
     6662For use of ISODISTORT, please cite:
     6663  H. T. Stokes, D. M. Hatch, and B. J. Campbell, ISODISTORT, ISOTROPY Software Suite, iso.byu.edu.
     6664  B. J. Campbell, H. T. Stokes, D. E. Tanner, and D. M. Hatch, "ISODISPLACE: An Internet Tool for Exploring Structural Distortions."
     6665  J. Appl. Cryst. 39, 607-614 (2006).
     6666  '''),0,WACV)
     6667        topSizer.Add(wx.StaticText(ISODIST,label=' Subset selection if desired:'))
     6668        laueName = ['Cubic','Hexagonal','Trigonal','Tetragonal','Orthorhombic','Monoclinic','Triclinic']
     6669        littleSizer = wx.FlexGridSizer(0,8,5,5)
     6670        Indx = {}
     6671        for name in laueName:
     6672            laueCk = wx.CheckBox(ISODIST,label=name)
     6673            Indx[laueCk.GetId()] = name
     6674            laueCk.SetValue(data['ISODISTORT']['SGselect'][name[:4]])
     6675            laueCk.Bind(wx.EVT_CHECKBOX,OnLaue)
     6676            littleSizer.Add(laueCk,0,WACV)
     6677        allBtn = wx.Button(ISODIST,label='Toggle all')
     6678        allBtn.Bind(wx.EVT_BUTTON,OnAllBtn)
     6679        littleSizer.Add(allBtn)
     6680        topSizer.Add(littleSizer)
     6681       
     6682        mainSizer.Add(topSizer)
     6683         
     6684        if 'radio' in data['ISODISTORT']:
     6685            Radio = data['ISODISTORT']['radio']
     6686            rowLabels = []
     6687            table = []
     6688            for i,item in enumerate(Radio):
     6689                if CheckItem(Radio[item]):
     6690                    if data['ISODISTORT']['selection'] and data['ISODISTORT']['selection'][0] == i:
     6691                        table.append([True,Radio[item]])
     6692                    else:
     6693                        table.append([False,Radio[item]])
     6694                    rowLabels.append(str(i))
     6695            isoTable = G2G.Table(table,rowLabels=rowLabels,colLabels=colLabels,types=colTypes)
     6696            isoGrid = G2G.GSGrid(ISODIST)
     6697            isoGrid.SetTable(isoTable,True,useFracEdit=False)
     6698            isoGrid.AutoSizeColumns(True)
     6699            isoGrid.SetColLabelAlignment(wx.ALIGN_LEFT,wx.ALIGN_CENTRE)
     6700            bottomSizer.Add(isoGrid)
     6701            attr = wg.GridCellAttr()
     6702            attr.SetReadOnly(True)
     6703            attr.SetBackgroundColour(VERY_LIGHT_GREY)
     6704            isoGrid.SetColAttr(1,attr)
     6705            isoGrid.Bind(wg.EVT_GRID_CELL_LEFT_CLICK, OnSelect)
     6706        mainSizer.Add(bottomSizer)
     6707        SetPhaseWindow(ISODIST,mainSizer,Scroll=Scroll)
     6708       
     6709    def OnNewISOPhase(event):
     6710        ''' Make cif file with ISODISTORT
     6711        '''
    65506712        import ISODISTORT as ISO
    6551         ISO.GetISODISTORT(data)
    6552         print('run ISODISTORT under construction')
    6553        
    6554        
    6555            
     6713
     6714        if data['ISODISTORT']:
     6715            CIFfile = ISO.GetISODISTORTcif(data)
     6716            print(CIFfile)
     6717        else:
     6718            print('ERROR-need to run ISODISTORT first - see General/Compute menu')
     6719           
     6720       
     6721         
    65566722#### DIFFax Layer Data page ################################################################################
    65576723    def UpdateLayerData(Scroll=0):
     
    1311413280            G2gd.SetDataMenuBar(G2frame,G2frame.dataWindow.FRMCMenu)
    1311513281            UpdateRMC()
     13282        elif text == 'ISODISTORT':
     13283            G2gd.SetDataMenuBar(G2frame,G2frame.dataWindow.ISODData)
     13284            UpdateISODISTORT()
    1311613285        elif text == 'Draw Options':
    1311713286            G2gd.SetDataMenuBar(G2frame,G2frame.dataWindow.DataDrawOptions)
     
    1315613325        G2frame.Bind(wx.EVT_MENU, OnRunMultiMCSA, id=G2G.wxID_MULTIMCSA)
    1315713326        G2frame.Bind(wx.EVT_MENU, OnTransform, id=G2G.wxID_TRANSFORMSTRUCTURE)
     13327        G2frame.Bind(wx.EVT_MENU, OnRunISODISTORT, id=G2G.wxID_ISODISTORT)
    1315813328        G2frame.Bind(wx.EVT_MENU, OnCompare, id=G2G.wxID_COMPARESTRUCTURE)
    1315913329        G2frame.Bind(wx.EVT_MENU, OnUseBilbao, id=G2G.wxID_USEBILBAOMAG)
     
    1327213442        G2frame.Bind(wx.EVT_MENU, OnPeaksDelete, id=G2G.wxID_PEAKSDELETE)
    1327313443        G2frame.Bind(wx.EVT_MENU, OnPeaksClear, id=G2G.wxID_PEAKSCLEAR)
    13274         # fullrmc
     13444        # RMCProfile/fullrmc/PDFfit
    1327513445        FillSelectPageMenu(TabSelectionIdDict, G2frame.dataWindow.FRMCMenu)
    1327613446        G2frame.Bind(wx.EVT_MENU, OnSetupRMC, id=G2G.wxID_SETUPRMC)
     
    1327813448        G2frame.Bind(wx.EVT_MENU, OnViewRMC, id=G2G.wxID_VIEWRMC)
    1327913449        G2frame.Bind(wx.EVT_MENU, OnStopRMC, id=G2G.wxID_STOPRMC)
    13280         G2frame.Bind(wx.EVT_MENU, OnRunISODISTORT, id=G2G.wxID_ISODISTORT)
     13450        G2frame.Bind(wx.EVT_MENU, OnNewISOPhase, id=G2G.wxID_ISODNEWPHASE)
    1328113451        # MC/SA
    1328213452        FillSelectPageMenu(TabSelectionIdDict, G2frame.dataWindow.MCSAMenu)
     
    1336813538    if 'RMC' not in data:
    1336913539        data['RMC'] = {'RMCProfile':{},'fullrmc':{},'PDFfit':{}}
     13540    if 'ISODISTORT' not in data:
     13541        data['ISODISTORT'] = {}
    1337013542#end patch   
    1337113543
     
    1341513587        RigidBodies.Bind(wx.EVT_CHAR,rbKeyPress)
    1341613588        Pages.append('RB Models')
     13589       
    1341713590    MapPeaks = G2G.GSGrid(G2frame.phaseDisplay)
    1341813591#    MapPeaks.SetScrollRate(0,0)
    1341913592    G2frame.phaseDisplay.gridList.append(MapPeaks)   
    1342013593    G2frame.phaseDisplay.AddPage(MapPeaks,'Map peaks')
     13594   
    1342113595    if data['General']['doDysnomia']:
    1342213596        G2frame.MEMData = wx.ScrolledWindow(G2frame.phaseDisplay)
    1342313597        G2frame.phaseDisplay.AddPage(G2frame.MEMData,'Dysnomia')
    13424         Pages.append('Dysnomia')       
     13598        Pages.append('Dysnomia')
     13599       
    1342513600    Pages.append('Map peaks')
    1342613601    if data['General']['Type'] not in ['faulted',] and not data['General']['Modulated']:
     
    1343113606        G2frame.phaseDisplay.AddPage(G2frame.FRMC,'RMC')
    1343213607        Pages.append('RMC')
     13608       
     13609    if data['General']['Type'] == 'nuclear':
     13610        ISODIST = wx.ScrolledWindow(G2frame.phaseDisplay)
     13611        G2frame.phaseDisplay.AddPage(ISODIST,'ISODISTORT')
     13612        Pages.append('ISODISTORT')       
     13613   
    1343313614    Texture = wx.ScrolledWindow(G2frame.phaseDisplay)
    1343413615    G2frame.phaseDisplay.AddPage(Texture,'Texture')
  • trunk/GSASIIpwd.py

    r5050 r5054  
    29632963    fatm.write('format pdffit\n')
    29642964    fatm.write('scale   1.000000\n')    #fixed
    2965     sharp = '%10.6f,%10.6f,%10.6f,%10.6f\n'%(RMCPdict['delta2'][0],RMCPdict['delta1'][0],RMCPdict['sratio'][0],RMCPdict['rcut'][0])
     2965    if RMCPdict['shape'] == 'sphere':
     2966        sharp = '%10.6f,%10.6f,%10.6f\n'%(RMCPdict['delta2'][0],RMCPdict['delta1'][0],RMCPdict['sratio'][0])
     2967    else:
     2968        sharp = '%10.6f,%10.6f,%10.6f,%10.6f\n'%(RMCPdict['delta2'][0],RMCPdict['delta1'][0],RMCPdict['sratio'][0],RMCPdict['rcut'])
    29662969    fatm.write('sharp '+sharp)
    29672970    shape = ''
    2968     if RMCPdict['spdiameter'] > 0.:
    2969         shape = 'sphere, %10.6f\n'%RMCPdict['spdiameter']
     2971    if RMCPdict['shape'] == 'sphere' and RMCPdict['spdiameter'][0] > 0.:
     2972        shape = '   sphere, %10.6f\n'%RMCPdict['spdiameter'][0]
    29702973    elif RMCPdict['stepcut'] > 0.:
    29712974        shape = 'stepcut, %10.6f\n'%RMCPdict['stepcut']
     
    29912994   
    29922995def MakePDFfitRunFile(Phase,RMCPdict):
    2993     '''Make the PDFfit atoms file
     2996    '''Make the PDFfit python run file
    29942997    '''
    2995     print(RMCPdict)
     2998   
     2999    def GetCellConstr(SGData):
     3000        if SGData['SGLaue'] in ['m3', 'm3m']:
     3001            return [1,1,1,0,0,0]
     3002        elif SGData['SGLaue'] in ['3','3m1','31m','6/m','6/mmm','4/m','4/mmm']:
     3003            return [1,1,2,0,0,0]
     3004        elif SGData['SGLaue'] in ['3R','3mR']:
     3005            return [1,1,1,2,2,2]
     3006        elif SGData['SGLaue'] == 'mmm':
     3007            return [1,2,3,0,0,0]
     3008        elif SGData['SGLaue'] == '2/m':
     3009            if SGData['SGUniq'] == 'a':
     3010                return [1,2,3,4,0,0]
     3011            elif SGData['SGUniq'] == 'b':
     3012                return [1,2,3,0,4,0]
     3013            elif SGData['SGUniq'] == 'c':
     3014                return [1,2,3,0,0,4]
     3015        else:
     3016            return [1,2,3,4,5,6]
     3017       
    29963018    General = Phase['General']
    29973019    rundata = '''
     
    30003022from diffpy.pdffit2 import PdfFit
    30013023pf = PdfFit()
    3002 # Load data ------------------------------------------------------------------
    3003 qmax = 30.0  # Q-cutoff used in PDF calculation in 1/A
    3004 qdamp = 0.01 # instrument Q-resolution factor, responsible for PDF decay
    30053024'''
    3006     rundata += "pf.read_data(%s, 'X', qmax, qdamp)\n"
    3007     rundata += "pf.read_data(%s, 'N', qmax, qdamp)\n"   
    3008     rundata += "pf.read_struct(%s)\n"
     3025    Nd = 0
     3026    Np = 0
     3027    for file in RMCPdict['files']:
     3028        if 'Neutron' in file:
     3029            Nd += 1
     3030            dType = 'Ndata'
     3031        else:
     3032            Nd += 1
     3033            dType = 'Xdata'
     3034        rundata += "pf.read_data(%s, '%s', 30.0, %.4f)\n"%(dType[0],RMCPdict['files'][file][0],RMCPdict[dType]['qdamp'][0])
     3035        rundata += 'pf.pdfrange(%d, %6.2f, %6.2f\n'%(Nd,RMCPdict[dType]['Fitrange'][0],RMCPdict[dType]['Fitrange'][1])
     3036        rundata += 'pf.setdata(%d)\n'%Nd
     3037        for item in ['dscale','qdamp','qbroad']:
     3038            rundata += "pf.setvar('%s', %.2f)\n"%(item,RMCPdict[dType][item][0])
     3039            if RMCPdict[dType][item][1]:
     3040                Np += 1
     3041                rundata += 'pf.constrain("%s","@%d")\n'%(item,Np)
     3042    rundata += "pf.read_struct(%s)\n"%(General['Name']+'-PDFfit.stru')
     3043    for item in ['delta1','delta2','sratio']:
     3044        if RMCPdict[item][1]:
     3045            Np += 1
     3046            rundata += 'pf.constrain(pf.%s,"@%d")\n'%(item,Np)
     3047    if 'sphere' in RMCPdict['shape'][0] and RMCPdict['spdiameter'][1]:
     3048        Np += 1
     3049        rundata += 'pf.constrain(pf.spdiameter,"@%d")\n'%Np
     3050       
     3051    if RMCPdict['cellref']:
     3052        cellconst = GetCellConstr(RMCPdict['SGData'])
     3053        for ic in range(6):
     3054            if cellconst[ic]:
     3055                rundata += 'pf.constrain(pf.lat(%d), "@%d")\n'%(ic+1,Np+cellconst[ic])
     3056#Atom constraints here -------------------------------------------------------       
     3057   
     3058   
     3059   
     3060# Refine & Save results ---------------------------------------------------------------   
     3061    rundata += 'pf.refine()\n'
     3062    fName = General['Name'].replace(' ','_')+'-PDFfit'
     3063    Nd = 0   
     3064    for file in RMCPdict['files']:
     3065        Nd += 1
     3066        rundata += 'pf.save_pdf(%d, %s)\n'%(Nd,fName+file[0]+'.fgr')
     3067       
     3068    rundata += 'pf.save_struct(1, %s)\n'%(fName+'.rstr')
     3069    rundata += 'pf.save_res(%s)\n'%(fName+'.res')
     3070   
     3071   
     3072    print(rundata)
     3073   
     3074   
    30093075 
    3010     fName = General['Name']+'.py'   
    3011     rfile = open(fName,'w')
    3012     rfile.writelines(rundata)
    3013     rfile.close()
     3076    # rfile = open(fName+.py','w')
     3077    # rfile.writelines(rundata)
     3078    # rfile.close()
    30143079   
    30153080 
Note: See TracChangeset for help on using the changeset viewer.