From 73d588996339d60714834bdc49da0c509422b7d1 Mon Sep 17 00:00:00 2001 From: Remy Prechelt <prechelt@hawaii.edu> Date: Tue, 30 Jun 2020 08:52:35 -1000 Subject: [PATCH] Added additional tests for magnetic field + homogeneous medium. --- Environment/IMagneticFieldModel.h | 2 +- Environment/UniformMagneticField.h | 2 +- Environment/testEnvironment.cc | 51 ++++++++++-------------------- 3 files changed, 19 insertions(+), 36 deletions(-) diff --git a/Environment/IMagneticFieldModel.h b/Environment/IMagneticFieldModel.h index 5941f3ba4..a2666ba26 100644 --- a/Environment/IMagneticFieldModel.h +++ b/Environment/IMagneticFieldModel.h @@ -1,5 +1,5 @@ /* - * (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. * diff --git a/Environment/UniformMagneticField.h b/Environment/UniformMagneticField.h index 4e3ee298a..31f2a1b94 100644 --- a/Environment/UniformMagneticField.h +++ b/Environment/UniformMagneticField.h @@ -1,5 +1,5 @@ /* - * (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. * diff --git a/Environment/testEnvironment.cc b/Environment/testEnvironment.cc index ae993ad13..55ef5fba4 100644 --- a/Environment/testEnvironment.cc +++ b/Environment/testEnvironment.cc @@ -245,8 +245,11 @@ TEST_CASE("UniformMagneticField w/ Homogeneous Medium") { // create a magnetic field vector QuantityVector B0(0_T, 0_T, 0_T); + // the constant density + const auto density{19.2_g / cube(1_cm)}; + // 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 QuantityVector B1(23_T, 57_T, -4_T); @@ -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, 1000_km, -1000_km, 1000_km))); 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 - Vector const axis(gCS, QuantityVector<dimensionless_d>(0, 0, 1)); + // check the density and nuclear composition + REQUIRE(density == medium.GetMassDensity(Point(gCS, 0_m, 0_m, 0_m))); + medium.GetNuclearComposition(); - // the parameters of our exponential model - LengthType const lambda = 3_m; - auto const rho0 = 1_g / units::si::detail::static_pow<3>(1_cm); + // create a line of length 1 m + Line const line(gOrigin, Vector<SpeedType::dimension_type>( + gCS, {1_m / second, 0_m / second, 0_m / second})); - // create a magnetic field vector - QuantityVector B0(23_T, 57_T, -4_T); + // the end time of our line + auto const tEnd = 1_s; - // create our atmospheric model - AtmModel medium(B0, gOrigin, axis, rho0, lambda, protonComposition); - - // 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 the associated trajectory + Trajectory<Line> const trajectory(line, tEnd); - // and test at several locations - 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, 0_m, 0_m, 0_m))); + // and check the integrated grammage + REQUIRE((medium.IntegratedGrammage(trajectory, 3_m) / (density * 3_m)) == Approx(1)); + REQUIRE((medium.ArclengthFromGrammage(trajectory, density * 5_m) / 5_m) == Approx(1)); } -- GitLab