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
05e2d2a7
Commit
05e2d2a7
authored
3 years ago
by
Fan Hu
Committed by
Maximilian Reininghaus
2 years ago
Browse files
Options
Downloads
Patches
Plain Diff
format and update
parent
d1e3b17c
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
examples/environment_example.cpp
+28
-21
28 additions, 21 deletions
examples/environment_example.cpp
with
28 additions
and
21 deletions
examples/environment_example.cpp
+
28
−
21
View file @
05e2d2a7
...
...
@@ -19,37 +19,44 @@ using EnvType = Environment<IMediumType>;
int
main
()
{
// define the environment and universe
EnvType
env
;
auto
*
universe
=
env
.
getUniverse
().
get
();
auto
const
&
rootCS
=
env
.
getCoordinateSystem
();
VolumeTreeNode
<
IMediumType
>*
universe
=
env
.
getUniverse
().
get
();
// create a geometry object
// create a geometry object: a sphere with radius of 1000m
CoordinateSystemPtr
const
&
rootCS
=
env
.
getCoordinateSystem
();
Point
const
center
{
rootCS
,
0
_m
,
0
_m
,
0
_m
};
auto
radius
=
1000
_m
;
LengthType
radius
=
1000
_m
;
auto
sphere
=
std
::
make_unique
<
Sphere
>
(
center
,
radius
);
// create node from geometry object
and put it into universe
// create node from geometry object
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
);
// set medium properties to our node, say it is water
auto
nuc_comp
=
NuclearComposition
({{
Code
::
Hydrogen
,
Code
::
Oxygen
},
{
0.11
,
0.89
}});
MassDensityType
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
// put our node into universe
// node: this has to be down after setting node model properties, since
// std::move will make our previous defined node, which is a unique pointer
// un-referencable in the context
universe
->
addChild
(
std
::
move
(
node
));
// example to explore the media properties of 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
));
IMediumType
const
&
media_prop_
=
env
.
getUniverse
()
->
getContainingNode
(
ptest
)
->
getModelProperties
();
MassDensityType
rho_
=
media_prop_
.
getMassDensity
(
ptest
);
NuclearComposition
nuc_comp_
=
media_prop_
.
getNuclearComposition
();
std
::
vector
<
Code
>
nucs_
=
nuc_comp_
.
getComponents
();
std
::
vector
<
double
>
fracs_
=
nuc_comp_
.
getFractions
();
CORSIKA_LOG_INFO
(
"radius: {:.2f} m, density: {:.2f} g/cm^3, nucs: ({:d}, {:d}), fracs: ({:.2f}, "
"{:.2f})"
,
h
/
1
_m
,
rho_
/
1
_g
*
(
1
_cm
*
1
_cm
*
1
_cm
),
get_PDG
(
nucs_
[
0
]),
get_PDG
(
nucs_
[
1
]),
fracs_
[
0
],
fracs_
[
1
]);
}
return
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