Changeset 4824


Ignore:
Timestamp:
Feb 20, 2021 2:44:46 PM (3 years ago)
Author:
vondreele
Message:

add new refinable RB parameter for atom site fraction - always there; can be used in constraints.. Available for residue & vector style RBs
fixes to delete RB routines
fixes to RB naming when adding RB to structure
Implement use of view position for new RB origin

Location:
trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/GSASIIobj.py

    r4823 r4824  
    601601                  :ref:`Rigid Body Objects <RBData_table>`
    602602RBname            The name for the rigid body (str)
     603AtomFrac          The atom fractions for the rigid body
    603604ThermalMotion     The thermal motion description for the rigid body, which includes a choice for
    604605                  the model and can include TLS parameters or an overall Uiso value.
  • trunk/GSASIIphsGUI.py

    r4820 r4824  
    34343434            colR = colLabels.index('refine')
    34353435            colSS = colLabels.index('site sym')
     3436            colF = colLabels.index('frac')
    34363437            colX = colLabels.index('x')
    34373438            colIA = colLabels.index('I/A')
     
    34473448            attr.IncRef()               #fix from Jim Hester
    34483449            attr.SetEditor(G2G.GridFractionEditor(Atoms))
    3449             for c in range(colX,colX+3):
     3450            for c in range(colX,colX+4):
    34503451                attr = wx.grid.GridCellAttr()
    34513452                attr.IncRef()               #fix from Jim Hester
     
    35013502                                saveCSI = CSI[0][i]
    35023503                            Atoms.SetCellTextColour(row,ci,BLACK)
     3504                if 'F' in rbExcl:
     3505                    Atoms.SetCellStyle(row,colF,VERY_LIGHT_GREY,True)
    35033506                if 'X' in rbExcl:
    35043507                    for c in range(0,colX+3):
     
    35113514            SetPhaseWindow(Atoms,Scroll=Atoms.GetScrollPos(wx.VERTICAL))
    35123515
    3513 #### FillAtomsGrid executable code starts here
     3516#### onSetOrigin.
    35143517        if not data['Drawing']:                 #if new drawing - no drawing data!
    35153518            SetupDrawingData()
     
    35223525        rbAtmDict = {}
    35233526        for rbObj in resRBData+vecRBData:
    3524             exclList = ['X' for i in range(len(rbObj['Ids']))]
     3527            exclList = ['FX' for i in range(len(rbObj['Ids']))]
    35253528            rbAtmDict.update(dict(zip(rbObj['Ids'],exclList)))
    35263529            if rbObj['ThermalMotion'][0] != 'None':
    35273530                for id in rbObj['Ids']:
    35283531                    rbAtmDict[id] += 'U'           
    3529         # exclList will be 'x' or 'xu' if TLS used in RB
     3532        # exclList will be 'fx' or 'fxu' if TLS used in RB
    35303533        Items = [G2G.wxID_ATOMSEDITINSERT,G2G.wxID_ATOMSEDITDELETE,
    35313534            G2G.wxID_ATOMSMODIFY,G2G.wxID_ATOMSTRANSFORM,G2G.wxID_MAKEMOLECULE,
     
    99479950                    typeHint=float,OnLeave=OnOrigX,xmin=-1,xmax=1.,size=(70,-1))
    99489951                topSizer.Add(origX,0,WACV)
    9949             topSizer.Add((5,0),)
    99509952            Ocheck = wx.CheckBox(RigidBodies,-1,'Refine?')
    99519953            Ocheck.Bind(wx.EVT_CHECKBOX,OnOrigRef)
     
    99539955            topSizer.Add(Ocheck,0,WACV)
    99549956            topSizer.Add(wx.StaticText(RigidBodies,-1,
    9955                     'Rotation angle (deg)\n&& Orient. vector (frac)'),0,WACV)
     9957                'Rotation angle (deg)\n&& Orient. vector (frac)'),0,WACV)
    99569958            Indx['Orien'] = {}
    99579959            Orien,OrienV = G2mth.Q2AVdeg(RBObj['Orient'][0])
     
    99779979                         
    99789980        def ResrbSizer(RBObj,resIndx):
    9979             '''Displays details for selected rigid body'''
     9981            '''Displays details for selected residue rigid body'''
    99809982            def OnTorsionRef(event):
    99819983                Obj = event.GetEventObject()
     
    99929994                G2plt.PlotStructure(G2frame,data)
    99939995               
     9996            def OnFrac(invalid,value,tc):
     9997                for i,Id in enumerate(RBObj['Ids']):
     9998                    if data['Atoms'][AtLookUp[Id]][cx+3]:
     9999                        data['Atoms'][AtLookUp[Id]][cx+3] = value
     10000                       
     10001            def OnRefFrac(event):
     10002                RBObj['AtomFrac'][1] = not RBObj['AtomFrac'][1]
     10003               
    999410004            def OnDelResRB(event):
    999510005                Obj = event.GetEventObject()
    999610006                RBId = Indx[Obj.GetId()]
    9997                 RBObjs = data['RBModels']['Residue']
    9998                 for i,rbObj in enumerate(RBObjs):
    9999                     if RBId == rbObj['RBId']:
    10000                         RBData['Residue'][RBId]['useCount'] -= 1
    10001                         del data['RBModels']['Residue'][i]
     10007                RBData['Residue'][RBId]['useCount'] -= 1
     10008                del data['RBModels']['Residue'][resIndx]
    1000210009                G2plt.PlotStructure(G2frame,data)
    1000310010                wx.CallAfter(FillRigidBodyGrid,True)
     
    1004710054                torSizer.Add(torCheck,0,WACV)
    1004810055            resrbSizer.Add(torSizer)
     10056            members = 'Rigid body members: '
     10057            for Id in RBObj['Ids']:
     10058                members += data['Atoms'][AtLookUp[Id]][ct-1].strip()+', '
     10059            resrbSizer.Add(wx.StaticText(RigidBodies,label=members[:-2]),0,WACV)
     10060            fracSizer = wx.BoxSizer(wx.HORIZONTAL)
     10061            fracSizer.Add(wx.StaticText(RigidBodies,label='Rigid Body atom site fraction: '))
     10062            fracTxt = G2G.ValidatedTxtCtrl(RigidBodies,RBObj['AtomFrac'],0,nDig=(10,3),OnLeave=OnFrac)
     10063            fracSizer.Add(fracTxt,0,WACV)
     10064            fracRef = wx.CheckBox(RigidBodies,label='Refine?')
     10065            fracRef.SetValue(RBObj['AtomFrac'][1])
     10066            fracRef.Bind(wx.EVT_CHECKBOX,OnRefFrac)
     10067            fracSizer.Add(fracRef,0,WACV)
     10068            resrbSizer.Add(fracSizer)
    1004910069            tchoice = ['None','Uiso','T','TL','TLS']
    1005010070            thermSizer = wx.BoxSizer(wx.HORIZONTAL)
     
    1006210082           
    1006310083        def VecrbSizer(RBObj):
     10084            '''Displays details for selected vector rigid body'''
     10085            def OnFrac(invalid,value,tc):
     10086                for Id in RBObj['Ids']:
     10087                    if data['Atoms'][AtLookUp[Id]][cx+3]:
     10088                        data['Atoms'][AtLookUp[Id]][cx+3] = value
     10089                       
     10090            def OnRefFrac(event):
     10091                RBObj['AtomFrac'][1] = not RBObj['AtomFrac'][1]
     10092               
    1006410093            def OnDelVecRB(event):
    1006510094                Obj = event.GetEventObject()
    1006610095                RBId = Indx[Obj.GetId()]
    1006710096                RBData['Vector'][RBId]['useCount'] -= 1               
    10068                 RBObjs = data['RBModels']['Vector']
    10069                 for rbObj in RBObjs:
    10070                     if RBId == rbObj['RBId']:
    10071                        data['RBModels']['Vector'].remove(rbObj)                 
     10097                del data['RBModels']['Vector'][resIndx]
    1007210098                G2plt.PlotStructure(G2frame,data)
    1007310099                wx.CallAfter(FillRigidBodyGrid,True)
     
    1008510111            vecrbSizer.Add(topLine)
    1008610112            vecrbSizer.Add(LocationSizer(RBObj,'Vector'))
     10113            members = 'Rigid body members: '
     10114            for Id in RBObj['Ids']:
     10115                members += data['Atoms'][AtLookUp[Id]][ct-1].strip()+', '
     10116            vecrbSizer.Add(wx.StaticText(RigidBodies,label=members[:-2]),0,WACV)
     10117            fracSizer = wx.BoxSizer(wx.HORIZONTAL)
     10118            fracSizer.Add(wx.StaticText(RigidBodies,label='Rigid Body atom site fraction: '))
     10119            fracTxt = G2G.ValidatedTxtCtrl(RigidBodies,RBObj['AtomFrac'],0,nDig=(10,3),OnLeave=OnFrac)
     10120            fracSizer.Add(fracTxt,0,WACV)
     10121            fracRef = wx.CheckBox(RigidBodies,label='Refine?')
     10122            fracRef.SetValue(RBObj['AtomFrac'][1])
     10123            fracRef.Bind(wx.EVT_CHECKBOX,OnRefFrac)
     10124            fracSizer.Add(fracRef,0,WACV)
     10125            vecrbSizer.Add(fracSizer)
    1008710126            tchoice = ['None','Uiso','T','TL','TLS']
    1008810127            thermSizer = wx.BoxSizer(wx.HORIZONTAL)
     
    1016610205            resVarLookup = []
    1016710206            for irb,RBObj in enumerate(data['RBModels']['Residue']):
     10207                # patch
     10208                if 'AtomFrac' not in RBObj:
     10209                    RBObj['AtomFrac'] = [1.0,False]
     10210                #end patch
    1016810211                name = RBObj['RBname']+RBObj['numChain']
    1016910212                RBnames.append(name)
     
    1019710240            RBnames = []
    1019810241            for RBObj in data['RBModels']['Vector']:
     10242                # patch
     10243                if 'AtomFrac' not in RBObj:
     10244                    RBObj['AtomFrac'] = [1.0,False]
     10245                #end patch
    1019910246                RBnames.append(RBObj['RBname'])
    1020010247            if prevVecId is not None:
     
    1024810295        if dlg.ShowModal() == wx.ID_OK:
    1024910296            sel = dlg.GetSelection()
    10250             for item in ['Orig','Orient','ThermalMotion']:
     10297            for item in ['Orig','Orient','ThermalMotion','AtomFract']:
    1025110298                sourceRB.update({item:RBObjs[sel][item],})
    1025210299        dlg.Destroy()
     
    1039210439                    UpdateDrawAtoms()
    1039310440                    G2plt.PlotStructure(G2frame,data)
    10394                    
     10441               
    1039510442                rbType = data['testRBObj']['rbType']
    10396                 rbObj['Ids'] = Ids
    10397                 rbId = rbObj['RBId']
     10443                rbNames = []
     10444                for item in data['RBModels'][rbType]:
     10445                    rbNames.append(item['RBname'])
     10446                rbObj['Ids'] = Ids          #atomids
     10447                rbId = rbObj['RBId']        #RB obj id
     10448                rbObj['AtomFract'] = [1.0,False]
    1039810449                rbObj['ThermalMotion'] = ['None',[0. for i in range(21)],[False for i in range(21)]] #type,values,flags
    10399                 rbObj['RBname'] += ':'+str(RBData[rbType][rbId]['useCount'])
     10450                i = 0
     10451                while True:     #find unique name
     10452                    rbName = '%s:%d'%(rbObj['RBname'],i)
     10453                    if rbName in rbNames:
     10454                        i += 1
     10455                    else:
     10456                        break
     10457                rbObj['RBname'] = rbName
    1040010458                if type(rbObj['Orig'][0]) is tuple:      # patch because somehow adding RB origin is becoming a tuple               
    1040110459                    if GSASIIpath.GetConfigValue('debug'): print('patching origin!')
     
    1066110719                    axis = np.array(axis)/nl.norm(axis)
    1066210720                data['testRBObj']['rbObj']['symAxis'] = axis
     10721                UpdateTablePlot()
     10722               
     10723            def OnOrigSet(event):
     10724                data['testRBObj']['rbObj']['Orig'][0] = data['Drawing']['viewPoint'][0]
     10725                for i,item in enumerate(Xsizers):
     10726                    item.SetValue(data['testRBObj']['rbObj']['Orig'][0][i])
    1066310727                UpdateTablePlot()
    1066410728               
     
    1077310837            fixOrig = G2G.G2CheckBox(RigidBodies,'Lock',rbObj,'fixOrig')
    1077410838            OriSizer.Add(fixOrig,0,WACV,10)
    10775             mainSizer.Add(OriSizer)
     10839            if not rbObj['fixOrig']:
     10840                origSet = wx.Button(RigidBodies,label='Set to view point')
     10841                origSet.Bind(wx.EVT_BUTTON,OnOrigSet)
     10842                OriSizer.Add(origSet,0,WACV)
     10843                mainSizer.Add(OriSizer)
    1077610844            Sytsym,Mult = G2spc.SytSym(rbObj['Orig'][0],data['General']['SGData'])[:2]
    1077710845            sytsymtxt = wx.StaticText(RigidBodies,label='Origin site symmetry: %s, multiplicity: %d '%(Sytsym,Mult))
     
    1113011198                    QuatC = G2mth.prodQQ(QuatB,QuatA)
    1113111199                    rbObj['Orient'] = [QuatC,' ']
     11200                    rbObj['AtomFract'] = [1.0,False]
    1113211201                    rbObj['ThermalMotion'] = ['None',[0. for i in range(21)],[False for i in range(21)]] #type,values,flags
    1113311202                    SXYZ = []
  • trunk/GSASIIstrIO.py

    r4823 r4824  
    11921192           
    11931193    def PrintRBObjects(resRBData,vecRBData):
    1194        
     1194               
    11951195        def PrintRBThermals():
    11961196            tlstr = ['11','22','33','12','13','23']
     
    12281228                pFile.write('Orientation angle,vector: %10.3f %10.4f %10.4f %10.4f Refine? %s\n'%
    12291229                    (Angle,Qrijk[1],Qrijk[2],Qrijk[3],RB['Orient'][1]))
     1230                pFile.write('Atom site frac: %10.3f Refine? %s\n'%(RB['AtomFrac'][0],RB['AtomFrac'][1]))
    12301231                Torsions = RB['Torsions']
    12311232                if len(Torsions):
     
    12441245                pFile.write('Orientation angle,vector: %10.3f %10.4f %10.4f %10.4f Refine? %s\n'%
    12451246                    (Angle,Qrijk[1],Qrijk[2],Qrijk[3],RB['Orient'][1]))
     1247                pFile.write('Atom site frac: %10.3f Refine? %s\n'%(RB['AtomFrac'][0],RB['AtomFrac'][1]))
    12461248                PrintRBThermals()
    12471249               
     
    13821384            elif RB['Orient'][1] == 'V' and i not in fixAxis:
    13831385                phaseVary += [name,]
     1386        name = pfx+'RB'+'f:'+str(iRB)+':'+rbid
     1387        phaseDict[name] = RB['AtomFrac'][0]
     1388        if RB['AtomFrac'][1]:
     1389            phaseVary += [name,]
     1390               
    13841391    def MakeRBThermals(rbKey,phaseVary,phaseDict):
    13851392        rbid = str(rbids.index(RB['RBId']))
     
    36463653        else:
    36473654            sigstr += 12*' '
     3655    name = pfx+'RBf:'+rbsx
     3656    namstr += '%12s'%('Frac')
     3657    valstr += '%12.5f'%(parmDict[name])
     3658    if name in sigDict:
     3659        sigstr += '%12.5f'%(sigDict[name])
     3660    else:
     3661        sigstr += 12*' '
    36483662    return (namstr,valstr,sigstr)
    36493663
  • trunk/GSASIIstrMath.py

    r4682 r4824  
    5252def ApplyRBModels(parmDict,Phases,rigidbodyDict,Update=False):
    5353    ''' Takes RB info from RBModels in Phase and RB data in rigidbodyDict along with
    54     current RB values in parmDict & modifies atom contents (xyz & Uij) of parmDict
     54    current RB values in parmDict & modifies atom contents (fxyz & Uij) of parmDict
    5555    '''
    5656    atxIds = ['Ax:','Ay:','Az:']
     
    9292                RBObj['Orient'][0][i] = parmDict[pfx+po+rbsx]
    9393            RBObj['Orient'][0] = G2mth.normQ(RBObj['Orient'][0])
     94            RBObj['AtomFrac'][0] = parmDict[pfx+'RBf:'+rbsx]
    9495            TLS = RBObj['ThermalMotion']
    9596            if 'T' in TLS[0]:
     
    108109            for i,x in enumerate(XYZ):
    109110                atId = RBObj['Ids'][i]
     111                if parmDict[pfx+'Afrac:'+str(AtLookup[atId])]:
     112                    parmDict[pfx+'Afrac:'+str(AtLookup[atId])] = RBObj['AtomFrac'][0]
    110113                for j in [0,1,2]:
    111114                    parmDict[pfx+atxIds[j]+str(AtLookup[atId])] = x[j]
     
    124127                RBObj['Orient'][0][i] = parmDict[pfx+po+rbsx]               
    125128            RBObj['Orient'][0] = G2mth.normQ(RBObj['Orient'][0])
     129            RBObj['AtomFrac'][0] = parmDict[pfx+'RBf:'+rbsx]
    126130            TLS = RBObj['ThermalMotion']
    127131            if 'T' in TLS[0]:
     
    142146            for i,x in enumerate(XYZ):
    143147                atId = RBObj['Ids'][i]
     148                if parmDict[pfx+'Afrac:'+str(AtLookup[atId])]:
     149                    parmDict[pfx+'Afrac:'+str(AtLookup[atId])] = RBObj['AtomFrac'][0]
    144150                for j in [0,1,2]:
    145151                    parmDict[pfx+atxIds[j]+str(AtLookup[atId])] = x[j]
     
    176182    pfx = str(Phase['pId'])+'::'
    177183    RBModels =  Phase['RBModels']
     184   
    178185    for irb,RBObj in enumerate(RBModels.get('Vector',[])):
    179186        symAxis = RBObj.get('symAxis')
     
    191198        for ia,atId in enumerate(RBObj['Ids']):
    192199            atNum = AtLookup[atId]
     200            if parmDict[pfx+'Afrac:'+str(AtLookup[atId])]:
     201                dFdvDict[pfx+'RBf:'+rbsx] += dFdvDict[pfx+'Afrac:'+str(atNum)]
    193202            dx = 0.00001
    194203            for iv in range(len(VModel['VectMag'])):
     
    237246                dFdvDict[pfx+'RBVU:'+rbsx] += dFdvDict[pfx+'AUiso:'+str(AtLookup[atId])]
    238247
    239 
    240248    for irb,RBObj in enumerate(RBModels.get('Residue',[])):
    241249        symAxis = RBObj.get('symAxis')
     
    260268        for ia,atId in enumerate(RBObj['Ids']):
    261269            atNum = AtLookup[atId]
     270            if parmDict[pfx+'Afrac:'+str(AtLookup[atId])]:
     271                dFdvDict[pfx+'RBf:'+rbsx] += dFdvDict[pfx+'Afrac:'+str(atNum)]
    262272            dx = 0.00001
    263273            for i,name in enumerate(['RBRPx:','RBRPy:','RBRPz:']):
Note: See TracChangeset for help on using the changeset viewer.