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
61b64724
Commit
61b64724
authored
3 years ago
by
Nikos Karastathis
Browse files
Options
Downloads
Patches
Plain Diff
add a few more unit tests in antennas
parent
dbc504fd
No related branches found
No related tags found
1 merge request
!329
Radio interface
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
tests/modules/testRadio.cpp
+118
-103
118 additions, 103 deletions
tests/modules/testRadio.cpp
with
118 additions
and
103 deletions
tests/modules/testRadio.cpp
+
118
−
103
View file @
61b64724
...
...
@@ -257,113 +257,128 @@ TEST_CASE("Radio", "[processes]") {
}
// END: SECTION("ZHS process")
SECTION
(
"TimeDomainAntenna"
)
{
// create an environment so we can get a coordinate system
using
EnvType
=
Environment
<
IRefractiveIndexModel
<
IMediumModel
>>
;
EnvType
env6
;
using
UniRIndex
=
UniformRefractiveIndex
<
HomogeneousMedium
<
IRefractiveIndexModel
<
IMediumModel
>>>
;
// the antenna location
const
auto
point1
{
Point
(
env6
.
getCoordinateSystem
(),
1
_m
,
2
_m
,
3
_m
)};
const
auto
point2
{
Point
(
env6
.
getCoordinateSystem
(),
4
_m
,
5
_m
,
6
_m
)};
// get a coordinate system
const
CoordinateSystemPtr
rootCS6
=
env6
.
getCoordinateSystem
();
auto
Medium6
=
EnvType
::
createNode
<
Sphere
>
(
Point
{
rootCS6
,
0
_m
,
0
_m
,
0
_m
},
1
_km
*
std
::
numeric_limits
<
double
>::
infinity
());
auto
const
props6
=
Medium6
->
setModelProperties
<
UniRIndex
>
(
1
,
1
_kg
/
(
1
_m
*
1
_m
*
1
_m
),
NuclearComposition
({
Code
::
Nitrogen
},
{
1.
}));
env6
.
getUniverse
()
->
addChild
(
std
::
move
(
Medium6
));
// create times for the antenna
const
TimeType
t1
{
10
_s
};
const
TimeType
t2
{
10
_s
};
const
InverseTimeType
t3
{
1
/
1
_s
};
const
TimeType
t4
{
11
_s
};
// check that I can create an antenna at (1, 2, 3)
TimeDomainAntenna
ant1
(
"antenna_name"
,
point1
,
t1
,
t2
,
t3
,
t1
);
TimeDomainAntenna
ant2
(
"antenna_name2"
,
point2
,
t4
,
t2
,
t3
,
t4
);
// assert that the antenna name is correct
REQUIRE
(
ant1
.
getName
()
==
"antenna_name"
);
REQUIRE
(
ant2
.
getName
()
==
"antenna_name2"
);
// and check that the antenna is at the right location
REQUIRE
((
ant1
.
getLocation
()
-
point1
).
getNorm
()
<
1e-12
*
1
_m
);
REQUIRE
((
ant2
.
getLocation
()
-
point2
).
getNorm
()
<
1e-12
*
1
_m
);
}
// END: TEST_CASE("Radio", "[processes]")
// construct a radio detector instance to store our antennas
AntennaCollection
<
TimeDomainAntenna
>
detector
;
TEST_CASE
(
"Antennas"
)
{
// add this antenna to the process
detector
.
addAntenna
(
ant1
);
detector
.
addAntenna
(
ant2
);
CHECK
(
detector
.
size
()
==
2
);
SECTION
(
"TimeDomainAntenna"
)
{
// get a unit vector
Vector
<
dimensionless_d
>
v1
(
rootCS6
,
{
0
,
0
,
1
});
Vector
<
ElectricFieldType
::
dimension_type
>
v11
(
rootCS6
,
{
10
_V
/
1
_m
,
10
_V
/
1
_m
,
10
_V
/
1
_m
});
Vector
<
dimensionless_d
>
v2
(
rootCS6
,
{
0
,
1
,
0
});
Vector
<
ElectricFieldType
::
dimension_type
>
v22
(
rootCS6
,
{
20
_V
/
1
_m
,
20
_V
/
1
_m
,
20
_V
/
1
_m
});
// use receive methods
ant1
.
receive
(
15
_s
,
v1
,
v11
);
ant2
.
receive
(
16
_s
,
v2
,
v22
);
// use getWaveform() methods
auto
[
tx
,
Ex
]
=
ant1
.
getWaveformX
();
CHECK
(
Ex
[
5
]
-
10
==
0
);
CHECK
(
tx
[
5
]
-
5
*
1
_s
/
1
_ns
==
Approx
(
0.0
));
auto
[
ty
,
Ey
]
=
ant1
.
getWaveformY
();
CHECK
(
Ey
[
5
]
-
10
==
0
);
auto
[
tz
,
Ez
]
=
ant1
.
getWaveformZ
();
CHECK
(
Ez
[
5
]
-
10
==
0
);
CHECK
(
tx
[
5
]
-
ty
[
5
]
==
0
);
CHECK
(
ty
[
5
]
-
tz
[
5
]
==
0
);
auto
[
tx2
,
Ex2
]
=
ant2
.
getWaveformX
();
CHECK
(
Ex2
[
5
]
-
20
==
0
);
auto
[
ty2
,
Ey2
]
=
ant2
.
getWaveformY
();
CHECK
(
Ey2
[
5
]
-
20
==
0
);
auto
[
tz2
,
Ez2
]
=
ant2
.
getWaveformZ
();
CHECK
(
Ez2
[
5
]
-
20
==
0
);
// the following creates a star-shaped pattern of antennas in the ground
AntennaCollection
<
TimeDomainAntenna
>
detector__
;
const
auto
point11
{
Point
(
env6
.
getCoordinateSystem
(),
1000
_m
,
20
_m
,
30
_m
)};
const
TimeType
t2222
{
1e-6
_s
};
const
InverseTimeType
t3333
{
1e+9
_Hz
};
for
(
auto
radius_
=
100
_m
;
radius_
<=
200
_m
;
radius_
+=
100
_m
)
{
for
(
auto
phi_
=
0
;
phi_
<=
315
;
phi_
+=
45
)
{
auto
phiRad_
=
phi_
/
180.
*
M_PI
;
auto
const
point_
{
Point
(
env6
.
getCoordinateSystem
(),
radius_
*
cos
(
phiRad_
),
radius_
*
sin
(
phiRad_
),
0
_m
)};
auto
time__
{(
point11
-
point_
).
getNorm
()
/
constants
::
c
};
const
int
rr_
=
static_cast
<
int
>
(
radius_
/
1
_m
);
std
::
string
var_
=
"antenna_R="
+
std
::
to_string
(
rr_
)
+
"_m-Phi="
+
std
::
to_string
(
phi_
)
+
"degrees"
;
TimeDomainAntenna
ant111
(
var_
,
point_
,
time__
,
t2222
,
t3333
,
time__
);
detector__
.
addAntenna
(
ant111
);
}
}
// create an environment so we can get a coordinate system
using
EnvType
=
Environment
<
IRefractiveIndexModel
<
IMediumModel
>>
;
EnvType
env6
;
// this prints out the antenna names and locations
for
(
auto
const
antenna
:
detector__
.
getAntennas
())
{
CORSIKA_LOG_DEBUG
(
"Antenna name: {} "
,
antenna
.
getName
());
CORSIKA_LOG_DEBUG
(
"Antenna location: {} "
,
antenna
.
getLocation
());
}
using
UniRIndex
=
UniformRefractiveIndex
<
HomogeneousMedium
<
IRefractiveIndexModel
<
IMediumModel
>>>
;
}
// END: SECTION("TimeDomainAntenna")
// the antenna location
const
auto
point1
{
Point
(
env6
.
getCoordinateSystem
(),
1
_m
,
2
_m
,
3
_m
)};
const
auto
point2
{
Point
(
env6
.
getCoordinateSystem
(),
4
_m
,
5
_m
,
6
_m
)};
// get a coordinate system
const
CoordinateSystemPtr
rootCS6
=
env6
.
getCoordinateSystem
();
auto
Medium6
=
EnvType
::
createNode
<
Sphere
>
(
Point
{
rootCS6
,
0
_m
,
0
_m
,
0
_m
},
1
_km
*
std
::
numeric_limits
<
double
>::
infinity
());
auto
const
props6
=
Medium6
->
setModelProperties
<
UniRIndex
>
(
1
,
1
_kg
/
(
1
_m
*
1
_m
*
1
_m
),
NuclearComposition
({
Code
::
Nitrogen
},
{
1.
}));
env6
.
getUniverse
()
->
addChild
(
std
::
move
(
Medium6
));
// create times for the antenna
const
TimeType
t1
{
10
_s
};
const
TimeType
t2
{
10
_s
};
const
InverseTimeType
t3
{
1
/
1
_s
};
const
TimeType
t4
{
11
_s
};
// check that I can create an antenna at (1, 2, 3)
TimeDomainAntenna
ant1
(
"antenna_name"
,
point1
,
t1
,
t2
,
t3
,
t1
);
TimeDomainAntenna
ant2
(
"antenna_name2"
,
point2
,
t4
,
t2
,
t3
,
t4
);
// assert that the antenna name is correct
REQUIRE
(
ant1
.
getName
()
==
"antenna_name"
);
REQUIRE
(
ant2
.
getName
()
==
"antenna_name2"
);
// and check that the antenna is at the right location
REQUIRE
((
ant1
.
getLocation
()
-
point1
).
getNorm
()
<
1e-12
*
1
_m
);
REQUIRE
((
ant2
.
getLocation
()
-
point2
).
getNorm
()
<
1e-12
*
1
_m
);
// construct a radio detector instance to store our antennas
AntennaCollection
<
TimeDomainAntenna
>
detector
;
// add this antenna to the process
detector
.
addAntenna
(
ant1
);
detector
.
addAntenna
(
ant2
);
CHECK
(
detector
.
size
()
==
2
);
// get a unit vector
Vector
<
dimensionless_d
>
v1
(
rootCS6
,
{
0
,
0
,
1
});
Vector
<
ElectricFieldType
::
dimension_type
>
v11
(
rootCS6
,
{
10
_V
/
1
_m
,
10
_V
/
1
_m
,
10
_V
/
1
_m
});
Vector
<
dimensionless_d
>
v2
(
rootCS6
,
{
0
,
1
,
0
});
Vector
<
ElectricFieldType
::
dimension_type
>
v22
(
rootCS6
,
{
20
_V
/
1
_m
,
20
_V
/
1
_m
,
20
_V
/
1
_m
});
// use receive methods
ant1
.
receive
(
15
_s
,
v1
,
v11
);
ant2
.
receive
(
16
_s
,
v2
,
v22
);
// use getWaveform() methods
auto
[
tx
,
Ex
]
=
ant1
.
getWaveformX
();
CHECK
(
Ex
[
5
]
-
10
==
0
);
CHECK
(
tx
[
5
]
-
5
*
1
_s
/
1
_ns
==
Approx
(
0.0
));
auto
[
ty
,
Ey
]
=
ant1
.
getWaveformY
();
CHECK
(
Ey
[
5
]
-
10
==
0
);
auto
[
tz
,
Ez
]
=
ant1
.
getWaveformZ
();
CHECK
(
Ez
[
5
]
-
10
==
0
);
CHECK
(
tx
[
5
]
-
ty
[
5
]
==
0
);
CHECK
(
ty
[
5
]
-
tz
[
5
]
==
0
);
auto
[
tx2
,
Ex2
]
=
ant2
.
getWaveformX
();
CHECK
(
Ex2
[
5
]
-
20
==
0
);
auto
[
ty2
,
Ey2
]
=
ant2
.
getWaveformY
();
CHECK
(
Ey2
[
5
]
-
20
==
0
);
auto
[
tz2
,
Ez2
]
=
ant2
.
getWaveformZ
();
CHECK
(
Ez2
[
5
]
-
20
==
0
);
// the following creates a star-shaped pattern of antennas in the ground
AntennaCollection
<
TimeDomainAntenna
>
detector__
;
const
auto
point11
{
Point
(
env6
.
getCoordinateSystem
(),
1000
_m
,
20
_m
,
30
_m
)};
const
TimeType
t2222
{
1e-6
_s
};
const
InverseTimeType
t3333
{
1e+9
_Hz
};
std
::
vector
<
std
::
string
>
antenna_names
;
std
::
vector
<
Point
>
antenna_locations
;
for
(
auto
radius_
=
100
_m
;
radius_
<=
200
_m
;
radius_
+=
100
_m
)
{
for
(
auto
phi_
=
0
;
phi_
<=
315
;
phi_
+=
45
)
{
auto
phiRad_
=
phi_
/
180.
*
M_PI
;
auto
const
point_
{
Point
(
env6
.
getCoordinateSystem
(),
radius_
*
cos
(
phiRad_
),
radius_
*
sin
(
phiRad_
),
0
_m
)};
antenna_locations
.
push_back
(
point_
);
auto
time__
{(
point11
-
point_
).
getNorm
()
/
constants
::
c
};
const
int
rr_
=
static_cast
<
int
>
(
radius_
/
1
_m
);
std
::
string
var_
=
"antenna_R="
+
std
::
to_string
(
rr_
)
+
"_m-Phi="
+
std
::
to_string
(
phi_
)
+
"degrees"
;
antenna_names
.
push_back
(
var_
);
TimeDomainAntenna
ant111
(
var_
,
point_
,
time__
,
t2222
,
t3333
,
time__
);
detector__
.
addAntenna
(
ant111
);
}
}
CHECK
(
detector__
.
getAntennas
().
size
()
==
16
);
int
i
=
0
;
// this prints out the antenna names and locations
for
(
auto
const
antenna
:
detector__
.
getAntennas
())
{
CHECK
(
antenna
.
getName
()
==
antenna_names
[
i
]);
CHECK
(
distance
(
antenna
.
getLocation
(),
antenna_locations
[
i
])
/
1
_m
==
0
);
i
++
;
}
}
// END: SECTION("TimeDomainAntenna")
}
// END: TEST_CASE("Antennas")
TEST_CASE
(
"Propagators"
)
{
SECTION
(
"Simple Propagator w/ Uniform Refractive Index"
)
{
...
...
@@ -656,4 +671,4 @@ TEST_CASE("Radio", "[processes]") {
}
// END: SECTION("Straight Propagator w/ Exponential Refractive Index")
}
// END: TEST_CASE("
Radio", "[processes]
")
}
// END: TEST_CASE("
Propagators
")
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