Changeset 1924


Ignore:
Timestamp:
Jul 9, 2015 5:00:23 PM (7 years ago)
Author:
vondreele
Message:

work on H-atom riding constraints
extend "short" phase names to full length - needed for riding constraint development

Location:
trunk
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/GSASIIconstrGUI.py

    r1915 r1924  
    3030import GSASIIstrIO as G2stIO
    3131import GSASIImapvars as G2mv
     32import GSASIImath as G2mth
     33import GSASIIlattice as G2lat
    3234import GSASIIgrid as G2gd
    3335import GSASIIctrls as G2G
     
    702704        legend = "Select atoms to ride (only one of the atom variables will be varied when all are set to be varied)"
    703705        GetAddAtomVars(page,title1,title2,varList,constrDictEnt,'riding')
    704        
    705        
    706706   
    707707    def OnAddFunction(event):
     
    759759        OnPageChanged(None)
    760760                       
     761    def FindNeighbors(phase,FrstName,AtNames):
     762        General = phase['General']
     763        cx,ct,cs,cia = General['AtomPtrs']
     764        Atoms = phase['Atoms']
     765        atNames = [atom[ct-1] for atom in Atoms]
     766        Cell = General['Cell'][1:7]
     767        Amat,Bmat = G2lat.cell2AB(Cell)
     768        atTypes = General['AtomTypes']
     769        Radii = np.array(General['BondRadii'])
     770        AtInfo = dict(zip(atTypes,Radii)) #or General['BondRadii']
     771        Orig = atNames.index(FrstName.split()[1])
     772        OType = Atoms[Orig][ct]
     773        XYZ = G2mth.getAtomXYZ(Atoms,cx)       
     774        Neigh = []
     775        Dx = np.inner(Amat,XYZ-XYZ[Orig]).T
     776        dist = np.sqrt(np.sum(Dx**2,axis=1))
     777        sumR = AtInfo[OType]+0.5
     778        IndB = ma.nonzero(ma.masked_greater(dist-0.85*sumR,0.))
     779        for j in IndB[0]:
     780            if j != Orig:
     781                Neigh.append(AtNames[j])
     782        return Neigh
     783       
    761784    def GetAddAtomVars(page,title1,title2,varList,constrDictEnt,constType):
    762785        '''Get the atom variables to be added for OnAddAtomEquiv. Then create and
    763         check the constraints.
     786        check the constraints. Riding for H atoms only.
    764787        '''
    765788        Atoms = {G2obj.VarDescr(i)[0]:[] for i in varList if 'Atom' in G2obj.VarDescr(i)[0]}
     
    778801            sel = dlg.GetSelection()
    779802            FrstAtom = AtNames[sel]
    780             AtNames.remove(FrstAtom)
     803            if 'riding' in constType:
     804                phaseName = (FrstAtom.split(' in ')[1]).strip()
     805                phase = Phases[phaseName]
     806                AtNames = FindNeighbors(phase,FrstAtom,AtNames)
     807            else:
     808                AtNames.remove(FrstAtom)
    781809        dlg.Destroy()
    782810        if FrstAtom == '':
     
    796824        for name in Atoms[FrstAtom]:
    797825            newcons = []
    798             constr = [[1.0,G2obj.G2VarObj(name)]]
     826            constr = []
     827            if 'riding' in constType:
     828                if 'AU11' in name or 'AUiso' in name:
     829                    parts = name.split('AU11').split('AUiso')
     830                    constr = [[1.0,G2obj.G2VarObj(parts[0]+'AUiso'+parts[1])]]
     831                elif 'AU' not in name:
     832                    constr = [[1.0,G2obj.G2VarObj(name)]]
     833            else:
     834                constr = [[1.0,G2obj.G2VarObj(name)]]
    799835            pref = name.rsplit(':',1)[0]
    800             if 'riding' in constType and 'U' in pref:
    801                 continue
    802836            for sel in Selections:
    803837                id = Atoms[AtNames[sel]][0].rsplit(':',1)[-1]
    804                 constr += [[1.0,G2obj.G2VarObj('%s:%s'%(pref,id))]]
     838                if 'riding' in constType:
     839                    if 'AU11' in pref or 'AUiso' in pref:
     840                        constr += [[1.2,G2obj.G2VarObj('%s:%s'%(parts[0]+'AUiso',id))]]
     841                    elif 'AU' not in pref:
     842                        constr += [[1.0,G2obj.G2VarObj('%s:%s'%(pref,id))]]
     843                else:
     844                    constr += [[1.0,G2obj.G2VarObj('%s:%s'%(pref,id))]]
     845            if not constr:
     846                continue
    805847            if 'frac' in pref and 'riding' not in constType:
    806848                newcons = [constr+[1.0,None,'c']]
  • trunk/GSASIIgrid.py

    r1917 r1924  
    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')
     624        self.ConstraintEdit.Append(id=wxID_ADDRIDING, kind=wx.ITEM_NORMAL,text='Add H riding constraints',
     625            help='Add H atom riding constraints between atom parameter values')
    626626        self.ConstraintEdit.Enable(wxID_ADDRIDING,False)
    627627        wxID_ADDRIDING
  • trunk/GSASIIobj.py

    r1915 r1924  
    996996        PhaseIdLookup[pId] = (ph,ranId)
    997997        PhaseRanIdLookup[ranId] = pId
    998         shortname = ph[:10]
     998        shortname = ph  #[:10]
    999999        while shortname in ShortPhaseNames.values():
    10001000            shortname = ph[:8] + ' ('+ pId + ')'
  • trunk/GSASIIphsGUI.py

    r1918 r1924  
    15401540        indx = Atoms.GetSelectedRows()
    15411541        if indx:
    1542             DisAglData['OrigIndx'] = indx
     1542            generalData = data['General']
    15431543            if 'DisAglCtls' in generalData:
    15441544                DisAglCtls = generalData['DisAglCtls']
     
    15521552            generalData['DisAglCtls'] = DisAglCtls
    15531553            atomData = data['Atoms']
    1554             generalData = data['General']
    15551554            colLabels = [Atoms.GetColLabelValue(c) for c in range(Atoms.GetNumberCols())]
    15561555            for ind in indx:
  • trunk/GSASIIstrMath.py

    r1923 r1924  
    602602            if parm in parmDict:
    603603                keys[key][iatm] = parmDict[parm]
    604     Fdata = np.where(Fdata,Fdata,1.e-8)         #avoid divide by zero in derivative calc.?
     604    Fdata = np.where(Fdata,Fdata,1.e-8)         #avoid divide by zero in derivative calc.
    605605    return Tdata,Mdata,Fdata,Xdata,dXdata,IAdata,Uisodata,Uijdata
    606606   
  • trunk/imports/G2sfact.py

    r1917 r1924  
    196196                else:
    197197                    if Tw != '1':  #fix reversed twin ids
     198                        if first:
     199                            self.warnings += '\nPrimary twin id changed to 1\nNB: multiple primary twins not working'
     200                            first = False
    198201                        Tw = '1'
    199202                    TwId = int(Tw)-1
Note: See TracChangeset for help on using the changeset viewer.