Skip to content

Commit ffbfabc

Browse files
committed
Add derivative calc to KslCalc - currently not used
fix spin RB geometry in G2strMath
1 parent 15477b6 commit ffbfabc

3 files changed

Lines changed: 16 additions & 5 deletions

File tree

GSASII/GSASIIlattice.py

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2999,7 +2999,7 @@ def SHarmcal(SytSym,SHFln,psi,gam):
29992999
SHVal += (SHFln[term][0]*Ksl)
30003000
return SHVal
30013001

3002-
def KslCalc(trm,psi,gam):
3002+
def KslCalc(trm,psi,gam,ifDerv=False):
30033003
'''Compute one angular part term in spherical harmonics
30043004
30053005
:param str trm:sp. harm term name in the form of 'C(l,m)' or 'C(l,m)c' for cubic
@@ -3008,11 +3008,22 @@ def KslCalc(trm,psi,gam):
30083008
30093009
:returns array Ksl: spherical harmonics angular part for psi,gam pairs
30103010
'''
3011+
delt = 0.0001
30113012
l,m = eval(trm.strip('C').strip('c'))
30123013
if 'c' in trm:
3013-
return CubicSHarm(l,m,psi,gam)
3014+
if ifDerv:
3015+
dYdp = (CubicSHarm(l,m,psi+delt,gam)-CubicSHarm(l,m,psi-delt,gam))/(2.0*delt)
3016+
dYdg = (CubicSHarm(l,m,psi,gam+delt)-CubicSHarm(l,m,psi,gam-delt))/(2.0*delt)
3017+
return CubicSHarm(l,m,psi,gam),dYdp,dYdg
3018+
else:
3019+
return CubicSHarm(l,m,psi,gam)
30143020
else:
3015-
return SphHarmAng(l,m,1.0,psi,gam)
3021+
if ifDerv:
3022+
dYdp = (SphHarmAng(l,m,1.0,psi+delt,gam)-SphHarmAng(l,m,1.0,psi-delt,gam))/(2.0*delt)
3023+
dYdg = (SphHarmAng(l,m,1.0,psi,gam+delt)-SphHarmAng(l,m,1.0,psi,gam-delt))/(2.0*delt)
3024+
return SphHarmAng(l,m,1.0,psi,gam),dYdp,dYdg
3025+
else:
3026+
return SphHarmAng(l,m,1.0,psi,gam)
30163027

30173028
def SphHarmAng(L,M,P,Th,Ph):
30183029
''' Compute spherical harmonics values using scipy.special.sph_harm

GSASII/GSASIIplot.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7412,7 +7412,7 @@ def SetProjection(Zclip):
74127412
symAxis = np.array(SpnData.get('symAxis',[0,0,1]))
74137413
Npsi,Ngam = 90,45
74147414
QA = G2mth.invQ(SpnData['Orient'][0]) #rotate about chosen axis
7415-
QB = G2mth.make2Quat(symAxis,np.array([0,0,1.]))[0] #position obj polar axis
7415+
QB = G2mth.make2Quat(np.array([0,0,1.]),symAxis)[0] #position obj polar axis
74167416
QP = G2mth.AVdeg2Q(360./Npsi,np.array([0,0,1.])) #this shifts by 1 azimuth pixel
74177417
Q = G2mth.prodQQ(QB,QA)
74187418
Q = G2mth.prodQQ(Q,QP)

GSASII/GSASIIstrMath.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -449,7 +449,7 @@ def MakeSpHarmFF(HKL,Amat,Bmat,SHCdict,Tdata,hType,FFtables,ORBtables,BLtables,F
449449

450450
def MakePolar(Orient,QB):
451451
QA = G2mth.invQ(Orient) #rotates about chosen axis
452-
Q = G2mth.prodQQ(QA,QB) #might be switched? QB,QA is order for plotting
452+
Q = G2mth.prodQQ(QB,QA) #might be switched? QB,QA is order for plotting
453453
M = np.inner(G2mth.Q2Mat(Q),Bmat)
454454
return G2lat.H2ThPh2(hkl,M)[1:]
455455

0 commit comments

Comments
 (0)