From 9d7f4bf5d0e89a06f689d99a92105163d3faebfe Mon Sep 17 00:00:00 2001 From: ralfulrich <ralf.ulrich@kit.edu> Date: Wed, 7 Oct 2020 17:00:01 +0200 Subject: [PATCH] use new setupEnvironment and setupStack everywhere --- .../CONEXSourceCut/testCONEXSourceCut.cc | 20 +++++-- Processes/NullModel/testNullModel.cc | 54 +++++++++++++++++++ Processes/QGSJetII/testQGSJetII.cc | 2 +- Processes/Sibyll/testSibyll.cc | 6 +-- 4 files changed, 73 insertions(+), 9 deletions(-) create mode 100644 Processes/NullModel/testNullModel.cc diff --git a/Processes/CONEXSourceCut/testCONEXSourceCut.cc b/Processes/CONEXSourceCut/testCONEXSourceCut.cc index 378cd9259..cd0e58f06 100644 --- a/Processes/CONEXSourceCut/testCONEXSourceCut.cc +++ b/Processes/CONEXSourceCut/testCONEXSourceCut.cc @@ -12,6 +12,7 @@ #include <corsika/environment/LayeredSphericalAtmosphereBuilder.h> #include <corsika/environment/MediumPropertyModel.h> #include <corsika/environment/UniformMagneticField.h> +#include <corsika/environment/UniformMediumType.h> #include <corsika/geometry/Point.h> #include <corsika/geometry/RootCoordinateSystem.h> @@ -62,11 +63,20 @@ TEST_CASE("CONEXSourceCut") { {{particles::Code::Nitrogen, particles::Code::Oxygen}, {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(1144.9069_g / (1_cm * 1_cm), 878153.55_cm, 10_km); - builder.addExponentialLayer(1305.5948_g / (1_cm * 1_cm), 636143.04_cm, 40_km); - builder.addExponentialLayer(540.1778_g / (1_cm * 1_cm), 772170.16_cm, 100_km); - builder.addLinearLayer(1e9_cm, 112.8_km); + builder.addExponentialLayer<MEnv>(1222.6562_g / (1_cm * 1_cm), 994186.38_cm, 4_km, + environment::EMediumType::eAir, + geometry::Vector(rootCS, 0_T, 0_T, 1_T)); + builder.addExponentialLayer<MEnv>(1144.9069_g / (1_cm * 1_cm), 878153.55_cm, 10_km, + environment::EMediumType::eAir, + geometry::Vector(rootCS, 0_T, 0_T, 1_T)); + builder.addExponentialLayer<MEnv>(1305.5948_g / (1_cm * 1_cm), 636143.04_cm, 40_km, + environment::EMediumType::eAir, + geometry::Vector(rootCS, 0_T, 0_T, 1_T)); + builder.addExponentialLayer<MEnv>(540.1778_g / (1_cm * 1_cm), 772170.16_cm, 100_km, + environment::EMediumType::eAir, + geometry::Vector(rootCS, 0_T, 0_T, 1_T)); + builder.addLinearLayer<MEnv>(1e9_cm, 112.8_km, environment::EMediumType::eAir, + geometry::Vector(rootCS, 0_T, 0_T, 1_T)); builder.assemble(env); diff --git a/Processes/NullModel/testNullModel.cc b/Processes/NullModel/testNullModel.cc new file mode 100644 index 000000000..0440bad4b --- /dev/null +++ b/Processes/NullModel/testNullModel.cc @@ -0,0 +1,54 @@ +/* + * (c) Copyright 2018 CORSIKA Project, corsika-project@lists.kit.edu + * + * This software is distributed under the terms of the GNU General Public + * Licence version 3 (GPL Version 3). See file LICENSE for a full version of + * the license. + */ + +#include <catch2/catch.hpp> + +#include <corsika/process/null_model/NullModel.h> + +#include <corsika/geometry/Point.h> +#include <corsika/geometry/RootCoordinateSystem.h> +#include <corsika/geometry/Vector.h> + +#include <corsika/units/PhysicalUnits.h> + +#include <corsika/setup/SetupStack.h> +#include <corsika/setup/SetupTrajectory.h> + +using namespace corsika::units::si; +using namespace corsika::process::null_model; +using namespace corsika; + +TEST_CASE("NullModel", "[processes]") { + + auto [env, csPtr, nodePtr] = setup::testing::setupEnvironment(particles::Code::Oxygen); + auto const& cs = *csPtr; + [[maybe_unused]] auto const& env_dummy = env; + [[maybe_unused]] auto const& node_dummy = nodePtr; + + + auto [stack, view] = setup::testing::setupStack(particles::Code::Electron, 0,0, 100_GeV, nodePtr, cs); + [[maybe_unused]] const auto& dummyView = view; + auto particle = stack->first(); + + geometry::Point const origin(cs, {0_m, 0_m, 0_m}); + geometry::Vector<units::si::SpeedType::dimension_type> v(cs, 0_m / second, + 0_m / second, 1_m / second); + geometry::Line line(origin, v); + geometry::Trajectory<geometry::Line> track(line, 10_s); + + SECTION("interface") { + + NullModel model(10_m); + + [[maybe_unused]] const process::EProcessReturn ret = + model.DoContinuous(particle, track); + LengthType const length = model.MaxStepLength(particle, track); + + CHECK((length / 10_m) == Approx(1)); + } +} diff --git a/Processes/QGSJetII/testQGSJetII.cc b/Processes/QGSJetII/testQGSJetII.cc index 84dad94cf..1078f4477 100644 --- a/Processes/QGSJetII/testQGSJetII.cc +++ b/Processes/QGSJetII/testQGSJetII.cc @@ -137,7 +137,7 @@ TEST_CASE("QgsjetIIInterface", "[processes]") { Interaction model; - [[maybe_unused]] const process::EProcessReturn ret = model.DoInteraction(view); + [[maybe_unused]] const process::EProcessReturn ret = model.DoInteraction(*secViewPtr); [[maybe_unused]] const GrammageType length = model.GetInteractionLength(particle); CHECK(length / (1_g / square(1_cm)) == Approx(93.04).margin(0.1)); diff --git a/Processes/Sibyll/testSibyll.cc b/Processes/Sibyll/testSibyll.cc index 007be947e..68e974098 100644 --- a/Processes/Sibyll/testSibyll.cc +++ b/Processes/Sibyll/testSibyll.cc @@ -115,8 +115,8 @@ TEST_CASE("SibyllInterface", "[processes]") { Interaction model; - [[maybe_unused]] const process::EProcessReturn ret = model.DoInteraction(view); - auto const pSum = sumMomentum(view, cs); + [[maybe_unused]] const process::EProcessReturn ret = model.DoInteraction(*view); + auto const pSum = sumMomentum(*view, cs); /* Interactions between hadrons (h) and nuclei (A) in Sibyll are treated in the @@ -195,7 +195,7 @@ TEST_CASE("SibyllInterface", "[processes]") { Interaction hmodel; NuclearInteraction model(hmodel, *env); - [[maybe_unused]] const process::EProcessReturn ret = model.DoInteraction(view); + [[maybe_unused]] const process::EProcessReturn ret = model.DoInteraction(*view); [[maybe_unused]] const GrammageType length = model.GetInteractionLength(particle); CHECK(length / 1_g * 1_cm * 1_cm == Approx(44.2).margin(.1)); CHECK(view.getSize() == 11); -- GitLab