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
d1e3b17c
Commit
d1e3b17c
authored
3 years ago
by
Fan Hu
Committed by
Maximilian Reininghaus
2 years ago
Browse files
Options
Downloads
Patches
Plain Diff
add environment example
parent
abd2af5a
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
examples/CMakeLists.txt
+2
-0
2 additions, 0 deletions
examples/CMakeLists.txt
examples/environment_example.cpp
+56
-0
56 additions, 0 deletions
examples/environment_example.cpp
with
58 additions
and
0 deletions
examples/CMakeLists.txt
+
2
−
0
View file @
d1e3b17c
...
...
@@ -64,3 +64,5 @@ CORSIKA_REGISTER_EXAMPLE (corsika RUN_OPTIONS --energy=100 --zenith=10 --nevent=
add_executable
(
mars mars.cpp
)
target_link_libraries
(
mars CORSIKA8::CORSIKA8
)
add_executable
(
environment environment.cpp
)
target_link_libraries
(
environment CORSIKA8::CORSIKA8
)
This diff is collapsed.
Click to expand it.
examples/environment_example.cpp
0 → 100644
+
56
−
0
View file @
d1e3b17c
#include
<corsika/media/Environment.hpp>
#include
<corsika/media/HomogeneousMedium.hpp>
#include
<corsika/media/IMediumModel.hpp>
#include
<corsika/media/MediumProperties.hpp>
#include
<corsika/media/MediumPropertyModel.hpp>
using
namespace
corsika
;
// Example to show how to construct an environment in CORSIKA
// MediumType is constructed via "mixin inheritance"
// Here, we construct our base class with IMediumModel and IMediumPropertyModel:
// the former allow us define a density profile and nuclear composite,
// the later is used to determine energy losses parameters.
using
IMediumType
=
IMediumPropertyModel
<
IMediumModel
>
;
using
EnvType
=
Environment
<
IMediumType
>
;
int
main
()
{
// define the environment and universe
EnvType
env
;
auto
*
universe
=
env
.
getUniverse
().
get
();
auto
const
&
rootCS
=
env
.
getCoordinateSystem
();
// create a geometry object
Point
const
center
{
rootCS
,
0
_m
,
0
_m
,
0
_m
};
auto
radius
=
1000
_m
;
auto
sphere
=
std
::
make_unique
<
Sphere
>
(
center
,
radius
);
// create node from geometry object and put it into universe
auto
node
=
std
::
make_unique
<
VolumeTreeNode
<
IMediumType
>>
(
std
::
move
(
sphere
));
universe
->
addChild
(
std
::
move
(
node
));
// set media properties to our node, say it is water
auto
nuc_comp
=
NuclearComposition
({{
Code
::
Carbon
,
Code
::
Oxygen
},
{
0.11
,
0.89
}});
auto
density
=
1
_g
/
(
1
_cm
*
1
_cm
*
1
_cm
);
auto
medium
=
std
::
make_shared
<
MediumPropertyModel
<
HomogeneousMedium
<
IMediumType
>>>
(
Medium
::
WaterLiquid
,
density
,
nuc_comp
);
node
->
setModelProperties
(
medium
);
// example to explore the node
for
(
LengthType
h
=
0
_m
;
h
<
radius
;
h
+=
100
_m
)
{
Point
const
ptest
{
rootCS
,
0
_m
,
0
_m
,
h
};
auto
rho
=
env
.
getUniverse
()
->
getContainingNode
(
ptest
)
->
getModelProperties
()
.
getMassDensity
(
ptest
);
CORSIKA_LOG_INFO
(
"radius: {:.2f} m, density: {:.2f} g/cm^3, "
,
h
/
1
_m
,
rho
/
1
_g
*
(
1
_cm
*
1
_cm
*
1
_cm
));
}
return
0
;
}
\ 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