Skip to content

Commit 3422c6d

Browse files
committed
RB fixes
1 parent d4c3799 commit 3422c6d

3 files changed

Lines changed: 22 additions & 12 deletions

File tree

GSASII/GSASIIdataGUI.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7684,8 +7684,8 @@ def _makemenu(): # routine to create menu when first used
76847684
'Locate rigid body in structure mapping to existing atoms')
76857685
self.RigidBodiesEdit.Append(G2G.wxID_AUTOFINDRESRB,'Auto find residues',
76867686
'Auto find of residue RBs in macromolecule')
7687-
self.RigidBodiesEdit.Append(G2G.wxID_COPYRBPARMS,'Copy rigid body parms',
7688-
'Copy rigid body location & TLS parameters')
7687+
self.RigidBodiesEdit.Append(G2G.wxID_COPYRBPARMS,'Duplicate rigid body parms',
7688+
'Duplicate rigid body location & TLS parameters')
76897689
self.RigidBodiesEdit.Append(G2G.wxID_GLOBALTHERM,'Global thermal motion',
76907690
'Global setting of residue thermal motion models')
76917691
self.RigidBodiesEdit.Append(G2G.wxID_GLOBALRESREFINE,'Global residue refine',

GSASII/GSASIImath.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1364,7 +1364,8 @@ def QsymAxis(Q,symAxis):
13641364
if symAxis is None:
13651365
return Q
13661366
a,v = Q2AV(Q)
1367-
symaxis = np.array(symAxis)
1367+
v = vnorm(v)
1368+
symaxis = vnorm(np.array(symAxis))
13681369
vdotsym = min(1.0,max(-1.0,np.vdot(v,symaxis)))
13691370
if vdotsym in [-1.0,1.0]: #Q, symAxis parallel/antiparallel
13701371
return Q
@@ -1426,6 +1427,7 @@ def UpdateRBXYZ(Bmat,RBObj,RBData,RBType):
14261427
XYZ = [np.array(RBObj['Orig'][0]),]
14271428
return XYZ,Cart
14281429
# if symmetry axis is defined, place symmetry axis along quaternion
1430+
RBRes['symAxis'] = RBRes.get('symAxis',[0,0,1])
14291431
Q = QsymAxis(RBObj['Orient'][0],RBRes['symAxis'])
14301432
XYZ = np.zeros_like(Cart)
14311433
for i,xyz in enumerate(Cart):
@@ -1480,7 +1482,7 @@ def UpdateRBUIJ(Bmat,Cart,RBObj):
14801482
S[0]*X[1]-S[1]*X[2]+S[7]*X[0]
14811483
Umat = G2lat.U6toUij(U)
14821484
Umat = np.inner(np.inner(QMat,Umat),QMat)
1483-
beta = np.inner(np.inner(Bmat,Umat),Bmat)
1485+
beta = np.inner(np.inner(Bmat.T,Umat),Bmat.T)
14841486
Uout.append(['A',0.0,]+list(G2lat.UijtoU6(beta)*gvec))
14851487
else:
14861488
Uout.append(['N',])

GSASII/GSASIIphsGUI.py

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9665,6 +9665,8 @@ def OnThermval(invalid,value,tc):
96659665
data['Atoms'][AtLookUp[Id]][cia+1] = Uout[i][1]
96669666
else:
96679667
data['Atoms'][AtLookUp[Id]][cia+2:cia+8] = Uout[i][2:8]
9668+
data['Drawing']['Atoms'] = []
9669+
UpdateDrawAtoms(G2frame,data)
96689670
G2plt.PlotStructure(G2frame,data)
96699671

96709672
def OnTLSRef(event):
@@ -9724,13 +9726,18 @@ def ApplyAV(A,V):
97249726
if not any(Q):
97259727
raise ValueError
97269728
RBObj['Orient'][0] = Q
9727-
if rbType != 'Spin':
9728-
newXYZ = G2mth.UpdateRBXYZ(Bmat,RBObj,RBData,rbType)[0]
9729+
if rbType != 'Spin':
9730+
newXYZ,Cart = G2mth.UpdateRBXYZ(Bmat,RBObj,RBData,rbType)
9731+
Uout = G2mth.UpdateRBUIJ(Bmat,Cart,RBObj)
97299732
maxFrac = 0.0
9730-
for Id in RBObj['Ids']:
9733+
for i,Id in enumerate(RBObj['Ids']):
97319734
maxFrac = max(maxFrac,data['Atoms'][AtLookUp[Id]][cx+3])
97329735
for i,Id in enumerate(RBObj['Ids']):
97339736
data['Atoms'][AtLookUp[Id]][cx:cx+3] = newXYZ[i]
9737+
if Uout[i][0] == 'I':
9738+
data['Atoms'][AtLookUp[Id]][cia+1] = Uout[i][1]
9739+
else:
9740+
data['Atoms'][AtLookUp[Id]][cia+2:cia+8] = Uout[i][2:8]
97349741
data['Atoms'][AtLookUp[Id]][cx+3] = maxFrac
97359742
data['Atoms'] = G2lat.RBsymCheck(data['Atoms'],ct,cx,cs,AtLookUp,Amat,RBObj['Ids'],SGData)
97369743

@@ -10553,10 +10560,10 @@ def RepaintRBInfo(rbType,rbIndx,Scroll=0):
1055310560

1055410561
def OnRBCopyParms(event):
1055510562
RBObjs = []
10556-
for rbType in ['Vector','Residue']:
10563+
for rbType in ['Vector',]:
1055710564
RBObjs += data['RBModels'].get(rbType,[])
1055810565
if not len(RBObjs):
10559-
print ('**** ERROR - no rigid bodies defined ****')
10566+
print ('**** ERROR - only allowed for defined Vector rigid bodies ****')
1056010567
return
1056110568
if len(RBObjs) == 1:
1056210569
print ('**** INFO - only one rigid body defined; nothing to copy to ****')
@@ -10565,19 +10572,19 @@ def OnRBCopyParms(event):
1056510572
sourceRB = {}
1056610573
for RBObj in RBObjs:
1056710574
Source.append(RBObj['RBname'])
10568-
dlg = wx.SingleChoiceDialog(G2frame,'Select source','Copy rigid body parameters',Source)
10575+
dlg = wx.SingleChoiceDialog(G2frame,'Select source','Duplicate rigid body parameters',Source)
1056910576
if dlg.ShowModal() == wx.ID_OK:
1057010577
sel = dlg.GetSelection()
1057110578
for item in ['Orig','Orient','ThermalMotion','AtomFract']:
1057210579
sourceRB.update({item:RBObjs[sel][item],})
1057310580
dlg.Destroy()
1057410581
if not sourceRB:
1057510582
return
10576-
dlg = wx.MultiChoiceDialog(G2frame,'Select targets','Copy rigid body parameters',Source)
10583+
dlg = wx.MultiChoiceDialog(G2frame,'Select targets','Duplicate rigid body parameters',Source)
1057710584
if dlg.ShowModal() == wx.ID_OK:
1057810585
sel = dlg.GetSelections()
1057910586
for x in sel:
10580-
RBObjs[x].update(copy.copy(sourceRB))
10587+
RBObjs[x].update(copy.copy(sourceRB)) #NB: this duplicates the objects; not make independent copies!
1058110588
G2plt.PlotStructure(G2frame,data)
1058210589
wx.CallAfter(FillRigidBodyGrid,True)
1058310590

@@ -11581,6 +11588,7 @@ def OnRBRemoveAll(event):
1158111588
RBData = G2frame.GPXtree.GetItemPyData(
1158211589
G2gd.GetGPXtreeItemId(G2frame,G2frame.root,'Rigid bodies'))
1158311590
for RBType in ['Vector','Residue','Spin']:
11591+
RBData[RBType] = RBData.get(RBType,[])
1158411592
for rbId in RBData[RBType]:
1158511593
RBData[RBType][rbId]['useCount'] = 0
1158611594
FillRigidBodyGrid(True)

0 commit comments

Comments
 (0)