Skip to content

Commit 15477b6

Browse files
committed
add axis choices for vector & residue RBs; needed to resolve RB placement on special positions
fix import of structure factors from Olex2 prepared cif files.
1 parent 4a3c3b5 commit 15477b6

3 files changed

Lines changed: 43 additions & 33 deletions

File tree

GSASII/GSASIImath.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@
4545
acosd = lambda x: 180.*np.arccos(x)/np.pi
4646
atand = lambda x: 180.*np.arctan(x)/np.pi
4747
atan2d = lambda y,x: 180.*np.arctan2(y,x)/np.pi
48+
vnorm = lambda v: v/nl.norm(v)
4849
try: # fails on doc build
4950
twopi = 2.0*np.pi
5051
twopisq = 2.0*np.pi**2
@@ -1355,7 +1356,7 @@ def RotateRBXYZ(Bmat,Cart,oriQ,symAxis=None):
13551356
Q = oriQ
13561357
else:
13571358
a,v = Q2AV(oriQ)
1358-
symaxis = np.array(symAxis)
1359+
symaxis = vnorm(np.array(symAxis))
13591360
vdotsym = min(1.0,max(-1.0,np.vdot(v,symaxis)))
13601361
xformAng = np.arccos(vdotsym)
13611362
xformVec = np.cross(symaxis,v)
@@ -1405,7 +1406,7 @@ def UpdateRBXYZ(Bmat,RBObj,RBData,RBType):
14051406
Q = RBObj['Orient'][0]
14061407
else:
14071408
a,v = Q2AV(RBObj['Orient'][0])
1408-
symaxis = np.array(RBObj.get('symAxis'))
1409+
symaxis = vnorm(np.array(RBObj.get('symAxis')))
14091410
vdotsym = min(1.0,max(-1.0,np.vdot(v,symaxis)))
14101411
xformAng = np.arccos(vdotsym)
14111412
xformVec = np.cross(symaxis,v)

GSASII/GSASIIphsGUI.py

Lines changed: 30 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -9580,7 +9580,7 @@ def OnTLSRef(event):
95809580
thermSizer.Add(Tcheck,0,WACV)
95819581
return thermSizer
95829582

9583-
def LocationSizer(RBObj,rbType):
9583+
def LocationSizer(RBObj,rbType,rbId):
95849584

95859585
def OnOrigRef(event):
95869586
RBObj['Orig'][1] = Ocheck.GetValue()
@@ -9655,6 +9655,21 @@ def OnOrien(*args, **kwargs):
96559655
except ValueError:
96569656
pass
96579657

9658+
def OnSymRadioSet(event):
9659+
'''Set the polar axis for the sp. harm. as
9660+
RBdata['Spin'][RBId]['symAxis']. This may never be
9661+
set, so use RBdata['Spin'][RBId].get('symAxis') to
9662+
access this so the default value is [0,0,1].
9663+
'''
9664+
Obj = event.GetEventObject()
9665+
axis = ([1,0,0],[0,1,0],[0,0,1],[1,1,0],[1,1,1])[Obj.GetSelection()]
9666+
RBObj['symAxis'] = axis
9667+
A,V = G2mth.Q2AVdeg(RBObj['Orient'][0])
9668+
ApplyAV(A,V)
9669+
data['Drawing']['Atoms'] = []
9670+
UpdateDrawAtoms(G2frame,data)
9671+
G2plt.PlotStructure(G2frame,data)
9672+
96589673
SGData = data['General']['SGData']
96599674
rbSizer = wx.BoxSizer(wx.VERTICAL)
96609675
topSizer = wx.FlexGridSizer(0,7,5,5)
@@ -9725,6 +9740,17 @@ def OnOrien(*args, **kwargs):
97259740
sytsymtxt = wx.StaticText(RigidBodies,label='%s site symmetry: %s, multiplicity: %d '%(Name,Sytsym,Mult))
97269741
rbSizer.Add(topSizer)
97279742
rbSizer.Add(sytsymtxt)
9743+
choices = [' x ',' y ',' z ','x+y','x+y+z']
9744+
RBObj['symAxis'] = RBObj.get('symAxis',[0,0,1]) #set default as 'z'
9745+
try:
9746+
symax = dict(zip([str(x) for x in [[1,0,0],[0,1,0],[0,0,1],[1,1,0],[1,1,1]]],choices))[str(RBObj['symAxis'])]
9747+
except KeyError:
9748+
symax = ' z '
9749+
symRadioSet = wx.RadioBox(RigidBodies,choices=choices,label='RB polar axis is aligned along:')
9750+
symRadioSet.SetStringSelection(symax)
9751+
symRadioSet.Bind(wx.EVT_RADIOBOX, OnSymRadioSet)
9752+
Indx[symRadioSet.GetId()] = rbId
9753+
rbSizer.Add(symRadioSet)
97289754
return rbSizer
97299755

