diff --git a/Environment/LayeredSphericalAtmosphereBuilder.h b/Environment/LayeredSphericalAtmosphereBuilder.h index 3c383c7b7b4107ff3a3639d4832ae4a478f5b672..cbb705bbfd869a71aef2ca82b7d2d1ab561260c3 100644 --- a/Environment/LayeredSphericalAtmosphereBuilder.h +++ b/Environment/LayeredSphericalAtmosphereBuilder.h @@ -11,6 +11,9 @@ #include <corsika/environment/NuclearComposition.h> #include <corsika/environment/SlidingPlanarExponential.h> #include <corsika/environment/VolumeTreeNode.h> +#include <corsika/environment/FlatExponential.h> +#include <corsika/environment/HomogeneousMedium.h> + #include <corsika/geometry/Point.h> #include <corsika/units/PhysicalConstants.h> #include <corsika/units/PhysicalUnits.h> diff --git a/Processes/UrQMD/testUrQMD.cc b/Processes/UrQMD/testUrQMD.cc index 2b1f5bcefeb69a5ea327dd3684c228b0c188a184..537b656c664c3b4f98d012f8b123bc41b34b4f72 100644 --- a/Processes/UrQMD/testUrQMD.cc +++ b/Processes/UrQMD/testUrQMD.cc @@ -53,69 +53,6 @@ auto sumMomentum(TStackView const& view, geometry::CoordinateSystem const& vCS) return sum; } -auto setupEnvironment(particles::Code vTargetCode) { - // setup environment, geometry - auto env = std::make_unique<environment::Environment<environment::IMediumModel>>(); - auto& universe = *(env->GetUniverse()); - const geometry::CoordinateSystem& cs = env->GetCoordinateSystem(); - - auto theMedium = - environment::Environment<environment::IMediumModel>::CreateNode<geometry::Sphere>( - geometry::Point{cs, 0_m, 0_m, 0_m}, - 1_km * std::numeric_limits<double>::infinity()); - - using MyHomogeneousModel = environment::HomogeneousMedium<environment::IMediumModel>; - theMedium->SetModelProperties<MyHomogeneousModel>( - 1_kg / (1_m * 1_m * 1_m), - environment::NuclearComposition(std::vector<particles::Code>{vTargetCode}, - std::vector<float>{1.})); - - auto const* nodePtr = theMedium.get(); - universe.AddChild(std::move(theMedium)); - - return std::make_tuple(std::move(env), &cs, nodePtr); -} - -template <typename TNodeType> -auto setupStack(int vA, int vZ, HEPEnergyType vMomentum, TNodeType* vNodePtr, - geometry::CoordinateSystem const& cs) { - auto stack = std::make_unique<setup::Stack>(); - auto constexpr mN = corsika::units::constants::nucleonMass; - - geometry::Point const origin(cs, {0_m, 0_m, 0_m}); - corsika::stack::MomentumVector const pLab(cs, {vMomentum, 0_GeV, 0_GeV}); - - HEPEnergyType const E0 = sqrt(units::static_pow<2>(mN * vA) + pLab.squaredNorm()); - auto particle = - stack->AddParticle(std::tuple<particles::Code, units::si::HEPEnergyType, - corsika::stack::MomentumVector, geometry::Point, - units::si::TimeType, unsigned short, unsigned short>{ - particles::Code::Nucleus, E0, pLab, origin, 0_ns, vA, vZ}); - - particle.SetNode(vNodePtr); - return std::make_tuple( - std::move(stack), std::make_unique<decltype(setup::StackView{particle})>(particle)); -} - -template <typename TNodeType> -auto setupStack(particles::Code vProjectileType, HEPEnergyType vMomentum, - TNodeType* vNodePtr, geometry::CoordinateSystem const& cs) { - auto stack = std::make_unique<setup::Stack>(); - - geometry::Point const origin(cs, {0_m, 0_m, 0_m}); - corsika::stack::MomentumVector const pLab(cs, {vMomentum, 0_GeV, 0_GeV}); - - HEPEnergyType const E0 = sqrt( - units::static_pow<2>(particles::GetMass(vProjectileType)) + pLab.squaredNorm()); - auto particle = stack->AddParticle( - std::tuple<particles::Code, units::si::HEPEnergyType, - corsika::stack::MomentumVector, geometry::Point, units::si::TimeType>{ - vProjectileType, E0, pLab, origin, 0_ns}); - - particle.SetNode(vNodePtr); - return std::make_tuple( - std::move(stack), std::make_unique<decltype(setup::StackView{particle})>(particle)); -} TEST_CASE("UrQMD") { SECTION("conversion") { diff --git a/Setup/SetupEnvironment.h b/Setup/SetupEnvironment.h index 89f5147326dee4c95d038c87590f31e3e0c78e04..3e141455db2e967d12af60ba4d911ee3e72a96dd 100644 --- a/Setup/SetupEnvironment.h +++ b/Setup/SetupEnvironment.h @@ -13,16 +13,65 @@ #include <corsika/environment/IMediumModel.h> #include <corsika/environment/IMediumTypeModel.h> #include <corsika/environment/IRefractiveIndexModel.h> -#include <corsika/environment/InhomogeneousMedium.h> namespace corsika::setup { /** Definition of the default environemnt model interface. Each model interface provides properties of the environment in a position - bdependent way. + bdependent way. */ - - using IEnvironment = environment::IMediumTypeModel<environment::IMagneticFieldModel<environment::IMediumModel>>; - using Environment = environment::Environment<IEnvironment>; -} // namespace corsika::setup + + using EnvironmentInterface = environment::IMediumTypeModel< + environment::IMagneticFieldModel<environment::IMediumModel>>; + using Environment = environment::Environment<EnvironmentInterface>; + +} // end namespace corsika::setup + +#include <corsika/environment/HomogeneousMedium.h> +#include <corsika/environment/InhomogeneousMedium.h> +#include <corsika/environment/UniformMagneticField.h> +#include <corsika/environment/UniformMediumType.h> + +/** + * standard environment for unit testing. This can be moved to + * "test" directory, when available. + */ +namespace corsika::setup::testing { + + auto setupEnvironment(particles::Code vTargetCode) { + + using namespace corsika::units::si; + using namespace corsika; + + auto env = std::make_unique<setup::Environment>(); + auto& universe = *(env->GetUniverse()); + const geometry::CoordinateSystem& cs = env->GetCoordinateSystem(); + + /** + * our world is a sphere at 0,0,0 with R=infty + */ + auto world = setup::Environment::CreateNode<geometry::Sphere>( + geometry::Point{cs, 0_m, 0_m, 0_m}, + 1_km * std::numeric_limits<double>::infinity()); + + /** + * construct suited environment medium model: + */ + using MyHomogeneousModel = + environment::UniformMediumType<environment::UniformMagneticField< + environment::HomogeneousMedium<setup::EnvironmentInterface>>>; + + world->SetModelProperties<MyHomogeneousModel>( + environment::EMediumType::eAir, geometry::Vector(cs, 0_T, 0_T, 1_T), + 1_kg / (1_m * 1_m * 1_m), + environment::NuclearComposition(std::vector<particles::Code>{vTargetCode}, + std::vector<float>{1.})); + + auto const* nodePtr = world.get(); + universe.AddChild(std::move(world)); + + return std::make_tuple(std::move(env), &cs, nodePtr); + } + +} // namespace corsika::setup::testing diff --git a/Setup/SetupStack.h b/Setup/SetupStack.h index 8930cb74eeae2ba63bbead4f79085617880ed0ba..b54911bb03e146ab352b08e401cd6e05bfab07c6 100644 --- a/Setup/SetupStack.h +++ b/Setup/SetupStack.h @@ -131,3 +131,44 @@ namespace corsika::setup { using StackView = detail::TheStackView; } // namespace corsika::setup + +namespace corsika::setup::testing { + + /** + * standard setup for unit tests. This can be moved to "test" + * directory, when available. + */ + auto setupStack(particles::Code vProjectileType, int vA, int vZ, + units::si::HEPEnergyType vMomentum, + setup::Environment::BaseNodeType* vNodePtr, + geometry::CoordinateSystem const& cs) { + + using namespace corsika; + using namespace corsika::units::si; + + auto stack = std::make_unique<setup::Stack>(); + auto constexpr mN = corsika::units::constants::nucleonMass; + + geometry::Point const origin(cs, {0_m, 0_m, 0_m}); + corsika::stack::MomentumVector const pLab(cs, {vMomentum, 0_GeV, 0_GeV}); + + if (vProjectileType == particles::Code::Nucleus) { + HEPEnergyType const E0 = sqrt(units::static_pow<2>(mN * vA) + pLab.squaredNorm()); + auto particle = stack->AddParticle( + std::make_tuple(particles::Code::Nucleus, E0, pLab, origin, 0_ns, vA, vZ)); + } else { // not a nucleus + HEPEnergyType const E0 = sqrt( + units::static_pow<2>(particles::GetMass(vProjectileType)) + pLab.squaredNorm()); + auto particle = stack->AddParticle( + std::tuple<particles::Code, units::si::HEPEnergyType, + corsika::stack::MomentumVector, geometry::Point, + units::si::TimeType>{vProjectileType, E0, pLab, origin, 0_ns}); + } + + particle.SetNode(vNodePtr); + return std::make_tuple( + std::move(stack), + std::make_unique<decltype(corsika::stack::SecondaryView(particle))>(particle)); + } + +} // namespace corsika::setup::testing