Skip to content

Commit 75ce746

Browse files
committed
fixes to deformation stuff
1 parent cf19727 commit 75ce746

File tree

3 files changed

+39
-39
lines changed

3 files changed

+39
-39
lines changed

GSASII/GSASIIlattice.py

Lines changed: 31 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -2526,9 +2526,8 @@ def GenRBCoeff(sytsym,RBsym,L):
25262526
cubic = False
25272527
if sytsym in ['23','m3','432','-43m','m3m']:
25282528
cubic = True
2529-
for iord in range(L+1):
2530-
if not iord: continue
2531-
for n in range(iord+1):
2529+
for iord in range(1,L+1):
2530+
for n in range(-iord,iord+1):
25322531
rbChk,sgn = RBChk(sytsym,iord,n)
25332532
if rbChk:
25342533
if cubic:
@@ -2553,7 +2552,7 @@ def GenShCoeff(sytsym,L):
25532552
cubic = False
25542553
if sytsym in ['23','m3','432','-43m','m3m','53m']:
25552554
cubic = True
2556-
for n in range(L+1):
2555+
for n in range(-L,L+1):
25572556
rbChk,sgn = RBChk(sytsym,L,n)
25582557
if rbChk:
25592558
if cubic:
@@ -2901,34 +2900,34 @@ def H2ThPh2(H,Bmat):
29012900
Az = atan2d(Hcart[:,1],Hcart[:,0])
29022901
return R,Az,Pl
29032902

2904-
def H2ThPh(H,Bmat,Q):
2905-
'''Convert HKL to spherical polar & azimuth angles
2906-
2907-
:param array H: array of hkl as [n,3]
2908-
:param [3,3] array Bmat: inv crystal to Cartesian transformation
2909-
:param array Q: quaternion for rotation of HKL to new polar axis
2910-
:returns array Th: HKL azimuth angles
2911-
:returns array Ph: HKL polar angles
2912-
'''
2913-
# A,V = G2mth.Q2AVdeg(Q)
2914-
# QR,R = G2mth.make2Quat(V,np.array([0.,0.,1.0]))
2915-
# QA = G2mth.AVdeg2Q(A,np.array([0.,0.,1.0]))
2916-
# Q2 = G2mth.prodQQ(QR,QA)
2917-
Qmat = G2mth.Q2Mat(Q)
2918-
CH1 = np.inner(H,Bmat.T)
2919-
CH = np.inner(CH1,Qmat.T)
2920-
N = nl.norm(CH,axis=1)
2921-
CH /= N[:,nxs]
2922-
H3 = np.array([0,0,1.])
2923-
DHR = np.inner(CH,H3)
2924-
Ph = np.where(DHR <= 1.0,acosd(DHR),0.0) #polar angle 0<=Ph<=180.; correct
2925-
TH = CH*np.array([1.,1.,0.])[nxs,:] #projection of CH onto xy plane
2926-
N = nl.norm(TH,axis=1)
2927-
N = np.where(N > 1.e-5,N,1.)
2928-
TH /= N[:,nxs]
2929-
Th = atan2d(TH[:,1],TH[:,0]) #azimuth angle 0<=Th<360<
2930-
Th = np.where(Th<0.,Th+360.,Th)
2931-
return Th,Ph #azimuth,polar angles
2903+
# def H2ThPh(H,Bmat,Q):
2904+
# '''Convert HKL to spherical polar & azimuth angles - wrong!
2905+
2906+
# :param array H: array of hkl as [n,3]
2907+
# :param [3,3] array Bmat: inv crystal to Cartesian transformation
2908+
# :param array Q: quaternion for rotation of HKL to new polar axis
2909+
# :returns array Th: HKL azimuth angles
2910+
# :returns array Ph: HKL polar angles
2911+
# '''
2912+
# # A,V = G2mth.Q2AVdeg(Q)
2913+
# # QR,R = G2mth.make2Quat(V,np.array([0.,0.,1.0]))
2914+
# # QA = G2mth.AVdeg2Q(A,np.array([0.,0.,1.0]))
2915+
# # Q2 = G2mth.prodQQ(QR,QA)
2916+
# Qmat = G2mth.Q2Mat(Q)
2917+
# CH1 = np.inner(H,Bmat.T)
2918+
# CH = np.inner(CH1,Qmat.T)
2919+
# N = nl.norm(CH,axis=1)
2920+
# CH /= N[:,nxs]
2921+
# H3 = np.array([0,0,1.])
2922+
# DHR = np.inner(CH,H3)
2923+
# Ph = np.where(DHR <= 1.0,acosd(DHR),0.0) #polar angle 0<=Ph<=180.; correct
2924+
# TH = CH*np.array([1.,1.,0.])[nxs,:] #projection of CH onto xy plane
2925+
# N = nl.norm(TH,axis=1)
2926+
# N = np.where(N > 1.e-5,N,1.)
2927+
# TH /= N[:,nxs]
2928+
# Th = atan2d(TH[:,1],TH[:,0]) #azimuth angle 0<=Th<360<
2929+
# Th = np.where(Th<0.,Th+360.,Th)
2930+
# return Th,Ph #azimuth,polar angles
29322931

