IAP GITLAB

Skip to content
Snippets Groups Projects
Commit 04164a42 authored by Maximilian Reininghaus's avatar Maximilian Reininghaus :vulcan:
Browse files

fixed build & test

parent 7bbfe4c7
No related branches found
No related tags found
No related merge requests found
...@@ -24,10 +24,9 @@ namespace corsika::environment { ...@@ -24,10 +24,9 @@ namespace corsika::environment {
auto IntegrateGrammage( auto IntegrateGrammage(
corsika::geometry::Trajectory<corsika::geometry::Line> const& line, corsika::geometry::Trajectory<corsika::geometry::Line> const& line,
corsika::units::si::LengthType length) const { corsika::units::si::LengthType length) const {
auto const c0 = GetImplementation().fRho(line.GetPosition(0)); auto const c0 = GetImplementation().EvaluateAt(line.GetPosition(0));
auto const c1 = GetImplementation().fRho.Derivative<1>(line.GetPosition(0), auto const c1 = GetImplementation().fRho.FirstDerivative(
line.NormalizedDirection()); line.GetPosition(0), line.NormalizedDirection());
return (c0 + 0.5 * c1 * length) * length; return (c0 + 0.5 * c1 * length) * length;
} }
...@@ -35,8 +34,8 @@ namespace corsika::environment { ...@@ -35,8 +34,8 @@ namespace corsika::environment {
corsika::geometry::Trajectory<corsika::geometry::Line> const& line, corsika::geometry::Trajectory<corsika::geometry::Line> const& line,
corsika::units::si::GrammageType grammage) const { corsika::units::si::GrammageType grammage) const {
auto const c0 = GetImplementation().fRho(line.GetPosition(0)); auto const c0 = GetImplementation().fRho(line.GetPosition(0));
auto const c1 = GetImplementation().fRho.Derivative<1>(line.GetPosition(0), auto const c1 = GetImplementation().fRho.FirstDerivative(
line.NormalizedDirection()); line.GetPosition(0), line.NormalizedDirection());
return (1 - 0.5 * grammage * c1 / (c0 * c0)) * grammage / c0; return (1 - 0.5 * grammage * c1 / (c0 * c0)) * grammage / c0;
} }
......
...@@ -47,6 +47,10 @@ struct Exponential { ...@@ -47,6 +47,10 @@ struct Exponential {
return v.GetComponents()[0] * (*this)(p) / return v.GetComponents()[0] * (*this)(p) /
corsika::units::si::detail::static_pow<N>(1_m); corsika::units::si::detail::static_pow<N>(1_m);
} }
auto FirstDerivative(Point const& p, Vector<dimensionless_d> const& v) const {
return Derivative<1>(p, v);
}
}; };
TEST_CASE("DensityFunction") { TEST_CASE("DensityFunction") {
...@@ -57,7 +61,7 @@ TEST_CASE("DensityFunction") { ...@@ -57,7 +61,7 @@ TEST_CASE("DensityFunction") {
Vector direction(cs, QuantityVector<dimensionless_d>(1, 0, 0)); Vector direction(cs, QuantityVector<dimensionless_d>(1, 0, 0));
Line line(origin, Vector<SpeedType::dimension_type>( Line line(origin, Vector<SpeedType::dimension_type>(
cs, {200_m / second, 0_m / second, 0_m / second})); cs, {20_m / second, 0_m / second, 0_m / second}));
auto const tEnd = 5_s; auto const tEnd = 5_s;
Trajectory<Line> const trajectory(line, tEnd); Trajectory<Line> const trajectory(line, tEnd);
...@@ -69,7 +73,13 @@ TEST_CASE("DensityFunction") { ...@@ -69,7 +73,13 @@ TEST_CASE("DensityFunction") {
DensityFunction const rho(e); DensityFunction const rho(e);
REQUIRE(rho.EvaluateAt(origin) == e(origin)); REQUIRE(rho.EvaluateAt(origin) == e(origin));
auto const exactGrammage = [](auto x) { return rho0 * exp(x / 1_m); }; auto const exactGrammage = [](auto l) { return 1_m * rho0 * (exp(l / 1_m) - 1); };
REQUIRE(rho.IntegrateGrammage(trajectory, 5_cm) / exactGrammage(5_cm) == auto const exactLength = [](auto X) { return 1_m * log(1 + X / (rho0 * 1_m)); };
Approx(1).epsilon(1e-2));
auto constexpr l = 15_cm;
CHECK(rho.IntegrateGrammage(trajectory, l) / exactGrammage(l) ==
Approx(1).epsilon(1e-2));
CHECK(rho.ArclengthFromGrammage(trajectory, exactGrammage(l)) /
exactLength(exactGrammage(l)) ==
Approx(1).epsilon(1e-2));
} }
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