IAP GITLAB

Skip to content
Snippets Groups Projects
Commit 73d58899 authored by Remy Prechelt's avatar Remy Prechelt
Browse files

Added additional tests for magnetic field + homogeneous medium.

parent 1e90b806
No related branches found
No related tags found
No related merge requests found
/* /*
* (c) Copyright 2018 CORSIKA Project, corsika-project@lists.kit.edu * (c) Copyright 2020 CORSIKA Project, corsika-project@lists.kit.edu
* *
* See file AUTHORS for a list of contributors. * See file AUTHORS for a list of contributors.
* *
......
/* /*
* (c) Copyright 2018 CORSIKA Project, corsika-project@lists.kit.edu * (c) Copyright 2020 CORSIKA Project, corsika-project@lists.kit.edu
* *
* See file AUTHORS for a list of contributors. * See file AUTHORS for a list of contributors.
* *
......
...@@ -245,8 +245,11 @@ TEST_CASE("UniformMagneticField w/ Homogeneous Medium") { ...@@ -245,8 +245,11 @@ TEST_CASE("UniformMagneticField w/ Homogeneous Medium") {
// create a magnetic field vector // create a magnetic field vector
QuantityVector B0(0_T, 0_T, 0_T); QuantityVector B0(0_T, 0_T, 0_T);
// the constant density
const auto density{19.2_g / cube(1_cm)};
// create our atmospheric model // create our atmospheric model
AtmModel medium(B0, 19.2_g / cube(1_cm), protonComposition); AtmModel medium(B0, density, protonComposition);
// create a new magnetic field vector // create a new magnetic field vector
QuantityVector B1(23_T, 57_T, -4_T); QuantityVector B1(23_T, 57_T, -4_T);
...@@ -258,42 +261,22 @@ TEST_CASE("UniformMagneticField w/ Homogeneous Medium") { ...@@ -258,42 +261,22 @@ TEST_CASE("UniformMagneticField w/ Homogeneous Medium") {
REQUIRE(B1 == medium.GetMagneticField(Point(gCS, -10_m, 4_m, 35_km))); REQUIRE(B1 == medium.GetMagneticField(Point(gCS, -10_m, 4_m, 35_km)));
REQUIRE(B1 == medium.GetMagneticField(Point(gCS, 1000_km, -1000_km, 1000_km))); REQUIRE(B1 == medium.GetMagneticField(Point(gCS, 1000_km, -1000_km, 1000_km)));
REQUIRE(B1 == medium.GetMagneticField(Point(gCS, 0_m, 0_m, 0_m))); REQUIRE(B1 == medium.GetMagneticField(Point(gCS, 0_m, 0_m, 0_m)));
}
TEST_CASE("UniformMagneticField w/ FlatExponential") {
// setup our interface types
using IModelInterface = IMagneticFieldModel<IMediumModel>;
using AtmModel = UniformMagneticField<FlatExponential<IModelInterface>>;
// the composition we use for the homogenous medium
NuclearComposition const protonComposition(std::vector<Code>{Code::Proton},
std::vector<float>{1.f});
// define our quantity vector // check the density and nuclear composition
Vector const axis(gCS, QuantityVector<dimensionless_d>(0, 0, 1)); REQUIRE(density == medium.GetMassDensity(Point(gCS, 0_m, 0_m, 0_m)));
medium.GetNuclearComposition();
// the parameters of our exponential model // create a line of length 1 m
LengthType const lambda = 3_m; Line const line(gOrigin, Vector<SpeedType::dimension_type>(
auto const rho0 = 1_g / units::si::detail::static_pow<3>(1_cm); gCS, {1_m / second, 0_m / second, 0_m / second}));
// create a magnetic field vector // the end time of our line
QuantityVector B0(23_T, 57_T, -4_T); auto const tEnd = 1_s;
// create our atmospheric model // and the associated trajectory
AtmModel medium(B0, gOrigin, axis, rho0, lambda, protonComposition); Trajectory<Line> const trajectory(line, tEnd);
// check that the returned magnetic field is correct
REQUIRE(B0 == medium.GetMagneticField(Point(gCS, -10_m, 4_m, 35_km)));
// create a new magnetic field vector
QuantityVector B1(23_T, 57_T, -4_T);
// and update this atmospheric model
medium.SetMagneticField(B1);
// and test at several locations // and check the integrated grammage
REQUIRE(B1 == medium.GetMagneticField(Point(gCS, -10_m, 4_m, 35_km))); REQUIRE((medium.IntegratedGrammage(trajectory, 3_m) / (density * 3_m)) == Approx(1));
REQUIRE(B1 == medium.GetMagneticField(Point(gCS, 1000_km, -1000_km, 1000_km))); REQUIRE((medium.ArclengthFromGrammage(trajectory, density * 5_m) / 5_m) == Approx(1));
REQUIRE(B1 == medium.GetMagneticField(Point(gCS, 0_m, 0_m, 0_m)));
} }
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