mirror of
https://github.com/pim-n/pg-rad
synced 2026-03-23 21:58:12 +01:00
Add detector architecture + isotropic detectors
This commit is contained in:
@ -7,7 +7,13 @@ from pg_rad.physics import calculate_fluence_at
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def phi_ref(test_landscape):
|
||||
def isotropic_detector():
|
||||
from pg_rad.detector.detectors import IsotropicDetector
|
||||
return IsotropicDetector(name="test_detector", eff=1.0)
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def phi_ref(test_landscape, isotropic_detector):
|
||||
source = test_landscape.point_sources[0]
|
||||
|
||||
r = np.linalg.norm(np.array([10, 10, 0]) - np.array(source.pos))
|
||||
@ -17,7 +23,8 @@ def phi_ref(test_landscape):
|
||||
mu_air = source.isotope.mu_mass_air * test_landscape.air_density
|
||||
mu_air *= 0.1
|
||||
|
||||
return A * b * np.exp(-mu_air * r) / (4 * np.pi * r**2)
|
||||
eff = isotropic_detector.get_efficiency(source.isotope.E)
|
||||
return A * eff * b * np.exp(-mu_air * r) / (4 * np.pi * r**2)
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
@ -38,6 +45,10 @@ def test_landscape():
|
||||
activity_MBq: 100
|
||||
position: [0, 0, 0]
|
||||
isotope: CS137
|
||||
|
||||
detector:
|
||||
name: dummy
|
||||
is_isotropic: True
|
||||
"""
|
||||
|
||||
cp = ConfigParser(test_yaml).parse()
|
||||
@ -45,9 +56,11 @@ def test_landscape():
|
||||
return landscape
|
||||
|
||||
|
||||
def test_single_source_fluence(phi_ref, test_landscape):
|
||||
def test_single_source_fluence(phi_ref, test_landscape, isotropic_detector):
|
||||
phi = calculate_fluence_at(
|
||||
test_landscape,
|
||||
np.array([10, 10, 0]),
|
||||
isotropic_detector,
|
||||
tangent_vectors=None,
|
||||
)
|
||||
assert pytest.approx(phi[0], rel=1E-3) == phi_ref
|
||||
|
||||
Reference in New Issue
Block a user