update tests to reflect new Landscape design

This commit is contained in:
Pim Nelissen
2026-02-13 16:07:42 +01:00
parent 0db1fe0626
commit beb411d456
5 changed files with 10 additions and 18 deletions

View File

@ -14,7 +14,7 @@ class LandscapeDirector:
def build_test_landscape(self): def build_test_landscape(self):
fp = files('pg_rad.data').joinpath(TEST_EXP_DATA) fp = files('pg_rad.data').joinpath(TEST_EXP_DATA)
source = PointSource(activity=100, isotope=CS137(), pos=(0, 0, 0)) source = PointSource(activity=100E9, isotope=CS137(), pos=(0, 0, 0))
lb = LandscapeBuilder("Test landscape") lb = LandscapeBuilder("Test landscape")
lb.set_air_density(1.243) lb.set_air_density(1.243)
lb.set_path_from_experimental_data(fp, z=0) lb.set_path_from_experimental_data(fp, z=0)

View File

@ -46,7 +46,7 @@ class Landscape:
def calculate_fluence_at(self, pos: tuple): def calculate_fluence_at(self, pos: tuple):
total_phi = 0. total_phi = 0.
for source in self.sources: for source in self.point_sources:
r = source.distance_to(pos) r = source.distance_to(pos)
phi_source = phi_single_source( phi_source = phi_single_source(
r=r, r=r,

View File

@ -19,12 +19,11 @@ def test_exact_attenuation_retrieval(energy, mu):
@pytest.mark.parametrize("energy,mu", [ @pytest.mark.parametrize("energy,mu", [
(0.662, 0.0778), (0.662, 0.0778)
(1.25, 0.06)
]) ])
def test_attenuation_interpolation(energy, mu): def test_attenuation_interpolation(energy, mu):
""" """
Test Cs-137 and Co-60 mass attenuation coefficients. Test retreival for Cs-137 mass attenuation coefficient.
""" """
interp_mu = get_mass_attenuation_coeff(energy) interp_mu = get_mass_attenuation_coeff(energy)
assert pytest.approx(interp_mu, rel=1E-2) == mu assert pytest.approx(interp_mu, rel=1E-2) == mu

View File

@ -2,9 +2,7 @@ from math import dist, exp, pi
import pytest import pytest
from pg_rad.isotopes import CS137 from pg_rad.landscape import LandscapeDirector
from pg_rad.landscape import Landscape
from pg_rad.objects import PointSource
@pytest.fixture @pytest.fixture
@ -27,12 +25,7 @@ def phi_ref():
@pytest.fixture @pytest.fixture
def test_landscape(): def test_landscape():
landscape = Landscape() landscape = LandscapeDirector().build_test_landscape()
source = PointSource(
pos=(0, 0, 0),
activity=100E9,
isotope=CS137)
landscape.add_sources(source)
return landscape return landscape

View File

@ -2,17 +2,17 @@ import numpy as np
import pytest import pytest
from pg_rad.objects import PointSource from pg_rad.objects import PointSource
from pg_rad.isotopes import Isotope from pg_rad.isotopes import CS137
@pytest.fixture @pytest.fixture
def test_sources(): def test_sources():
iso = Isotope("test", E=662, b=0) iso = CS137()
pos_a = np.random.rand(3) pos_a = np.random.rand(3)
pos_b = np.random.rand(3) pos_b = np.random.rand(3)
a = PointSource(pos_a, activity=None, isotope=iso) a = PointSource(pos=pos_a, activity=None, isotope=iso)
b = PointSource(pos_b, activity=None, isotope=iso) b = PointSource(pos=pos_b, activity=None, isotope=iso)
return pos_a, pos_b, a, b return pos_a, pos_b, a, b