97309756
def SpnrbSizer(RBObj,spnIndx):
@@ -9747,17 +9773,6 @@ def OnDelSpnRB(event):
97479773
G2plt.PlotStructure(G2frame,data)
97489774
wx.CallAfter(FillRigidBodyGrid,True)
97499775

9750-
def OnSymRadioSet(event):
9751-
'''Set the polar axis for the sp. harm. as
9752-
RBdata['Spin'][RBId]['symAxis']. This may never be
9753-
set, so use RBdata['Spin'][RBId].get('symAxis') to
9754-
access this so the default value is [0,0,1].
9755-
'''
9756-
Obj = event.GetEventObject()
9757-
axis = ([1,0,0],[0,1,0],[0,0,1],[1,1,0],[1,1,1])[Obj.GetSelection()]
9758-
RBObj['symAxis'] = axis
9759-
G2plt.PlotStructure(G2frame,data)
9760-
97619776
def OnAddShell(event):
97629777
rbNames = []
97639778
rbIds = {}
@@ -9965,15 +9980,7 @@ def OnSliceShell(event):
99659980
Indx[hidesh.GetId()] = 0
99669981
topLine.Add(hidesh,0,WACV)
99679982
sprbSizer.Add(wx.StaticText(RigidBodies,label='Spinning RB orientation parameters for %s:'%RBObj['RBname'][0]))
9968-
sprbSizer.Add(LocationSizer(RBObj,'Spin'))
9969-
choices = [' x ',' y ',' z ','x+y','x+y+z']
9970-
RBObj['symAxis'] = RBObj.get('symAxis',[0,0,1]) #set default as 'z'
9971-
symax = dict(zip([str(x) for x in [[1,0,0],[0,1,0],[0,0,1],[1,1,0],[1,1,1]]],choices))[str(RBObj['symAxis'])]
9972-
symRadioSet = wx.RadioBox(RigidBodies,choices=choices,label='Sp harm polar axis is aligned along:')
9973-
symRadioSet.SetStringSelection(symax)
9974-
symRadioSet.Bind(wx.EVT_RADIOBOX, OnSymRadioSet)
9975-
Indx[symRadioSet.GetId()] = rbId
9976-
sprbSizer.Add(symRadioSet)
9983+
sprbSizer.Add(LocationSizer(RBObj,'Spin',rbId))
99779984
plotLine = wx.BoxSizer(wx.HORIZONTAL)
99789985
RBObj['useAtColor'] = RBObj.get('useAtColor',True)
99799986
atColor = wx.CheckBox(RigidBodies,label='Use atom color?')
@@ -10073,7 +10080,7 @@ def OnDelResRB(event):
1007310080
topLine.Add(wx.StaticText(RigidBodies,-1,
1007410081
' (variables '+varname+')'),0,WACV)
1007510082
resrbSizer.Add(topLine)
10076-
resrbSizer.Add(LocationSizer(RBObj,'Residue'))
10083+
resrbSizer.Add(LocationSizer(RBObj,'Residue',rbId))
1007710084
if len(RBObj['Torsions']):
1007810085
resrbSizer.Add(wx.StaticText(RigidBodies,-1,'Torsions:'),0)
1007910086
torSizer = wx.FlexGridSizer(0,8,5,5)
@@ -10162,7 +10169,7 @@ def OnDelVecRB(event):
1016210169
Indx[delRB.GetId()] = rbId
1016310170
topLine.Add(delRB,0,WACV)
1016410171
vecrbSizer.Add(topLine)
10165-
vecrbSizer.Add(LocationSizer(RBObj,'Vector'))
10172+
vecrbSizer.Add(LocationSizer(RBObj,'Vector',rbId))
1016610173
members = 'Rigid body members: '
1016710174
for Id in RBObj['Ids']:
1016810175
members += data['Atoms'][AtLookUp[Id]][ct-1].strip()+', '

