From a8dcb9613141ca77cb5de01cd474ad0d72946a1a Mon Sep 17 00:00:00 2001 From: Felix Riehn <felix@matilda> Date: Wed, 28 Nov 2018 19:18:01 +0000 Subject: [PATCH] added cross section unit --- Framework/Units/PhysicalConstants.h | 2 +- Framework/Units/PhysicalUnits.h | 25 +++++++++++++++++++++++++ Framework/Units/testUnits.cc | 3 ++- 3 files changed, 28 insertions(+), 2 deletions(-) diff --git a/Framework/Units/PhysicalConstants.h b/Framework/Units/PhysicalConstants.h index 915f2d59..c3d5824e 100644 --- a/Framework/Units/PhysicalConstants.h +++ b/Framework/Units/PhysicalConstants.h @@ -54,7 +54,7 @@ namespace corsika::units::si::constants { // unified atomic mass unit constexpr quantity<mass_d> u{Rep(1.6605402e-27L) * kilogram}; - // millibarn + // barn constexpr quantity<area_d> barn{Rep(1.e-28L) * meter * meter}; // etc. diff --git a/Framework/Units/PhysicalUnits.h b/Framework/Units/PhysicalUnits.h index adaa004d..9060037e 100644 --- a/Framework/Units/PhysicalUnits.h +++ b/Framework/Units/PhysicalUnits.h @@ -24,6 +24,31 @@ namespace phys { } // namespace units } // namespace phys +namespace phys { + namespace units { + namespace literals { + QUANTITY_DEFINE_SCALING_LITERALS(barn, area_d, + magnitude(corsika::units::si::constants::barn)) + + // phys::units::quantity<energy_d/mass_d> Joule2Kg = c2; // 1_Joule / 1_kg; + + } // namespace literals + } // namespace units +} + +namespace phys { + namespace units { + namespace literals { + QUANTITY_DEFINE_SCALING_LITERALS(meter, length_d, + magnitude(corsika::units::si::constants::meter)) + + // phys::units::quantity<energy_d/mass_d> Joule2Kg = c2; // 1_Joule / 1_kg; + + } // namespace literals + } // namespace units +} + + namespace corsika::units::si { using namespace phys::units; using namespace phys::units::literals; diff --git a/Framework/Units/testUnits.cc b/Framework/Units/testUnits.cc index 3528cf67..fc844c10 100644 --- a/Framework/Units/testUnits.cc +++ b/Framework/Units/testUnits.cc @@ -54,7 +54,8 @@ TEST_CASE("PhysicalUnits", "[Units]") { REQUIRE(1_mol / 1_amol == Approx(1e18)); REQUIRE(1_K / 1_zK == Approx(1e21)); REQUIRE(1_K / 1_yK == Approx(1e24)); - + // REQUIRE(1_barn / 1_mbarn == Approx(1e3)); + REQUIRE(1_A / 1_hA == Approx(1e-2)); REQUIRE(1_m / 1_km == Approx(1e-3)); REQUIRE(1_m / 1_Mm == Approx(1e-6)); -- GitLab