From 6338b6c74562cb306454a3d81f846184fbe36541 Mon Sep 17 00:00:00 2001 From: "Seth R. Johnson" Date: Wed, 11 Dec 2024 16:14:00 -0500 Subject: [PATCH] Enable optical stepping loop (#1546) * Mark errored tracks for printing with tracking cut action * Update maximum optical steps to 1k * Reset killed tracks at start of loop * Update tests --- src/celeritas/optical/CoreTrackView.hh | 4 ++-- .../optical/action/detail/PreStepExecutor.hh | 5 +++++ src/celeritas/optical/detail/OpticalLaunchAction.cc | 2 +- test/celeritas/optical/OpticalCollector.test.cc | 13 ++++++------- 4 files changed, 14 insertions(+), 10 deletions(-) diff --git a/src/celeritas/optical/CoreTrackView.hh b/src/celeritas/optical/CoreTrackView.hh index 19bc750d51..cb4c071b0f 100644 --- a/src/celeritas/optical/CoreTrackView.hh +++ b/src/celeritas/optical/CoreTrackView.hh @@ -221,8 +221,8 @@ CELER_FUNCTION void CoreTrackView::apply_errored() { auto sim = this->sim(); CELER_EXPECT(is_track_valid(sim.status())); - sim.status(TrackStatus::killed); - sim.post_step_action({}); + sim.status(TrackStatus::errored); + sim.post_step_action(params_.scalars.tracking_cut_action); } //---------------------------------------------------------------------------// diff --git a/src/celeritas/optical/action/detail/PreStepExecutor.hh b/src/celeritas/optical/action/detail/PreStepExecutor.hh index 99aa229915..10f2f4ac27 100644 --- a/src/celeritas/optical/action/detail/PreStepExecutor.hh +++ b/src/celeritas/optical/action/detail/PreStepExecutor.hh @@ -32,6 +32,11 @@ struct PreStepExecutor CELER_FUNCTION void PreStepExecutor::operator()(CoreTrackView const& track) { auto sim = track.sim(); + if (sim.status() == TrackStatus::killed) + { + // Deactivate tracks killed in previous loop + sim.status(TrackStatus::inactive); + } if (sim.status() == TrackStatus::inactive) { // Clear step limit and actions for an empty track slot diff --git a/src/celeritas/optical/detail/OpticalLaunchAction.cc b/src/celeritas/optical/detail/OpticalLaunchAction.cc index c1987e9cb9..96e6140dae 100644 --- a/src/celeritas/optical/detail/OpticalLaunchAction.cc +++ b/src/celeritas/optical/detail/OpticalLaunchAction.cc @@ -151,7 +151,7 @@ void OpticalLaunchAction::execute_impl(CoreParams const&, CELER_ASSERT(offload_state); CELER_ASSERT(optical_state.size() > 0); - constexpr size_type max_step_iters{1}; + constexpr size_type max_step_iters{1024}; size_type num_step_iters{0}; size_type num_steps{0}; diff --git a/test/celeritas/optical/OpticalCollector.test.cc b/test/celeritas/optical/OpticalCollector.test.cc index 03e0edc8c6..85b5c868f3 100644 --- a/test/celeritas/optical/OpticalCollector.test.cc +++ b/test/celeritas/optical/OpticalCollector.test.cc @@ -518,8 +518,7 @@ TEST_F(LArSphereOffloadTest, host_generate_small) "Celeritas core state initialization complete", "No Cherenkov photons to generate", "Generated 964 Scintillation photons from 2 distributions", - R"(Exceeded step count of 1: aborting optical transport loop with 32 active tracks, 0 alive tracks, 32 vacancies, and 932 queued)", - R"(Generated 964 optical photons which completed 32 total steps over 1 iterations)", + R"(Generated 964 optical photons which completed 964 total steps over 31 iterations)", "Deallocating host core state (stream 0)", }; if (CELERITAS_REAL_TYPE == CELERITAS_REAL_TYPE_DOUBLE) @@ -527,7 +526,7 @@ TEST_F(LArSphereOffloadTest, host_generate_small) EXPECT_VEC_EQ(expected_log_messages, scoped_log_.messages()); } static char const* const expected_log_levels[] - = {"status", "status", "debug", "debug", "error", "debug", "debug"}; + = {"status", "status", "debug", "debug", "debug", "debug"}; EXPECT_VEC_EQ(expected_log_levels, scoped_log_.levels()); } @@ -548,15 +547,15 @@ TEST_F(LArSphereOffloadTest, host_generate) "Celeritas core state initialization complete", "Generated 4258 Cherenkov photons from 4 distributions", "Generated 319935 Scintillation photons from 4 distributions", - R"(Exceeded step count of 1: aborting optical transport loop with 262144 active tracks, 0 alive tracks, 262144 vacancies, and 62049 queued)", - R"(Generated 324193 optical photons which completed 262144 total steps over 1 iterations)", - "Deallocating host core state (stream 0)"}; + R"(Generated 324193 optical photons which completed 324193 total steps over 2 iterations)", + "Deallocating host core state (stream 0)", + }; if (CELERITAS_REAL_TYPE == CELERITAS_REAL_TYPE_DOUBLE) { EXPECT_VEC_EQ(expected_log_messages, scoped_log_.messages()); } static char const* const expected_log_levels[] - = {"status", "status", "debug", "debug", "error", "debug", "debug"}; + = {"status", "status", "debug", "debug", "debug", "debug"}; EXPECT_VEC_EQ(expected_log_levels, scoped_log_.levels()); EXPECT_EQ(2, result.optical_launch_step);