IAP GITLAB
Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
C
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
Package Registry
Model registry
Operate
Environments
Terraform modules
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
Pranav Sampathkumar
corsika
Commits
c35fcc85
Commit
c35fcc85
authored
3 years ago
by
Nikos Karastathis
Committed by
Ralf Ulrich
3 years ago
Browse files
Options
Downloads
Patches
Plain Diff
some tests for new getTime() method for start and end of track
parent
79c21d48
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
tests/framework/testGeometry.cpp
+40
-0
40 additions, 0 deletions
tests/framework/testGeometry.cpp
with
40 additions
and
0 deletions
tests/framework/testGeometry.cpp
+
40
−
0
View file @
c35fcc85
...
...
@@ -21,6 +21,8 @@
#include
<corsika/framework/geometry/Sphere.hpp>
#include
<corsika/framework/geometry/StraightTrajectory.hpp>
#include
<corsika/setup/SetupStack.hpp>
#include
<PhysicalUnitsCatch2.hpp>
// namespace corsike::testing
using
namespace
corsika
;
...
...
@@ -331,6 +333,21 @@ TEST_CASE("Geometry Box") {
TEST_CASE
(
"Geometry Trajectories"
)
{
CoordinateSystemPtr
rootCS
=
get_root_CoordinateSystem
();
Point
r0
(
rootCS
,
{
0
_m
,
0
_m
,
0
_m
});
// Create a particle and and a stack so we can test .getTime() method
const
Code
particle
{
Code
::
Electron
};
setup
::
Stack
stack
;
// the mass of the particle
const
auto
pmass
{
get_mass
(
particle
)};
// set an arbitrary energy value
const
HEPEnergyType
E0
{
1
_TeV
};
// compute the corresponding momentum
const
HEPMomentumType
P0
{
sqrt
(
E0
*
E0
-
pmass
*
pmass
)};
// create the momentum vector
const
auto
plab
{
MomentumVector
(
rootCS
,
{
0
_GeV
,
0
_GeV
,
P0
})};
// create an arbitrary location of the particle
const
Point
pos
(
rootCS
,
50
_m
,
10
_m
,
80
_m
);
// add it finally to the stack
auto
const
particle1
{
stack
.
addParticle
(
std
::
make_tuple
(
particle
,
plab
,
pos
,
0
_ns
))};
SECTION
(
"Line"
)
{
SpeedType
const
V0
=
3
_m
/
second
;
...
...
@@ -357,6 +374,8 @@ TEST_CASE("Geometry Trajectories") {
auto
const
t
=
1
_s
;
StraightTrajectory
base
(
line
,
t
);
CHECK
(
line
.
getPosition
(
t
).
getCoordinates
()
==
base
.
getPosition
(
1.
).
getCoordinates
());
// test the getTime() method for straight trajectory
CHECK
(
base
.
getTime
(
particle1
,
1
)
/
1
_s
==
Approx
(
1
));
CHECK
((
base
.
getDirection
(
0
).
getComponents
(
rootCS
)
-
QuantityVector
<
dimensionless_d
>
{
1
,
0
,
0
})
...
...
@@ -375,6 +394,8 @@ TEST_CASE("Geometry Trajectories") {
std
::
numeric_limits
<
TimeType
::
value_type
>::
infinity
()
*
1
_s
);
base2
.
setDuration
(
10
_s
);
CHECK
(
base2
.
getDuration
()
/
1
_s
==
Approx
(
10
));
// test the getTime() method for straight trajectory
CHECK
(
base2
.
getTime
(
particle1
,
0
)
/
1
_s
==
Approx
(
0
));
base2
.
setLength
(
1.3
_m
);
CHECK
(
base2
.
getDuration
()
*
V0
/
meter
==
Approx
(
1.3
));
...
...
@@ -406,6 +427,25 @@ TEST_CASE("Geometry Trajectories") {
.
getNorm
()
.
magnitude
()
==
Approx
(
0
).
margin
(
absMargin
));
}
SECTION
(
"LeapFrog Trajectory"
)
{
// Create a velocity Vector
VelocityVector
v0
(
rootCS
,
{
5e+2
_m
/
second
,
5e+2
_m
/
second
,
5e+2
_m
/
second
});
// Create a magnetic filed Vector
Vector
B0
(
rootCS
,
5
_T
,
5
_T
,
5
_T
);
// provide a k constant and a random time for the LeapFrog Trajectory
auto
const
k
{
1
_m
*
((
1
_m
)
/
((
1
_s
*
1
_s
)
*
1
_V
))};
auto
const
t
=
1e-12
_s
;
// construct a LeapFrog Trajectory
LeapFrogTrajectory
base
(
pos
,
v0
,
B0
,
k
,
t
);
// test the getTime() method for trajectories
CHECK
(
(
base
.
getTime
(
particle1
,
1
)
-
t
)
/
1
_s
==
0
);
CHECK
(
base
.
getTime
(
particle1
,
0
)
/
1
_s
==
Approx
(
0
)
);
CHECK
(
(
base
.
getTime
(
particle1
,
0
)
+
t
)
/
1
_s
==
Approx
(
1e-12
)
);
}
}
TEST_CASE
(
"Distance between points"
)
{
...
...
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