IAP GITLAB

Skip to content
Snippets Groups Projects
Commit 0f868194 authored by Nikos Karastathis's avatar Nikos Karastathis :ocean: Committed by Ralf Ulrich
Browse files

clang format

parent 128eed1f
No related branches found
No related tags found
1 merge request!402Resolve "ExponentialRefractiveIndex assumes a flat environment"
...@@ -54,8 +54,8 @@ namespace corsika { ...@@ -54,8 +54,8 @@ namespace corsika {
} }
template <typename TTimeType, typename TSpaceVecType> template <typename TTimeType, typename TSpaceVecType>
inline FourVector<TTimeType, TSpaceVecType>& FourVector<TTimeType, TSpaceVecType>:: inline FourVector<TTimeType, TSpaceVecType>&
operator+=(FourVector const& b) { FourVector<TTimeType, TSpaceVecType>::operator+=(FourVector const& b) {
timeLike_ += b.timeLike_; timeLike_ += b.timeLike_;
spaceLike_ += b.spaceLike_; spaceLike_ += b.spaceLike_;
...@@ -63,39 +63,39 @@ namespace corsika { ...@@ -63,39 +63,39 @@ namespace corsika {
} }
template <typename TTimeType, typename TSpaceVecType> template <typename TTimeType, typename TSpaceVecType>
inline FourVector<TTimeType, TSpaceVecType>& FourVector<TTimeType, TSpaceVecType>:: inline FourVector<TTimeType, TSpaceVecType>&
operator-=(FourVector const& b) { FourVector<TTimeType, TSpaceVecType>::operator-=(FourVector const& b) {
timeLike_ -= b.timeLike_; timeLike_ -= b.timeLike_;
spaceLike_ -= b.spaceLike_; spaceLike_ -= b.spaceLike_;
return *this; return *this;
} }
template <typename TTimeType, typename TSpaceVecType> template <typename TTimeType, typename TSpaceVecType>
inline FourVector<TTimeType, TSpaceVecType>& FourVector<TTimeType, TSpaceVecType>:: inline FourVector<TTimeType, TSpaceVecType>&
operator*=(double const b) { FourVector<TTimeType, TSpaceVecType>::operator*=(double const b) {
timeLike_ *= b; timeLike_ *= b;
spaceLike_ *= b; spaceLike_ *= b;
return *this; return *this;
} }
template <typename TTimeType, typename TSpaceVecType> template <typename TTimeType, typename TSpaceVecType>
inline FourVector<TTimeType, TSpaceVecType>& FourVector<TTimeType, TSpaceVecType>:: inline FourVector<TTimeType, TSpaceVecType>&
operator/=(double const b) { FourVector<TTimeType, TSpaceVecType>::operator/=(double const b) {
timeLike_ /= b; timeLike_ /= b;
spaceLike_.getComponents() /= b; spaceLike_.getComponents() /= b;
return *this; return *this;
} }
template <typename TTimeType, typename TSpaceVecType> template <typename TTimeType, typename TSpaceVecType>
inline FourVector<TTimeType, TSpaceVecType>& FourVector<TTimeType, TSpaceVecType>:: inline FourVector<TTimeType, TSpaceVecType>&
operator/(double const b) { FourVector<TTimeType, TSpaceVecType>::operator/(double const b) {
*this /= b; *this /= b;
return *this; return *this;
} }
template <typename TTimeType, typename TSpaceVecType> template <typename TTimeType, typename TSpaceVecType>
inline typename FourVector<TTimeType, TSpaceVecType>::norm_type inline typename FourVector<TTimeType, TSpaceVecType>::norm_type
FourVector<TTimeType, TSpaceVecType>::operator*(FourVector const& b) { FourVector<TTimeType, TSpaceVecType>::operator*(FourVector const& b) {
if constexpr (std::is_same<time_type, decltype(std::declval<space_type>() / meter * if constexpr (std::is_same<time_type, decltype(std::declval<space_type>() / meter *
second)>::value) second)>::value)
return timeLike_ * b.timeLike_ * constants::cSquared - spaceLike_.norm(); return timeLike_ * b.timeLike_ * constants::cSquared - spaceLike_.norm();
......
...@@ -17,8 +17,8 @@ ...@@ -17,8 +17,8 @@
namespace corsika { namespace corsika {
template <typename TDimension> template <typename TDimension>
inline typename QuantityVector<TDimension>::quantity_type QuantityVector<TDimension>:: inline typename QuantityVector<TDimension>::quantity_type
operator[](size_t const index) const { QuantityVector<TDimension>::operator[](size_t const index) const {
return quantity_type(phys::units::detail::magnitude_tag, eigenVector_[index]); return quantity_type(phys::units::detail::magnitude_tag, eigenVector_[index]);
} }
......
...@@ -15,7 +15,8 @@ namespace corsika { ...@@ -15,7 +15,8 @@ namespace corsika {
template <typename T> template <typename T>
template <typename... Args> template <typename... Args>
ExponentialRefractiveIndex<T>::ExponentialRefractiveIndex( ExponentialRefractiveIndex<T>::ExponentialRefractiveIndex(
double const n0, InverseLengthType const lambda, Point const center, LengthType const radius, Args&&... args) double const n0, InverseLengthType const lambda, Point const center,
LengthType const radius, Args&&... args)
: T(std::forward<Args>(args)...) : T(std::forward<Args>(args)...)
, n0_(n0) , n0_(n0)
, lambda_(lambda) , lambda_(lambda)
......
...@@ -20,7 +20,7 @@ namespace corsika { ...@@ -20,7 +20,7 @@ namespace corsika {
template <class AConstIterator, class BConstIterator> template <class AConstIterator, class BConstIterator>
inline typename WeightProviderIterator<AConstIterator, BConstIterator>::value_type inline typename WeightProviderIterator<AConstIterator, BConstIterator>::value_type
WeightProviderIterator<AConstIterator, BConstIterator>::operator*() const { WeightProviderIterator<AConstIterator, BConstIterator>::operator*() const {
return ((*aIter_) * (*bIter_)).magnitude(); return ((*aIter_) * (*bIter_)).magnitude();
} }
......
...@@ -56,8 +56,8 @@ namespace corsika::proposal { ...@@ -56,8 +56,8 @@ namespace corsika::proposal {
PROPOSAL::InterpolationSettings::TABLES_PATH = corsika_data("PROPOSAL").c_str(); PROPOSAL::InterpolationSettings::TABLES_PATH = corsika_data("PROPOSAL").c_str();
} }
inline size_t ProposalProcessBase::hash::operator()(const calc_key_t& p) const inline size_t ProposalProcessBase::hash::operator()(
noexcept { const calc_key_t& p) const noexcept {
return p.first ^ std::hash<Code>{}(p.second); return p.first ^ std::hash<Code>{}(p.second);
} }
......
...@@ -23,9 +23,9 @@ namespace corsika { ...@@ -23,9 +23,9 @@ namespace corsika {
class ExponentialRefractiveIndex : public T { class ExponentialRefractiveIndex : public T {
double n0_; ///< n0 constant. double n0_; ///< n0 constant.
InverseLengthType lambda_; ///< lambda parameter. InverseLengthType lambda_; ///< lambda parameter.
LengthType radius_; ///< the planet radius. LengthType radius_; ///< the planet radius.
Point center_; ///< center of the planet. Point center_; ///< center of the planet.
public: public:
/** /**
...@@ -38,7 +38,8 @@ namespace corsika { ...@@ -38,7 +38,8 @@ namespace corsika {
* @param field The refractive index to return to a given point. * @param field The refractive index to return to a given point.
*/ */
template <typename... Args> template <typename... Args>
ExponentialRefractiveIndex(double const n0, InverseLengthType const lambda, Point const center, LengthType const radius, ExponentialRefractiveIndex(double const n0, InverseLengthType const lambda,
Point const center, LengthType const radius,
Args&&... args); Args&&... args);
/** /**
......
...@@ -10,6 +10,7 @@ ...@@ -10,6 +10,7 @@
#include <corsika/framework/geometry/Line.hpp> #include <corsika/framework/geometry/Line.hpp>
#include <corsika/framework/geometry/RootCoordinateSystem.hpp> #include <corsika/framework/geometry/RootCoordinateSystem.hpp>
#include <corsika/framework/geometry/Vector.hpp> #include <corsika/framework/geometry/Vector.hpp>
#include <corsika/media/Environment.hpp> #include <corsika/media/Environment.hpp>
#include <corsika/media/LayeredSphericalAtmosphereBuilder.hpp> #include <corsika/media/LayeredSphericalAtmosphereBuilder.hpp>
#include <corsika/media/UniformMagneticField.hpp> #include <corsika/media/UniformMagneticField.hpp>
...@@ -19,6 +20,7 @@ ...@@ -19,6 +20,7 @@
#include <corsika/media/NuclearComposition.hpp> #include <corsika/media/NuclearComposition.hpp>
#include <corsika/media/UniformRefractiveIndex.hpp> #include <corsika/media/UniformRefractiveIndex.hpp>
#include <corsika/media/ExponentialRefractiveIndex.hpp> #include <corsika/media/ExponentialRefractiveIndex.hpp>
#include <corsika/media/CORSIKA7Atmospheres.hpp>
#include <SetupTestTrajectory.hpp> #include <SetupTestTrajectory.hpp>
#include <corsika/setup/SetupTrajectory.hpp> #include <corsika/setup/SetupTrajectory.hpp>
...@@ -124,18 +126,21 @@ TEST_CASE("ExponentialRefractiveIndex w/ Homogeneous medium") { ...@@ -124,18 +126,21 @@ TEST_CASE("ExponentialRefractiveIndex w/ Homogeneous medium") {
// the center of the earth // the center of the earth
Point const center_{gCS, 0_m, 0_m, 0_m}; Point const center_{gCS, 0_m, 0_m, 0_m};
// earth's radius // earth's radius
LengthType const radius_ {constants::EarthRadius::Mean}; LengthType const radius_{constants::EarthRadius::Mean};
// create the atmospheric model and check refractive index // create the atmospheric model and check refractive index
AtmModel medium(n0, lambda, center_, constants::EarthRadius::Mean, density, protonComposition); AtmModel medium(n0, lambda, center_, constants::EarthRadius::Mean, density,
CHECK(n0 - medium.getRefractiveIndex(Point(gCS, 0_m, 0_m, constants::EarthRadius::Mean)) == Approx(0)); protonComposition);
CHECK(n0 - medium.getRefractiveIndex(
Point(gCS, 0_m, 0_m, constants::EarthRadius::Mean)) ==
Approx(0));
// another refractive index // another refractive index
const double n0_{1}; const double n0_{1};
const InverseLengthType lambda_{1 / 1_km}; const InverseLengthType lambda_{1 / 1_km};
// distance from the center // distance from the center
LengthType const dist_ {4_km}; LengthType const dist_{4_km};
// create the atmospheric model and check refractive index // create the atmospheric model and check refractive index
AtmModel medium_(n0_, lambda_, center_, dist_, density, protonComposition); AtmModel medium_(n0_, lambda_, center_, dist_, density, protonComposition);
...@@ -172,7 +177,7 @@ TEST_CASE("ExponentialRefractiveIndex w/ Homogeneous medium") { ...@@ -172,7 +177,7 @@ TEST_CASE("ExponentialRefractiveIndex w/ Homogeneous medium") {
REQUIRE((medium_.getArclengthFromGrammage(track, density * 5_m) / 5_m) == Approx(1)); REQUIRE((medium_.getArclengthFromGrammage(track, density * 5_m) / 5_m) == Approx(1));
} }
TEST_CASE("ExponentialRefractiveIndex w/ Layered atmosphere") { TEST_CASE("ExponentialRefractiveIndex w/ 5-layered atmosphere") {
logging::set_level(logging::level::info); logging::set_level(logging::level::info);
...@@ -187,32 +192,18 @@ TEST_CASE("ExponentialRefractiveIndex w/ Layered atmosphere") { ...@@ -187,32 +192,18 @@ TEST_CASE("ExponentialRefractiveIndex w/ Layered atmosphere") {
const InverseLengthType lambda{1 / 1_km}; const InverseLengthType lambda{1 / 1_km};
// a reference point to calculate the refractive index there // a reference point to calculate the refractive index there
Point const ref_ {gCS, 0_m, 0_m, constants::EarthRadius::Mean}; Point const ref_{gCS, 0_m, 0_m, constants::EarthRadius::Mean};
// setup a realistic environment // setup a 5-layered environment
using EnvironmentInterface = using EnvironmentInterface =
IRefractiveIndexModel<IMediumPropertyModel<IMagneticFieldModel<IMediumModel>>>; IRefractiveIndexModel<IMediumPropertyModel<IMagneticFieldModel<IMediumModel>>>;
using EnvType = Environment<EnvironmentInterface>; using EnvType = Environment<EnvironmentInterface>;
EnvType env; EnvType env;
auto builder = make_layered_spherical_atmosphere_builder< create_5layer_atmosphere<EnvironmentInterface, MyExtraEnv>(
EnvironmentInterface, MyExtraEnv>::create(center_, env, AtmosphereId::LinsleyUSStd, center_, n0, lambda, center_,
constants::EarthRadius::Mean, n0, lambda, constants::EarthRadius::Mean, Medium::AirDry1Atm,
center_, constants::EarthRadius::Mean, MagneticFieldVector{gCS, 0_T, 50_uT, 0_T});
Medium::AirDry1Atm,
MagneticFieldVector{gCS, 10_uT,
0_T, 0_T});
builder.setNuclearComposition(
{{Code::Nitrogen, Code::Oxygen},
{0.7847f, 1.f - 0.7847f}});
builder.addExponentialLayer(1222.6562_g / (1_cm * 1_cm), 994186.38_cm, 2_km);
builder.addExponentialLayer(1222.6562_g / (1_cm * 1_cm), 994186.38_cm, 4_km);
builder.addExponentialLayer(1144.9069_g / (1_cm * 1_cm), 878153.55_cm, 10_km);
builder.addExponentialLayer(1305.5948_g / (1_cm * 1_cm), 636143.04_cm, 40_km);
builder.addExponentialLayer(540.1778_g / (1_cm * 1_cm), 772170.16_cm, 100_km);
builder.addLinearLayer(1e9_cm, 112.8_km + constants::EarthRadius::Mean);
builder.assemble(env);
// get the universe for this environment // get the universe for this environment
auto const* const universe{env.getUniverse().get()}; auto const* const universe{env.getUniverse().get()};
......
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