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
515c9abd
Commit
515c9abd
authored
6 years ago
by
Maximilian Reininghaus
Browse files
Options
Downloads
Plain Diff
Merge branch 'si-to-hep' into 'master'
conversion SI to HEP See merge request
!62
parents
aae0786d
02ee2d9f
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
Framework/Units/PhysicalUnits.h
+25
-0
25 additions, 0 deletions
Framework/Units/PhysicalUnits.h
Framework/Units/testUnits.cc
+15
-0
15 additions, 0 deletions
Framework/Units/testUnits.cc
with
40 additions
and
0 deletions
Framework/Units/PhysicalUnits.h
+
25
−
0
View file @
515c9abd
...
@@ -114,11 +114,36 @@ namespace corsika::units::si {
...
@@ -114,11 +114,36 @@ namespace corsika::units::si {
static_pow
<
p
>
(
corsika
::
units
::
constants
::
hBar
)
*
static_pow
<
p
>
(
corsika
::
units
::
constants
::
hBar
)
*
static_pow
<
q
>
(
corsika
::
units
::
constants
::
c
);
static_pow
<
q
>
(
corsika
::
units
::
constants
::
c
);
}
}
template
<
typename
DimFrom
>
auto
constexpr
ConversionFactorSIToHEP
()
{
static_assert
(
DimFrom
::
dim4
==
0
&&
DimFrom
::
dim5
==
0
&&
DimFrom
::
dim6
==
0
&&
DimFrom
::
dim7
==
0
&&
DimFrom
::
dim8
==
0
,
"must be pure L, M, T type"
);
int
constexpr
l
=
DimFrom
::
dim1
;
// SI length dim.
int
constexpr
m
=
DimFrom
::
dim2
;
// SI mass dim.
int
constexpr
t
=
DimFrom
::
dim3
;
// SI time dim.
int
constexpr
p
=
-
m
;
int
constexpr
q
=
m
+
t
;
int
constexpr
e
=
m
-
t
-
l
;
using
namespace
detail
;
return
static_pow
<
e
>
(
corsika
::
units
::
constants
::
hBarC
)
*
static_pow
<
p
>
(
corsika
::
units
::
constants
::
hBar
)
*
static_pow
<
q
>
(
corsika
::
units
::
constants
::
c
);
}
template
<
typename
DimTo
,
typename
DimFrom
>
template
<
typename
DimTo
,
typename
DimFrom
>
auto
constexpr
ConvertHEPToSI
(
quantity
<
DimFrom
>
q
)
{
auto
constexpr
ConvertHEPToSI
(
quantity
<
DimFrom
>
q
)
{
return
ConversionFactorHEPToSI
<
DimFrom
,
DimTo
>
()
*
q
;
return
ConversionFactorHEPToSI
<
DimFrom
,
DimTo
>
()
*
q
;
}
}
template
<
typename
DimFrom
>
auto
constexpr
ConvertSIToHEP
(
quantity
<
DimFrom
>
q
)
{
return
ConversionFactorSIToHEP
<
DimFrom
>
()
*
q
;
}
}
// end namespace corsika::units::si
}
// end namespace corsika::units::si
/**
/**
...
...
This diff is collapsed.
Click to expand it.
Framework/Units/testUnits.cc
+
15
−
0
View file @
515c9abd
...
@@ -140,4 +140,19 @@ TEST_CASE("PhysicalUnits", "[Units]") {
...
@@ -140,4 +140,19 @@ TEST_CASE("PhysicalUnits", "[Units]") {
REQUIRE
((
protonMassSI
/
1.672'621'898e-27
_kg
)
==
Approx
(
1
));
REQUIRE
((
protonMassSI
/
1.672'621'898e-27
_kg
)
==
Approx
(
1
));
REQUIRE
((
protonMassSI
/
(
1.007'276
*
corsika
::
units
::
constants
::
u
))
==
Approx
(
1
));
REQUIRE
((
protonMassSI
/
(
1.007'276
*
corsika
::
units
::
constants
::
u
))
==
Approx
(
1
));
}
}
SECTION
(
"SI/HEP conversion"
)
{
REQUIRE
(
ConvertSIToHEP
(
units
::
constants
::
c
)
==
Approx
(
1
));
REQUIRE
(
ConvertSIToHEP
(
units
::
constants
::
hBar
)
==
Approx
(
1
));
{
auto
const
invLength
=
1
/
197.326978
_fm
;
// should be convertible to HEPEnergy
HEPEnergyType
const
energy
=
ConvertSIToHEP
(
invLength
);
REQUIRE
(
energy
/
1
_MeV
==
Approx
(
1
));
}
REQUIRE
(
ConvertSIToHEP
(
6.5823e-25
_s
)
*
1
_GeV
==
Approx
(
1
).
epsilon
(
1e-4
));
REQUIRE
(
ConvertSIToHEP
(
3.8938e-32
*
meter
*
meter
)
*
1
_GeV
*
1
_GeV
==
Approx
(
1
).
epsilon
(
1e-4
));
}
}
}
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