Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid stuck particles #341

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/PROPOSAL/detail/PROPOSAL/Propagator.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
39 changes: 39 additions & 0 deletions tests/Propagator_TEST.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,45 @@ TEST(Propagator, min_energy)
}
}

TEST(Propagator, BorderTransition)
{
auto p_def = MuMinusDef();
auto medium = Air();
auto cuts = std::make_shared<EnergyCutSettings>(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<Density_homogeneous>(medium);
auto sphere1 = std::make_shared<Sphere>(Cartesian3D(0, 0, -637218600), 1e20, 637413400);
sphere1->SetHierarchy(1);
auto sphere2 = std::make_shared<Sphere>(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<Sector> 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);
Expand Down