Changeset 4824
- Timestamp:
- Feb 20, 2021 2:44:46 PM (3 years ago)
- Location:
- trunk
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/GSASIIobj.py
r4823 r4824 601 601 :ref:`Rigid Body Objects <RBData_table>` 602 602 RBname The name for the rigid body (str) 603 AtomFrac The atom fractions for the rigid body 603 604 ThermalMotion The thermal motion description for the rigid body, which includes a choice for 604 605 the model and can include TLS parameters or an overall Uiso value. -
trunk/GSASIIphsGUI.py
r4820 r4824 3434 3434 colR = colLabels.index('refine') 3435 3435 colSS = colLabels.index('site sym') 3436 colF = colLabels.index('frac') 3436 3437 colX = colLabels.index('x') 3437 3438 colIA = colLabels.index('I/A') … … 3447 3448 attr.IncRef() #fix from Jim Hester 3448 3449 attr.SetEditor(G2G.GridFractionEditor(Atoms)) 3449 for c in range(colX,colX+ 3):3450 for c in range(colX,colX+4): 3450 3451 attr = wx.grid.GridCellAttr() 3451 3452 attr.IncRef() #fix from Jim Hester … … 3501 3502 saveCSI = CSI[0][i] 3502 3503 Atoms.SetCellTextColour(row,ci,BLACK) 3504 if 'F' in rbExcl: 3505 Atoms.SetCellStyle(row,colF,VERY_LIGHT_GREY,True) 3503 3506 if 'X' in rbExcl: 3504 3507 for c in range(0,colX+3): … … 3511 3514 SetPhaseWindow(Atoms,Scroll=Atoms.GetScrollPos(wx.VERTICAL)) 3512 3515 3513 #### FillAtomsGrid executable code starts here3516 #### onSetOrigin. 3514 3517 if not data['Drawing']: #if new drawing - no drawing data! 3515 3518 SetupDrawingData() … … 3522 3525 rbAtmDict = {} 3523 3526 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']))] 3525 3528 rbAtmDict.update(dict(zip(rbObj['Ids'],exclList))) 3526 3529 if rbObj['ThermalMotion'][0] != 'None': 3527 3530 for id in rbObj['Ids']: 3528 3531 rbAtmDict[id] += 'U' 3529 # exclList will be ' x' or 'xu' if TLS used in RB3532 # exclList will be 'fx' or 'fxu' if TLS used in RB 3530 3533 Items = [G2G.wxID_ATOMSEDITINSERT,G2G.wxID_ATOMSEDITDELETE, 3531 3534 G2G.wxID_ATOMSMODIFY,G2G.wxID_ATOMSTRANSFORM,G2G.wxID_MAKEMOLECULE, … … 9947 9950 typeHint=float,OnLeave=OnOrigX,xmin=-1,xmax=1.,size=(70,-1)) 9948 9951 topSizer.Add(origX,0,WACV) 9949 topSizer.Add((5,0),)9950 9952 Ocheck = wx.CheckBox(RigidBodies,-1,'Refine?') 9951 9953 Ocheck.Bind(wx.EVT_CHECKBOX,OnOrigRef) … … 9953 9955 topSizer.Add(Ocheck,0,WACV) 9954 9956 topSizer.Add(wx.StaticText(RigidBodies,-1, 9955 9957 'Rotation angle (deg)\n&& Orient. vector (frac)'),0,WACV) 9956 9958 Indx['Orien'] = {} 9957 9959 Orien,OrienV = G2mth.Q2AVdeg(RBObj['Orient'][0]) … … 9977 9979 9978 9980 def ResrbSizer(RBObj,resIndx): 9979 '''Displays details for selected r igid body'''9981 '''Displays details for selected residue rigid body''' 9980 9982 def OnTorsionRef(event): 9981 9983 Obj = event.GetEventObject() … … 9992 9994 G2plt.PlotStructure(G2frame,data) 9993 9995 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 9994 10004 def OnDelResRB(event): 9995 10005 Obj = event.GetEventObject() 9996 10006 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] 10002 10009 G2plt.PlotStructure(G2frame,data) 10003 10010 wx.CallAfter(FillRigidBodyGrid,True) … … 10047 10054 torSizer.Add(torCheck,0,WACV) 10048 10055 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) 10049 10069 tchoice = ['None','Uiso','T','TL','TLS'] 10050 10070 thermSizer = wx.BoxSizer(wx.HORIZONTAL) … … 10062 10082 10063 10083 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 10064 10093 def OnDelVecRB(event): 10065 10094 Obj = event.GetEventObject() 10066 10095 RBId = Indx[Obj.GetId()] 10067 10096 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] 10072 10098 G2plt.PlotStructure(G2frame,data) 10073 10099 wx.CallAfter(FillRigidBodyGrid,True) … … 10085 10111 vecrbSizer.Add(topLine) 10086 10112 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) 10087 10126 tchoice = ['None','Uiso','T','TL','TLS'] 10088 10127 thermSizer = wx.BoxSizer(wx.HORIZONTAL) … … 10166 10205 resVarLookup = [] 10167 10206 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 10168 10211 name = RBObj['RBname']+RBObj['numChain'] 10169 10212 RBnames.append(name) … … 10197 10240 RBnames = [] 10198 10241 for RBObj in data['RBModels']['Vector']: 10242 # patch 10243 if 'AtomFrac' not in RBObj: 10244 RBObj['AtomFrac'] = [1.0,False] 10245 #end patch 10199 10246 RBnames.append(RBObj['RBname']) 10200 10247 if prevVecId is not None: … … 10248 10295 if dlg.ShowModal() == wx.ID_OK: 10249 10296 sel = dlg.GetSelection() 10250 for item in ['Orig','Orient','ThermalMotion' ]:10297 for item in ['Orig','Orient','ThermalMotion','AtomFract']: 10251 10298 sourceRB.update({item:RBObjs[sel][item],}) 10252 10299 dlg.Destroy() … … 10392 10439 UpdateDrawAtoms() 10393 10440 G2plt.PlotStructure(G2frame,data) 10394 10441 10395 10442 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] 10398 10449 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 10400 10458 if type(rbObj['Orig'][0]) is tuple: # patch because somehow adding RB origin is becoming a tuple 10401 10459 if GSASIIpath.GetConfigValue('debug'): print('patching origin!') … … 10661 10719 axis = np.array(axis)/nl.norm(axis) 10662 10720 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]) 10663 10727 UpdateTablePlot() 10664 10728 … … 10773 10837 fixOrig = G2G.G2CheckBox(RigidBodies,'Lock',rbObj,'fixOrig') 10774 10838 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) 10776 10844 Sytsym,Mult = G2spc.SytSym(rbObj['Orig'][0],data['General']['SGData'])[:2] 10777 10845 sytsymtxt = wx.StaticText(RigidBodies,label='Origin site symmetry: %s, multiplicity: %d '%(Sytsym,Mult)) … … 11130 11198 QuatC = G2mth.prodQQ(QuatB,QuatA) 11131 11199 rbObj['Orient'] = [QuatC,' '] 11200 rbObj['AtomFract'] = [1.0,False] 11132 11201 rbObj['ThermalMotion'] = ['None',[0. for i in range(21)],[False for i in range(21)]] #type,values,flags 11133 11202 SXYZ = [] -
trunk/GSASIIstrIO.py
r4823 r4824 1192 1192 1193 1193 def PrintRBObjects(resRBData,vecRBData): 1194 1194 1195 1195 def PrintRBThermals(): 1196 1196 tlstr = ['11','22','33','12','13','23'] … … 1228 1228 pFile.write('Orientation angle,vector: %10.3f %10.4f %10.4f %10.4f Refine? %s\n'% 1229 1229 (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])) 1230 1231 Torsions = RB['Torsions'] 1231 1232 if len(Torsions): … … 1244 1245 pFile.write('Orientation angle,vector: %10.3f %10.4f %10.4f %10.4f Refine? %s\n'% 1245 1246 (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])) 1246 1248 PrintRBThermals() 1247 1249 … … 1382 1384 elif RB['Orient'][1] == 'V' and i not in fixAxis: 1383 1385 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 1384 1391 def MakeRBThermals(rbKey,phaseVary,phaseDict): 1385 1392 rbid = str(rbids.index(RB['RBId'])) … … 3646 3653 else: 3647 3654 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*' ' 3648 3662 return (namstr,valstr,sigstr) 3649 3663 -
trunk/GSASIIstrMath.py
r4682 r4824 52 52 def ApplyRBModels(parmDict,Phases,rigidbodyDict,Update=False): 53 53 ''' 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 parmDict54 current RB values in parmDict & modifies atom contents (fxyz & Uij) of parmDict 55 55 ''' 56 56 atxIds = ['Ax:','Ay:','Az:'] … … 92 92 RBObj['Orient'][0][i] = parmDict[pfx+po+rbsx] 93 93 RBObj['Orient'][0] = G2mth.normQ(RBObj['Orient'][0]) 94 RBObj['AtomFrac'][0] = parmDict[pfx+'RBf:'+rbsx] 94 95 TLS = RBObj['ThermalMotion'] 95 96 if 'T' in TLS[0]: … … 108 109 for i,x in enumerate(XYZ): 109 110 atId = RBObj['Ids'][i] 111 if parmDict[pfx+'Afrac:'+str(AtLookup[atId])]: 112 parmDict[pfx+'Afrac:'+str(AtLookup[atId])] = RBObj['AtomFrac'][0] 110 113 for j in [0,1,2]: 111 114 parmDict[pfx+atxIds[j]+str(AtLookup[atId])] = x[j] … … 124 127 RBObj['Orient'][0][i] = parmDict[pfx+po+rbsx] 125 128 RBObj['Orient'][0] = G2mth.normQ(RBObj['Orient'][0]) 129 RBObj['AtomFrac'][0] = parmDict[pfx+'RBf:'+rbsx] 126 130 TLS = RBObj['ThermalMotion'] 127 131 if 'T' in TLS[0]: … … 142 146 for i,x in enumerate(XYZ): 143 147 atId = RBObj['Ids'][i] 148 if parmDict[pfx+'Afrac:'+str(AtLookup[atId])]: 149 parmDict[pfx+'Afrac:'+str(AtLookup[atId])] = RBObj['AtomFrac'][0] 144 150 for j in [0,1,2]: 145 151 parmDict[pfx+atxIds[j]+str(AtLookup[atId])] = x[j] … … 176 182 pfx = str(Phase['pId'])+'::' 177 183 RBModels = Phase['RBModels'] 184 178 185 for irb,RBObj in enumerate(RBModels.get('Vector',[])): 179 186 symAxis = RBObj.get('symAxis') … … 191 198 for ia,atId in enumerate(RBObj['Ids']): 192 199 atNum = AtLookup[atId] 200 if parmDict[pfx+'Afrac:'+str(AtLookup[atId])]: 201 dFdvDict[pfx+'RBf:'+rbsx] += dFdvDict[pfx+'Afrac:'+str(atNum)] 193 202 dx = 0.00001 194 203 for iv in range(len(VModel['VectMag'])): … … 237 246 dFdvDict[pfx+'RBVU:'+rbsx] += dFdvDict[pfx+'AUiso:'+str(AtLookup[atId])] 238 247 239 240 248 for irb,RBObj in enumerate(RBModels.get('Residue',[])): 241 249 symAxis = RBObj.get('symAxis') … … 260 268 for ia,atId in enumerate(RBObj['Ids']): 261 269 atNum = AtLookup[atId] 270 if parmDict[pfx+'Afrac:'+str(AtLookup[atId])]: 271 dFdvDict[pfx+'RBf:'+rbsx] += dFdvDict[pfx+'Afrac:'+str(atNum)] 262 272 dx = 0.00001 263 273 for i,name in enumerate(['RBRPx:','RBRPy:','RBRPz:']):
Note: See TracChangeset
for help on using the changeset viewer.