IAP GITLAB

Skip to content
Snippets Groups Projects
Commit 74ac6d40 authored by Alan Coleman's avatar Alan Coleman Committed by Maximilian Reininghaus
Browse files

Fix issue 550, added unit tests to catch this

parent 3da5c83e
No related branches found
No related tags found
1 merge request!472Corrected implementation of FlatExponential
...@@ -29,7 +29,7 @@ namespace corsika { ...@@ -29,7 +29,7 @@ namespace corsika {
template <typename T> template <typename T>
inline MassDensityType FlatExponential<T>::getMassDensity(Point const& point) const { inline MassDensityType FlatExponential<T>::getMassDensity(Point const& point) const {
return BaseExponential<FlatExponential<T>>::getMassDensity( return BaseExponential<FlatExponential<T>>::getMassDensity(
(point - BaseExponential<FlatExponential<T>>::getAnchorPoint()).getNorm()); (point - BaseExponential<FlatExponential<T>>::getAnchorPoint()).dot(axis_));
} }
template <typename T> template <typename T>
......
...@@ -101,11 +101,19 @@ TEST_CASE("FlatExponential") { ...@@ -101,11 +101,19 @@ TEST_CASE("FlatExponential") {
LengthType const length = 2_m; LengthType const length = 2_m;
TimeType const tEnd = length / speed; TimeType const tEnd = length / speed;
CHECK((medium.getMassDensity(gOrigin)) == rho0);
CHECK(medium.getNuclearComposition().getFractions() == std::vector<double>{1.}); CHECK(medium.getNuclearComposition().getFractions() == std::vector<double>{1.});
CHECK(medium.getNuclearComposition().getComponents() == CHECK(medium.getNuclearComposition().getComponents() ==
std::vector<Code>{Code::Proton}); std::vector<Code>{Code::Proton});
SECTION("horizontal") { SECTION("horizontal") {
//Check that not moving along axis does not change density
CHECK(medium.getMassDensity(Point(gCS, 1_m, 0_m, 0_m)) == rho0);
CHECK(medium.getMassDensity(Point(gCS, 1_m, 0_m, 0_m)) == rho0);
CHECK(medium.getMassDensity(Point(gCS, -1_m, 0_m, 0_m)) == rho0);
CHECK(medium.getMassDensity(Point(gCS, 0_m, 1_m, 0_m)) == rho0);
CHECK(medium.getMassDensity(Point(gCS, 0_m,-1_m, 0_m)) == rho0);
Line const line(gOrigin, Vector<SpeedType::dimension_type>( Line const line(gOrigin, Vector<SpeedType::dimension_type>(
gCS, {speed, 0_m / second, 0_m / second})); gCS, {speed, 0_m / second, 0_m / second}));
setup::Trajectory const trajectory = setup::Trajectory const trajectory =
...@@ -117,6 +125,10 @@ TEST_CASE("FlatExponential") { ...@@ -117,6 +125,10 @@ TEST_CASE("FlatExponential") {
} }
SECTION("vertical") { SECTION("vertical") {
//Moving along axis does change density
CHECK(medium.getMassDensity(Point(gCS, 0_m, 0_m, 1_m)) > rho0);
CHECK(medium.getMassDensity(Point(gCS, 0_m, 0_m, -1_m)) < rho0);
Line const line(gOrigin, Vector<SpeedType::dimension_type>( Line const line(gOrigin, Vector<SpeedType::dimension_type>(
gCS, {0_m / second, 0_m / second, speed})); gCS, {0_m / second, 0_m / second, speed}));
setup::Trajectory const trajectory = setup::Trajectory const trajectory =
......
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