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
02081138
Commit
02081138
authored
3 years ago
by
Nikos Karastathis
Committed by
Ralf Ulrich
3 years ago
Browse files
Options
Downloads
Patches
Plain Diff
specify environments used in unit tests
parent
0283fb7b
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!418
No set up files new
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
tests/common/SetupTestEnvironment.hpp
+34
-25
34 additions, 25 deletions
tests/common/SetupTestEnvironment.hpp
tests/common/SetupTestStack.hpp
+32
-20
32 additions, 20 deletions
tests/common/SetupTestStack.hpp
with
66 additions
and
45 deletions
tests/common/SetupTestEnvironment.hpp
+
34
−
25
View file @
02081138
...
@@ -18,43 +18,52 @@
...
@@ -18,43 +18,52 @@
#include
<limits>
#include
<limits>
namespace
corsika
::
setup
::
testing
{
namespace
corsika
{
/**
using
DummyEnvironmentInterface
=
IMediumPropertyModel
<
IMagneticFieldModel
<
IMediumModel
>>
;
using
DummyEnvironment
=
Environment
<
DummyEnvironmentInterface
>
;
namespace
setup
::
testing
{
/**
* \function setup_environment
* \function setup_environment
*
*
* standard environment for unit testing.
* standard environment for unit testing.
*
*
*/
*/
inline
std
::
tuple
<
std
::
unique_ptr
<
setup
::
Environment
>
,
CoordinateSystemPtr
const
*
,
inline
std
::
tuple
<
std
::
unique_ptr
<
Dummy
Environment
>
,
CoordinateSystemPtr
const
*
,
setup
::
Environment
::
BaseNodeType
*>
Dummy
Environment
::
BaseNodeType
*>
setup_environment
(
Code
const
vTargetCode
,
setup_environment
(
Code
const
vTargetCode
,
MagneticFluxType
const
&
BfieldZ
=
MagneticFluxType
::
zero
())
{
MagneticFluxType
const
&
BfieldZ
=
MagneticFluxType
::
zero
())
{
auto
env
=
std
::
make_unique
<
setup
::
Environment
>
();
auto
env
=
std
::
make_unique
<
Dummy
Environment
>
();
auto
&
universe
=
*
(
env
->
getUniverse
());
auto
&
universe
=
*
(
env
->
getUniverse
());
CoordinateSystemPtr
const
&
cs
=
env
->
getCoordinateSystem
();
CoordinateSystemPtr
const
&
cs
=
env
->
getCoordinateSystem
();
/**
/**
* our world is a sphere at 0,0,0 with R=infty
* our world is a sphere at 0,0,0 with R=infty
*/
*/
auto
world
=
setup
::
Environment
::
createNode
<
Sphere
>
(
Point
{
cs
,
0
_m
,
0
_m
,
0
_m
},
100
_km
);
auto
world
=
DummyEnvironment
::
createNode
<
Sphere
>
(
Point
{
cs
,
0
_m
,
0
_m
,
0
_m
},
100
_km
);
/**
/**
* construct suited environment medium model:
* construct suited environment medium model:
*/
*/
using
MyHomogeneousModel
=
MediumPropertyModel
<
using
MyHomogeneousModel
=
MediumPropertyModel
<
UniformMagneticField
<
HomogeneousMedium
<
setup
::
EnvironmentInterface
>>>
;
UniformMagneticField
<
HomogeneousMedium
<
DummyEnvironmentInterface
>>>
;
world
->
setModelProperties
<
MyHomogeneousModel
>
(
Medium
::
AirDry1Atm
,
Vector
(
cs
,
0
_T
,
0
_T
,
BfieldZ
),
1
_kg
/
(
1
_m
*
1
_m
*
1
_m
),
NuclearComposition
(
std
::
vector
<
Code
>
{
vTargetCode
},
std
::
vector
<
double
>
{
1.
}));
world
->
setModelProperties
<
MyHomogeneousModel
>
(
DummyEnvironment
::
BaseNodeType
*
nodePtr
=
world
.
get
();
Medium
::
AirDry1Atm
,
Vector
(
cs
,
0
_T
,
0
_T
,
BfieldZ
),
1
_kg
/
(
1
_m
*
1
_m
*
1
_m
),
universe
.
addChild
(
std
::
move
(
world
));
NuclearComposition
(
std
::
vector
<
Code
>
{
vTargetCode
},
std
::
vector
<
double
>
{
1.
}));
setup
::
Environment
::
BaseNodeType
*
nodePtr
=
world
.
get
(
);
return
std
::
make_tuple
(
std
::
move
(
env
),
&
cs
,
nodePtr
);
universe
.
addChild
(
std
::
move
(
world
));
}
return
std
::
make_tuple
(
std
::
move
(
env
),
&
cs
,
nodePtr
);
}
// namespace setup::testing
}
}
// namespace corsika
::setup::testing
}
// namespace corsika
This diff is collapsed.
Click to expand it.
tests/common/SetupTestStack.hpp
+
32
−
20
View file @
02081138
...
@@ -11,8 +11,13 @@
...
@@ -11,8 +11,13 @@
#include
<corsika/framework/geometry/Point.hpp>
#include
<corsika/framework/geometry/Point.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/framework/geometry/CoordinateSystem.hpp>
#include
<corsika/setup/SetupStack.hpp>
#include
<corsika/media/UniformMagneticField.hpp>
#include
<corsika/media/MediumPropertyModel.hpp>
#include
<corsika/media/HomogeneousMedium.hpp>
#include
<tests/common/SetupStack.hpp>
#include
<SetupStack.hpp>
/**
/**
* \file SetupTestStack
* \file SetupTestStack
...
@@ -20,34 +25,41 @@
...
@@ -20,34 +25,41 @@
* standard stack setup for unit tests.
* standard stack setup for unit tests.
*/
*/
namespace
corsika
::
setup
::
testing
{
namespace
corsika
{
/**
using
DummyEnvironmentInterface
=
IMediumPropertyModel
<
IMagneticFieldModel
<
IMediumModel
>>
;
using
DummyEnvironment
=
Environment
<
DummyEnvironmentInterface
>
;
namespace
setup
::
testing
{
/**
* \function setup_stack
* \function setup_stack
*
*
* standard stack setup for unit tests.
* standard stack setup for unit tests.
*
*
* \return a tuple with element 0 being a Stack object filled with
* \return a tuple with element 0 being a Stack object filled with
* one particle, and element 1 the StackView on it.
* one particle, and element 1 the StackView on it.
*/
*/
inline
std
::
tuple
<
std
::
unique_ptr
<
test
::
Stack
>
,
std
::
unique_ptr
<
test
::
StackView
>>
setup_stack
(
Code
const
vProjectileType
,
HEPEnergyType
const
vMomentum
,
DummyEnvironment
::
BaseNodeType
*
const
vNodePtr
,
CoordinateSystemPtr
const
&
cs
)
{
inline
std
::
tuple
<
std
::
unique_ptr
<
setup
::
Stack
>
,
std
::
unique_ptr
<
setup
::
StackView
>>
auto
stack
=
std
::
make_unique
<
test
::
Stack
>
();
setup_stack
(
Code
const
vProjectileType
,
HEPEnergyType
const
vMomentum
,
setup
::
Environment
::
BaseNodeType
*
const
vNodePtr
,
CoordinateSystemPtr
const
&
cs
)
{
auto
stack
=
std
::
make_unique
<
setup
::
Stack
>
();
Point
const
origin
(
cs
,
{
0
_m
,
0
_m
,
0
_m
});
MomentumVector
const
pLab
(
cs
,
{
vMomentum
,
0
_GeV
,
0
_GeV
});
HEPMassType
const
mass
=
get_mass
(
vProjectileType
);
HEPEnergyType
const
Ekin
=
sqrt
(
vMomentum
*
vMomentum
+
mass
*
mass
)
-
mass
;
Point
const
origin
(
cs
,
{
0
_m
,
0
_m
,
0
_m
});
auto
particle
=
stack
->
addParticle
(
MomentumVector
const
pLab
(
cs
,
{
vMomentum
,
0
_GeV
,
0
_GeV
});
std
::
make_tuple
(
vProjectileType
,
Ekin
,
pLab
.
normalized
(),
origin
,
0
_ns
));
HEPMassType
const
mass
=
get_mass
(
vProjectileType
);
particle
.
setNode
(
vNodePtr
);
HEPEnergyType
const
Ekin
=
sqrt
(
vMomentum
*
vMomentum
+
mass
*
mass
)
-
mass
;
return
std
::
make_tuple
(
std
::
move
(
stack
),
std
::
make_unique
<
test
::
StackView
>
(
particle
));
}
auto
particle
=
stack
->
addParticle
(
}
// namespace setup::testing
std
::
make_tuple
(
vProjectileType
,
Ekin
,
pLab
.
normalized
(),
origin
,
0
_ns
));
particle
.
setNode
(
vNodePtr
);
return
std
::
make_tuple
(
std
::
move
(
stack
),
std
::
make_unique
<
setup
::
StackView
>
(
particle
));
}
}
// namespace corsika
::setup::testing
}
// namespace corsika
\ No newline at end of file
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