- Timestamp:
- Feb 16, 2021 3:17:35 PM (2 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/GSASIIlattice.py
r4810 r4818 19 19 The "*A* tensor" terms are defined as 20 20 :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}`, where21 :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 22 22 *d* is the d-spacing, and :math:`d^*` is the reciprocal lattice spacing, 23 23 :math:`Q = 2 \\pi d^* = 2 \\pi / d`. … … 1069 1069 else: 1070 1070 return True 1071 1072 def 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 1071 1099 1072 1100 def GetBraviasNum(center,system): -
trunk/GSASIIphsGUI.py
r4816 r4818 9887 9887 9888 9888 def OnOrigX(invalid,value,tc): 9889 '''Called when the position info is changed (vector 9890 or azimuth) 9891 ''' 9889 9892 newXYZ = G2mth.UpdateRBXYZ(Bmat,RBObj,RBData,rbType)[0] 9890 9893 Sytsym,Mult = G2spc.SytSym(rbObj['Orig'][0],SGData)[:2] … … 9892 9895 for i,Id in enumerate(RBObj['Ids']): 9893 9896 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) 9894 9899 data['Drawing']['Atoms'] = [] 9895 9900 UpdateDrawAtoms(atomStyle) … … 9911 9916 for i,Id in enumerate(RBObj['Ids']): 9912 9917 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) 9913 9920 data['Drawing']['Atoms'] = [] 9914 9921 UpdateDrawAtoms(atomStyle) … … 9918 9925 9919 9926 SGData = data['General']['SGData'] 9920 maxMult = len(SGData['SGOps'])*len(SGData['SGCen'])9921 if SGData['SGInv']: maxMult *= 29922 9927 rbSizer = wx.BoxSizer(wx.VERTICAL) 9923 9928 topSizer = wx.FlexGridSizer(0,6,5,5) … … 10355 10360 return 10356 10361 dlg.Destroy() 10357 SGData = data['General']['SGData']10358 maxMult = len(SGData['SGOps'])*len(SGData['SGCen'])10359 if SGData['SGInv']: maxMult *= 210360 Mult = G2spc.SytSym(rbObj['Orig'][0],SGData)[1]10361 10362 Ids = [] 10362 10363 updateNeeded = False … … 10373 10374 atomData[line[5]][cx:cx+3] = line[2:5] 10374 10375 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) 10375 10379 if updateNeeded: 10376 10380 UpdateDrawAtoms() … … 10671 10675 rbName = rbObj['RBname'] 10672 10676 rbId = rbObj['RBId'] 10673 Orien = rbObj['Orient'][0]10674 rbRef = data['testRBObj']['rbRef']10675 10677 Torsions = rbObj['Torsions'] 10676 #refName = []10677 #for ref in rbRef:10678 # refName.append(data['testRBObj']['rbAtTypes'][ref]+str(ref))10679 10678 atNames = data['testRBObj']['atNames'] 10680 10679 topSizer = wx.BoxSizer(wx.HORIZONTAL) 10681 10680 helpText = ''' 10682 10681 This 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. 10682 the initial settings for the position and orientation of the body, as well as 10683 any internal torsion angles. The origin determines where the origin of the rigid body 10684 will be placed in the unit cell (expressed in fractional coordinates). The 10685 orientation is determined by a quaternion that is expressed here as vector 10686 (in fraction coordinates) and an azimuthal rotation (in degrees) around that 10687 quaternion vector. For systems where the rigid body is placed on a 10688 crystallographic symmetry element, the "Rigid body symmetry axis" 10689 ("x", "y", "z", "x+y" or "x+y+z") specifies the rotation axis that aligns with 10690 an allowed rotation for this symmetry element (NB: could be perpendicular to a 10691 mirror). This places the selected Cartesian axis along the quaternion vector. 10692 The quaternion vector may be set by the user to force the rotation to be about 10693 a particular crystallographic direction (e.g. along a rotation axis or 10694 perpendicular to a mirror). The rotation action can be tested via the slider. 10695 10695 10696 10696 %%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. 10697 are not already assigned to rigid bodies, a table shows each atom in the rigid 10698 body and the closest crystallographic atom, and the distance between them. 10699 Set this pairing by using the pulldown menu in the "Assign as atom" column by 10700 selecting a particular atom. If the selection is changed, "Update Assignments" 10701 recomputes 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 10703 to 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 10705 or more pairs are assignments allow use of the "Set both" button, which 10706 sets the orientation and origin to best give the smallest distances between 10707 the assigned atoms. NB: if apparently stuck with a poor fit, try shifting the 10708 Orientation azimuth slider and try Set both again. 10704 10709 Note that when a row in the table is selected, the corresponding atoms 10705 10710 are highlighted in green. The tab key or the "Crystal Highlight" pulldown 10706 10711 can be used to highlight differing unit cell atoms. Alt-Tab highlights different 10707 10712 RB 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 10715 orange 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 10717 operations and/or by entering appropriate values in the Orientation azimuth 10718 and vector x,y,z boxes. Symmetry element issues should be attended to by 10719 proper selections as noted above. "Add" will then add the rigid body atoms to 10720 the Atom list. 10721 10715 10722 %%The GSAS-II graphics window shows the unit cell contents (use the 10716 10723 "Ball & Sticks" or "Sticks" buttons to change the display of this) and … … 10720 10727 The mouse can also be used to position the rigid body in the plot by holding 10721 10728 the 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 rotate s around the screen z10723 (out of plane); Alt+right mouse translates the RB in the screen x-y plane.10729 the RB in the screen x & y; Alt+middle mouse to rotate the RB around the viewing 10730 direction; Alt+right mouse translates the RB in the screen x-y plane. 10724 10731 Note that dragging the mouse without the Alt button changes the view 10725 10732 of the crystal structure. … … 10864 10871 rowLabels = [l[1] for l in matchTable] 10865 10872 displayTable = [] 10873 Actions = True 10866 10874 for i,l in enumerate(matchTable): 10867 10875 lbl = '' … … 10869 10877 if rbAssignments[i] is None: 10870 10878 displayTable.append([l[0],-1,'?',-1,'Create new']) 10879 Actions = False 10871 10880 else: 10872 10881 lbl = rbAssignments[i] … … 10881 10890 RigidBodies.atomsGrid.Bind(wg.EVT_GRID_LABEL_LEFT_CLICK,OnRowSelect) 10882 10891 choiceeditor = wg.GridCellChoiceEditor( 10883 data['testRBObj']['availAtoms'] +['Create new'], False)10892 data['testRBObj']['availAtoms'], False) 10884 10893 RigidBodies.atomsGrid.SetTable(RigidBodies.atomsTable,True) 10885 10894 # make all grid entries read only … … 10902 10911 gridSizer.Add((5,5)) 10903 10912 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) 10931 10941 mainSizer.Add(gridSizer) 10932 10942 mainSizer.Layout() … … 10976 10986 return 10977 10987 general = data['General'] 10988 SGData = general['SGData'] 10978 10989 Amat,Bmat = G2lat.cell2AB(general['Cell'][1:7]) 10979 cx,ct = general['AtomPtrs'][:2]10990 cx,ct,cs,cia = general['AtomPtrs'] 10980 10991 atomData = data['Atoms'] 10992 AtLookUp = G2mth.FillAtomLookUp(atomData,cia+8) 10981 10993 Indx = {} 10982 10994 data['testRBObj'] = {}
Note: See TracChangeset
for help on using the changeset viewer.