Skip to content

Commit

Permalink
Merge pull request #529 from beomki-yeo/handle-no-interaction
Browse files Browse the repository at this point in the history
Handle no interaction case
  • Loading branch information
beomki-yeo authored Aug 3, 2023
2 parents 8255f21 + cf03811 commit e50e0f9
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
18 changes: 18 additions & 0 deletions core/include/detray/materials/interaction.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,11 @@ struct interaction {
const scalar_t Ne{mat.get_material().molar_electron_density()};
const relativistic_quantities rq(m, qOverP, q);
const scalar_t eps{rq.compute_epsilon(Ne, path_segment)};

if (eps <= 0.f) {
return 0.f;
}

const scalar_t dhalf{rq.compute_delta_half(mat.get_material())};
const scalar_t u{rq.compute_mass_term(constant<scalar_t>::m_e)};
const scalar_t wmax{rq.compute_WMax(m)};
Expand All @@ -57,6 +62,11 @@ struct interaction {
const scalar_t Ne{mat.get_material().molar_electron_density()};
const relativistic_quantities rq(m, qOverP, q);
const scalar_t eps{rq.compute_epsilon(Ne, path_segment)};

if (eps <= 0.f) {
return 0.f;
}

const scalar_t dhalf{rq.compute_delta_half(mat.get_material())};
const scalar_t t{rq.compute_mass_term(constant<scalar_t>::m_e)};
// uses RPP2018 eq. 33.11
Expand Down Expand Up @@ -142,6 +152,10 @@ struct interaction {
DETRAY_HOST_DEVICE scalar_type
theta0Highland(const scalar_type xOverX0, const scalar_type momentumInv,
const scalar_type q2OverBeta2) const {
if (xOverX0 <= 0.f) {
return 0.f;
}

// RPP2018 eq. 33.15 (treats beta and q² consistenly)
const scalar_type t{std::sqrt(xOverX0 * q2OverBeta2)};
// log((x/X0) * (q²/beta²)) = log((sqrt(x/X0) * (q/beta))²)
Expand All @@ -154,6 +168,10 @@ struct interaction {
DETRAY_HOST_DEVICE scalar_type
theta0RossiGreisen(const scalar_type xOverX0, const scalar_type momentumInv,
const scalar_type q2OverBeta2) const {
if (xOverX0 <= 0.f) {
return 0.f;
}

// TODO add source paper/ resource
const scalar_type t{std::sqrt(xOverX0 * q2OverBeta2)};
return 17.5f * unit<scalar_type>::MeV * momentumInv * t *
Expand Down
2 changes: 1 addition & 1 deletion core/include/detray/materials/material_rod.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ struct material_rod : public detail::homogeneous_material_tag {
DETRAY_HOST_DEVICE constexpr scalar_type path_segment(
const scalar_type cos_inc_angle, const scalar_type approach) const {
// Assume that is.local[0] is radial distance of line intersector
if (approach > m_radius) {
if (std::abs(approach) > m_radius) {
return 0.f;
}

Expand Down

0 comments on commit e50e0f9

Please sign in to comment.