-
Notifications
You must be signed in to change notification settings - Fork 191
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add tags to take MC step, size error
- Loading branch information
Francois Foucart
committed
Nov 1, 2024
1 parent
1bd140a
commit 3f49648
Showing
13 changed files
with
200 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
133 changes: 133 additions & 0 deletions
133
src/Evolution/Particles/MonteCarlo/Actions/InitializeMonteCarlo.hpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,133 @@ | ||
// Distributed under the MIT License. | ||
// See LICENSE.txt for details. | ||
|
||
#pragma once | ||
|
||
#include <tuple> | ||
|
||
#include "DataStructures/DataBox/DataBox.hpp" | ||
#include "Domain/Tags.hpp" | ||
#include "Evolution/Initialization/InitialData.hpp" | ||
#include "Evolution/Particles/MonteCarlo/MortarData.hpp" | ||
#include "Evolution/Particles/MonteCarlo/Packet.hpp" | ||
#include "Evolution/Particles/MonteCarlo/Tags.hpp" | ||
#include "Parallel/AlgorithmExecution.hpp" | ||
#include "Parallel/GlobalCache.hpp" | ||
#include "ParallelAlgorithms/Initialization/MutateAssign.hpp" | ||
#include "Utilities/TMPL.hpp" | ||
|
||
/// \cond | ||
namespace tuples { | ||
template <typename...> | ||
class TaggedTuple; | ||
} // namespace tuples | ||
|
||
namespace Parallel { | ||
template <typename Metavariables> | ||
class GlobalCache; | ||
} // namespace Parallel | ||
/// \endcond | ||
|
||
namespace Initialization::Actions { | ||
|
||
/// \ingroup InitializationGroup | ||
/// \brief Allocate variables needed for evolution of Monte Carlo transport | ||
/// | ||
/// Uses: | ||
/// - evolution::dg::subcell::Tags::Mesh<dim> | ||
/// | ||
/// DataBox changes: | ||
/// - Adds: | ||
/// * Particles::MonteCarlo::Tags::PacketsOnElement | ||
/// * Particles::MonteCarlo::Tags::RandomNumberGenerator | ||
/// * Particles::MonteCarlo::Tags::DesiredPacketEnergyAtEmission | ||
/// <NeutrinoSpecies> | ||
/// * Particles::MonteCarlo::Tags::CellLightCrossingTime<DataVector> | ||
/// * Background hydro variables | ||
/// * Particles::MonteCarlo::Tags::MortarDataTag<dim> | ||
/// | ||
/// - Removes: nothing | ||
/// - Modifies: nothing | ||
template <typename System, size_t EnergyBins, size_t NeutrinoSpecies> | ||
struct InitializeMCTags { | ||
public: | ||
using hydro_variables_tag = typename System::hydro_variables_tag; | ||
|
||
static constexpr size_t dim = System::volume_dim; | ||
using simple_tags = | ||
tmpl::list<Particles::MonteCarlo::Tags::PacketsOnElement, | ||
Particles::MonteCarlo::Tags::RandomNumberGenerator, | ||
Particles::MonteCarlo::Tags::DesiredPacketEnergyAtEmission< | ||
NeutrinoSpecies>, | ||
Particles::MonteCarlo::Tags::CellLightCrossingTime<DataVector>, | ||
hydro_variables_tag, | ||
Particles::MonteCarlo::Tags::MortarDataTag<dim>>; | ||
|
||
using compute_tags = tmpl::list<>; | ||
|
||
template <typename DbTagsList, typename... InboxTags, typename Metavariables, | ||
typename ArrayIndex, typename ActionList, | ||
typename ParallelComponent> | ||
static Parallel::iterable_action_return_t apply( | ||
db::DataBox<DbTagsList>& box, | ||
const tuples::TaggedTuple<InboxTags...>& /*inboxes*/, | ||
const Parallel::GlobalCache<Metavariables>& /*cache*/, | ||
const ArrayIndex& /*array_index*/, ActionList /*meta*/, | ||
const ParallelComponent* const /*meta*/) { | ||
typename Particles::MonteCarlo::Tags::PacketsOnElement::type all_packets; | ||
Initialization::mutate_assign< | ||
tmpl::list<Particles::MonteCarlo::Tags::PacketsOnElement>>( | ||
make_not_null(&box), std::move(all_packets)); | ||
|
||
// Currently seeds with 0 for testing... | ||
typename Particles::MonteCarlo::Tags::RandomNumberGenerator::type rng(0); | ||
Initialization::mutate_assign< | ||
tmpl::list<Particles::MonteCarlo::Tags::RandomNumberGenerator>>( | ||
make_not_null(&box), std::move(rng)); | ||
|
||
// Currently hard-code energy at emission; should be set by option | ||
typename Particles::MonteCarlo::Tags::DesiredPacketEnergyAtEmission< | ||
NeutrinoSpecies>::type packet_energy_at_emission; | ||
for (size_t s = 0; s < NeutrinoSpecies; s++) { | ||
packet_energy_at_emission[s] = 1.e-12; | ||
} | ||
Initialization::mutate_assign< | ||
tmpl::list<Particles::MonteCarlo::Tags::DesiredPacketEnergyAtEmission< | ||
NeutrinoSpecies>>>(make_not_null(&box), | ||
std::move(packet_energy_at_emission)); | ||
|
||
// const double initial_time = db::get<::Tags::Time>(box); | ||
const size_t num_grid_points = | ||
Check failure on line 100 in src/Evolution/Particles/MonteCarlo/Actions/InitializeMonteCarlo.hpp GitHub Actions / Clang-tidy (Debug)
|
||
db::get<evolution::dg::subcell::Tags::Mesh<dim>>(box) | ||
Check failure on line 101 in src/Evolution/Particles/MonteCarlo/Actions/InitializeMonteCarlo.hpp GitHub Actions / Clang-tidy (Debug)
|
||
.number_of_grid_points(); | ||
typename Particles::MonteCarlo::Tags::CellLightCrossingTime< | ||
DataVector>::type cell_light_crossing_time(num_grid_points, 1.0); | ||
Initialization::mutate_assign<tmpl::list< | ||
Particles::MonteCarlo::Tags::CellLightCrossingTime<DataVector>>>( | ||
make_not_null(&box), std::move(cell_light_crossing_time)); | ||
|
||
// const auto& inertial_coords = | ||
// db::get<domain::Tags::Coordinates<dim, Frame::Inertial>>(box); | ||
// Get hydro variables | ||
using HydroVars = typename hydro_variables_tag::type; | ||
HydroVars hydro_variables{num_grid_points, -1.0}; | ||
// Might need a more general initial data tag in the future | ||
// hydro_variables.assign_subset(evolution::Initialization::initial_data( | ||
// Parallel::get<::Tags::AnalyticSolutionOrData>(cache), inertial_coords, | ||
// initial_time, typename hydro_variables_tag::tags_list{})); | ||
Initialization::mutate_assign<tmpl::list<hydro_variables_tag>>( | ||
make_not_null(&box), std::move(hydro_variables)); | ||
|
||
// Initialize empty mortar data; do we need more at initialization stage? | ||
using MortarData = | ||
typename Particles::MonteCarlo::Tags::MortarDataTag<dim>::type; | ||
MortarData mortar_data; | ||
Initialization::mutate_assign< | ||
tmpl::list<Particles::MonteCarlo::Tags::MortarDataTag<dim>>>( | ||
make_not_null(&box), std::move(mortar_data)); | ||
|
||
return {Parallel::AlgorithmExecution::Continue, std::nullopt}; | ||
} | ||
}; | ||
|
||
} // namespace Initialization::Actions |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters