Changeset 3990 for trunk/GSASIIphsGUI.py


Ignore:
Timestamp:
May 22, 2019 2:04:11 PM (3 years ago)
Author:
vondreele
Message:

MEM Dysnomia now works but can be uncontrolled. No feedback into GSAS-II yet

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/GSASIIphsGUI.py

    r3982 r3990  
    4040import sys
    4141import random as ran
     42import subprocess as subp
    4243import GSASIIpath
    4344GSASIIpath.SetVersionNumber("$Revision$")
     
    21862187
    21872188            def OnDysnomia(event):
    2188                 generalData['doDysnomia'] = not generalData['doDysnomia']
     2189                data['General']['doDysnomia'] = not data['General']['doDysnomia']
    21892190                pages = [G2frame.phaseDisplay.GetPageText(PageNum) for PageNum in range(G2frame.phaseDisplay.GetPageCount())]
    21902191                if generalData['doDysnomia']:
    21912192                    if 'Dysnomia' not in pages:
    21922193                        G2frame.MEMData = wx.ScrolledWindow(G2frame.phaseDisplay)
     2194                        G2frame.Bind(wx.EVT_MENU, OnLoadDysnomia, id=G2G.wxID_LOADDYSNOMIA)
     2195                        G2frame.Bind(wx.EVT_MENU, OnSaveDysnomia, id=G2G.wxID_SAVEDYSNOMIA)
     2196                        G2frame.Bind(wx.EVT_MENU, OnRunDysnomia, id=G2G.wxID_RUNDYSNOMIA)
    21932197                        G2frame.phaseDisplay.InsertPage(7,G2frame.MEMData,'Dysnomia')
    21942198                        Id = wx.NewId()
    21952199                        TabSelectionIdDict[Id] = 'Dysnomia'
     2200                       
     2201                       
    21962202                        if 'Dysnomia' not in data:  #set defaults here
    21972203                            data['Dysnomia'] = {'DenStart':'uniform','Optimize':'ZSPA','Lagrange':['user',0.001,0.05],
    2198                                 'wt pwr':0,'E_factor':1.,'Ncyc':5000,'prior':'uniform','Lam frac':[1,0,0,0,0,0,0,0]}
     2204                                'wt pwr':0,'E_factor':1.,'Ncyc':5000,'prior':'uniform','Lam frac':[1,0,0,0,0,0,0,0],
     2205                                'overlap':1.0}
    21992206                else:
    22002207                    if 'Dysnomia' in pages:
     
    41254132        ''' Present the controls for running Dysnomia
    41264133        '''
    4127 #data['Dysonmia'] = {'DenStart':'uniform','Optimize':'ZSPA','Lagrange':['user',0.001,0.05],
     4134#data['Dysnomia'] = {'DenStart':'uniform','Optimize':'ZSPA','Lagrange':['user',0.001,0.05],
    41284135#    'wt pwr':0,'E_factor':1.,'Ncyc':5000,'prior':'uniform','Lam frac':[1,0,0,0,0,0,0,0]}
    41294136        def OnOptMeth(event):
     
    41454152            MEMData.GetSizer().Clear(True)
    41464153        DysData = data['Dysnomia']
     4154        if 'overlap' not in DysData:
     4155            DysData['overlap'] = 1.0
    41474156        mainSizer = wx.BoxSizer(wx.VERTICAL)
    41484157        mainSizer.Add(wx.StaticText(MEMData,label=' Maximum Entropy Method (Dysnomia) controls:'))
     
    41534162        OptMeth.Bind(wx.EVT_COMBOBOX,OnOptMeth)
    41544163        lineSizer.Add(OptMeth,0,WACV)
     4164        lineSizer.Add(wx.StaticText(MEMData,label=' Peak overlap factor'),0,WACV)
     4165        overlap = G2G.ValidatedTxtCtrl(MEMData,DysData,'overlap',nDig=(10,4),min=0.1,max=1.)
     4166        lineSizer.Add(overlap,0,WACV)
    41554167        mainSizer.Add(lineSizer)
    41564168        if DysData['Optimize'] == 'ZSPA':
     
    42064218    def OnRunDysnomia(event):
    42074219       
    4208        
     4220#data['Dysnomia'] = {'DenStart':'uniform','Optimize':'ZSPA','Lagrange':['user',0.001,0.05],
     4221#    'wt pwr':0,'E_factor':1.,'Ncyc':5000,'prior':'uniform','Lam frac':[1,0,0,0,0,0,0,0]}
     4222
    42094223        generalData = data['General']
    42104224        Map = generalData['Map']
    4211         Phase = generalData['Name'].replace(' ','_')
    4212         DysData = data['Dysnomia']
    4213         prf = open(Phase+'.prf','w')
    4214         prf.write(Phase+'.mem\n') #or .fos?
    4215         prf.write(Phase+'.out\n')
    4216         prf.write(Phase+'.pgrid\n')
    4217         prf.write(Phase+'.fba\n')
    4218         prf.write(Phase+'_eps.raw\n')
    4219        
    4220        
    4221 
    4222        
    4223         prf.close()
     4225        UseList = Map['RefList']
     4226        pId = G2gd.GetGPXtreeItemId(G2frame,G2frame.root,UseList[0])       #only use 1st histogram
     4227        reflSets = G2frame.GPXtree.GetItemPyData(G2gd.GetGPXtreeItemId(G2frame,pId,'Reflection Lists'))
     4228        reflData = reflSets[generalData['Name']]['RefList']
     4229        Type = Map['Type']
     4230        MEMtype = 0
     4231        if 'N' in Type:
     4232            for el in generalData['Isotope']:
     4233                isotope = generalData['Isotope'][el]
     4234                if generalData['Isotopes'][el][isotope]['SL'][0] < 0.:
     4235                    MEMtype = 1
     4236        prfName = str(G2pwd.makePRFfile(data,MEMtype))
     4237        if not G2pwd.makeMEMfile(data,reflData,MEMtype):
     4238            print('non standard space groupsnot permitted in Dysnomia')
     4239            return
    42244240
    42254241        wx.MessageBox(''' For use of Dysnomia, please cite:
     
    42284244      K. Moma, T. Ikeda, A.A. Belik & F. Izumi, Powder Diffr. 2013, 28, 184-193.
    42294245      doi:10.1017/S088571561300002X''',caption='Dysnomia (MEM)',style=wx.ICON_INFORMATION)
     4246       
     4247        path2GSAS2 = os.path.dirname(os.path.abspath(os.path.expanduser(__file__)))
     4248        DYSNOMIA = os.path.join(path2GSAS2,'Dysnomia','Dysnomia64.exe')
     4249        print('Run '+DYSNOMIA)
     4250       
     4251        subp.call([DYSNOMIA,prfName])
    42304252           
    42314253       
     
    96299651            wx.CallAfter(G2plt.PlotStructure,G2frame,data,firstCall=True)
    96309652        elif text == 'Dysnomia':
    9631             G2gd.SetDataMenuBar(G2frame,G2frame.dataWindow.MEMData)
     9653            G2gd.SetDataMenuBar(G2frame,G2frame.dataWindow.MEMMenu)
    96329654            UpdateDysnomia()
    96339655        elif text == 'Draw Options':
     
    97199741        # Dysnomia (MEM)
    97209742        if data['General']['doDysnomia']:
    9721             FillSelectPageMenu(TabSelectionIdDict, G2frame.dataWindow.MEMData)
     9743            FillSelectPageMenu(TabSelectionIdDict, G2frame.dataWindow.MEMMenu)
    97229744            G2frame.Bind(wx.EVT_MENU, OnLoadDysnomia, id=G2G.wxID_LOADDYSNOMIA)
    97239745            G2frame.Bind(wx.EVT_MENU, OnSaveDysnomia, id=G2G.wxID_SAVEDYSNOMIA)
     
    98589880    G2frame.phaseDisplay.AddPage(MapPeaks,'Map peaks')
    98599881    if data['General']['doDysnomia']:
    9860         G2frame.Dysnomia = wx.ScrolledWindow(G2frame.phaseDisplay)
    9861         G2frame.phaseDisplay.AddPage(G2frame.Dysnomia,'Dysnomia')
     9882        G2frame.MEMData = wx.ScrolledWindow(G2frame.phaseDisplay)
     9883        G2frame.phaseDisplay.AddPage(G2frame.MEMData,'Dysnomia')
    98629884        Pages.append('Dysnomia')       
    98639885    Pages.append('Map peaks')
Note: See TracChangeset for help on using the changeset viewer.