Skip to content

Commit

Permalink
add test for dynamical_theta_offset
Browse files Browse the repository at this point in the history
  • Loading branch information
newville committed Jan 4, 2025
1 parent 30386ec commit 3cbecaa
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
7 changes: 7 additions & 0 deletions python/tests/test_xray.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@


from xraydb.xray import (chantler_data, formula_to_mass_fracs,
dynamical_theta_offset,
_validate_mass_fracs, mass_fracs_to_molar_fracs,
transmission_sample)

Expand Down Expand Up @@ -610,6 +611,12 @@ def dw_fwhm(energy, crystal, hkl):
assert_allclose(dw_fwhm(10000, 'Si', (3, 1, 1)), 0.301, rtol=0.02)
assert_allclose(dw_fwhm(20000, 'Si', (3, 1, 1)), 0.593, rtol=0.02)

def test_dynamical_offset():
t_off = dynamical_theta_offset(10000, 'Si', hkl=(1,1,1))*1e6

assert t_off > 24
assert t_off < 26


def test_ionchamber_fluxes():
ic1 = ionchamber_fluxes(gas='helium', volts=1.25, length=20.0,
Expand Down
2 changes: 0 additions & 2 deletions python/xraydb/xray.py
Original file line number Diff line number Diff line change
Expand Up @@ -974,7 +974,6 @@ def ionchamber_fluxes(gas='nitrogen', volts=1.0, length=100.0, energy=10000.0,
photo=flux_photo, incoherent=flux_incoh, coherent=flux_coh)



def dynamical_theta_offset(energy, crystal='Si', hkl=(1, 1, 1), a=None,
m=1, polarization='s'):
"""angular offset from Bragg diffraction for a perfect signle crystal
Expand Down Expand Up @@ -1032,7 +1031,6 @@ def dynamical_theta_offset(energy, crystal='Si', hkl=(1, 1, 1), a=None,
gscale *= (1 + abs(np.cos(2*theta)))/2.0
elif polarization.startswith('p'):
gscale *= abs(np.cos(2*theta))
print(theta*180/np.pi)
return 8*gscale*(f0(crystal, 0)[0] + f1)*np.tan(theta)/np.pi


Expand Down

0 comments on commit 3cbecaa

Please sign in to comment.