IAP GITLAB

Skip to content
Snippets Groups Projects
Commit 9bf20a53 authored by ralfulrich's avatar ralfulrich
Browse files

added central tracking testing

parent 5500cf18
No related branches found
No related tags found
No related merge requests found
......@@ -32,3 +32,13 @@ target_include_directories (
install (FILES ${MODEL_HEADERS} DESTINATION include/${MODEL_NAMESPACE})
# #-- -- -- -- -- -- -- -- -- --
# #code unit testing
CORSIKA_ADD_TEST (testTracking)
target_link_libraries (
testTracking
ProcessTrackingLine
ProcessTrackingLeapFrogStraight
ProcessTrackingLeapFrogCurved
CORSIKAtesting
)
......@@ -6,7 +6,9 @@
* the license.
*/
#include <corsika/process/tracking_bfield/Tracking.h>
#include <corsika/process/tracking_leapfrog_curved/Tracking.h>
#include <corsika/process/tracking_leapfrog_straight/Tracking.h>
#include <corsika/process/tracking_line/Tracking.h>
#include <corsika/particles/ParticleProperties.h>
......@@ -28,19 +30,45 @@ using namespace corsika::units;
using namespace corsika::geometry;
using namespace corsika::units::si;
typedef corsika::geometry::Vector<corsika::units::si::magnetic_flux_density_d>
MagneticFieldVector;
template <typename T>
int sgn(T val) {
return (T(0) < val) - (val < T(0));
}
TEST_CASE("TrackingBField") {
/*
This is the unified and commond unit test for Tracking:
- tracking_leapfrog_curved::Tracking
- tracking_leapfrog_straight::Tracking
- tracking_line::Tracking
*/
TEMPLATE_TEST_CASE("TrackingLeapfrog_Curved", "tracking",
tracking_leapfrog_curved::Tracking,
tracking_leapfrog_straight::Tracking, tracking_line::Tracking) {
logging::SetLevel(logging::level::trace);
const HEPEnergyType P0 = 10_GeV;
auto PID = GENERATE(as<Code>{}, Code::MuPlus, Code::MuPlus, Code::Gamma);
auto Bfield = GENERATE(as<MagneticFluxType>{}, 0_T, 50_uT, -50_uT);
// for algorithms that know magnetic deflections choose: +-50uT, 0uT
// otherwise just 0uT
auto Bfield = GENERATE(filter(
[]([[maybe_unused]] MagneticFluxType v) {
if constexpr (std::is_same_v<TestType, tracking_line::Tracking>)
return v == 0_uT;
else
return true;
},
values<MagneticFluxType>({50_uT, 0_uT, -50_uT})));
// particle --> (world) --> | --> (target)
// true: start inside "world" volume
// false: start inside "target" volume
auto outer = GENERATE(as<bool>{}, true, false);
SECTION(fmt::format("Tracking PID={}, Bfield={} uT, from outside={}", PID,
......@@ -57,7 +85,7 @@ TEST_CASE("TrackingBField") {
if (chargeNumber != 0 and Bfield != 0_T) {
deflect = -sgn(chargeNumber) * sgn(Bfield / 1_T); // direction of deflection
LengthType const gyroradius =
P0 * 1_V / (constants::c * abs(chargeNumber) * abs(Bfield) * 1_eV);
P0 * 1_V / (constants::c * abs(chargeNumber) * abs(Bfield) * 1_eV);
radius = gyroradius;
}
......@@ -65,8 +93,7 @@ TEST_CASE("TrackingBField") {
{ [[maybe_unused]] const auto& env_dummy = env; }
auto const& cs = *csPtr;
tracking_leapfrog_straight::Tracking tracking;
using tracking_leapfrog_straight::MagneticFieldVector;
TestType tracking;
Point const center(cs, {0_m, 0_m, 0_m});
auto target = setup::Environment::CreateNode<geometry::Sphere>(center, radius);
......@@ -122,6 +149,7 @@ TEST_CASE("TrackingBField") {
deflect, particle.GetMomentum().GetComponents(),
particle.GetPosition().GetCoordinates(), pointCheck.GetCoordinates());
CHECK((particle.GetPosition() - pointCheck).norm() / radius == Approx(0).margin(1e-3));
CHECK((particle.GetPosition() - pointCheck).norm() / radius ==
Approx(0).margin(1e-3));
}
}
......@@ -34,11 +34,4 @@ target_include_directories (
install (FILES ${MODEL_HEADERS} DESTINATION include/${MODEL_NAMESPACE})
# #-- -- -- -- -- -- -- -- -- --
# #code unit testing
CORSIKA_ADD_TEST (testTrackingLeapFrogCurved)
target_link_libraries (
testTrackingLeapFrogCurved
ProcessTrackingLeapFrogCurved
CORSIKAtesting
)
# Note: all Tracking Algorithms are tested in testTracking
......@@ -5,7 +5,7 @@ set (
set (
MODEL_NAMESPACE
corsika/process/tracking_leapfrag_straight
corsika/process/tracking_leapfrog_straight
)
add_library (ProcessTrackingLeapFrogStraight INTERFACE)
......@@ -33,11 +33,4 @@ target_include_directories (
install (FILES ${MODEL_HEADERS} DESTINATION include/${MODEL_NAMESPACE})
# #-- -- -- -- -- -- -- -- -- --
# #code unit testing
CORSIKA_ADD_TEST (testTrackingLeapFrogStraight)
target_link_libraries (
testTrackingLeapFrogStraight
ProcessTrackingLeapFrogStraight
CORSIKAtesting
)
# Note: all Tracking Algorithms are tested in testTracking
/*
* (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.
*/
#pragma once
#include <corsika/environment/Environment.h>
#include <corsika/geometry/Point.h>
#include <corsika/geometry/Vector.h>
#include <corsika/particles/ParticleProperties.h>
#include <corsika/stack/CombinedStack.h>
#include <corsika/stack/node/GeometryNodeStackExtension.h>
#include <corsika/stack/nuclear_extension/NuclearStackExtension.h>
#include <corsika/units/PhysicalUnits.h>
class TestMagneticField {
using MagneticFieldVector =
corsika::geometry::Vector<corsika::units::si::magnetic_flux_density_d>;
TestMagneticField() = delete;
public:
TestMagneticField(const corsika::units::si::MagneticFluxType& field)
: Bz_(field) {}
void SetMagneticField(const corsika::units::si::MagneticFluxType& field) { Bz_ = field; }
MagneticFieldVector GetMagneticField(corsika::geometry::Point const& p) const {
using namespace corsika::units::si;
return MagneticFieldVector(p.GetCoordinateSystem(), 0_T, 0_T, Bz_);
}
private:
corsika::units::si::MagneticFluxType Bz_;
};
using TestEnvironmentType = corsika::environment::Environment<TestMagneticField>;
template <typename T>
using SetupGeometryDataInterface =
corsika::stack::node::GeometryDataInterface<T, TestEnvironmentType>;
// combine particle data stack with geometry information for tracking
template <typename StackIter>
using StackWithGeometryInterface = corsika::stack::CombinedParticleInterface<
corsika::stack::nuclear_extension::ParticleDataStack::MPIType,
SetupGeometryDataInterface, StackIter>;
using TestTrackingBFieldStack = corsika::stack::CombinedStack<
typename corsika::stack::nuclear_extension::ParticleDataStack::StackImpl,
corsika::stack::node::GeometryData<TestEnvironmentType>, StackWithGeometryInterface>;
......@@ -34,11 +34,4 @@ target_include_directories (
install (FILES ${MODEL_HEADERS} DESTINATION include/${MODEL_NAMESPACE})
# #-- -- -- -- -- -- -- -- -- --
# #code unit testing
CORSIKA_ADD_TEST (testTrackingLine)
target_link_libraries (
testTrackingLine
ProcessTrackingLine
CORSIKAtesting
)
# Note: all Tracking Algorithms are tested in testTracking
/*
* (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 <corsika/process/tracking_line/Tracking.h>
#include <testTrackingLineStack.h> // test-build, and include file is obtained from CMAKE_CURRENT_SOURCE_DIR
#include <corsika/environment/Environment.h>
#include <corsika/particles/ParticleProperties.h>
#include <corsika/geometry/Point.h>
#include <corsika/geometry/Sphere.h>
#include <corsika/geometry/Vector.h>
#include <corsika/geometry/Intersections.hpp>
#include <corsika/setup/SetupTrajectory.h>
using corsika::setup::Trajectory;
#include <catch2/catch.hpp>
using namespace corsika;
using namespace corsika::process;
using namespace corsika::units;
using namespace corsika::geometry;
#include <iostream>
using namespace std;
using namespace corsika::units::si;
TEST_CASE("TrackingLine") {
}
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