29332932
def SetUVvec(Neigh):
29342933
''' Set deformation coordinate choices from neighbors; called in G2phsGUI/UpdateDeformation

GSASII/GSASIIphsGUI.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12134,7 +12134,7 @@ def NeSizer(deformation,orbSizer,dId,orb,Indx):
1213412134

1213512135
def Dsizer(deformation,orbSizer,dId,orb,Indx):
1213612136
orbSizer.Add(wx.StaticText(deformation,label=item+':'))
12137-
orbSizer.Add(G2G.ValidatedTxtCtrl(deformation,orb[1][item],0,nDig=(8,3),xmin=-2.,xmax=2.))
12137+
orbSizer.Add(G2G.ValidatedTxtCtrl(deformation,orb[1][item],0,nDig=(8,5),xmin=-1.,xmax=1.))
1213812138
Tcheck = wx.CheckBox(deformation,-1,'Refine?')
1213912139
Tcheck.SetValue(orb[1][item][1])
1214012140
Tcheck.Bind(wx.EVT_CHECKBOX,OnDeformRef)
@@ -12163,9 +12163,9 @@ def OnNewHarm(event):
1216312163
if name not in Hkeys: #new names found
1216412164
notFound = False
1216512165
Harm[1].update({name:[0.0,False]})
12166-
if '0' not in name:
12167-
negname = name.replace(',',',-')
12168-
Harm[1].update({negname:[0.0,False]})
12166+
# if '0' not in name:
12167+
# negname = name.replace(',',',-')
12168+
# Harm[1].update({negname:[0.0,False]})
1216912169
Order += 1
1217012170
wx.CallAfter(UpdateDeformation,dId)
1217112171

GSASII/GSASIIstrMath.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -448,15 +448,16 @@ def MakeSpHarmFF(HKL,Amat,Bmat,SHCdict,Tdata,hType,FFtables,ORBtables,BLtables,F
448448
def MakePolar(Orient,QB):
449449
QA = G2mth.invQ(Orient) #rotates about chosen axis
450450
Q = G2mth.prodQQ(QB,QA) #might be switched? QB,QA is order for plotting
451-
return G2lat.H2ThPh(np.reshape(HKL,(-1,3)),Bmat,Q)
451+
M = np.inner(G2mth.Q2Mat(Q),Bmat)
452+
return G2lat.H2ThPh2(np.reshape(HKL,(-1,3)),M)
452453

453454
dFFdS = {}
454455
atFlg = []
455-
Th,Ph = G2lat.H2ThPh(np.reshape(HKL,(-1,3)),Bmat,[1.,0.,0.,1.])
456+
Th,Ph = G2lat.H2ThPh2(np.reshape(HKL,(-1,3)),Bmat)
456457
SQR = np.repeat(SQ,HKL.shape[1])
457458
for iAt,Atype in enumerate(Tdata):
458459
if 'Q' in Atype:
459-
Th,Ph = G2lat.H2ThPh(np.reshape(HKL,(-1,3)),Bmat,[1.,0.,0.,1.])
460+
Th,Ph = G2lat.H2ThPh2(np.reshape(HKL,(-1,3)),Bmat)
460461
atFlg.append(1.0)
461462
SHdat = SHCdict[iAt]
462463
symAxis = np.array(SHdat['symAxis'])

0 commit comments

Comments
 (0)