Changeset 1915 for trunk


Ignore:
Timestamp:
Jun 30, 2015 3:52:34 PM (7 years ago)
Author:
vondreele
Message:

start on riding constraints - works for atom frac,x,y,z; skipping u's for now.
start on an add H atoms tool - just the GUI (hidden for now)
more twin work.
removed GSASII.BAT - it didn't work on many user's systems.
need a H atom geometry fixup routine

Location:
trunk
Files:
1 deleted
10 edited

Legend:

Unmodified
Added
Removed
  • trunk

    • Property svn:ignore
      •  

        old new  
        11Exercises
         2GSASII.BAT
  • trunk/GSASII.py

    r1913 r1915  
    835835                UseList[histoName]['Twins'] = [[np.array([[1,0,0],[0,1,0],[0,0,1]]),[1.0,False]],]
    836836                for iT in range(reflData.get('TwMax',0)):
    837                     UseList[histoName]['Twins'].append([[],0.0])
     837                    UseList[histoName]['Twins'].append([False,0.0])
    838838                for iref,ref in enumerate(reflData['RefList']):
    839839                    hkl = ref[:3]
  • trunk/GSASIIconstrGUI.py

    r1898 r1915  
    689689        legend = "Select atoms to make equivalent (only one of the atom variables will be varied when all are set to be varied)"
    690690        GetAddAtomVars(page,title1,title2,varList,constrDictEnt,'equivalence')
     691       
     692    def OnAddRiding(event):
     693        ''' Add riding equivalences between all parameters on atoms '''
     694        page = G2frame.Page
     695        vartype,varList,constrDictEnt = PageSelection(page)
     696        title1 = "Setup riding atoms "
     697        title2 = "Select additional atoms(s) to ride on "
     698        if not varList:
     699            G2frame.ErrorDialog('No variables','There are no variables of type '+vartype,
     700                                parent=G2frame.dataFrame)
     701            return
     702        legend = "Select atoms to ride (only one of the atom variables will be varied when all are set to be varied)"
     703        GetAddAtomVars(page,title1,title2,varList,constrDictEnt,'riding')
     704       
     705       
    691706   
    692707    def OnAddFunction(event):
     
    774789        if dlg.ShowModal() == wx.ID_OK:
    775790            Selections = dlg.GetSelections()[:]
     791        else:
     792            print 'no target atom selected'
     793            dlg.Destroy()
     794            return
    776795        dlg.Destroy()
    777796        for name in Atoms[FrstAtom]:
     
    779798            constr = [[1.0,G2obj.G2VarObj(name)]]
    780799            pref = name.rsplit(':',1)[0]
     800            if 'riding' in constType and 'U' in pref:
     801                continue
    781802            for sel in Selections:
    782803                id = Atoms[AtNames[sel]][0].rsplit(':',1)[-1]
    783804                constr += [[1.0,G2obj.G2VarObj('%s:%s'%(pref,id))]]
    784             if 'frac' in pref:
     805            if 'frac' in pref and 'riding' not in constType:
    785806                newcons = [constr+[1.0,None,'c']]
    786807            else:
     
    10111032        text = G2frame.dataDisplay.GetPageText(page)
    10121033        G2frame.dataFrame.ConstraintEdit.Enable(G2gd.wxID_EQUIVALANCEATOMS,False)
     1034        G2frame.dataFrame.ConstraintEdit.Enable(G2gd.wxID_ADDRIDING,False)
    10131035        if text == 'Histogram/Phase constraints':
    10141036            G2frame.Page = [page,'hap']
     
    10201042            G2frame.Page = [page,'phs']
    10211043            G2frame.dataFrame.ConstraintEdit.Enable(G2gd.wxID_EQUIVALANCEATOMS,True)
     1044            G2frame.dataFrame.ConstraintEdit.Enable(G2gd.wxID_ADDRIDING,True)
    10221045            UpdateConstraintPanel(PhaseConstr,'Phase')
    10231046        elif text == 'Global constraints':
     
    10541077    G2frame.dataFrame.Bind(wx.EVT_MENU, OnAddHold, id=G2gd.wxID_HOLDADD)
    10551078    G2frame.dataFrame.Bind(wx.EVT_MENU, OnAddAtomEquiv, id=G2gd.wxID_EQUIVALANCEATOMS)
     1079    G2frame.dataFrame.Bind(wx.EVT_MENU, OnAddRiding, id=G2gd.wxID_ADDRIDING)
    10561080    # tab commands
    10571081    for id in (G2gd.wxID_CONSPHASE,
  • trunk/GSASIIddataGUI.py

    r1913 r1915  
    817817            Obj = event.GetEventObject()
    818818            UseList[G2frame.hist]['Twins'][0][1][1] = Obj.GetValue()
     819           
     820        def OnTwinInv(event):
     821            Obj = event.GetEventObject()
     822            it = Indx[Obj.GetId()]
     823            UseList[G2frame.hist]['Twins'][it][0] = Obj.GetValue()
    819824                       
    820825        def OnTwinDel(event):
     
    850855                    Style = wx.TE_READONLY
    851856                    TwVal = Twin[1][0]
    852                 if len(Twin[0]):
     857                if 'bool' not in str(type(Twin[0])):
    853858                    matSizer.Add(wx.StaticText(DData,-1,' Twin Law: '),0,WACV)
    854859                    for im,Mat in enumerate(twinMat):
     
    863868                        matSizer.Add(mat,0,WACV|wx.LEFT,5)
    864869                else:
    865                     matSizer.Add(wx.StaticText(DData,-1,' Nonmerohedral twin component %d:'%(it)),0,WACV)
     870                    matSizer.Add(wx.StaticText(DData,-1,' Nonmerohedral twin component %d: '%(it)),0,WACV)
     871                    if not SGData['SGInv']:
     872                        twinv = wx.CheckBox(DData,wx.ID_ANY,label=' Use enantiomorph?')
     873                        twinv.SetValue(Twin[0])
     874                        Indx[twinv.GetId()] = it
     875                        twinv.Bind(wx.EVT_CHECKBOX, OnTwinInv)
     876                        matSizer.Add(twinv,0,WACV)
    866877                twinsizer.Add(matSizer,0,WACV|wx.LEFT,5)
    867878                valSizer = wx.BoxSizer(wx.HORIZONTAL)
     
    875886                    twinval.SetBackgroundColour(VERY_LIGHT_GREY)
    876887                valSizer.Add(twinval,0,WACV)
    877                 if it and len(Twin[0]):
     888                if it and 'bool' not in str(type(Twin[0])):
    878889                    twindel = wx.CheckBox(DData,wx.ID_ANY,label=' Delete?')
    879890                    Indx[twindel.GetId()] = it
  • trunk/GSASIIgrid.py

    r1907 r1915  
    6767    wxID_ATOMSMODIFY, wxID_ATOMSTRANSFORM, wxID_ATOMSVIEWADD, wxID_ATOMVIEWINSERT,
    6868    wxID_RELOADDRAWATOMS,wxID_ATOMSDISAGL,wxID_ATOMMOVE,wxID_MAKEMOLECULE,
    69     wxID_ASSIGNATMS2RB,wxID_ATOMSPDISAGL, wxID_ISODISP,
    70 ] = [wx.NewId() for item in range(15)]
     69    wxID_ASSIGNATMS2RB,wxID_ATOMSPDISAGL, wxID_ISODISP,wxID_ADDHATOM,
     70] = [wx.NewId() for item in range(16)]
    7171
    7272[ wxID_DRAWATOMSTYLE, wxID_DRAWATOMLABEL, wxID_DRAWATOMCOLOR, wxID_DRAWATOMRESETCOLOR,
     
    116116] = [wx.NewId() for item in range(6)]
    117117
    118 [ wxID_CONSTRAINTADD,wxID_EQUIVADD,wxID_HOLDADD,wxID_FUNCTADD,
     118[ wxID_CONSTRAINTADD,wxID_EQUIVADD,wxID_HOLDADD,wxID_FUNCTADD,wxID_ADDRIDING,
    119119  wxID_CONSPHASE, wxID_CONSHIST, wxID_CONSHAP, wxID_CONSGLOBAL,wxID_EQUIVALANCEATOMS,
    120 ] = [wx.NewId() for item in range(9)]
     120] = [wx.NewId() for item in range(10)]
    121121
    122122[ wxID_RESTRAINTADD, wxID_RESTSELPHASE,wxID_RESTDELETE, wxID_RESRCHANGEVAL,
     
    622622            help='Add equivalences between atom parameter values')
    623623        self.ConstraintEdit.Enable(wxID_EQUIVALANCEATOMS,False)
     624        self.ConstraintEdit.Append(id=wxID_ADDRIDING, kind=wx.ITEM_NORMAL,text='Add riding constraints',
     625            help='Add riding constraints between atom parameter values')
     626        self.ConstraintEdit.Enable(wxID_ADDRIDING,False)
     627        wxID_ADDRIDING
    624628        self.PostfillDataMenu()
    625629
     
    11281132        self.AtomEdit.Append(id=wxID_ATOMVIEWINSERT, kind=wx.ITEM_NORMAL,text='Insert view point',
    11291133            help='Select atom row to insert before; inserted as an H atom')
     1134        self.AtomEdit.Append(id=wxID_ADDHATOM, kind=wx.ITEM_NORMAL,text='Insert H atoms',
     1135            help='Insert H atoms in standard positions bonded to selected atoms')
    11301136        self.AtomEdit.Append(id=wxID_ATOMMOVE, kind=wx.ITEM_NORMAL,text='Move atom to view point',
    11311137            help='Select single atom to move')
     
    14191425    if 'UsrReject' not in data:
    14201426        data['UsrReject'] = {'minF/sig':0,'MinExt':0.01,'MaxDF/F':20.,'MaxD':500.,'MinD':0.05}
    1421      
     1427    if 'HatomFix' not in data:
     1428        data['HatomFix'] = False
    14221429   
    14231430    #end patch
     
    15091516        def OnFsqRef(event):
    15101517            data['F**2'] = fsqRef.GetValue()
     1518           
     1519        def OnHatomFix(event):
     1520            data['HatomFix'] = Hfix.GetValue()
    15111521       
    15121522        def OnUsrRej(event):
     
    15671577                usrrej.Bind(wx.EVT_KILL_FOCUS,OnUsrRej)
    15681578                LSSizer.Add(usrrej,0,WACV)
     1579        Hfix = wx.CheckBox(G2frame.dataDisplay,-1,label='Regularize H atoms? ')
     1580        Hfix.SetValue(data['HatomFix'])
     1581        Hfix.Bind(wx.EVT_CHECKBOX,OnHatomFix)
     1582#        LSSizer.Add(Hfix,0,WACV)   #for now
    15691583        return LSSizer
    15701584       
  • trunk/GSASIIobj.py

    r1884 r1915  
    873873    'min dM/M':0.0001,'shift factor':1.,'max cyc':3,'F**2':False,
    874874    'UsrReject':{'minF/sig':0,'MinExt':0.01,'MaxDF/F':100.,'MaxD':500.,'MinD':0.05},
    875     'Copy2Next':False,'Reverse Seq':False,
     875    'Copy2Next':False,'Reverse Seq':False,'HatomFix':False,
    876876    'Author':'no name',
    877877    'FreePrm1':'Sample humidity (%)',
  • trunk/GSASIIphsGUI.py

    r1908 r1915  
    14481448        Items = [G2gd.wxID_ATOMSEDITINSERT,G2gd.wxID_ATOMSEDITDELETE,G2gd.wxID_ATOMSREFINE,
    14491449            G2gd.wxID_ATOMSMODIFY,G2gd.wxID_ATOMSTRANSFORM,G2gd.wxID_MAKEMOLECULE,
    1450             G2gd.wxID_ATOMVIEWINSERT,G2gd.wxID_ATOMMOVE]
     1450            G2gd.wxID_ATOMVIEWINSERT,G2gd.wxID_ATOMMOVE,G2gd.wxID_ADDHATOM]
    14511451        if atomData:
    14521452            for item in Items:   
     
    15351535            FillAtomsGrid(Atoms)
    15361536        event.StopPropagation()
     1537       
     1538    def OnHydAtomAdd(event):
     1539        print "Doesn't do anything yet!"
     1540        indx = Atoms.GetSelectedRows()
     1541        if indx:
     1542            DisAglData['OrigIndx'] = indx
     1543            if 'DisAglCtls' in generalData:
     1544                DisAglCtls = generalData['DisAglCtls']
     1545            dlg = G2gd.DisAglDialog(G2frame,DisAglCtls,generalData)
     1546            if dlg.ShowModal() == wx.ID_OK:
     1547                DisAglCtls = dlg.GetData()
     1548            else:
     1549                dlg.Destroy()
     1550                return
     1551            dlg.Destroy()
     1552            generalData['DisAglCtls'] = DisAglCtls
     1553            atomData = data['Atoms']
     1554            generalData = data['General']
     1555            colLabels = [Atoms.GetColLabelValue(c) for c in range(Atoms.GetNumberCols())]
     1556            for ind in indx:
     1557                atom = atomData[ind]
    15371558       
    15381559    def OnAtomMove(event):
     
    38853906        for i in result:
    38863907            histoName = TextList[i]
     3908            Id = G2gd.GetPatternTreeItemId(G2frame,G2frame.root,histoName)
     3909            refDict,reflData = G2frame.PatternTree.GetItemPyData(Id)
    38873910            UseList[histoName] = {'Histogram':histoName,'Show':False,'Scale':[1.0,True],
    38883911                'Babinet':{'BabA':[0.0,False],'BabU':[0.0,False]},
     
    38903913                {'Tbar':0.1,'Cos2TM':0.955,'Eg':[1.e-7,False],'Es':[1.e-7,False],'Ep':[1.e-7,False]},],
    38913914                'Flack':[0.0,False],'Twins':[[np.array([[1,0,0],[0,1,0],[0,0,1]]),[1.0,False]],]}                       
     3915            for iT in range(reflData.get('TwMax',0)):
     3916                UseList[histoName]['Twins'].append([False,0.0])
    38923917            UpdateHKLFdata(histoName)
    38933918            data['Histograms'] = UseList
     
    61676192        G2frame.dataFrame.Bind(wx.EVT_MENU, OnAtomInsert, id=G2gd.wxID_ATOMSEDITINSERT)
    61686193        G2frame.dataFrame.Bind(wx.EVT_MENU, OnAtomViewInsert, id=G2gd.wxID_ATOMVIEWINSERT)
     6194        G2frame.dataFrame.Bind(wx.EVT_MENU, OnHydAtomAdd, id=G2gd.wxID_ADDHATOM)
    61696195        G2frame.dataFrame.Bind(wx.EVT_MENU, OnAtomMove, id=G2gd.wxID_ATOMMOVE)
    61706196        G2frame.dataFrame.Bind(wx.EVT_MENU, AtomDelete, id=G2gd.wxID_ATOMSEDITDELETE)
  • trunk/GSASIIstrIO.py

    r1910 r1915  
    599599    else:
    600600        print >>pFile,' Minimum delta-M/M for convergence: ','%.2g'%(Controls['min dM/M'])
     601    print >>pFile,' Regularize hydrogens (if any):',Controls.get('HatomFix',False)
    601602    print >>pFile,' Initial shift factor: ','%.3f'%(Controls['shift factor'])
    602603    if SeqRef:
     
    22652266                controlDict[pfx+'TwinLaw'] = []               
    22662267                for it,twin in enumerate(Twins):
    2267                     if len(twin[0]):
     2268                    if 'bool' in str(type(twin[0])):
     2269                        controlDict[pfx+'TwinLaw'].append(np.zeros((3,3)))
     2270                    else:
    22682271                        controlDict[pfx+'TwinLaw'].append(twin[0])
    2269                     else:
    2270                         controlDict[pfx+'TwinLaw'].append(np.zeros((3,3)))
    22712272                    if it:
    22722273                        hapDict[pfx+'TwinFr:'+str(it)] = twin[1]
     
    22962297                    if len(Twins) > 1:
    22972298                        for it,twin in enumerate(Twins):
    2298                             if len(twin[0]):
     2299                            if 'bool' in str(type(twin[0])):
     2300                                print >>pFile,' Nonmerohedral twin fr.: %5.3f Refine? '%(hapDict[pfx+'TwinFr:'+str(it)]),Twins[0][1][1]
     2301                            else:
    22992302                                print >>pFile,' Twin law: %s'%(str(twin[0]).replace('\n',',')),' Twin fr.: %5.3f Refine? '%(hapDict[pfx+'TwinFr:'+str(it)]),Twins[0][1][1]
    2300                             else:
    2301                                 print >>pFile,' Nonmerohedral twin fr.: %5.3f Refine? '%(hapDict[pfx+'TwinFr:'+str(it)]),Twins[0][1][1]
    23022303                       
    23032304                Histogram['Reflection Lists'] = phase       
  • trunk/GSASIIstrMath.py

    r1914 r1915  
    26572657    G2mv.Dict2Map(parmDict,varylist)
    26582658    Histograms,Phases,restraintDict,rigidbodyDict = HistoPhases
     2659    #fixup H atom positions here?
    26592660    ApplyRBModels(parmDict,Phases,rigidbodyDict)        #,Update=True??
    26602661    nvar = len(varylist)
     
    27332734    Next = 0
    27342735    ApplyRBModels(parmDict,Phases,rigidbodyDict)
     2736    #fixup Hatom positions here....
    27352737    histoList = Histograms.keys()
    27362738    histoList.sort()
  • trunk/imports/G2sfact.py

    r1913 r1915  
    8585            return False
    8686
    87 class HKLF4_ReaderClass(G2IO.ImportStructFactor):
    88     'Routines to import F**2, sig(F**2) reflections from a HKLF 4 file'
     87class SHELX4_ReaderClass(G2IO.ImportStructFactor):
     88    'Routines to import F**2, sig(F**2) reflections from a Shelx HKLF 4 file'
    8989    def __init__(self):
    9090        if 'linux' in sys.platform:  # wx 3.0.0.0 on gtk does not like Unicode in menus
     
    149149
    150150    def ContentsValidator(self, filepointer):
    151         'Discover how many characters are in the SHELX file - could be 32-44 depending on satellites'
    152         numCols = 0     #this needs to be done differently
     151        '''Discover how many columns before F^2 are in the SHELX HKL5 file
     152        - could be 3-6 depending on satellites'''
     153        numCols = 0
    153154        for i,line in enumerate(filepointer):
    154             numCols = max(numCols,len(line.split()))
     155            for j,item in enumerate(line.split()):  #find 1st col with '.'; has F^2
     156                if '.' in item:
     157                    numCols = max(numCols,j)
     158                    break
    155159            if i > 20:
    156160                break
    157         self.Super = numCols-6     #= 0,1,2,or 3
     161        self.Super = numCols-3     #= 0,1,2,or 3
    158162        if self.Super > 1:
    159163            raise self.ImportException("Supersymmetry too high; GSAS-II limited to (3+1) supersymmetry")           
    160         return True #ColumnValidator(self, filepointer)
     164        return True
    161165
    162166    def Reader(self,filename,filepointer, ParentFrame=None, **unused):
Note: See TracChangeset for help on using the changeset viewer.