-
Notifications
You must be signed in to change notification settings - Fork 45
Support decay in stepping loop #1991
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
base: develop
Are you sure you want to change the base?
Changes from all commits
2cf22fe
8f9a328
ffa73cc
888d0bf
9a467b1
c30626c
08a2f1f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,54 @@ | ||
| //------------------------------- -*- C++ -*- -------------------------------// | ||
| // Copyright Celeritas contributors: see top-level COPYRIGHT file for details | ||
| // SPDX-License-Identifier: (Apache-2.0 OR MIT) | ||
| //---------------------------------------------------------------------------// | ||
| //! \file celeritas/decay/DecayData.hh | ||
| //---------------------------------------------------------------------------// | ||
| #pragma once | ||
|
|
||
| #include "corecel/Macros.hh" | ||
| #include "corecel/Types.hh" | ||
| #include "corecel/data/Collection.hh" | ||
| #include "celeritas/Types.hh" | ||
|
|
||
| namespace celeritas | ||
| { | ||
| //---------------------------------------------------------------------------// | ||
| /*! | ||
| * Data for a decay interactor. | ||
| * | ||
| * This stores the particle IDs of the daughters for a specific decay channel. | ||
| */ | ||
| struct DecayChannelData | ||
| { | ||
| //! Daughter particle IDs | ||
| ItemRange<ParticleId> daughters; | ||
|
|
||
| //! Whether the data is assigned | ||
| explicit CELER_FUNCTION operator bool() const | ||
| { | ||
| return !daughters.empty(); | ||
| } | ||
| }; | ||
|
|
||
| //---------------------------------------------------------------------------// | ||
| /*! | ||
| * Decay channels for a particle type. | ||
| */ | ||
| struct DecayTableData | ||
| { | ||
| //! Decay channels | ||
| ItemRange<DecayChannelId> channel_ids; | ||
| //! Branching ratio of each decay channel | ||
| ItemRange<real_type> branching_ratios; | ||
|
|
||
| //! Whether the data is assigned | ||
| explicit CELER_FUNCTION operator bool() const | ||
| { | ||
| return !channel_ids.empty() | ||
| && branching_ratios.size() == channel_ids.size(); | ||
| } | ||
| }; | ||
|
|
||
| //---------------------------------------------------------------------------// | ||
| } // namespace celeritas | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,90 @@ | ||
| //------------------------------- -*- C++ -*- -------------------------------// | ||
| // Copyright Celeritas contributors: see top-level COPYRIGHT file for details | ||
| // SPDX-License-Identifier: (Apache-2.0 OR MIT) | ||
| //---------------------------------------------------------------------------// | ||
| //! \file celeritas/decay/DecayProcess.cc | ||
| //---------------------------------------------------------------------------// | ||
| #include "DecayProcess.hh" | ||
|
|
||
| #include <set> | ||
|
|
||
| #include "corecel/Assert.hh" | ||
| #include "celeritas/decay/DecayData.hh" | ||
| #include "celeritas/decay/channel/MuDecayChannel.hh" | ||
| #include "celeritas/phys/PDGNumber.hh" | ||
| #include "celeritas/phys/ParticleParams.hh" | ||
|
|
||
| namespace celeritas | ||
| { | ||
| //---------------------------------------------------------------------------// | ||
| /*! | ||
| * Construct from particles and input data. | ||
| */ | ||
| DecayProcess::DecayProcess(SPConstParticles particles, | ||
| inp::DecayPhysics const& input) | ||
| : particles_(std::move(particles)), input_(input) | ||
| { | ||
| CELER_EXPECT(particles_); | ||
| CELER_VALIDATE(input_, << "no decay tables are present"); | ||
| } | ||
|
|
||
| //---------------------------------------------------------------------------// | ||
| /*! | ||
| * Construct the decay channels. | ||
| */ | ||
| auto DecayProcess::build_channels(ActionIdIter start_id) const -> VecChannel | ||
| { | ||
| VecChannel result; | ||
| std::set<DecayChannelType> types; | ||
| for (auto const& [pdg, table] : input_.tables) | ||
| { | ||
| for (auto const& channel : table) | ||
| { | ||
| // Identify the unique channel types | ||
| auto [iter, inserted] = types.insert(channel.type); | ||
| if (inserted) | ||
| { | ||
| // Construct an action for each channel | ||
| switch (*iter) | ||
| { | ||
| case DecayChannelType::muon: | ||
| result.push_back(std::make_shared<MuDecayChannel>( | ||
| *start_id++, input_)); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Does this mean that for muons we'd create two separate step actions, one for each particle type? |
||
| break; | ||
| default: | ||
| CELER_NOT_IMPLEMENTED("Decay channel type"); | ||
| } | ||
| } | ||
| } | ||
| } | ||
| CELER_VALIDATE(!result.empty(), | ||
| << "no supported channels for decay process"); | ||
| return result; | ||
| } | ||
|
|
||
| //---------------------------------------------------------------------------// | ||
| /*! | ||
| * Get the decay table for a particle. | ||
| */ | ||
| auto DecayProcess::decay_table(ParticleId pid) const -> DecayTable | ||
| { | ||
| auto iter = input_.tables.find(particles_->id_to_pdg(pid)); | ||
| if (iter == input_.tables.end()) | ||
| { | ||
| return {}; | ||
| } | ||
| return iter->second; | ||
| } | ||
|
|
||
| //---------------------------------------------------------------------------// | ||
| /*! | ||
| * Whether the decay process applies to the particle. | ||
| */ | ||
| bool DecayProcess::is_applicable(ParticleId pid) const | ||
| { | ||
| return input_.tables.find(particles_->id_to_pdg(pid)) | ||
| != input_.tables.end(); | ||
| } | ||
|
|
||
| //---------------------------------------------------------------------------// | ||
| } // namespace celeritas | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,64 @@ | ||
| //------------------------------- -*- C++ -*- -------------------------------// | ||
| // Copyright Celeritas contributors: see top-level COPYRIGHT file for details | ||
| // SPDX-License-Identifier: (Apache-2.0 OR MIT) | ||
| //---------------------------------------------------------------------------// | ||
| //! \file celeritas/decay/DecayProcess.hh | ||
| //---------------------------------------------------------------------------// | ||
| #pragma once | ||
|
|
||
| #include <memory> | ||
|
|
||
| #include "celeritas/Types.hh" | ||
| #include "celeritas/decay/channel/DecayChannel.hh" | ||
| #include "celeritas/inp/Physics.hh" | ||
| #include "celeritas/phys/ImportedProcessAdapter.hh" | ||
| #include "celeritas/phys/Process.hh" | ||
|
|
||
| namespace celeritas | ||
| { | ||
| class ParticleParams; | ||
|
|
||
| //---------------------------------------------------------------------------// | ||
| /*! | ||
| * Process for decay. | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. A little more documentation here would be good: this single class manages all possible particle decay channels, each of which is analogous to a model for the action process. |
||
| */ | ||
| class DecayProcess final : public Process | ||
| { | ||
| public: | ||
| //!@{ | ||
| //! \name Type aliases | ||
| using SPConstChannel = std::shared_ptr<DecayChannel const>; | ||
| using SPConstParticles = std::shared_ptr<ParticleParams const>; | ||
| using VecChannel = std::vector<SPConstChannel>; | ||
| using DecayTable = inp::DecayPhysics::DecayTable; | ||
| //!@} | ||
|
|
||
| public: | ||
| // Construct from particles and input data | ||
| DecayProcess(SPConstParticles, inp::DecayPhysics const&); | ||
|
|
||
| // Construct the decay channels | ||
| VecChannel build_channels(ActionIdIter start_id) const; | ||
|
|
||
| // Get the decay table for a particle | ||
| DecayTable decay_table(ParticleId) const; | ||
|
|
||
| // Whether the decay process applies to the particle | ||
| bool is_applicable(ParticleId) const; | ||
|
|
||
| //!@{ | ||
| //! \name Process interface | ||
|
|
||
| //! Whether the process applies when the particle is stopped | ||
| bool applies_at_rest() const final { return true; } | ||
| //! Name of the process | ||
| std::string_view label() const final { return "Decay"; } | ||
| //!@} | ||
|
|
||
| private: | ||
| SPConstParticles particles_; | ||
| inp::DecayPhysics const& input_; | ||
| }; | ||
|
|
||
| //---------------------------------------------------------------------------// | ||
| } // namespace celeritas | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,30 @@ | ||
| //------------------------------- -*- C++ -*- -------------------------------// | ||
| // Copyright Celeritas contributors: see top-level COPYRIGHT file for details | ||
| // SPDX-License-Identifier: (Apache-2.0 OR MIT) | ||
| //---------------------------------------------------------------------------// | ||
| //! \file celeritas/decay/channel/DecayChannel.hh | ||
| //---------------------------------------------------------------------------// | ||
| #pragma once | ||
|
|
||
| #include "corecel/Types.hh" | ||
| #include "celeritas/Types.hh" | ||
| #include "celeritas/global/ActionInterface.hh" | ||
|
|
||
| namespace celeritas | ||
| { | ||
| //---------------------------------------------------------------------------// | ||
| /*! | ||
| * Abstract base class representing a decay channel. | ||
| * | ||
| * This class is responsible for validating the input decay table data and | ||
| * launching a kernel for the decay interactor. | ||
| */ | ||
| class DecayChannel : public CoreStepActionInterface | ||
| { | ||
| public: | ||
| //! Dependency ordering of the action | ||
| StepActionOrder order() const final { return StepActionOrder::post; } | ||
| }; | ||
|
|
||
| //---------------------------------------------------------------------------// | ||
| } // namespace celeritas |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add a note that these are stored by the
PhysicsParamsDataand used in theProcessGroup(processes that apply to a particular particle type).