GSASII/imports/G2sfact_CIF.py

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ def Reader(self, filename, ParentFrame=None, **kwarg):
9898
# scan blocks for reflections
9999
self.errors = 'Error during scan of blocks for datasets'
100100
blklist = []
101-
EmbeddedShelx = []
101+
EmbeddedShelx = [] #as made by Olex2
102102
for blk in cf.keys(): # scan for reflections, F or F2 values and cell lengths.
103103
# Ignore blocks that do not have structure factors and a cell
104104
blkkeys = [k.lower() for k in cf[blk].keys()]
@@ -110,7 +110,7 @@ def Reader(self, filename, ParentFrame=None, **kwarg):
110110
if hklitems[i][0] in blkkeys and hklitems[i][1] in blkkeys and hklitems[i][2] in blkkeys:
111111
dnIndex = i
112112
break
113-
if '_shelx_hkl_file' in blkkeys:
113+
if '_shelx_hkl_file' in blkkeys: #found Olex2 reflection block from Shelx; should be h,k,l,Fo^2,sig(Fo^2)
114114
blklist.append(blk)
115115
EmbeddedShelx.append(blk)
116116
break
@@ -190,17 +190,20 @@ def Reader(self, filename, ParentFrame=None, **kwarg):
190190
self.errors = ' Error reading line '+str(line+1)
191191
if not len(S.strip()): continue
192192
items = S.split()
193-
h,k,l,Fo,sigFo = items[:5]
193+
h,k,l,Fo,sigFo = items[:5] #will only be h,k,l,fo^2,sig(Fo^2)
194194
h,k,l = [int(h),int(k),int(l)]
195-
if not any([h,k,l]):
195+
if not any([h,k,l]): #end of file found
196196
break
197197
Fo = float(Fo)
198198
sigFo = float(sigFo)
199-
self.RefDict['RefList'].append([h,k,l,1,0,Fo**2,2.*Fo*sigFo,0,Fo**2,0,0,1])
199+
self.RefDict['RefList'].append([h,k,l,1,0,Fo,sigFo,0,Fo,0,0,1])
200200
self.RefDict['RefList'] = np.array(self.RefDict['RefList'])
201201
self.RefDict['Type'] = 'SXC'
202202
self.RefDict['Super'] = 0
203-
self.UpdateParameters(Type='SXC',Wave=None) # histogram type
203+
wave = 0.70926
204+
if blk.get('_diffrn_radiation_wavelength'):
205+
wave = float(blk['_diffrn_radiation_wavelength'])
206+
self.UpdateParameters(Type='SXC',Wave=wave) # histogram type
204207
return True
205208
except:
206209
return False
@@ -348,11 +351,10 @@ def Reader(self, filename, ParentFrame=None, **kwarg):
348351
Type = 'SNC'
349352
self.RefDict['Type'] = Type
350353
self.RefDict['Super'] = im
354+
wave = 0.70926
351355
if blk.get('_diffrn_radiation_wavelength'):
352356
wave = float(blk['_diffrn_radiation_wavelength'])
353357
elif blk.get('_diffrn_radiation.wavelength'):
354358
wave = float(blk['_diffrn_radiation.wavelength'])
355-
else:
356-
wave = 0.70926
357359
self.UpdateParameters(Type=Type,Wave=wave) # histogram type
358360
return True

0 commit comments

Comments
 (0)