Skip to content

Commit

Permalink
Throw CELER_NOT_IMPLEMENTED at construction time; clean up;
Browse files Browse the repository at this point in the history
  • Loading branch information
stognini committed Mar 20, 2024
1 parent 5d2fa13 commit f5b0fe2
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 30 deletions.
13 changes: 6 additions & 7 deletions src/celeritas/optical/ScintillationGenerator.hh
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,12 @@ ScintillationGenerator::ScintillationGenerator(
, sample_phi_(0, 2 * constants::pi)
, is_neutral_{dist_.charge == zero_quantity()}
{
if (shared_.scintillation_by_particle())
{
// TODO: implement sampling for particles
CELER_NOT_IMPLEMENTED("scintillation by particle type");
}

CELER_EXPECT(dist_);
CELER_EXPECT(shared_);
CELER_EXPECT(photons_.size() == dist_.num_photons);
Expand Down Expand Up @@ -118,13 +124,6 @@ template<class Generator>
CELER_FUNCTION Span<OpticalPrimary>
ScintillationGenerator::operator()(Generator& rng)
{
if (shared_.scintillation_by_particle())
{
// TODO: implement sampling for particles
CELER_NOT_IMPLEMENTED("scintillation by particle type");
}

// Loop for generating scintillation photons
size_type num_generated{0};
auto const& mat_spectrum = shared_.materials[dist_.material];

Expand Down
13 changes: 7 additions & 6 deletions src/celeritas/optical/ScintillationPreGenerator.hh
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,12 @@ inline CELER_FUNCTION ScintillationPreGenerator::ScintillationPreGenerator(
CELER_EXPECT(mat_id_);
CELER_EXPECT(shared_);
CELER_EXPECT(step_);

if (shared_.scintillation_by_particle())
{
// TODO: implement sampling for particles
CELER_NOT_IMPLEMENTED("scintillation by particle type");
}
}

//---------------------------------------------------------------------------//
Expand All @@ -99,12 +105,7 @@ template<class Generator>
inline CELER_FUNCTION OpticalDistributionData
ScintillationPreGenerator::operator()(Generator& rng)
{
if (shared_.scintillation_by_particle())
{
// TODO: implement sampling for particles
CELER_NOT_IMPLEMENTED("scintillation by particle type");
}

// Material-only sampling
auto const& material = shared_.materials[mat_id_];
CELER_EXPECT(material);

Expand Down
21 changes: 4 additions & 17 deletions test/celeritas/optical/Scintillation.test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
#include "corecel/data/Collection.hh"
#include "corecel/data/CollectionBuilder.hh"
#include "corecel/data/CollectionMirror.hh"
#include "geocel/UnitUtils.hh"
#include "celeritas/Quantities.hh"
#include "celeritas/Types.hh"
#include "celeritas/optical/OpticalDistributionData.hh"
Expand Down Expand Up @@ -81,8 +80,8 @@ class ScintillationTest : public OpticalTestBase
//! Create material components
std::vector<ImportScintComponent> build_material_components()
{
static constexpr double nm = 1e-9 * units::meter;
static constexpr double ns = 1e-9 * units::second;
static constexpr double nm = 1e-7; // to cm
static constexpr double ns = 1e-9; // to s

std::vector<ImportScintComponent> comps;
comps.push_back({0.65713, 128 * nm, 10 * nm, 10 * ns, 6 * ns});
Expand Down Expand Up @@ -125,7 +124,7 @@ class ScintillationTest : public OpticalTestBase
pregen_data.points[StepPoint::pre].speed = LightSpeed(0.99);
pregen_data.points[StepPoint::post].speed = LightSpeed(0.99 * 0.9);
pregen_data.points[StepPoint::pre].pos = {0, 0, 0};
pregen_data.points[StepPoint::post].pos = {0, 0, from_cm(1)};
pregen_data.points[StepPoint::post].pos = {0, 0, 1};
return pregen_data;
}

Expand Down Expand Up @@ -314,10 +313,9 @@ TEST_F(ScintillationTest, basic)
// Create the generator
ScintillationGenerator generate_photons(
result, params->host_ref(), make_span(storage));
RandomEngine& rng_engine = this->rng();

// Generate optical photons for a given input
auto photons = generate_photons(rng_engine);
auto photons = generate_photons(this->rng());

// Check results
std::vector<real_type> energy, time, cos_theta, polarization_x, cos_polar;
Expand Down Expand Up @@ -354,17 +352,6 @@ TEST_F(ScintillationTest, basic)
-0.57457399792055};
static double const expected_cos_polar[] = {0, 0, 0, 0};

/* CI gpu (clhep, vecgeom, debug) log
Expected: expected_time
4 of 4 elements differ
by 9.9999999999999998e-13 relative error or 1e-14 absolute error
i expected_time time Difference
0 3.2080893159083e-08 3.20580539320367e-08 -0.000711926159069127
1 6.136381528505e-09 6.11117967007341e-09 -0.00410695754729784
2 1.7964298529751e-06 1.79642453445081e-06 -2.96060783146328e-06
3 8.0854850049769e-07 8.08544680544845e-07 -4.72445727405664e-06
*/

EXPECT_VEC_SOFT_EQ(expected_energy, energy);
EXPECT_VEC_SOFT_EQ(expected_time, time);
EXPECT_VEC_SOFT_EQ(expected_cos_theta, cos_theta);
Expand Down

0 comments on commit f5b0fe2

Please sign in to comment.