From c3ccb9a09c18d31f7c708efaef3790d1303c6bf4 Mon Sep 17 00:00:00 2001 From: Jean-Marco Alameddine Date: Fri, 20 Jan 2023 15:56:28 +0100 Subject: [PATCH 1/2] Add GEOMETRY_PRECISION when approaching border to avoid getting stuck in front of it --- src/PROPOSAL/detail/PROPOSAL/Propagator.cxx | 1 + 1 file changed, 1 insertion(+) diff --git a/src/PROPOSAL/detail/PROPOSAL/Propagator.cxx b/src/PROPOSAL/detail/PROPOSAL/Propagator.cxx index 37929328d..e19c4d804 100644 --- a/src/PROPOSAL/detail/PROPOSAL/Propagator.cxx +++ b/src/PROPOSAL/detail/PROPOSAL/Propagator.cxx @@ -252,6 +252,7 @@ int Propagator::AdvanceParticle(ParticleState &state, // reached geometry border advancement_type = ReachedBorder; distance = distance_to_border; + distance += GEOMETRY_PRECISION; // avoid particles getting stuck in front of border } else { // iteration not finished! discard energy and grammage advancement_type = InvalidStep; From 3277618b129262be2365a0a3425eba35aed4b390 Mon Sep 17 00:00:00 2001 From: Jean-Marco Alameddine Date: Fri, 20 Jan 2023 16:45:28 +0100 Subject: [PATCH 2/2] Add test of Propagator including a medium transition in air --- tests/Propagator_TEST.cxx | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/tests/Propagator_TEST.cxx b/tests/Propagator_TEST.cxx index e72726cb7..22be518d8 100644 --- a/tests/Propagator_TEST.cxx +++ b/tests/Propagator_TEST.cxx @@ -57,6 +57,45 @@ TEST(Propagator, min_energy) } } +TEST(Propagator, BorderTransition) +{ + auto p_def = MuMinusDef(); + auto medium = Air(); + auto cuts = std::make_shared(INF, 0.05, false); + auto cross = GetStdCrossSections(p_def, medium, cuts, true); + + auto collection = PropagationUtility::Collection(); + collection.interaction_calc = make_interaction(cross, true); + collection.displacement_calc = make_displacement(cross, true); + collection.time_calc = make_time(cross, p_def, true); + collection.scattering = make_scattering(MultipleScatteringType::Highland, {}, p_def, medium); + + auto prop_utility = PropagationUtility(collection); + + auto density_distr = std::make_shared(medium); + auto sphere1 = std::make_shared(Cartesian3D(0, 0, -637218600), 1e20, 637413400); + sphere1->SetHierarchy(1); + auto sphere2 = std::make_shared(Cartesian3D(0, 0, -637218600), 637413400, 0); + sphere2->SetHierarchy(2); + + auto sector1 = std::make_tuple(sphere1, prop_utility, density_distr); + auto sector2 = std::make_tuple(sphere2, prop_utility, density_distr); + + std::vector sec_vec = {sector1, sector2}; + + auto prop = Propagator(p_def, sec_vec); + + auto init_state = ParticleState(); + init_state.energy = 1e9; + init_state.position = Cartesian3D(0, 0, 1.01948e+07); + init_state.direction = Cartesian3D(0, 0, -1); + + for (size_t i=0; i<1000; i++) { + std::cout << i << std::endl; + auto sec = prop.Propagate(init_state); + } +} + int main(int argc, char** argv) { ::testing::InitGoogleTest(&argc, argv);