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
8a9ba767
Commit
8a9ba767
authored
4 years ago
by
Maximilian Reininghaus
Committed by
Maximilian Reininghaus
4 years ago
Browse files
Options
Downloads
Patches
Plain Diff
read UrQMD cross-section file
parent
4dce9b9c
No related branches found
Branches containing commit
No related tags found
Tags containing commit
2 merge requests
!234
WIP: Initial example of python as script language from C++
,
!205
UrQMD improvements
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
Processes/UrQMD/UrQMD.cc
+125
-2
125 additions, 2 deletions
Processes/UrQMD/UrQMD.cc
Processes/UrQMD/UrQMD.h
+12
-1
12 additions, 1 deletion
Processes/UrQMD/UrQMD.h
with
137 additions
and
3 deletions
Processes/UrQMD/UrQMD.cc
+
125
−
2
View file @
8a9ba767
...
@@ -15,19 +15,107 @@
...
@@ -15,19 +15,107 @@
#include
<corsika/units/PhysicalUnits.h>
#include
<corsika/units/PhysicalUnits.h>
#include
<algorithm>
#include
<algorithm>
#include
<array>
#include
<cassert>
#include
<cmath>
#include
<fstream>
#include
<functional>
#include
<functional>
#include
<iostream>
#include
<iostream>
#include
<random>
#include
<random>
#include
<sstream>
using
namespace
corsika
::
process
::
UrQMD
;
using
namespace
corsika
::
process
::
UrQMD
;
using
namespace
corsika
::
units
::
si
;
using
namespace
corsika
::
units
::
si
;
UrQMD
::
UrQMD
()
{
iniurqmd_
();
}
using
SetupStack
=
corsika
::
setup
::
Stack
;
using
SetupStack
=
corsika
::
setup
::
Stack
;
using
SetupParticle
=
corsika
::
setup
::
Stack
::
StackIterator
;
using
SetupParticle
=
corsika
::
setup
::
Stack
::
StackIterator
;
using
SetupProjectile
=
corsika
::
setup
::
StackView
::
StackIterator
;
using
SetupProjectile
=
corsika
::
setup
::
StackView
::
StackIterator
;
UrQMD
::
UrQMD
(
std
::
filesystem
::
path
const
&
xs_file
)
{
readXSFile
(
xs_file
);
iniurqmd_
();
}
CrossSectionType
UrQMD
::
GetTabulatedCrossSection
(
particles
::
Code
vProjectileCode
,
corsika
::
particles
::
Code
vTargetCode
,
HEPEnergyType
vLabEnergy
)
const
{
// translated to C++ from CORSIKA 7 subroutine cxtot_u
auto
const
kinEnergy
=
vLabEnergy
-
particles
::
GetMass
(
vProjectileCode
);
assert
(
kinEnergy
>=
HEPEnergyType
::
zero
());
double
const
logKinEnergy
=
std
::
log10
(
kinEnergy
*
(
1
/
1
_GeV
));
double
const
ye
=
std
::
max
(
10
*
logKinEnergy
+
10.5
,
1.
);
int
const
je
=
std
::
min
(
int
(
ye
),
int
(
xs_interp_support_table
.
shape
()[
2
]
-
2
));
std
::
array
<
double
,
3
>
w
;
w
[
2
-
1
]
=
ye
-
je
;
w
[
3
-
1
]
=
w
[
2
-
1
]
*
(
w
[
2
-
1
]
-
1.
)
*
.5
;
w
[
1
-
1
]
=
1
-
w
[
2
-
1
]
+
w
[
3
-
1
];
w
[
2
-
1
]
=
w
[
2
-
1
]
-
2
*
w
[
3
-
1
];
int
projectileIndex
;
switch
(
vProjectileCode
)
{
case
particles
::
Code
::
Proton
:
projectileIndex
=
0
;
break
;
case
particles
::
Code
::
AntiProton
:
projectileIndex
=
1
;
break
;
case
particles
::
Code
::
Neutron
:
projectileIndex
=
2
;
break
;
case
particles
::
Code
::
AntiNeutron
:
projectileIndex
=
3
;
break
;
case
particles
::
Code
::
PiPlus
:
projectileIndex
=
4
;
break
;
case
particles
::
Code
::
PiMinus
:
projectileIndex
=
5
;
break
;
case
particles
::
Code
::
KPlus
:
projectileIndex
=
6
;
break
;
case
particles
::
Code
::
KMinus
:
projectileIndex
=
7
;
break
;
case
particles
::
Code
::
K0Short
:
case
particles
::
Code
::
K0Long
:
projectileIndex
=
8
;
break
;
default:
std
::
cout
<<
"WARNING: UrQMD cross-section not tabulated for "
<<
vProjectileCode
<<
std
::
endl
;
return
CrossSectionType
::
zero
();
}
int
targetIndex
;
switch
(
vTargetCode
)
{
case
particles
::
Code
::
Nitrogen
:
targetIndex
=
0
;
break
;
case
particles
::
Code
::
Oxygen
:
targetIndex
=
1
;
break
;
case
particles
::
Code
::
Argon
:
targetIndex
=
2
;
break
;
default:
std
::
stringstream
ss
;
ss
<<
"UrQMD cross-section not tabluated for target "
<<
vTargetCode
;
throw
std
::
runtime_error
(
ss
.
str
().
data
());
}
auto
result
=
CrossSectionType
::
zero
();
for
(
int
i
=
0
;
i
<
3
;
++
i
)
{
result
+=
xs_interp_support_table
[
projectileIndex
][
targetIndex
][
je
+
i
-
1
-
1
]
*
w
[
i
];
}
return
result
;
}
CrossSectionType
UrQMD
::
GetCrossSection
(
particles
::
Code
vProjectileCode
,
CrossSectionType
UrQMD
::
GetCrossSection
(
particles
::
Code
vProjectileCode
,
corsika
::
particles
::
Code
vTargetCode
,
corsika
::
particles
::
Code
vTargetCode
,
HEPEnergyType
vLabEnergy
,
HEPEnergyType
vLabEnergy
,
...
@@ -344,3 +432,38 @@ std::pair<int, int> corsika::process::UrQMD::ConvertToUrQMD(
...
@@ -344,3 +432,38 @@ std::pair<int, int> corsika::process::UrQMD::ConvertToUrQMD(
return
mapPDGToUrQMD
.
at
(
static_cast
<
int
>
(
GetPDG
(
code
)));
return
mapPDGToUrQMD
.
at
(
static_cast
<
int
>
(
GetPDG
(
code
)));
}
}
void
UrQMD
::
readXSFile
(
std
::
filesystem
::
path
const
&
filename
)
{
std
::
ifstream
file
(
filename
,
std
::
ios
::
in
);
if
(
!
file
.
is_open
())
{
throw
std
::
runtime_error
(
filename
.
native
()
+
" could not be opened."
);
}
std
::
string
line
;
std
::
getline
(
file
,
line
);
std
::
stringstream
ss
(
line
);
char
dummy
;
int
nTargets
,
nProjectiles
,
nSupports
;
ss
>>
dummy
>>
nTargets
>>
nProjectiles
>>
nSupports
;
decltype
(
xs_interp_support_table
)
::
extent_gen
extents
;
xs_interp_support_table
.
resize
(
extents
[
nProjectiles
][
nTargets
][
nSupports
]);
for
(
int
i
=
0
;
i
<
nTargets
;
++
i
)
{
for
(
int
j
=
0
;
j
<
nProjectiles
;
++
j
)
{
for
(
int
k
=
0
;
k
<
nSupports
;
++
k
)
{
std
::
getline
(
file
,
line
);
std
::
stringstream
s
(
line
);
double
energy
,
sigma
;
s
>>
energy
>>
sigma
;
xs_interp_support_table
[
j
][
i
][
k
]
=
sigma
*
1
_mb
;
}
std
::
getline
(
file
,
line
);
std
::
getline
(
file
,
line
);
}
}
}
This diff is collapsed.
Click to expand it.
Processes/UrQMD/UrQMD.h
+
12
−
1
View file @
8a9ba767
...
@@ -16,15 +16,20 @@
...
@@ -16,15 +16,20 @@
#include
<corsika/random/RNGManager.h>
#include
<corsika/random/RNGManager.h>
#include
<corsika/setup/SetupStack.h>
#include
<corsika/setup/SetupStack.h>
#include
<corsika/units/PhysicalUnits.h>
#include
<corsika/units/PhysicalUnits.h>
#include
<corsika/utl/CorsikaData.h>
#include
<boost/multi_array.hpp>
#include
<array>
#include
<array>
#include
<filesystem>
#include
<random>
#include
<random>
#include
<utility>
#include
<utility>
namespace
corsika
::
process
::
UrQMD
{
namespace
corsika
::
process
::
UrQMD
{
class
UrQMD
:
public
corsika
::
process
::
InteractionProcess
<
UrQMD
>
{
class
UrQMD
:
public
corsika
::
process
::
InteractionProcess
<
UrQMD
>
{
public:
public:
UrQMD
();
UrQMD
(
std
::
filesystem
::
path
const
&
path
=
utl
::
CorsikaData
(
"UrQMD/UrQMD-1.3.1-xs.dat"
));
void
Init
()
{}
void
Init
()
{}
corsika
::
units
::
si
::
GrammageType
GetInteractionLength
(
corsika
::
units
::
si
::
GrammageType
GetInteractionLength
(
corsika
::
setup
::
Stack
::
StackIterator
const
&
)
const
;
corsika
::
setup
::
Stack
::
StackIterator
const
&
)
const
;
...
@@ -37,16 +42,22 @@ namespace corsika::process::UrQMD {
...
@@ -37,16 +42,22 @@ namespace corsika::process::UrQMD {
particles
::
Code
,
particles
::
Code
,
corsika
::
units
::
si
::
HEPEnergyType
,
particles
::
Code
,
particles
::
Code
,
corsika
::
units
::
si
::
HEPEnergyType
,
int
Ap
=
1
)
const
;
int
Ap
=
1
)
const
;
corsika
::
units
::
si
::
CrossSectionType
GetTabulatedCrossSection
(
particles
::
Code
,
particles
::
Code
,
corsika
::
units
::
si
::
HEPEnergyType
)
const
;
corsika
::
process
::
EProcessReturn
DoInteraction
(
corsika
::
process
::
EProcessReturn
DoInteraction
(
corsika
::
setup
::
StackView
::
StackIterator
&
);
corsika
::
setup
::
StackView
::
StackIterator
&
);
bool
CanInteract
(
particles
::
Code
)
const
;
bool
CanInteract
(
particles
::
Code
)
const
;
private
:
private
:
void
readXSFile
(
std
::
filesystem
::
path
const
&
);
corsika
::
random
::
RNG
&
fRNG
=
corsika
::
random
::
RNG
&
fRNG
=
corsika
::
random
::
RNGManager
::
GetInstance
().
GetRandomStream
(
"UrQMD"
);
corsika
::
random
::
RNGManager
::
GetInstance
().
GetRandomStream
(
"UrQMD"
);
std
::
uniform_int_distribution
<
int
>
fBooleanDist
{
0
,
1
};
std
::
uniform_int_distribution
<
int
>
fBooleanDist
{
0
,
1
};
boost
::
multi_array
<
corsika
::
units
::
si
::
CrossSectionType
,
3
>
xs_interp_support_table
;
};
};
namespace
constants
{
namespace
constants
{
...
...
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