Skip to content

Commit d56f804

Browse files
committed
changes to Absorbcorrect matrix math for deformation
1 parent ac8e805 commit d56f804

File tree

3 files changed

+26
-7
lines changed

3 files changed

+26
-7
lines changed

GSASII/Absorb.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ class Absorb(wx.Frame):
8989
Pack = 0.50
9090
Radius = 0.4
9191
muT = 0.0
92+
muR = 0.0
9293
def _init_coll_ABOUT_Items(self, parent):
9394

9495
parent.Append(wxID_ABSORBABOUT,'About')
@@ -465,8 +466,9 @@ def SetWaveEnergy(self,Wave):
465466
self.muT = muT
466467

467468
if self.Volume:
469+
self.muR = self.Radius*self.Pack*muT/(10.0*self.Volume)
468470
Text += "%s %s%10.4g %s" % ("Total",' '+Gkmu+' =',self.Pack*muT/self.Volume,'cm'+Pwrm1+', ')
469-
Text += "%s%10.4g%s" % ('Total '+Gkmu+'R =',self.Radius*self.Pack*muT/(10.0*self.Volume),', ')
471+
Text += "%s%10.4g%s" % ('Total '+Gkmu+'R =',self.muR,', ')
470472
Text += "%s%10.4f%s\n" % ('Transmission exp(-2'+Gkmu+'R) =', \
471473
100.0*math.exp(-2.*self.Radius*self.Pack*muT/(10.0*self.Volume)),'%')
472474
if muT > 0.:
@@ -475,6 +477,9 @@ def SetWaveEnergy(self,Wave):
475477
Text += "%s %10.4g mm\n"%("1/e (~27.2%) penetration depth = ",pene)
476478
else:
477479
Text += "%s %10.4g %sm\n"%("1/e (~27.2%) penetration depth = ",1000.0*pene,Gkmu)
480+
Tth = np.array([0.0,140.0])
481+
Xabs = 1./G2pwd.Absorb('Cylinder',self.muR,Tth)
482+
Text += "%s %10.4g to %10.4g\n"%("Cylinder absorption correction extremes:",Xabs[0],Xabs[1])
478483
self.Results.SetValue(Text)
479484
den = Mass/(0.602*self.Volume)
480485
if self.ifVol:
@@ -602,8 +607,7 @@ def UpDateAbsPlot(self,Wave,rePlot=True):
602607
self.bx.set_title(r"Cylinder abs. corr. for $\lambda= %.4f\AA$"%self.Wave,x=0,ha='left')
603608
self.bx.set_xlabel(r"$2\theta$",fontsize=14)
604609
Tth = np.arange(0.,140.0,0.1)
605-
pmut = self.Radius*self.Pack*self.muT/(10.0*self.Volume)
606-
Xabs = 1./G2pwd.Absorb('Cylinder',pmut,Tth)
610+
Xabs = 1./G2pwd.Absorb('Cylinder',self.muR,Tth)
607611
self.bx.plot(Tth,Xabs)
608612
Ymin = 0.0
609613
Ymax = 0.0

GSASII/GSASIIlattice.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2887,6 +2887,20 @@ def GetKclKsl(L,N,SGLaue,psi,phi,beta):
28872887
Kcl = pcrs*(cosd(N*beta)+sind(N*beta))
28882888
return Kcl*Ksl,Lnorm(L)
28892889

