diff --git a/Environment/IMagneticFieldModel.h b/Environment/IMagneticFieldModel.h index 5941f3ba473c6f4d5bc9a864dd31256ac1355e18..a2666ba267f530e7a56346f1ad7faf141ca9d7c1 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 4e3ee298ad9cd0d53a0edca1386905eb8e6e6677..31f2a1b94b78cb6ef5e7e318019c48401f87beb9 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 ae993ad13de2bc921e13f7b2b2b936c050f0cd59..55ef5fba4f2473e6e59141953c1b191d2ceadaec 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)); }