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
954acac1
Commit
954acac1
authored
5 years ago
by
Maximilian Reininghaus
Browse files
Options
Downloads
Patches
Plain Diff
restructured test
parent
76ebfb48
No related branches found
No related tags found
1 merge request
!100
Resolve "Low energy hadronic interactions: UrQMD interface"
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
Processes/UrQMD/UrQMD.cc
+7
-8
7 additions, 8 deletions
Processes/UrQMD/UrQMD.cc
Processes/UrQMD/UrQMD.h
+1
-2
1 addition, 2 deletions
Processes/UrQMD/UrQMD.h
Processes/UrQMD/testUrQMD.cc
+75
-45
75 additions, 45 deletions
Processes/UrQMD/testUrQMD.cc
with
83 additions
and
55 deletions
Processes/UrQMD/UrQMD.cc
+
7
−
8
View file @
954acac1
...
...
@@ -25,22 +25,22 @@ template <typename TParticle> // need template here, as this is called both with
// SetupParticle as well as SetupProjectile
CrossSectionType
UrQMD
::
GetCrossSection
(
TParticle
const
&
vProjectile
,
corsika
::
particles
::
Code
vTargetCode
,
corsika
::
units
::
si
::
HEPEnergyType
vProjectileEnergyLab
)
corsika
::
particles
::
Code
vTargetCode
)
const
{
using
namespace
units
::
si
;
// TODO: energy cuts, return 0 for non-hadrons
auto
const
projectileCode
=
vProjectile
.
GetPID
();
auto
const
projectileEnergyLab
=
vProjectile
.
GetEnergy
();
// the following is a translation of ptsigtot() into C++
if
(
projectileCode
!=
particles
::
Code
::
Nucleus
&&
!
IsNucleus
(
vTargetCode
))
{
// both particles are "special"
auto
const
mProj
=
particles
::
GetMass
(
projectileCode
);
auto
const
mTar
=
particles
::
GetMass
(
vTargetCode
);
double
sqrtS
=
sqrt
(
detail
::
static_pow
<
2
>
(
mProj
)
+
detail
::
static_pow
<
2
>
(
mTar
)
+
2
*
vP
rojectileEnergyLab
*
mTar
)
*
double
sqrtS
=
sqrt
(
units
::
si
::
detail
::
static_pow
<
2
>
(
mProj
)
+
units
::
si
::
detail
::
static_pow
<
2
>
(
mTar
)
+
2
*
p
rojectileEnergyLab
*
mTar
)
*
(
1
/
1
_GeV
);
// we must set some UrQMD globals first...
...
...
@@ -61,7 +61,7 @@ template <typename TParticle> // need template here, as this is called both with
int
const
At
=
IsNucleus
(
vTargetCode
)
?
particles
::
GetNucleusA
(
vTargetCode
)
:
1
;
double
const
maxImpact
=
nucrad_
(
Ap
)
+
nucrad_
(
At
)
+
2
*
options_
.
CTParam
[
30
-
1
];
return
10
_mb
*
M_PI
*
detail
::
static_pow
<
2
>
(
maxImpact
);
return
10
_mb
*
M_PI
*
units
::
si
::
detail
::
static_pow
<
2
>
(
maxImpact
);
// is a constant cross-section really reasonable?
}
}
...
...
@@ -72,8 +72,7 @@ GrammageType UrQMD::GetInteractionLength(SetupParticle& vParticle, SetupTrack&)
using
namespace
std
::
placeholders
;
CrossSectionType
const
weightedProdCrossSection
=
mediumComposition
.
WeightedSum
(
std
::
bind
(
&
UrQMD
::
GetCrossSection
<
decltype
(
vParticle
)
>
,
this
,
vParticle
,
_1
,
vParticle
.
GetEnergy
()));
std
::
bind
(
&
UrQMD
::
GetCrossSection
<
decltype
(
vParticle
)
>
,
this
,
vParticle
,
_1
));
return
mediumComposition
.
GetAverageMassNumber
()
*
units
::
constants
::
u
/
weightedProdCrossSection
;
...
...
@@ -97,7 +96,7 @@ corsika::process::EProcessReturn UrQMD::DoInteraction(SetupProjectile& vProjecti
crossSections
.
reserve
(
components
.
size
());
for
(
auto
const
c
:
components
)
{
crossSections
.
push_back
(
GetCrossSection
(
vProjectile
,
c
,
projectileEnergyLab
));
crossSections
.
push_back
(
GetCrossSection
(
vProjectile
,
c
));
}
return
crossSections
;
...
...
This diff is collapsed.
Click to expand it.
Processes/UrQMD/UrQMD.h
+
1
−
2
View file @
954acac1
...
...
@@ -20,8 +20,7 @@ namespace corsika::process::UrQMD {
template
<
typename
TParticle
>
corsika
::
units
::
si
::
CrossSectionType
GetCrossSection
(
TParticle
const
&
,
corsika
::
particles
::
Code
,
corsika
::
units
::
si
::
HEPEnergyType
)
const
;
TParticle
const
&
,
corsika
::
particles
::
Code
)
const
;
corsika
::
process
::
EProcessReturn
DoInteraction
(
corsika
::
setup
::
StackView
::
StackIterator
&
);
...
...
This diff is collapsed.
Click to expand it.
Processes/UrQMD/testUrQMD.cc
+
75
−
45
View file @
954acac1
...
...
@@ -28,6 +28,8 @@
#include
<corsika/environment/HomogeneousMedium.h>
#include
<corsika/environment/NuclearComposition.h>
#include
<tuple>
#define CATCH_CONFIG_MAIN // This tells Catch to provide a main() - only do this in one
// cpp file
#include
<catch2/catch.hpp>
...
...
@@ -52,15 +54,12 @@ auto sumCharge(TStack& stack) {
return
totalCharge
;
}
TEST_CASE
(
"UrQMD"
)
{
feenableexcept
(
FE_INVALID
);
corsika
::
random
::
RNGManager
::
GetInstance
().
RegisterRandomStream
(
"UrQMD"
);
UrQMD
urqmd
;
// setup environment, geometry
environment
::
Environment
<
environment
::
IMediumModel
>
env
;
auto
&
universe
=
*
(
env
.
GetUniverse
());
const
geometry
::
CoordinateSystem
&
cs
=
env
.
GetCoordinateSystem
();
auto
setupEnvironment
(
particles
::
Code
vTargetCode
)
{
// setup environment, geometry
auto
env
=
std
::
make_unique
<
environment
::
Environment
<
environment
::
IMediumModel
>>
();
auto
&
universe
=
*
(
env
->
GetUniverse
());
const
geometry
::
CoordinateSystem
&
cs
=
env
->
GetCoordinateSystem
();
auto
theMedium
=
environment
::
Environment
<
environment
::
IMediumModel
>::
CreateNode
<
geometry
::
Sphere
>
(
...
...
@@ -71,59 +70,90 @@ TEST_CASE("UrQMD") {
theMedium
->
SetModelProperties
<
MyHomogeneousModel
>
(
1
_kg
/
(
1
_m
*
1
_m
*
1
_m
),
environment
::
NuclearComposition
(
std
::
vector
<
particles
::
Code
>
{
particles
::
Code
::
Oxygen
},
std
::
vector
<
float
>
{
1.
}));
std
::
vector
<
particles
::
Code
>
{
vTargetCode
},
std
::
vector
<
float
>
{
1.
}));
auto
const
*
nodePtr
=
theMedium
.
get
();
universe
.
AddChild
(
std
::
move
(
theMedium
));
return
std
::
make_tuple
(
std
::
move
(
env
),
&
cs
,
nodePtr
);
}
geometry
::
Point
const
origin
(
cs
,
{
0
_m
,
0
_m
,
0
_m
});
geometry
::
Vector
<
units
::
si
::
SpeedType
::
dimension_type
>
v
(
cs
,
0
_m
/
second
,
0
_m
/
second
,
1
_m
/
second
);
geometry
::
Line
line
(
origin
,
v
);
geometry
::
Trajectory
<
geometry
::
Line
>
track
(
line
,
10
_s
);
const
HEPEnergyType
P0
=
1000
_GeV
;
auto
pLab
=
corsika
::
stack
::
MomentumVector
(
cs
,
{
P0
,
0
_GeV
,
0
_GeV
});
SECTION
(
"nucleon projectile"
)
{
setup
::
Stack
stack
;
unsigned
short
constexpr
A
=
16
,
Z
=
8
;
template
<
typename
TNodeType
>
auto
setupStack
(
int
vA
,
int
vZ
,
HEPEnergyType
vMomentum
,
TNodeType
*
vNodePtr
,
geometry
::
CoordinateSystem
const
&
cs
)
{
auto
stack
=
std
::
make_unique
<
setup
::
Stack
>
();
auto
constexpr
mN
=
corsika
::
units
::
constants
::
nucleonMass
;
HEPMomentumType
E0
=
sqrt
(
A
*
A
*
mN
*
mN
+
P0
*
P0
);
geometry
::
Point
const
origin
(
cs
,
{
0
_m
,
0
_m
,
0
_m
});
corsika
::
stack
::
MomentumVector
const
pLab
(
cs
,
{
vMomentum
,
0
_GeV
,
0
_GeV
});
HEPEnergyType
const
E0
=
sqrt
(
units
::
si
::
detail
::
static_pow
<
2
>
(
mN
*
vA
)
+
pLab
.
squaredNorm
());
auto
particle
=
stack
.
AddParticle
(
std
::
tuple
<
particles
::
Code
,
units
::
si
::
HEPEnergyType
,
stack
->
AddParticle
(
std
::
tuple
<
particles
::
Code
,
units
::
si
::
HEPEnergyType
,
corsika
::
stack
::
MomentumVector
,
geometry
::
Point
,
units
::
si
::
TimeType
,
unsigned
short
,
unsigned
short
>
{
particles
::
Code
::
Nucleus
,
E0
,
pLab
,
origin
,
0
_ns
,
A
,
Z
});
particles
::
Code
::
Nucleus
,
E0
,
pLab
,
origin
,
0
_ns
,
v
A
,
v
Z
});
particle
.
SetNode
(
nodePtr
);
corsika
::
stack
::
SecondaryView
view
(
particle
);
auto
projectile
=
view
.
GetProjectile
();
particle
.
SetNode
(
vNodePtr
);
return
std
::
make_tuple
(
std
::
move
(
stack
),
std
::
make_unique
<
decltype
(
corsika
::
stack
::
SecondaryView
(
particle
))
>
(
particle
));
}
template
<
typename
TNodeType
>
auto
setupStack
(
particles
::
Code
vProjectileType
,
HEPEnergyType
vMomentum
,
TNodeType
*
vNodePtr
,
geometry
::
CoordinateSystem
const
&
cs
)
{
auto
stack
=
std
::
make_unique
<
setup
::
Stack
>
();
geometry
::
Point
const
origin
(
cs
,
{
0
_m
,
0
_m
,
0
_m
});
corsika
::
stack
::
MomentumVector
const
pLab
(
cs
,
{
vMomentum
,
0
_GeV
,
0
_GeV
});
HEPEnergyType
const
E0
=
sqrt
(
units
::
si
::
detail
::
static_pow
<
2
>
(
particles
::
GetMass
(
vProjectileType
))
+
pLab
.
squaredNorm
());
auto
particle
=
stack
->
AddParticle
(
std
::
tuple
<
particles
::
Code
,
units
::
si
::
HEPEnergyType
,
corsika
::
stack
::
MomentumVector
,
geometry
::
Point
,
units
::
si
::
TimeType
>
{
vProjectileType
,
E0
,
pLab
,
origin
,
0
_ns
});
particle
.
SetNode
(
vNodePtr
);
return
std
::
make_tuple
(
std
::
move
(
stack
),
std
::
make_unique
<
decltype
(
corsika
::
stack
::
SecondaryView
(
particle
))
>
(
particle
));
}
//~ int main() {
TEST_CASE
(
"UrQMD"
)
{
feenableexcept
(
FE_INVALID
);
corsika
::
random
::
RNGManager
::
GetInstance
().
RegisterRandomStream
(
"UrQMD"
);
UrQMD
urqmd
;
SECTION
(
"cross sections"
)
{
auto
[
env
,
csPtr
,
nodePtr
]
=
setupEnvironment
(
particles
::
Code
::
Invalid
);
auto
const
&
cs
=
*
csPtr
;
particles
::
Code
validProjectileCodes
[]
=
{
particles
::
Code
::
PiPlus
,
particles
::
Code
::
PiMinus
,
particles
::
Code
::
Proton
,
particles
::
Code
::
Neutron
};
for
(
auto
code
:
validProjectileCodes
)
{
auto
[
stack
,
view
]
=
setupStack
(
code
,
100
_GeV
,
nodePtr
,
cs
);
REQUIRE
(
stack
->
GetSize
()
==
1
);
// simple check whether the cross-section is non-vanishing
REQUIRE
(
urqmd
.
GetCrossSection
(
view
->
GetProjectile
(),
particles
::
Code
::
Proton
)
/
1
_mb
>
0
);
REQUIRE
(
urqmd
.
GetCrossSection
(
view
->
GetProjectile
(),
particles
::
Code
::
Nitrogen
)
/
1
_mb
>
0
);
REQUIRE
(
urqmd
.
GetCrossSection
(
view
->
GetProjectile
(),
particles
::
Code
::
Oxygen
)
/
1
_mb
>
0
);
REQUIRE
(
urqmd
.
GetCrossSection
(
view
->
GetProjectile
(),
particles
::
Code
::
Nitrogen
)
/
1
_mb
>
0
);
}
}
SECTION
(
"nucleon projectile"
)
{
unsigned
short
constexpr
A
=
16
,
Z
=
8
;
[[
maybe_unused
]]
process
::
EProcessReturn
const
ret
=
urqmd
.
DoInteraction
(
projectile
);
REQUIRE
(
sumCharge
(
stack
)
==
Z
+
particles
::
GetChargeNumber
(
particles
::
Code
::
Oxygen
));
}
SECTION
(
"
\"
special
\"
projectile"
)
{
//~
SECTION("\"special\" projectile") {
setup
::
Stack
stack
;
auto
constexpr
code
=
particles
::
Code
::
PiPlus
;
auto
constexpr
mass
=
particles
::
GetMass
(
code
);
HEPMomentumType
E0
=
sqrt
(
mass
*
mass
+
pLab
.
squaredNorm
());
auto
particle
=
stack
.
AddParticle
(
std
::
tuple
<
particles
::
Code
,
units
::
si
::
HEPEnergyType
,
corsika
::
stack
::
MomentumVector
,
geometry
::
Point
,
units
::
si
::
TimeType
>
{
code
,
E0
,
pLab
,
origin
,
0
_ns
});
particle
.
SetNode
(
nodePtr
);
corsika
::
stack
::
SecondaryView
view
(
particle
);
auto
projectile
=
view
.
GetProjectile
();
//~ [[maybe_unused]] process::EProcessReturn const ret = urqmd.DoInteraction(projectile);
[[
maybe_unused
]]
process
::
EProcessReturn
const
ret
=
urqmd
.
DoInteraction
(
projectile
);
REQUIRE
(
sumCharge
(
stack
)
==
particles
::
GetChargeNumber
(
particles
::
Code
::
PiPlus
)
+
particles
::
GetChargeNumber
(
particles
::
Code
::
Oxygen
));
}
//~ REQUIRE(sumCharge(stack) == particles::GetChargeNumber(particles::Code::PiPlus) +
//~ particles::GetChargeNumber(particles::Code::Oxygen));
//~ }
}
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