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
Snippets
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
Antonio Augusto Alves Junior
corsika
Commits
182a4701
Commit
182a4701
authored
5 years ago
by
ralfulrich
Browse files
Options
Downloads
Patches
Plain Diff
style guide
parent
40b888f6
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
Framework/Cascade/CMakeLists.txt
+2
-1
2 additions, 1 deletion
Framework/Cascade/CMakeLists.txt
Framework/Cascade/Cascade.h
+60
-35
60 additions, 35 deletions
Framework/Cascade/Cascade.h
Framework/Cascade/testCascade.cc
+8
-6
8 additions, 6 deletions
Framework/Cascade/testCascade.cc
with
70 additions
and
42 deletions
Framework/Cascade/CMakeLists.txt
+
2
−
1
View file @
182a4701
...
@@ -43,8 +43,9 @@ target_link_libraries (
...
@@ -43,8 +43,9 @@ target_link_libraries (
CORSIKArandom
CORSIKArandom
ProcessSibyll
ProcessSibyll
CORSIKAcascade
CORSIKAcascade
ProcessStackInspector
#
ProcessStackInspector
ProcessTrackingLine
ProcessTrackingLine
ProcessNullModel
CORSIKAstackinterface
CORSIKAstackinterface
CORSIKAprocesses
CORSIKAprocesses
CORSIKAparticles
CORSIKAparticles
...
...
This diff is collapsed.
Click to expand it.
Framework/Cascade/Cascade.h
+
60
−
35
View file @
182a4701
...
@@ -17,9 +17,19 @@
...
@@ -17,9 +17,19 @@
#include
<corsika/random/ExponentialDistribution.h>
#include
<corsika/random/ExponentialDistribution.h>
#include
<corsika/random/RNGManager.h>
#include
<corsika/random/RNGManager.h>
#include
<corsika/random/UniformRealDistribution.h>
#include
<corsika/random/UniformRealDistribution.h>
#include
<corsika/s
etup/SetupTrajectory
.h>
#include
<corsika/s
tack/SecondaryView
.h>
#include
<corsika/units/PhysicalUnits.h>
#include
<corsika/units/PhysicalUnits.h>
#include
<corsika/setup/SetupTrajectory.h>
/* see Issue 161, we need to include SetupStack only because we need
to globally define StackView. This is clearly not nice and should
be changed, when possible. It might be that StackView needs to be
templated in Cascade, but this would be even worse... so we don't
do that until it is really needed.
*/
#include
<corsika/setup/SetupStack.h>
#include
<cassert>
#include
<cassert>
#include
<cmath>
#include
<cmath>
#include
<iostream>
#include
<iostream>
...
@@ -39,23 +49,22 @@ namespace corsika::cascade {
...
@@ -39,23 +49,22 @@ namespace corsika::cascade {
* it very versatile. Via the template arguments physics models are
* it very versatile. Via the template arguments physics models are
* plugged into the cascade simulation.
* plugged into the cascade simulation.
*
*
* <b>Tracking</b> must be a class according to the
* <b>
T
Tracking</b> must be a class according to the
* TrackingInterface providing the functions:
* TrackingInterface providing the functions:
* <code>auto GetTrack(Particle const& p)</auto>,
* <code>auto GetTrack(Particle const& p)</auto>,
* with the return type <code>geometry::Trajectory<corsika::geometry::Line>
* with the return type <code>geometry::Trajectory<corsika::geometry::Line>
* </code>
* </code>
*
*
* <b>ProcessList</b> must be a ProcessSequence. *
* <b>
T
ProcessList</b> must be a ProcessSequence. *
* <b>Stack</b> is the storage object for particle data, i.e. with
* <b>Stack</b> is the storage object for particle data, i.e. with
* Particle class type <code>Stack::ParticleType</code>
* Particle class type <code>Stack::ParticleType</code>
*
*
*
*
*/
*/
template
<
typename
Tracking
,
typename
ProcessList
,
typename
Stack
>
template
<
typename
T
Tracking
,
typename
T
ProcessList
,
typename
T
Stack
>
class
Cascade
{
class
Cascade
{
using
Particle
=
typename
Stack
::
ParticleType
;
using
Particle
=
typename
T
Stack
::
ParticleType
;
using
VolumeTreeNode
=
using
VolumeTreeNode
=
std
::
remove_pointer_t
<
decltype
(((
Particle
*
)
nullptr
)
->
GetNode
())
>
;
std
::
remove_pointer_t
<
decltype
(((
Particle
*
)
nullptr
)
->
GetNode
())
>
;
using
MediumInterface
=
typename
VolumeTreeNode
::
IModelProperties
;
using
MediumInterface
=
typename
VolumeTreeNode
::
IModelProperties
;
...
@@ -68,8 +77,8 @@ namespace corsika::cascade {
...
@@ -68,8 +77,8 @@ namespace corsika::cascade {
* Cascade class cannot be default constructed, but needs a valid
* Cascade class cannot be default constructed, but needs a valid
* list of physics processes for configuration at construct time.
* list of physics processes for configuration at construct time.
*/
*/
Cascade
(
corsika
::
environment
::
Environment
<
MediumInterface
>
const
&
env
,
Tracking
&
tr
,
Cascade
(
corsika
::
environment
::
Environment
<
MediumInterface
>
const
&
env
,
T
Tracking
&
tr
,
ProcessList
&
pl
,
Stack
&
stack
)
T
ProcessList
&
pl
,
T
Stack
&
stack
)
:
fEnvironment
(
env
)
:
fEnvironment
(
env
)
,
fTracking
(
tr
)
,
fTracking
(
tr
)
,
fProcessSequence
(
pl
)
,
fProcessSequence
(
pl
)
...
@@ -125,15 +134,16 @@ namespace corsika::cascade {
...
@@ -125,15 +134,16 @@ namespace corsika::cascade {
* New particles produced in one step are subject to further
* New particles produced in one step are subject to further
* processing, e.g. thinning, etc.
* processing, e.g. thinning, etc.
*/
*/
void
Step
(
Particle
&
particle
)
{
void
Step
(
Particle
&
vParticle
)
{
using
namespace
corsika
;
using
namespace
corsika
::
units
::
si
;
using
namespace
corsika
::
units
::
si
;
// determine geometric tracking
// determine geometric tracking
auto
[
step
,
geomMaxLength
,
nextVol
]
=
fTracking
.
GetTrack
(
p
article
);
auto
[
step
,
geomMaxLength
,
nextVol
]
=
fTracking
.
GetTrack
(
vP
article
);
// determine combined total interaction length (inverse)
// determine combined total interaction length (inverse)
InverseGrammageType
const
total_inv_lambda
=
InverseGrammageType
const
total_inv_lambda
=
fProcessSequence
.
GetTotalInverseInteractionLength
(
p
article
,
step
);
fProcessSequence
.
GetTotalInverseInteractionLength
(
vP
article
,
step
);
// sample random exponential step length in grammage
// sample random exponential step length in grammage
corsika
::
random
::
ExponentialDistribution
expDist
(
1
/
total_inv_lambda
);
corsika
::
random
::
ExponentialDistribution
expDist
(
1
/
total_inv_lambda
);
...
@@ -155,12 +165,12 @@ namespace corsika::cascade {
...
@@ -155,12 +165,12 @@ namespace corsika::cascade {
next_interact
);
next_interact
);
// determine the maximum geometric step length
// determine the maximum geometric step length
LengthType
const
distance_max
=
fProcessSequence
.
MaxStepLength
(
p
article
,
step
);
LengthType
const
distance_max
=
fProcessSequence
.
MaxStepLength
(
vP
article
,
step
);
std
::
cout
<<
"distance_max="
<<
distance_max
<<
std
::
endl
;
std
::
cout
<<
"distance_max="
<<
distance_max
<<
std
::
endl
;
// determine combined total inverse decay time
// determine combined total inverse decay time
InverseTimeType
const
total_inv_lifetime
=
InverseTimeType
const
total_inv_lifetime
=
fProcessSequence
.
GetTotalInverseLifetime
(
p
article
);
fProcessSequence
.
GetTotalInverseLifetime
(
vP
article
);
// sample random exponential decay time
// sample random exponential decay time
corsika
::
random
::
ExponentialDistribution
expDistDecay
(
1
/
total_inv_lifetime
);
corsika
::
random
::
ExponentialDistribution
expDistDecay
(
1
/
total_inv_lifetime
);
...
@@ -169,9 +179,8 @@ namespace corsika::cascade {
...
@@ -169,9 +179,8 @@ namespace corsika::cascade {
<<
", next_decay="
<<
next_decay
<<
std
::
endl
;
<<
", next_decay="
<<
next_decay
<<
std
::
endl
;
// convert next_decay from time to length [m]
// convert next_decay from time to length [m]
LengthType
const
distance_decay
=
next_decay
*
particle
.
GetMomentum
().
norm
()
/
LengthType
const
distance_decay
=
next_decay
*
vParticle
.
GetMomentum
().
norm
()
/
particle
.
GetEnergy
()
*
vParticle
.
GetEnergy
()
*
units
::
constants
::
c
;
corsika
::
units
::
constants
::
c
;
// take minimum of geometry, interaction, decay for next step
// take minimum of geometry, interaction, decay for next step
auto
const
min_distance
=
auto
const
min_distance
=
...
@@ -180,52 +189,68 @@ namespace corsika::cascade {
...
@@ -180,52 +189,68 @@ namespace corsika::cascade {
std
::
cout
<<
" move particle by : "
<<
min_distance
<<
std
::
endl
;
std
::
cout
<<
" move particle by : "
<<
min_distance
<<
std
::
endl
;
// here the particle is actually moved along the trajectory to new position:
// here the particle is actually moved along the trajectory to new position:
// std::visit(
corsika::
setup::ParticleUpdate<Particle>{
p
article}, step);
// std::visit(setup::ParticleUpdate<Particle>{
vP
article}, step);
p
article
.
SetPosition
(
step
.
PositionFromArclength
(
min_distance
));
vP
article
.
SetPosition
(
step
.
PositionFromArclength
(
min_distance
));
// .... also update time, momentum, direction, ...
// .... also update time, momentum, direction, ...
vParticle
.
SetTime
(
vParticle
.
GetTime
()
+
min_distance
/
units
::
constants
::
c
);
step
.
LimitEndTo
(
min_distance
);
step
.
LimitEndTo
(
min_distance
);
// apply all continuous processes on particle + track
// apply all continuous processes on particle + track
corsika
::
process
::
EProcessReturn
status
=
process
::
EProcessReturn
status
=
fProcessSequence
.
DoContinuous
(
vParticle
,
step
);
fProcessSequence
.
DoContinuous
(
particle
,
step
,
fStack
);
if
(
status
==
corsika
::
process
::
EProcessReturn
::
eParticleAbsorbed
)
{
if
(
status
==
process
::
EProcessReturn
::
eParticleAbsorbed
)
{
std
::
cout
<<
"Cascade: delete absorbed particle "
<<
p
article
.
GetPID
()
<<
" "
std
::
cout
<<
"Cascade: delete absorbed particle "
<<
vP
article
.
GetPID
()
<<
" "
<<
p
article
.
GetEnergy
()
/
1
_GeV
<<
"GeV"
<<
std
::
endl
;
<<
vP
article
.
GetEnergy
()
/
1
_GeV
<<
"GeV"
<<
std
::
endl
;
p
article
.
Delete
();
vP
article
.
Delete
();
return
;
return
;
}
}
std
::
cout
<<
"sth. happening before geometric limit ? "
std
::
cout
<<
"sth. happening before geometric limit ? "
<<
((
min_distance
<
geomMaxLength
)
?
"yes"
:
"no"
)
<<
std
::
endl
;
<<
((
min_distance
<
geomMaxLength
)
?
"yes"
:
"no"
)
<<
std
::
endl
;
/*
Create SecondaryView object on Stack. The data container
remains untouched and identical, and 'projectil' is identical
to 'vParticle' above this line. However,
projectil.AddSecondaries populate the SecondaryView, which can
then be used afterwards for further processing. Thus: it is
important to use projectle (and not vParticle) for Interaction,
and Decay!
*/
setup
::
StackView
secondaries
(
vParticle
);
[[
maybe_unused
]]
auto
projectile
=
secondaries
.
GetProjectile
();
if
(
min_distance
<
distance_max
)
{
// interaction to happen within geometric limit
// check whether decay or interaction limits this step
if
(
min_distance
<
geomMaxLength
)
{
// interaction to happen within geometric limit
if
(
min_distance
<
geomMaxLength
)
{
// interaction to happen within geometric limit
if
(
min_distance
==
distance_interact
)
{
if
(
min_distance
==
distance_interact
)
{
std
::
cout
<<
"collide"
<<
std
::
endl
;
std
::
cout
<<
"collide"
<<
std
::
endl
;
InverseGrammageType
const
actual_inv_length
=
InverseGrammageType
const
actual_inv_length
=
fProcessSequence
.
GetTotalInverseInteractionLength
(
p
article
,
step
);
fProcessSequence
.
GetTotalInverseInteractionLength
(
vP
article
,
step
);
corsika
::
random
::
UniformRealDistribution
<
InverseGrammageType
>
uniDist
(
random
::
UniformRealDistribution
<
InverseGrammageType
>
uniDist
(
actual_inv_length
);
actual_inv_length
);
const
auto
sample_process
=
uniDist
(
fRNG
);
const
auto
sample_process
=
uniDist
(
fRNG
);
InverseGrammageType
inv_lambda_count
=
0.
*
meter
*
meter
/
gram
;
InverseGrammageType
inv_lambda_count
=
0.
*
meter
*
meter
/
gram
;
fProcessSequence
.
SelectInteraction
(
p
article
,
step
,
fStack
,
sample_process
,
fProcessSequence
.
SelectInteraction
(
vP
article
,
projectile
,
step
,
sample_process
,
inv_lambda_count
);
inv_lambda_count
);
}
else
if
(
min_distance
==
distance_decay
)
{
}
else
if
(
min_distance
==
distance_decay
)
{
std
::
cout
<<
"decay"
<<
std
::
endl
;
std
::
cout
<<
"decay"
<<
std
::
endl
;
InverseTimeType
const
actual_decay_time
=
InverseTimeType
const
actual_decay_time
=
fProcessSequence
.
GetTotalInverseLifetime
(
p
article
);
fProcessSequence
.
GetTotalInverseLifetime
(
vP
article
);
corsika
::
random
::
UniformRealDistribution
<
InverseTimeType
>
uniDist
(
random
::
UniformRealDistribution
<
InverseTimeType
>
uniDist
(
actual_decay_time
);
actual_decay_time
);
const
auto
sample_process
=
uniDist
(
fRNG
);
const
auto
sample_process
=
uniDist
(
fRNG
);
InverseTimeType
inv_decay_count
=
0
/
second
;
InverseTimeType
inv_decay_count
=
0
/
second
;
fProcessSequence
.
SelectDecay
(
p
article
,
fStack
,
sample_process
,
inv_decay_count
);
fProcessSequence
.
SelectDecay
(
vP
article
,
projectile
,
sample_process
,
inv_decay_count
);
}
else
{
// step-length limitation within volume
}
else
{
// step-length limitation within volume
std
::
cout
<<
"step-length limitation"
<<
std
::
endl
;
std
::
cout
<<
"step-length limitation"
<<
std
::
endl
;
}
}
fProcessSequence
.
DoSecondaries
(
secondaries
);
vParticle
.
Delete
();
// last thing in Step function
auto
const
assertion
=
[
&
]
{
auto
const
assertion
=
[
&
]
{
auto
const
*
numericalNodeAfterStep
=
auto
const
*
numericalNodeAfterStep
=
...
@@ -244,9 +269,9 @@ namespace corsika::cascade {
...
@@ -244,9 +269,9 @@ namespace corsika::cascade {
private
:
private
:
corsika
::
environment
::
Environment
<
MediumInterface
>
const
&
fEnvironment
;
corsika
::
environment
::
Environment
<
MediumInterface
>
const
&
fEnvironment
;
Tracking
&
fTracking
;
T
Tracking
&
fTracking
;
ProcessList
&
fProcessSequence
;
T
ProcessList
&
fProcessSequence
;
Stack
&
fStack
;
T
Stack
&
fStack
;
corsika
::
random
::
RNG
&
fRNG
=
corsika
::
random
::
RNG
&
fRNG
=
corsika
::
random
::
RNGManager
::
GetInstance
().
GetRandomStream
(
"cascade"
);
corsika
::
random
::
RNGManager
::
GetInstance
().
GetRandomStream
(
"cascade"
);
};
// namespace corsika::cascade
};
// namespace corsika::cascade
...
...
This diff is collapsed.
Click to expand it.
Framework/Cascade/testCascade.cc
+
8
−
6
View file @
182a4701
...
@@ -16,6 +16,7 @@
...
@@ -16,6 +16,7 @@
#include
<corsika/cascade/Cascade.h>
#include
<corsika/cascade/Cascade.h>
#include
<corsika/process/ProcessSequence.h>
#include
<corsika/process/ProcessSequence.h>
#include
<corsika/process/null_model/NullModel.h>
#include
<corsika/process/stack_inspector/StackInspector.h>
#include
<corsika/process/stack_inspector/StackInspector.h>
#include
<corsika/process/tracking_line/TrackingLine.h>
#include
<corsika/process/tracking_line/TrackingLine.h>
...
@@ -74,13 +75,13 @@ public:
...
@@ -74,13 +75,13 @@ public:
ProcessSplit
(
HEPEnergyType
e
)
ProcessSplit
(
HEPEnergyType
e
)
:
fEcrit
(
e
)
{}
:
fEcrit
(
e
)
{}
template
<
typename
Particle
,
typename
T
>
template
<
typename
Particle
,
typename
T
rack
>
LengthType
MaxStepLength
(
Particle
&
,
T
&
)
const
{
LengthType
MaxStepLength
(
Particle
&
,
T
rack
&
)
const
{
return
1
_m
;
return
1
_m
;
}
}
template
<
typename
Particle
,
typename
T
,
typename
St
ack
>
template
<
typename
Particle
,
typename
T
r
ack
>
EProcessReturn
DoContinuous
(
Particle
&
p
,
T
&
,
St
ack
&
)
{
EProcessReturn
DoContinuous
(
Particle
&
p
,
T
r
ack
&
)
{
fCalls
++
;
fCalls
++
;
HEPEnergyType
E
=
p
.
GetEnergy
();
HEPEnergyType
E
=
p
.
GetEnergy
();
if
(
E
<
fEcrit
)
{
if
(
E
<
fEcrit
)
{
...
@@ -114,11 +115,12 @@ TEST_CASE("Cascade", "[Cascade]") {
...
@@ -114,11 +115,12 @@ TEST_CASE("Cascade", "[Cascade]") {
auto
env
=
MakeDummyEnv
();
auto
env
=
MakeDummyEnv
();
tracking_line
::
TrackingLine
tracking
;
tracking_line
::
TrackingLine
tracking
;
stack_inspector
::
StackInspector
<
TestCascadeStack
>
p0
(
true
);
stack_inspector
::
StackInspector
<
TestCascadeStack
>
stackInspect
(
true
);
null_model
::
NullModel
nullModel
;
const
HEPEnergyType
Ecrit
=
85
_MeV
;
const
HEPEnergyType
Ecrit
=
85
_MeV
;
ProcessSplit
p1
(
Ecrit
);
ProcessSplit
p1
(
Ecrit
);
auto
sequence
=
p0
<<
p1
;
auto
sequence
=
nullModel
/* << stackInspect*/
<<
p1
;
TestCascadeStack
stack
;
TestCascadeStack
stack
;
cascade
::
Cascade
EAS
(
env
,
tracking
,
sequence
,
stack
);
cascade
::
Cascade
EAS
(
env
,
tracking
,
sequence
,
stack
);
...
...
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