IAP GITLAB

Skip to content
Snippets Groups Projects
Commit ee55481f authored by Maximilian Reininghaus's avatar Maximilian Reininghaus :vulcan: Committed by Ralf Ulrich
Browse files

only density parameters as arugments to LayeredSphericalAtmosphereBuilder::addXYZLayer

parent 5c9290c7
No related branches found
No related tags found
1 merge request!265Add medium type, as new property (air, water, rock...)
...@@ -78,6 +78,13 @@ void registerRandomStreams(const int seed) { ...@@ -78,6 +78,13 @@ void registerRandomStreams(const int seed) {
template <typename T> template <typename T>
using MEnv = environment::MediumPropertyModel<environment::UniformMagneticField<T>>; using MEnv = environment::MediumPropertyModel<environment::UniformMagneticField<T>>;
template <typename... TArgs>
auto make_builder(geometry::Point const& center, TArgs... args) {
return environment::LayeredSphericalAtmosphereBuilder<setup::EnvironmentInterface, MEnv,
TArgs...>{
args..., center, units::constants::EarthRadius::Mean};
}
int main(int argc, char** argv) { int main(int argc, char** argv) {
logging::SetLevel(logging::level::info); logging::SetLevel(logging::level::info);
...@@ -101,26 +108,17 @@ int main(int argc, char** argv) { ...@@ -101,26 +108,17 @@ int main(int argc, char** argv) {
EnvType env; EnvType env;
const CoordinateSystem& rootCS = env.GetCoordinateSystem(); const CoordinateSystem& rootCS = env.GetCoordinateSystem();
Point const center{rootCS, 0_m, 0_m, 0_m}; Point const center{rootCS, 0_m, 0_m, 0_m};
environment::LayeredSphericalAtmosphereBuilder<setup::EnvironmentInterface, MEnv> auto builder = make_builder(center, environment::Medium::AirDry1Atm,
builder{center}; geometry::Vector{rootCS, 0_T, 0_T, 1_T});
builder.setNuclearComposition( builder.setNuclearComposition(
{{particles::Code::Nitrogen, particles::Code::Oxygen}, {{particles::Code::Nitrogen, particles::Code::Oxygen},
{0.7847f, 1.f - 0.7847f}}); // values taken from AIRES manual, Ar removed for now {0.7847f, 1.f - 0.7847f}}); // values taken from AIRES manual, Ar removed for now
builder.addExponentialLayer(1222.6562_g / (1_cm * 1_cm), 994186.38_cm, 4_km, builder.addExponentialLayer(1222.6562_g / (1_cm * 1_cm), 994186.38_cm, 4_km);
environment::Medium::AirDry1Atm, builder.addExponentialLayer(1144.9069_g / (1_cm * 1_cm), 878153.55_cm, 10_km);
geometry::Vector(rootCS, 0_T, 0_T, 1_T)); builder.addExponentialLayer(1305.5948_g / (1_cm * 1_cm), 636143.04_cm, 40_km);
builder.addExponentialLayer(1144.9069_g / (1_cm * 1_cm), 878153.55_cm, 10_km, builder.addExponentialLayer(540.1778_g / (1_cm * 1_cm), 772170.16_cm, 100_km);
environment::Medium::AirDry1Atm, builder.addLinearLayer(1e9_cm, 112.8_km);
geometry::Vector(rootCS, 0_T, 0_T, 1_T));
builder.addExponentialLayer(1305.5948_g / (1_cm * 1_cm), 636143.04_cm, 40_km,
environment::Medium::AirDry1Atm,
geometry::Vector(rootCS, 0_T, 0_T, 1_T));
builder.addExponentialLayer(540.1778_g / (1_cm * 1_cm), 772170.16_cm, 100_km,
environment::Medium::AirDry1Atm,
geometry::Vector(rootCS, 0_T, 0_T, 1_T));
builder.addLinearLayer(1e9_cm, 112.8_km, environment::Medium::AirDry1Atm,
geometry::Vector(rootCS, 0_T, 0_T, 1_T));
builder.assemble(env); builder.assemble(env);
// setup particle stack, and add primary particle // setup particle stack, and add primary particle
......
...@@ -18,8 +18,10 @@ ...@@ -18,8 +18,10 @@
#include <corsika/units/PhysicalConstants.h> #include <corsika/units/PhysicalConstants.h>
#include <corsika/units/PhysicalUnits.h> #include <corsika/units/PhysicalUnits.h>
#include <functional>
#include <memory> #include <memory>
#include <stack> #include <stack>
#include <tuple>
#include <type_traits> #include <type_traits>
namespace corsika::environment { namespace corsika::environment {
...@@ -52,12 +54,14 @@ namespace corsika::environment { ...@@ -52,12 +54,14 @@ namespace corsika::environment {
} // namespace detail } // namespace detail
template <typename TMediumInterface = environment::IMediumModel, template <typename TMediumInterface = environment::IMediumModel,
template <typename> typename TMediumModelExtra = detail::NoExtraModel> template <typename> typename TMediumModelExtra = detail::NoExtraModel,
typename... TModelArgs>
class LayeredSphericalAtmosphereBuilder { class LayeredSphericalAtmosphereBuilder {
std::unique_ptr<NuclearComposition> composition_; std::unique_ptr<NuclearComposition> composition_;
geometry::Point center_; geometry::Point center_;
units::si::LengthType previousRadius_{units::si::LengthType::zero()}; units::si::LengthType previousRadius_{units::si::LengthType::zero()};
units::si::LengthType earthRadius_; units::si::LengthType earthRadius_;
std::tuple<TModelArgs...> const additionalModelArgs_;
std::stack<typename VolumeTreeNode<TMediumInterface>::VTNUPtr> std::stack<typename VolumeTreeNode<TMediumInterface>::VTNUPtr>
layers_; // innermost layer first layers_; // innermost layer first
...@@ -76,18 +80,18 @@ namespace corsika::environment { ...@@ -76,18 +80,18 @@ namespace corsika::environment {
public: public:
LayeredSphericalAtmosphereBuilder( LayeredSphericalAtmosphereBuilder(
corsika::geometry::Point center, TModelArgs... args, corsika::geometry::Point center,
units::si::LengthType earthRadius = units::constants::EarthRadius::Mean) units::si::LengthType earthRadius = units::constants::EarthRadius::Mean)
: center_(center) : center_(center)
, earthRadius_(earthRadius) {} , earthRadius_(earthRadius)
, additionalModelArgs_{args...} {}
void setNuclearComposition(NuclearComposition composition) { void setNuclearComposition(NuclearComposition composition) {
composition_ = std::make_unique<NuclearComposition>(composition); composition_ = std::make_unique<NuclearComposition>(composition);
} }
template <typename... TArgs>
void addExponentialLayer(units::si::GrammageType b, units::si::LengthType c, void addExponentialLayer(units::si::GrammageType b, units::si::LengthType c,
units::si::LengthType upperBoundary, TArgs&&... args) { units::si::LengthType upperBoundary) {
using namespace units::si; using namespace units::si;
auto const radius = earthRadius_ + upperBoundary; auto const radius = earthRadius_ + upperBoundary;
...@@ -100,43 +104,56 @@ namespace corsika::environment { ...@@ -100,43 +104,56 @@ namespace corsika::environment {
auto const rho0 = b / c; auto const rho0 = b / c;
std::cout << "rho0 = " << rho0 << ", c = " << c << std::endl; std::cout << "rho0 = " << rho0 << ", c = " << c << std::endl;
if constexpr (detail::has_extra_models<TMediumModelExtra>::value) if constexpr (detail::has_extra_models<TMediumModelExtra>::value) {
node->template SetModelProperties< // helper lambda in which the last 5 arguments to make_shared<...> are bound
TMediumModelExtra<environment::SlidingPlanarExponential<TMediumInterface>>>( auto lastBound = [&](auto... argPack) {
args..., center_, rho0, -c, *composition_, earthRadius_); return std::make_shared<
else TMediumModelExtra<environment::SlidingPlanarExponential<TMediumInterface>>>(
node->template SetModelProperties< argPack..., center_, rho0, -c, *composition_, earthRadius_);
environment::SlidingPlanarExponential<TMediumInterface>>( };
// now unpack the additional arguments
auto model = std::apply(lastBound, additionalModelArgs_);
node->SetModelProperties(std::move(model));
} else {
node->template SetModelProperties<SlidingPlanarExponential<TMediumInterface>>(
center_, rho0, -c, *composition_, earthRadius_); center_, rho0, -c, *composition_, earthRadius_);
}
layers_.push(std::move(node)); layers_.push(std::move(node));
} }
template <typename... TArgs> void addLinearLayer(units::si::LengthType c, units::si::LengthType upperBoundary) {
void addLinearLayer(units::si::LengthType c, units::si::LengthType upperBoundary,
TArgs&&... args) {
using namespace units::si; using namespace units::si;
auto const radius = earthRadius_ + upperBoundary; auto const radius = earthRadius_ + upperBoundary;
checkRadius(radius); checkRadius(radius);
previousRadius_ = radius; previousRadius_ = radius;
auto node = std::make_unique<VolumeTreeNode<TMediumInterface>>(
std::make_unique<geometry::Sphere>(center_, radius));
units::si::GrammageType constexpr b = 1 * 1_g / (1_cm * 1_cm); units::si::GrammageType constexpr b = 1 * 1_g / (1_cm * 1_cm);
auto const rho0 = b / c; auto const rho0 = b / c;
std::cout << "rho0 = " << rho0; std::cout << "rho0 = " << rho0;
auto node = std::make_unique<VolumeTreeNode<TMediumInterface>>( if constexpr (detail::has_extra_models<TMediumModelExtra>::value) {
std::make_unique<geometry::Sphere>(center_, radius)); // helper lambda in which the last 2 arguments to make_shared<...> are bound
auto lastBound = [&](auto... argPack) {
return std::make_shared<
TMediumModelExtra<environment::HomogeneousMedium<TMediumInterface>>>(
argPack..., rho0, *composition_);
};
if constexpr (detail::has_extra_models<TMediumModelExtra>::value) // now unpack the additional arguments
node->template SetModelProperties< auto model = std::apply(lastBound, additionalModelArgs_);
TMediumModelExtra<environment::HomogeneousMedium<TMediumInterface>>>(
args..., rho0, *composition_); node->SetModelProperties(std::move(model));
else } else {
node->template SetModelProperties< node->template SetModelProperties<
environment::HomogeneousMedium<TMediumInterface>>(args..., rho0, environment::HomogeneousMedium<TMediumInterface>>(rho0, *composition_);
*composition_); }
layers_.push(std::move(node)); layers_.push(std::move(node));
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment