From 61106845707cd787f67ffb82881105c2890b85b4 Mon Sep 17 00:00:00 2001 From: Felix Riehn <felix@matilda> Date: Thu, 8 Sep 2022 15:05:16 +0100 Subject: [PATCH] added tests --- tests/modules/CMakeLists.txt | 3 +- tests/modules/testSophia.cpp | 76 ++++++++++++++++++++++++++++++++++++ 2 files changed, 78 insertions(+), 1 deletion(-) create mode 100644 tests/modules/testSophia.cpp diff --git a/tests/modules/CMakeLists.txt b/tests/modules/CMakeLists.txt index 78e3d5faf..3bb6cf8db 100644 --- a/tests/modules/CMakeLists.txt +++ b/tests/modules/CMakeLists.txt @@ -12,7 +12,8 @@ set (test_modules_sources testParticleCut.cpp testSibyll.cpp testEpos.cpp - testRadio.cpp + testRadio.cpp + testSophia.cpp ) CORSIKA_ADD_TEST (testModules SOURCES ${test_modules_sources}) diff --git a/tests/modules/testSophia.cpp b/tests/modules/testSophia.cpp new file mode 100644 index 000000000..16170f1da --- /dev/null +++ b/tests/modules/testSophia.cpp @@ -0,0 +1,76 @@ +/* + * (c) Copyright 2022 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 <corsika/modules/Sibyll.hpp> +#include <corsika/modules/sophia/ParticleConversion.hpp> + +#include <corsika/framework/core/ParticleProperties.hpp> +#include <corsika/framework/core/PhysicalUnits.hpp> +#include <corsika/framework/geometry/Point.hpp> +#include <corsika/framework/random/RNGManager.hpp> +#include <corsika/framework/utility/COMBoost.hpp> + +#include <SetupTestEnvironment.hpp> +#include <catch2/catch.hpp> +#include <tuple> + +/* + NOTE, WARNING, ATTENTION + + The sibyll/Random.hpp implements the hook of sibyll to the C8 random + number generator. It has to occur excatly ONCE per linked + executable. If you include the header below in multiple "tests" and + link them togehter, it will fail. + */ +#include <corsika/modules/sophia/Random.hpp> + +using namespace corsika; +using namespace corsika::sophia; + +using DummyEnvironmentInterface = IMediumPropertyModel<IMagneticFieldModel<IMediumModel>>; +using DummyEnvironment = Environment<DummyEnvironmentInterface>; + +TEST_CASE("Sophia", "modules") { + + logging::set_level(logging::level::info); + + SECTION("Sophia -> Corsika") { + CHECK(Code::Electron == + corsika::sophia::convertFromSophia(corsika::sophia::SophiaCode::Electron)); + } + + SECTION("Corsika -> Sophia") { + CHECK(corsika::sophia::convertToSophia(Electron::code) == + corsika::sophia::SophiaCode::Electron); + CHECK(corsika::sophia::convertToSophiaRaw(Proton::code) == 13); + } + + SECTION("canInteractInSophia") { + + CHECK(corsika::sophia::canInteract(Code::Photon)); + CHECK_FALSE(corsika::sophia::canInteract(Code::XiCPlus)); + + CHECK_FALSE(corsika::sophia::canInteract(Code::Electron)); + + CHECK_FALSE(corsika::sophia::canInteract(Code::Iron)); + CHECK_FALSE(corsika::sophia::canInteract(Code::Helium)); + } + + // SECTION("cross-section type") { + // CHECK(corsika::sophia::getSophiaXSCode(Code::Proton) == 1); + // CHECK(corsika::sophia::getSophiaXSCode(Code::Electron) == 0); + // } + + SECTION("sophia mass") { + CHECK_FALSE(corsika::sophia::getSophiaMass(Code::Electron) == 0_GeV); + // Nucleus not a particle + CHECK_THROWS(corsika::sophia::getSophiaMass(Code::Iron)); + // Higgs not a particle in Sophia + CHECK_THROWS(corsika::sophia::getSophiaMass(Code::H0)); + } +} -- GitLab