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
1 merge request!67Resolve "Add support for inhomogeneus density"
Pipeline #279 passed
......@@ -24,10 +24,9 @@ namespace corsika::environment {
auto IntegrateGrammage(
corsika::geometry::Trajectory<corsika::geometry::Line> const& line,
corsika::units::si::LengthType length) const {
auto const c0 = GetImplementation().fRho(line.GetPosition(0));
auto const c1 = GetImplementation().fRho.Derivative<1>(line.GetPosition(0),
line.NormalizedDirection());
auto const c0 = GetImplementation().EvaluateAt(line.GetPosition(0));
auto const c1 = GetImplementation().fRho.FirstDerivative(
line.GetPosition(0), line.NormalizedDirection());
return (c0 + 0.5 * c1 * length) * length;
}
......@@ -35,8 +34,8 @@ namespace corsika::environment {
corsika::geometry::Trajectory<corsika::geometry::Line> const& line,
corsika::units::si::GrammageType grammage) const {
auto const c0 = GetImplementation().fRho(line.GetPosition(0));
auto const c1 = GetImplementation().fRho.Derivative<1>(line.GetPosition(0),
line.NormalizedDirection());
auto const c1 = GetImplementation().fRho.FirstDerivative(
line.GetPosition(0), line.NormalizedDirection());
return (1 - 0.5 * grammage * c1 / (c0 * c0)) * grammage / c0;
}
......
......@@ -47,6 +47,10 @@ struct Exponential {
return v.GetComponents()[0] * (*this)(p) /
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") {
......@@ -57,7 +61,7 @@ TEST_CASE("DensityFunction") {
Vector direction(cs, QuantityVector<dimensionless_d>(1, 0, 0));
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;
Trajectory<Line> const trajectory(line, tEnd);
......@@ -69,7 +73,13 @@ TEST_CASE("DensityFunction") {
DensityFunction const rho(e);
REQUIRE(rho.EvaluateAt(origin) == e(origin));
auto const exactGrammage = [](auto x) { return rho0 * exp(x / 1_m); };
REQUIRE(rho.IntegrateGrammage(trajectory, 5_cm) / exactGrammage(5_cm) ==
Approx(1).epsilon(1e-2));
auto const exactGrammage = [](auto l) { return 1_m * rho0 * (exp(l / 1_m) - 1); };
auto const exactLength = [](auto X) { return 1_m * log(1 + X / (rho0 * 1_m)); };
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