IAP GITLAB
Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
corsika
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Issue analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Air Shower Physics
corsika
Commits
128eed1f
Commit
128eed1f
authored
3 years ago
by
Nikos Karastathis
Committed by
Ralf Ulrich
3 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Added tests.
parent
91a5af99
No related branches found
No related tags found
1 merge request
!402
Resolve "ExponentialRefractiveIndex assumes a flat environment"
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
tests/media/testRefractiveIndex.cpp
+73
-23
73 additions, 23 deletions
tests/media/testRefractiveIndex.cpp
with
73 additions
and
23 deletions
tests/media/testRefractiveIndex.cpp
+
73
−
23
View file @
128eed1f
...
...
@@ -10,10 +10,12 @@
#include
<corsika/framework/geometry/Line.hpp>
#include
<corsika/framework/geometry/RootCoordinateSystem.hpp>
#include
<corsika/framework/geometry/Vector.hpp>
#include
<corsika/media/FlatExponential.hpp>
#include
<corsika/media/Environment.hpp>
#include
<corsika/media/LayeredSphericalAtmosphereBuilder.hpp>
#include
<corsika/media/UniformMagneticField.hpp>
#include
<corsika/media/MediumPropertyModel.hpp>
#include
<corsika/media/HomogeneousMedium.hpp>
#include
<corsika/media/IMediumModel.hpp>
#include
<corsika/media/InhomogeneousMedium.hpp>
#include
<corsika/media/NuclearComposition.hpp>
#include
<corsika/media/UniformRefractiveIndex.hpp>
#include
<corsika/media/ExponentialRefractiveIndex.hpp>
...
...
@@ -24,11 +26,13 @@
#include
<catch2/catch.hpp>
using
namespace
corsika
;
template
<
typename
TInterface
>
using
MyExtraEnv
=
ExponentialRefractiveIndex
<
MediumPropertyModel
<
UniformMagneticField
<
TInterface
>>>
;
TEST_CASE
(
"UniformRefractiveIndex w/ Homogeneous"
)
{
logging
::
set_level
(
logging
::
level
::
info
);
corsika_logger
->
set_pattern
(
"[%n:%^%-8l%$] custom pattern: %v"
);
CoordinateSystemPtr
const
&
gCS
=
get_root_CoordinateSystem
();
...
...
@@ -97,14 +101,13 @@ TEST_CASE("UniformRefractiveIndex w/ Homogeneous") {
TEST_CASE
(
"ExponentialRefractiveIndex w/ Homogeneous medium"
)
{
logging
::
set_level
(
logging
::
level
::
info
);
corsika_logger
->
set_pattern
(
"[%n:%^%-8l%$] custom pattern: %v"
);
// get a CS and a point
CoordinateSystemPtr
const
&
gCS
=
get_root_CoordinateSystem
();
Point
const
gOrigin
(
gCS
,
{
0
_m
,
0
_m
,
0
_m
});
// setup
our
interface types
// setup interface types
using
IModelInterface
=
IRefractiveIndexModel
<
IMediumModel
>
;
using
AtmModel
=
ExponentialRefractiveIndex
<
HomogeneousMedium
<
IModelInterface
>>
;
...
...
@@ -115,30 +118,30 @@ TEST_CASE("ExponentialRefractiveIndex w/ Homogeneous medium") {
NuclearComposition
const
protonComposition
({
Code
::
Proton
},
{
1.
});
// a new refractive index
const
double
n0
{
2
};
const
InverseLengthType
lambda
{
56
/
1
_m
};
const
double
n0
{
1
};
const
InverseLengthType
lambda
{
6
/
1
_m
};
// the center of the earth
Point
const
center_
{
gCS
,
0
_m
,
0
_m
,
0
_m
};
// earth's radius
LengthType
const
radius_
{
constants
::
EarthRadius
::
Mean
};
// create the atmospheric model and check refractive index
AtmModel
medium
(
n0
,
lambda
,
density
,
protonComposition
);
CHECK
(
n0
==
medium
.
getRefractiveIndex
(
Point
(
gCS
,
1
0
_m
,
14
_m
,
0
_m
)
));
AtmModel
medium
(
n0
,
lambda
,
center_
,
constants
::
EarthRadius
::
Mean
,
density
,
protonComposition
);
CHECK
(
n0
-
medium
.
getRefractiveIndex
(
Point
(
gCS
,
0
_m
,
0
_m
,
constants
::
EarthRadius
::
Mean
))
==
Approx
(
0
));
// another refractive index
const
double
n0_
{
1
};
const
InverseLengthType
lambda_
{
1
/
1
_km
};
// create the atmospheric model and check refractive index
AtmModel
medium_
(
n0_
,
lambda_
,
density
,
protonComposition
);
CHECK
(
medium_
.
getRefractiveIndex
(
Point
(
gCS
,
12
_m
,
56
_m
,
1
_km
))
==
Approx
(
0.3678794
));
// another refractive index
const
double
n0__
{
4
};
const
InverseLengthType
lambda__
{
2
/
1
_m
};
// distance from the center
LengthType
const
dist_
{
4
_km
};
// create the atmospheric model and check refractive index
AtmModel
medium_
_
(
n0_
_
,
lambda__
,
density
,
protonComposition
);
CHECK
(
medium_
_
.
getRefractiveIndex
(
Point
(
gCS
,
0
_m
,
0
_
m
,
35
_km
))
==
Approx
(
0
));
AtmModel
medium_
(
n0_
,
lambda_
,
center_
,
dist
_
,
density
,
protonComposition
);
CHECK
(
medium_
.
getRefractiveIndex
(
Point
(
gCS
,
4
_km
,
3
_k
m
,
0
_km
))
==
Approx
(
0
.3678794412
));
// define
our
axis vector
// define axis vector
Vector
const
axis
(
gCS
,
QuantityVector
<
dimensionless_d
>
(
0
,
0
,
1
));
// check the density and nuclear composition
...
...
@@ -146,8 +149,6 @@ TEST_CASE("ExponentialRefractiveIndex w/ Homogeneous medium") {
medium
.
getNuclearComposition
();
REQUIRE
(
density
==
medium_
.
getMassDensity
(
Point
(
gCS
,
0
_m
,
0
_m
,
0
_m
)));
medium_
.
getNuclearComposition
();
REQUIRE
(
density
==
medium__
.
getMassDensity
(
Point
(
gCS
,
0
_m
,
0
_m
,
0
_m
)));
medium__
.
getNuclearComposition
();
SpeedType
const
velocity
=
1
_m
/
second
;
...
...
@@ -169,6 +170,55 @@ TEST_CASE("ExponentialRefractiveIndex w/ Homogeneous medium") {
REQUIRE
((
medium
.
getArclengthFromGrammage
(
track
,
density
*
5
_m
)
/
5
_m
)
==
Approx
(
1
));
REQUIRE
((
medium_
.
getIntegratedGrammage
(
track
)
/
(
density
*
length
))
==
Approx
(
1
));
REQUIRE
((
medium_
.
getArclengthFromGrammage
(
track
,
density
*
5
_m
)
/
5
_m
)
==
Approx
(
1
));
REQUIRE
((
medium__
.
getIntegratedGrammage
(
track
)
/
(
density
*
length
))
==
Approx
(
1
));
REQUIRE
((
medium__
.
getArclengthFromGrammage
(
track
,
density
*
5
_m
)
/
5
_m
)
==
Approx
(
1
));
}
TEST_CASE
(
"ExponentialRefractiveIndex w/ Layered atmosphere"
)
{
logging
::
set_level
(
logging
::
level
::
info
);
// get a CS
CoordinateSystemPtr
const
&
gCS
=
get_root_CoordinateSystem
();
// the center of the earth
Point
const
center_
{
gCS
,
0
_m
,
0
_m
,
0
_m
};
// another refractive index
const
double
n0
{
2
};
const
InverseLengthType
lambda
{
1
/
1
_km
};
// a reference point to calculate the refractive index there
Point
const
ref_
{
gCS
,
0
_m
,
0
_m
,
constants
::
EarthRadius
::
Mean
};
// setup a realistic environment
using
EnvironmentInterface
=
IRefractiveIndexModel
<
IMediumPropertyModel
<
IMagneticFieldModel
<
IMediumModel
>>>
;
using
EnvType
=
Environment
<
EnvironmentInterface
>
;
EnvType
env
;
auto
builder
=
make_layered_spherical_atmosphere_builder
<
EnvironmentInterface
,
MyExtraEnv
>::
create
(
center_
,
constants
::
EarthRadius
::
Mean
,
n0
,
lambda
,
center_
,
constants
::
EarthRadius
::
Mean
,
Medium
::
AirDry1Atm
,
MagneticFieldVector
{
gCS
,
10
_uT
,
0
_T
,
0
_T
});
builder
.
setNuclearComposition
(
{{
Code
::
Nitrogen
,
Code
::
Oxygen
},
{
0.7847
f
,
1.
f
-
0.7847
f
}});
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
auto
const
*
const
universe
{
env
.
getUniverse
().
get
()};
auto
const
*
node
{
universe
->
getContainingNode
(
ref_
)};
// get the refractive index
auto
const
rIndex
{
node
->
getModelProperties
().
getRefractiveIndex
(
ref_
)};
CHECK
(
rIndex
-
n0
==
Approx
(
0
));
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment