diff --git a/src/include/units/physical/dimensions.h b/src/include/units/physical/dimensions.h index eaec5174..496d626a 100644 --- a/src/include/units/physical/dimensions.h +++ b/src/include/units/physical/dimensions.h @@ -122,6 +122,12 @@ struct dim_inductance : derived_dimension, exp> {}; template R> struct dim_conductance : derived_dimension> {}; +// template T> +// struct dim_radioactivity : derived_dimension> {}; + +template T, DimensionOf M> +struct dim_catalytic_activity : derived_dimension, exp> {}; + } // namespace physical template @@ -190,13 +196,19 @@ concept Pressure = physical::QuantityOf; template concept MagneticInduction = physical::QuantityOf; -template +template concept MagneticFlux = physical::QuantityOf; -template +template concept Inductance = physical::QuantityOf; -template +template concept Conductance = physical::QuantityOf; +// template +// concept Radioactivity = physical::QuantityOf; + +template +concept CatalyticActivity = physical::QuantityOf; + } // namespace units diff --git a/src/include/units/physical/si/catalytic_activity.h b/src/include/units/physical/si/catalytic_activity.h new file mode 100644 index 00000000..8e7f2fc9 --- /dev/null +++ b/src/include/units/physical/si/catalytic_activity.h @@ -0,0 +1,60 @@ +// The MIT License (MIT) +// +// Copyright (c) 2018 Mateusz Pusz +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. + +#pragma once + +#include +#include +#include +#include +#include + +namespace units::si { + +struct katal : named_unit {}; +struct nanokatal : prefixed_unit {}; + +struct enzyme_unit : named_scaled_unit, katal> {}; + +struct dim_catalytic_activity : physical::dim_catalytic_activity {}; + +template +using catalytic_activity = quantity; + +inline namespace literals { + +// kat +constexpr auto operator"" q_kat(unsigned long long l) { return catalytic_activity(l); } +constexpr auto operator"" q_kat(long double l) { return catalytic_activity(l); } + +// nkat +constexpr auto operator"" q_nkat(unsigned long long l) { return catalytic_activity(l); } +constexpr auto operator"" q_nkat(long double l) { return catalytic_activity(l); } + +// U +constexpr auto operator"" q_U(unsigned long long l) { return catalytic_activity(l); } +constexpr auto operator"" q_U(long double l) { return catalytic_activity(l); } + +} // namespace literals + +} // namespace units::si + diff --git a/test/unit_test/runtime/fmt_units_test.cpp b/test/unit_test/runtime/fmt_units_test.cpp index 1b298a8e..d1c2bd70 100644 --- a/test/unit_test/runtime/fmt_units_test.cpp +++ b/test/unit_test/runtime/fmt_units_test.cpp @@ -43,6 +43,7 @@ #include "units/physical/si/magnetic_flux.h" #include "units/physical/si/inductance.h" #include "units/physical/si/conductance.h" +#include "units/physical/si/catalytic_activity.h" #include "units/format.h" #include @@ -229,6 +230,12 @@ TEST_CASE("fmt::format on synthesized unit symbols", "[text][fmt]") CHECK(fmt::format("{}", 1q_nS) == "1 nS"); } + SECTION("catalytic activity") + { + CHECK(fmt::format("{}", 1q_kat) == "1 kat"); + CHECK(fmt::format("{}", 1q_U) == "1 U"); + } + SECTION("addition with common ratio") { CHECK(fmt::format("{}", 1q_in + 1q_yd) == "37 in"); diff --git a/test/unit_test/static/si_test.cpp b/test/unit_test/static/si_test.cpp index 6720b60f..6ebd86a7 100644 --- a/test/unit_test/static/si_test.cpp +++ b/test/unit_test/static/si_test.cpp @@ -44,6 +44,7 @@ #include #include #include +#include #include namespace { @@ -236,6 +237,11 @@ static_assert(millisiemens::symbol == "mS"); static_assert(microsiemens::symbol == basic_symbol_text("µS", "uS")); static_assert(nanosiemens::symbol == "nS"); +// catalytic activity + +static_assert(1q_kat == 1q_mol / 1q_s); +static_assert(1'000'000q_U == 1q_mol / 1q_min); + /* ************** DERIVED DIMENSIONS IN TERMS OF BASE UNITS **************** */ // velocity