OpenMC/tests/unit_tests/test_data_dose.py
Matteo Zammataro 97e04c464a
Some checks are pending
Tests and Coverage / filter-changes (push) Waiting to run
Tests and Coverage / Python 3.13 (omp=n, mpi=n, dagmc=, libmesh=, event= (push) Blocked by required conditions
Tests and Coverage / Python 3.14 (omp=n, mpi=n, dagmc=, libmesh=, event= (push) Blocked by required conditions
Tests and Coverage / Python 3.14t (omp=n, mpi=n, dagmc=, libmesh=, event= (push) Blocked by required conditions
Tests and Coverage / Python 3.12 (omp=n, mpi=n, dagmc=n, libmesh=n, event=n (push) Blocked by required conditions
Tests and Coverage / Python 3.12 (omp=y, mpi=n, dagmc=n, libmesh=n, event=n (push) Blocked by required conditions
Tests and Coverage / Python 3.12 (omp=n, mpi=y, dagmc=n, libmesh=n, event=n (push) Blocked by required conditions
Tests and Coverage / Python 3.12 (omp=y, mpi=y, dagmc=n, libmesh=n, event=n (push) Blocked by required conditions
Tests and Coverage / Python 3.12 (omp=y, mpi=n, dagmc=, libmesh=y, event= (push) Blocked by required conditions
Tests and Coverage / Python 3.12 (omp=y, mpi=n, dagmc=, libmesh=, event=y (push) Blocked by required conditions
Tests and Coverage / Python 3.12 (omp=y, mpi=y, dagmc=y, libmesh=, event= (push) Blocked by required conditions
Tests and Coverage / Python 3.12 (omp=y, mpi=y, dagmc=, libmesh=y, event= (push) Blocked by required conditions
Tests and Coverage / coverage (push) Blocked by required conditions
Tests and Coverage / Check CI status (push) Blocked by required conditions
dockerhub-publish-develop / main (push) Waiting to run
dockerhub-publish-develop-dagmc-libmesh / main (push) Waiting to run
dockerhub-publish-develop-dagmc / main (push) Waiting to run
dockerhub-publish-develop-libmesh / main (push) Waiting to run
Add ambient dose coefficients (H*(10)) from ICRP74 (#3256)
Co-authored-by: matteo.zammataro <matteo.zammataro@newcleo.com>
Co-authored-by: Paul Romano <paul.k.romano@gmail.com>
2026-07-02 23:51:10 +00:00

86 lines
2.9 KiB
Python

from openmc.data import dose_coefficients
from pytest import approx, raises
def test_dose_coefficients():
# Spot checks on values from ICRP tables
energy, dose = dose_coefficients('photon', 'AP')
assert energy[0] == approx(0.01e6)
assert dose[0] == approx(0.0685)
assert energy[-1] == approx(10e9)
assert dose[-1] == approx(90.4) # updated in corrigendum
energy, dose = dose_coefficients('neutron', 'LLAT')
assert energy[0] == approx(1e-3)
assert dose[0] == approx(1.04)
assert energy[-1] == approx(10e9)
assert dose[-1] == approx(1.23e3)
energy, dose = dose_coefficients('electron', 'ISO')
assert energy[0] == approx(0.01e6)
assert dose[0] == approx(0.0188)
assert energy[-1] == approx(10e9)
assert dose[-1] == approx(699.0)
energy, dose = dose_coefficients('photon', data_source='icrp74')
assert energy[0] == approx(0.01e6)
assert dose[0] == approx(7.43*0.00653)
assert energy[-1] == approx(10.0e6)
assert dose[-1] == approx(24.0*0.990)
energy, dose = dose_coefficients('neutron', 'LLAT', data_source='icrp74')
assert energy[0] == approx(1e-3)
assert dose[0] == approx(1.68)
assert energy[-1] == approx(20.0e6)
assert dose[-1] == approx(338.0)
energy, dose = dose_coefficients(
'neutron', data_source='icrp74', dose_quantity='ambient')
assert energy[0] == approx(1e-3)
assert dose[0] == approx(6.60)
assert energy[-1] == approx(20.0e6)
assert dose[-1] == approx(600)
energy, dose = dose_coefficients(
'photon', data_source='icrp74', dose_quantity='ambient')
assert energy[0] == approx(0.01e6)
assert dose[0] == approx(0.061)
assert energy[-1] == approx(10e6)
assert dose[-1] == approx(25.6)
# Invalid particle/geometry should raise an exception
with raises(ValueError):
dose_coefficients('slime', 'LAT')
with raises(ValueError):
dose_coefficients('neutron', 'ZZ')
with raises(ValueError):
dose_coefficients('neutron', data_source='icrp7000')
with raises(ValueError):
dose_coefficients('neutron', dose_quantity='banana')
with raises(ValueError):
dose_coefficients(
'neutron', data_source='icrp116', dose_quantity='ambient')
with raises(ValueError):
dose_coefficients(
'neutron', 'ISO', data_source='icrp74', dose_quantity='ambient')
with raises(ValueError) as excinfo:
dose_coefficients("photons", data_source="icrp116")
expected_particles = [
"electron",
"helium",
"mu+",
"mu-",
"neutron",
"photon",
"photon kerma",
"pi+",
"pi-",
"positron",
"proton",
]
expected_msg = (
"'photons' has no effective dose data in data source icrp116. "
"Available particles for icrp116 with dose quantity effective are: "
f"{expected_particles}"
)
assert str(excinfo.value) == expected_msg