Changeset 4818 for trunk


Ignore:
Timestamp:
Feb 16, 2021 3:17:35 PM (8 months ago)
Author:
vondreele
Message:

Add new routine RBsymCheck to G2lat - it checks RB atom positions for symmetry equivalent duplicates in the RB and sets atom frac=0 if so. Also sets atom sytsym, mult for RB location/orientation. Result is correct total number of atoms in unit cell.
Implement in G2phsGUI in 3 places as needed.

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/GSASIIlattice.py

    r4810 r4818  
    1919The "*A* tensor" terms are defined as
    2020:math:`A = (\\begin{matrix} G_{11} & G_{22} & G_{33} & 2G_{12} & 2G_{13} & 2G_{23}\\end{matrix})` and *A* can be used in this fashion:
    21 :math:`d^* = \sqrt {A_0 h^2 + A_1 k^2 + A_2 l^2 + A_3 hk + A_4 hl + A_5 kl}`, where
     21:math:`d^* = \\sqrt {A_0 h^2 + A_1 k^2 + A_2 l^2 + A_3 hk + A_4 hl + A_5 kl}`, where
    2222*d* is the d-spacing, and :math:`d^*` is the reciprocal lattice spacing,
    2323:math:`Q = 2 \\pi d^* = 2 \\pi / d`.
     
    10691069    else:
    10701070        return True
     1071   
     1072def RBsymCheck(Atoms,ct,cx,cs,AtLookUp,Amat,RBObjIds,SGData):
     1073    """ Checks members of a rigid body to see if one is a symmetry equivalent of another.
     1074    If so the atom site frac is set to zero.
     1075    param: Atoms: atom array as defined in GSAS-II; modified here
     1076    param: ct: int location of atom type in Atoms item
     1077    param: cx: int location of x,y,z,frac in Atoms item
     1078    param: AtLookUp: dict: atom lookup by Id table
     1079    param: Amat: np .array: crystal-to-Cartesian transformationmatri
     1080    param: RBObjIds: list: atom Id belonging to rigid body being tested
     1081    param: SGData: Dict: GSAS-II space group info.
     1082    :return: Atoms with modified atom frac entries
     1083   
     1084    """
     1085    for i,Id in enumerate(RBObjIds):
     1086        XYZo = np.array(Atoms[AtLookUp[Id]][cx:cx+3])%1.
     1087        typo = Atoms[AtLookUp[Id]][ct]
     1088        for Jd in RBObjIds[i+1:]:
     1089            if Atoms[AtLookUp[Jd]][ct] == typo:
     1090                XYZt = Atoms[AtLookUp[Jd]][cx:cx+3]
     1091                Xeqv = list(G2spc.GenAtom(np.array(XYZt)%1.,SGData,True))
     1092                close = [np.allclose(np.inner(Amat,XYZo),np.inner(Amat,eqv[0]),atol=0.01) for eqv in Xeqv]
     1093                if True in close:
     1094                    Atoms[AtLookUp[Jd]][cx+3] = 0.0
     1095        Sytsym,Mult = G2spc.SytSym(Atoms[AtLookUp[Id]][cx:cx+3],SGData)[:2]
     1096        Atoms[AtLookUp[Id]][cs] = Sytsym
     1097        Atoms[AtLookUp[Id]][cs+1] = Mult           
     1098    return Atoms
    10711099                                   
    10721100def GetBraviasNum(center,system):
  • trunk/GSASIIphsGUI.py

    r4816 r4818  
    98879887               
    98889888            def OnOrigX(invalid,value,tc):
     9889                '''Called when the position info is changed (vector
     9890                or azimuth)
     9891                '''
    98899892                newXYZ = G2mth.UpdateRBXYZ(Bmat,RBObj,RBData,rbType)[0]
    98909893                Sytsym,Mult = G2spc.SytSym(rbObj['Orig'][0],SGData)[:2]
     
    98929895                for i,Id in enumerate(RBObj['Ids']):
    98939896                    data['Atoms'][AtLookUp[Id]][cx:cx+3] = newXYZ[i]
     9897                    data['Atoms'][AtLookUp[Id]][cx+3] = 1.0
     9898                data['Atoms'] = G2lat.RBsymCheck(data['Atoms'],ct,cx,cs,AtLookUp,Amat,RBObj['Ids'],SGData)
    98949899                data['Drawing']['Atoms'] = []
    98959900                UpdateDrawAtoms(atomStyle)
     
    99119916                    for i,Id in enumerate(RBObj['Ids']):
    99129917                        data['Atoms'][AtLookUp[Id]][cx:cx+3] = newXYZ[i]
     9918                        data['Atoms'][AtLookUp[Id]][cx+3] = 1.0
     9919                    data['Atoms'] = G2lat.RBsymCheck(data['Atoms'],ct,cx,cs,AtLookUp,Amat,RBObj['Ids'],SGData)
    99139920                    data['Drawing']['Atoms'] = []
    99149921                    UpdateDrawAtoms(atomStyle)
     
    99189925               
    99199926            SGData = data['General']['SGData']
    9920             maxMult = len(SGData['SGOps'])*len(SGData['SGCen'])
    9921             if SGData['SGInv']: maxMult *= 2
    99229927            rbSizer = wx.BoxSizer(wx.VERTICAL)
    99239928            topSizer = wx.FlexGridSizer(0,6,5,5)
     
    1035510360                        return
    1035610361                    dlg.Destroy()
    10357                 SGData = data['General']['SGData']
    10358                 maxMult = len(SGData['SGOps'])*len(SGData['SGCen'])
    10359                 if SGData['SGInv']: maxMult *= 2
    10360                 Mult = G2spc.SytSym(rbObj['Orig'][0],SGData)[1]
    1036110362                Ids = []
    1036210363                updateNeeded = False
     
    1037310374                        atomData[line[5]][cx:cx+3] = line[2:5]
    1037410375                        Ids.append(line[11])
     10376                if len(Ids):
     10377                    AtLookUp = G2mth.FillAtomLookUp(atomData,cia+8)
     10378                    G2lat.RBsymCheck(atomData,ct,cx,cs,AtLookUp,Amat,Ids,SGData)
    1037510379                if updateNeeded:
    1037610380                    UpdateDrawAtoms()
     
    1067110675            rbName = rbObj['RBname']
    1067210676            rbId = rbObj['RBId']
    10673             Orien = rbObj['Orient'][0]
    10674             rbRef = data['testRBObj']['rbRef']
    1067510677            Torsions = rbObj['Torsions']
    10676             #refName = []
    10677             #for ref in rbRef:
    10678             #    refName.append(data['testRBObj']['rbAtTypes'][ref]+str(ref))
    1067910678            atNames = data['testRBObj']['atNames']
    1068010679            topSizer = wx.BoxSizer(wx.HORIZONTAL)
    1068110680            helpText = '''
    1068210681This window is used to insert a rigid body into a unit cell, determining
    10683 the initial settings for the position and orientation of the body,
    10684 as well as any torsion angles. The origin
    10685 determines where the origin of the rigid body will be placed in the
    10686 unit cell (expressed in fractional coordinates).
    10687 The orientation is determined by a quaternion
    10688 that is expressed here as vector (in fraction coordinates) and an azimuthal
    10689 rotation (in degrees) around that quaternion vector. For systems where symmetry
    10690 dictates that the rigid body needs to be oriented in a particular direction,
    10691 the rigid body coordinate system must be defined with the symmetry
    10692 direction along the Cartesian x, y, z, x+y or x+y+z and this must be
    10693 selected with the "Rigid body symmetry axis." This places the
    10694 selected Cartesian axis along the quaternion vector.
     10682the initial settings for the position and orientation of the body, as well as
     10683any internal torsion angles. The origin determines where the origin of the rigid body
     10684will be placed in the unit cell (expressed in fractional coordinates). The
     10685orientation is determined by a quaternion that is expressed here as vector
     10686(in fraction coordinates) and an azimuthal rotation (in degrees) around that
     10687quaternion vector. For systems where the rigid body is placed on a
     10688crystallographic symmetry element, the "Rigid body symmetry axis"
     10689("x", "y", "z", "x+y" or "x+y+z") specifies the rotation axis that aligns with
     10690an allowed rotation for this symmetry element (NB: could be perpendicular to a
     10691mirror). This places the selected Cartesian axis along the quaternion vector.
     10692The quaternion vector may be set by the user to force the rotation to be about
     10693a particular crystallographic direction (e.g. along a rotation axis or
     10694perpendicular to a mirror). The rotation action can be tested via the slider.
    1069510695
    1069610696%%If there are atoms in the unit cell that are of the appropriate type and
    10697 are not already assigned to rigid bodies, a table shows each
    10698 atom in the rigid body and the closest atom unit cell atom, as well
    10699 as the distance between them. This pairing can be set manually using the
    10700 pulldown menu in the "Assign as atom" column, where a particular atom
    10701 can be selected. One option is "create new" which means that that RB atom
    10702 will not be paired to a unit cell atom. "Update Assignments" recomputes distance
    10703 between paired atoms.
     10697are not already assigned to rigid bodies, a table shows each atom in the rigid
     10698body and the closest crystallographic atom, and the distance between them.
     10699Set this pairing by using the pulldown menu in the "Assign as atom" column by
     10700selecting a particular atom. If the selection is changed, "Update Assignments"
     10701recomputes distance between paired atoms. If one atom is paired manually using
     10702"Assign as", the "Set Origin" button can be used to place the rigid body origin
     10703to best fit the paired atom(s). Likewise, with two or more atoms assigned, the
     10704"Set Orientation" button will determine the quaternion azimuth and vector. Three
     10705or more pairs are assignments allow use of the "Set both" button, which
     10706sets the orientation and origin to best give the smallest distances between
     10707the assigned atoms. NB: if apparently stuck with a poor fit, try shifting the
     10708Orientation azimuth slider and try Set both again.
    1070410709Note that when a row in the table is selected, the corresponding atoms
    1070510710are highlighted in green. The tab key or the "Crystal Highlight" pulldown
    1070610711can be used to highlight differing unit cell atoms. Alt-Tab highlights different
    1070710712RB atoms.
    10708 If at least one atom is paired manually using "Assign as", the
    10709 "Set Origin" button can be used to place the rigid body origin to best fit
    10710 the paired atom(s). Likewise, with two or more atoms assigned, the
    10711 "Set Orientation" button will determine the quaternion azimuth and vector. Three
    10712 or more pairs are assignments allow use of the "Set both" button, which
    10713 sets the orientation and origin to best give the smallest distances between
    10714 the assigned atoms.
     10713
     10714%%If there are no unassigned atoms of the right type (existing RBs will have
     10715orange sticks for bonds), then the table will show "Create new" in the
     10716"Assign as atom" column. The proposed RB can be positioned via Alt mouse
     10717operations and/or by entering appropriate values in the Orientation azimuth
     10718and vector x,y,z boxes. Symmetry element issues should be attended to by
     10719proper selections as noted above. "Add" will then add the rigid body atoms to
     10720the Atom list.
     10721
    1071510722%%The GSAS-II graphics window shows the unit cell contents (use the
    1071610723"Ball & Sticks" or "Sticks" buttons to change the display of this) and
     
    1072010727The mouse can also be used to position the rigid body in the plot by holding
    1072110728the Alt key down while dragging with the mouse: Alt+left button to rotates
    10722 the RB in the screen x & y; Alt+middle mouse to rotates around the screen z
    10723 (out of plane); Alt+right mouse translates the RB in the screen x-y plane.
     10729the RB in the screen x & y; Alt+middle mouse to rotate the RB around the viewing
     10730direction; Alt+right mouse translates the RB in the screen x-y plane.
    1072410731Note that dragging the mouse without the Alt button changes the view
    1072510732of the crystal structure.
     
    1086410871            rowLabels = [l[1] for l in matchTable]
    1086510872            displayTable = []
     10873            Actions = True
    1086610874            for i,l in enumerate(matchTable):
    1086710875                lbl = ''
     
    1086910877                    if rbAssignments[i] is None:
    1087010878                        displayTable.append([l[0],-1,'?',-1,'Create new'])
     10879                        Actions = False
    1087110880                    else:
    1087210881                        lbl = rbAssignments[i]
     
    1088110890            RigidBodies.atomsGrid.Bind(wg.EVT_GRID_LABEL_LEFT_CLICK,OnRowSelect)
    1088210891            choiceeditor = wg.GridCellChoiceEditor(
    10883                 data['testRBObj']['availAtoms']+['Create new'], False)
     10892                data['testRBObj']['availAtoms'], False)
    1088410893            RigidBodies.atomsGrid.SetTable(RigidBodies.atomsTable,True)
    1088510894            # make all grid entries read only
     
    1090210911            gridSizer.Add((5,5))
    1090310912
    10904             btnSizer = wx.BoxSizer(wx.VERTICAL)
    10905             hSizer = wx.BoxSizer(wx.HORIZONTAL)
    10906             hSizer.Add(wx.StaticText(RigidBodies,label='Crystal Highlight: '))
    10907             misc['showSelect'] = G2G.G2ChoiceButton(RigidBodies,
    10908                 data['testRBObj']['availAtoms'],None,None,showAtom,0,showCryAtom,size=(75,-1))
    10909             hSizer.Add(misc['showSelect'])
    10910             btnSizer.Add(hSizer)
    10911             btnSizer.Add((-1,20))
    10912             btnSizer.Add(wx.StaticText(RigidBodies,label='Actions with assigned\natom(s)...'),0,wx.ALL)
    10913             btnSizer.Add((-1,10))
    10914             btn = wx.Button(RigidBodies,label='Update Assignments')
    10915             btn.Bind(wx.EVT_BUTTON,UpdateTable)
    10916             btnSizer.Add(btn,0,wx.ALIGN_CENTER)
    10917             btnSizer.Add((-1,10))
    10918 
    10919             btn = wx.Button(RigidBodies,label='Set Origin')
    10920             btn.Bind(wx.EVT_BUTTON,onSetOrigin)
    10921             btnSizer.Add(btn,0,wx.ALIGN_CENTER)
    10922             btnSizer.Add((-1,5))
    10923             btn = wx.Button(RigidBodies,label='Set Orientation')
    10924             btn.Bind(wx.EVT_BUTTON,onFitOrientation)
    10925             btnSizer.Add(btn,0,wx.ALIGN_CENTER)
    10926             btnSizer.Add((-1,5))
    10927             btn = wx.Button(RigidBodies,label='Set both')
    10928             btn.Bind(wx.EVT_BUTTON,onFitBoth)
    10929             btnSizer.Add(btn,0,wx.ALIGN_CENTER)
    10930             gridSizer.Add(btnSizer)
     10913            if Actions:
     10914                btnSizer = wx.BoxSizer(wx.VERTICAL)
     10915                hSizer = wx.BoxSizer(wx.HORIZONTAL)
     10916                hSizer.Add(wx.StaticText(RigidBodies,label='Crystal Highlight: '))
     10917                misc['showSelect'] = G2G.G2ChoiceButton(RigidBodies,
     10918                    data['testRBObj']['availAtoms'],None,None,showAtom,0,showCryAtom,size=(75,-1))
     10919                hSizer.Add(misc['showSelect'])
     10920                btnSizer.Add(hSizer)
     10921                btnSizer.Add((-1,20))
     10922                btnSizer.Add(wx.StaticText(RigidBodies,label='Actions with assigned\natom(s)...'),0,wx.ALL)
     10923                btnSizer.Add((-1,10))
     10924                btn = wx.Button(RigidBodies,label='Update Assignments')
     10925                btn.Bind(wx.EVT_BUTTON,UpdateTable)
     10926                btnSizer.Add(btn,0,wx.ALIGN_CENTER)
     10927                btnSizer.Add((-1,10))
     10928   
     10929                btn = wx.Button(RigidBodies,label='Set Origin')
     10930                btn.Bind(wx.EVT_BUTTON,onSetOrigin)
     10931                btnSizer.Add(btn,0,wx.ALIGN_CENTER)
     10932                btnSizer.Add((-1,5))
     10933                btn = wx.Button(RigidBodies,label='Set Orientation')
     10934                btn.Bind(wx.EVT_BUTTON,onFitOrientation)
     10935                btnSizer.Add(btn,0,wx.ALIGN_CENTER)
     10936                btnSizer.Add((-1,5))
     10937                btn = wx.Button(RigidBodies,label='Set both')
     10938                btn.Bind(wx.EVT_BUTTON,onFitBoth)
     10939                btnSizer.Add(btn,0,wx.ALIGN_CENTER)
     10940                gridSizer.Add(btnSizer)
    1093110941            mainSizer.Add(gridSizer)
    1093210942            mainSizer.Layout()
     
    1097610986            return
    1097710987        general = data['General']
     10988        SGData = general['SGData']
    1097810989        Amat,Bmat = G2lat.cell2AB(general['Cell'][1:7])
    10979         cx,ct = general['AtomPtrs'][:2]
     10990        cx,ct,cs,cia = general['AtomPtrs']
    1098010991        atomData = data['Atoms']
     10992        AtLookUp = G2mth.FillAtomLookUp(atomData,cia+8)
    1098110993        Indx = {}
    1098210994        data['testRBObj'] = {}
Note: See TracChangeset for help on using the changeset viewer.