2890+
def H2ThPh2(H,Bmat):
2891+
'''Convert HKL to spherical polar & azimuth angles
2892+
2893+
:param array H: array of hkl as [n,3]
2894+
:param [3,3] array Bmat: inv crystal to Cartesian transformation
2895+
:returns array Th: HKL azimuth angles
2896+
:returns array Ph: HKL polar angles
2897+
'''
2898+
Hcart = np.inner(H,Bmat)
2899+
R = np.sqrt(np.sum(np.square(Hcart),axis=1))
2900+
Pl = acosd(Hcart[:,2]/R)
2901+
Az = atan2d(Hcart[:,1],Hcart[:,0])
2902+
return R,Az,Pl
2903+
28902904
def H2ThPh(H,Bmat,Q):
28912905
'''Convert HKL to spherical polar & azimuth angles
28922906

GSASII/GSASIIstrMath.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -428,7 +428,7 @@ def extendChanges(prms):
428428
RBsu[k] = np.sqrt(np.inner(Avec.T,np.inner(covMatrix,Avec)))
429429
return RBsu
430430

431-
def MakeSpHarmFF(HKL,Bmat,SHCdict,Tdata,hType,FFtables,ORBtables,BLtables,FF,SQ,ifDeriv=False):
431+
def MakeSpHarmFF(HKL,Amat,Bmat,SHCdict,Tdata,hType,FFtables,ORBtables,BLtables,FF,SQ,ifDeriv=False):
432432
''' Computes hkl dependent form factors & derivatives from spinning rigid bodies
433433
:param array HKL: reflection hkl set to be considered
434434
:param array Bmat: inv crystal to Cartesian transfomation matrix
@@ -555,7 +555,8 @@ def MakePolar(Orient,QB):
555555
orKeys = [item for item in orKeys if 'Sl' in item]
556556
orbs = SHCdict[iAt]
557557
UVmat = np.inner(nl.inv(SHCdict[-iAt]['UVmat']),Bmat)
558-
Th,Ph = G2lat.H2ThPh(np.reshape(HKL,(-1,3)),UVmat,[1.,0.,0.,1.])
558+
R,Th,Ph = G2lat.H2ThPh2(np.reshape(HKL,(-1,3)),UVmat)
559+
R = 1/R # correct dspacings
559560
atFlg.append(1.0)
560561
orbTable = ORBtables[Atype][orKeys[0]] # should point at either Sl core or a Bessel core
561562
ffOrb = {item:orbTable[item] for item in orbTable if item not in ['Slater','ZSlater','NSlater','SZE','popCore','popVal']}
@@ -1214,7 +1215,7 @@ def StructureFactor2(refDict,G,hfx,pfx,SGData,calcControls,parmDict):
12141215
#FF has to have the Bessel*Sph.Har.*atm form factor for each refletion in Uniq for Q atoms; otherwise just normal FF
12151216
#this must be done here. NB: same place for non-spherical atoms; same math except no Bessel part.
12161217
if pfx in SHCdict:
1217-
MakeSpHarmFF(Uniq,Bmat,SHCdict[pfx],Tdata,hType,FFtables,ORBtables,BLtables,FF,SQ) #Not Amat!
1218+
MakeSpHarmFF(Uniq,Amat,Bmat,SHCdict[pfx],Tdata,hType,FFtables,ORBtables,BLtables,FF,SQ) #Not Amat!
12181219
Bab = np.repeat(parmDict[phfx+'BabA']*np.exp(-parmDict[phfx+'BabU']*SQfactor),len(SGT)*len(TwinLaw))
12191220
if 'T' in calcControls[hfx+'histType']: #fa,fb are 2 X blkSize X nTwin X nOps x nAtoms
12201221
fa = np.array([np.reshape(((FF+FP).T-Bab).T,cosp.shape)*cosp*Tcorr,-np.reshape(Flack*FPP,sinp.shape)*sinp*Tcorr])
@@ -1337,7 +1338,7 @@ def StructureFactorDerv2(refDict,G,hfx,pfx,SGData,calcControls,parmDict):
13371338
Hij = np.array([Mast*np.multiply.outer(U,U) for U in np.reshape(Uniq,(-1,3))]) #Nref*Nops,3,3
13381339
Hij = np.reshape(np.array([G2lat.UijtoU6(uij) for uij in Hij]),(-1,len(SGT),6)) #Nref,Nops,6
13391340
if pfx in SHCdict:
1340-
dffdsh,atFlg = MakeSpHarmFF(Uniq,Bmat,SHCdict[pfx],Tdata,hType,FFtables,ORBtables,BLtables,FF,SQ,True)
1341+
dffdsh,atFlg = MakeSpHarmFF(Uniq,Amat,Bmat,SHCdict[pfx],Tdata,hType,FFtables,ORBtables,BLtables,FF,SQ,True)
13411342
if len(dffdSH):
13421343
for item in dffdSH:
13431344
dffdSH[item] = np.concatenate((dffdSH[item],dffdsh[item]))

0 commit comments

Comments
 (0)