Changeset 1898


Ignore:
Timestamp:
Jun 19, 2015 3:59:22 PM (7 years ago)
Author:
vondreele
Message:

new constraint option - constrain atom variables as a set; constrain sum of frac & equivalence all other parameters - intended for multiple atoms on same site
fix bug in instrument parms flag copy

Location:
trunk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/GSASIIconstrGUI.py

    r1831 r1898  
    676676        legend = "Select variables to make equivalent (only one of the variables will be varied when all are set to be varied)"
    677677        GetAddVars(page,title1,title2,varList,constrDictEnt,'equivalence')
     678       
     679    def OnAddAtomEquiv(event):
     680        ''' Add equivalences between all parameters on atoms '''
     681        page = G2frame.Page
     682        vartype,varList,constrDictEnt = PageSelection(page)
     683        title1 = "Setup equivalent atom variables"
     684        title2 = "Select additional atoms(s) to be equivalent with "
     685        if not varList:
     686            G2frame.ErrorDialog('No variables','There are no variables of type '+vartype,
     687                                parent=G2frame.dataFrame)
     688            return
     689        legend = "Select atoms to make equivalent (only one of the atom variables will be varied when all are set to be varied)"
     690        GetAddAtomVars(page,title1,title2,varList,constrDictEnt,'equivalence')
    678691   
    679692    def OnAddFunction(event):
     
    729742                    data[constrDictEnt] += newcons
    730743        dlg.Destroy()
     744        OnPageChanged(None)
     745                       
     746    def GetAddAtomVars(page,title1,title2,varList,constrDictEnt,constType):
     747        '''Get the atom variables to be added for OnAddAtomEquiv. Then create and
     748        check the constraints.
     749        '''
     750        Atoms = {G2obj.VarDescr(i)[0]:[] for i in varList if 'Atom' in G2obj.VarDescr(i)[0]}
     751        for item in varList:
     752            atName = G2obj.VarDescr(item)[0]
     753            if atName in Atoms:
     754                Atoms[atName].append(item)
     755        AtNames = Atoms.keys()
     756        AtNames.sort()
     757        dlg = G2G.G2SingleChoiceDialog(G2frame.dataFrame,'Select 1st atom:',
     758                                      title1,AtNames,
     759                                      monoFont=True,size=(625,400))
     760        dlg.CenterOnParent()
     761        FrstAtom = ''
     762        if dlg.ShowModal() == wx.ID_OK:
     763            sel = dlg.GetSelection()
     764            FrstAtom = AtNames[sel]
     765            AtNames.remove(FrstAtom)
     766        dlg.Destroy()
     767        if FrstAtom == '':
     768            print 'no atom selected'
     769            return
     770        dlg = G2G.G2MultiChoiceDialog(
     771            G2frame.dataFrame,title2+FrstAtom,
     772            'Constrain '+str(FrstAtom)+' with...',AtNames,
     773            toggle=False,size=(625,400),monoFont=True)
     774        if dlg.ShowModal() == wx.ID_OK:
     775            Selections = dlg.GetSelections()[:]
     776        dlg.Destroy()
     777        for name in Atoms[FrstAtom]:
     778            newcons = []
     779            constr = [[1.0,G2obj.G2VarObj(name)]]
     780            pref = name.rsplit(':',1)[0]
     781            for sel in Selections:
     782                id = Atoms[AtNames[sel]][0].rsplit(':',1)[-1]
     783                constr += [[1.0,G2obj.G2VarObj('%s:%s'%(pref,id))]]
     784            if 'frac' in pref:
     785                newcons = [constr+[1.0,None,'c']]
     786            else:
     787                newcons = [constr+[None,None,'e']]
     788            if len(newcons) > 0:
     789                if CheckAddedConstraint(newcons):
     790                    data[constrDictEnt] += newcons
    731791        OnPageChanged(None)
    732792                       
     
    9501010        oldPage = G2frame.dataDisplay.ChangeSelection(page)
    9511011        text = G2frame.dataDisplay.GetPageText(page)
     1012        G2frame.dataFrame.ConstraintEdit.Enable(G2gd.wxID_EQUIVALANCEATOMS,False)
    9521013        if text == 'Histogram/Phase constraints':
    9531014            G2frame.Page = [page,'hap']
     
    9581019        elif text == 'Phase constraints':
    9591020            G2frame.Page = [page,'phs']
     1021            G2frame.dataFrame.ConstraintEdit.Enable(G2gd.wxID_EQUIVALANCEATOMS,True)
    9601022            UpdateConstraintPanel(PhaseConstr,'Phase')
    9611023        elif text == 'Global constraints':
     
    9911053    G2frame.dataFrame.Bind(wx.EVT_MENU, OnAddEquivalence, id=G2gd.wxID_EQUIVADD)
    9921054    G2frame.dataFrame.Bind(wx.EVT_MENU, OnAddHold, id=G2gd.wxID_HOLDADD)
     1055    G2frame.dataFrame.Bind(wx.EVT_MENU, OnAddAtomEquiv, id=G2gd.wxID_EQUIVALANCEATOMS)
    9931056    # tab commands
    9941057    for id in (G2gd.wxID_CONSPHASE,
  • trunk/GSASIIgrid.py

    r1894 r1898  
    117117
    118118[ wxID_CONSTRAINTADD,wxID_EQUIVADD,wxID_HOLDADD,wxID_FUNCTADD,
    119   wxID_CONSPHASE, wxID_CONSHIST, wxID_CONSHAP, wxID_CONSGLOBAL,
    120 ] = [wx.NewId() for item in range(8)]
     119  wxID_CONSPHASE, wxID_CONSHIST, wxID_CONSHAP, wxID_CONSGLOBAL,wxID_EQUIVALANCEATOMS,
     120] = [wx.NewId() for item in range(9)]
    121121
    122122[ wxID_RESTRAINTADD, wxID_RESTSELPHASE,wxID_RESTDELETE, wxID_RESRCHANGEVAL,
     
    619619        self.ConstraintEdit.Append(id=wxID_FUNCTADD, kind=wx.ITEM_NORMAL,text='Add New Var',
    620620            help='Add variable composed of existing parameter')
     621        self.ConstraintEdit.Append(id=wxID_EQUIVALANCEATOMS, kind=wx.ITEM_NORMAL,text='Add atom equivalence',
     622            help='Add equivalences between atom parameter values')
     623        self.ConstraintEdit.Enable(wxID_EQUIVALANCEATOMS,False)
    621624        self.PostfillDataMenu()
    622625
  • trunk/GSASIIplot.py

    r1894 r1898  
    24852485#    sig = lambda Th,U,V,W: 1.17741*math.sqrt(U*tand(Th)**2+V*tand(Th)+W)*math.pi/18000.
    24862486#    gam = lambda Th,X,Y: (X/cosd(Th)+Y*tand(Th))*math.pi/18000.
    2487     gamFW = lambda s,g: np.exp(np.log(s**5+2.69269*s**4*g+2.42843*s**3*g**2+4.47163*s**2*g**3+0.07842*s*g**4+g**5)/5.)
     2487#    gamFW = lambda s,g: np.exp(np.log(s**5+2.69269*s**4*g+2.42843*s**3*g**2+4.47163*s**2*g**3+0.07842*s*g**4+g**5)/5.)
    24882488#    gamFW2 = lambda s,g: math.sqrt(s**2+(0.4654996*g)**2)+.5345004*g  #Ubaldo Bafile - private communication
    24892489    PatternId = G2frame.PatternId
  • trunk/GSASIIpwd.py

    r1893 r1898  
    479479   
    480480def getFWHM(pos,Inst):
    481     'needs a doc string'
    482     sig = lambda Th,U,V,W: 1.17741*math.sqrt(max(0.001,U*tand(Th)**2+V*tand(Th)+W))*math.pi/180.
     481    '1.17741*pi/180 = sqrt(8ln2)/(2pi/180)'
     482    sig = lambda Th,U,V,W: 1.17741*np.sqrt(max(0.001,U*tand(Th)**2+V*tand(Th)+W))*np.pi/180.
    483483    sigTOF = lambda dsp,S0,S1,S2,Sq:  S0+S1*dsp**2+S2*dsp**4+Sq/dsp**2
    484484    gam = lambda Th,X,Y: (X/cosd(Th)+Y*tand(Th))*math.pi/180.
  • trunk/GSASIIpwdGUI.py

    r1895 r1898  
    13111311            return
    13121312        keys = data.keys()
     1313        try:
     1314            keys.remove('Source')
     1315        except ListError:
     1316            pass
    13131317        flags = dict(zip(keys,[data[key][2] for key in keys]))
    13141318        instType = data['Type'][0]
     
    13291333            if len(data) == len(instData) and instType == instData['Type'][0]:   #don't mix data types or lam & lam1/lam2 parms!
    13301334                for item in instData:
    1331                     instData[item][2] = copy.copy(flags[item])
     1335                    if item not in ['Source',]:
     1336                        instData[item][2] = copy.copy(flags[item])
    13321337            else:
    13331338                print item+' not copied - instrument parameters not commensurate'
Note: See TracChangeset for help on using the changeset viewer.