forked from mpusz/mp-units
Added absorbed dose
This commit is contained in:
@@ -128,6 +128,9 @@ struct dim_conductance : derived_dimension<Child, U, exp<R, -1>> {};
|
||||
template<typename Child, Unit U, DimensionOf<dim_time> T, DimensionOf<dim_substance> M>
|
||||
struct dim_catalytic_activity : derived_dimension<Child, U, exp<T, -1>, exp<M, 1>> {};
|
||||
|
||||
template<typename Child, Unit U, DimensionOf<dim_energy> E, DimensionOf<dim_mass> M>
|
||||
struct dim_absorbed_dose : derived_dimension<Child, U, exp<E, 1>, exp<M, -1>> {};
|
||||
|
||||
} // namespace physical
|
||||
|
||||
template<typename T>
|
||||
@@ -211,4 +214,7 @@ concept Conductance = physical::QuantityOf<T, physical::dim_inductance>;
|
||||
template<typename T>
|
||||
concept CatalyticActivity = physical::QuantityOf<T, physical::dim_catalytic_activity>;
|
||||
|
||||
template<typename T>
|
||||
concept AbsorbedDose = physical::QuantityOf<T, physical::dim_absorbed_dose>;
|
||||
|
||||
} // namespace units
|
||||
|
58
src/include/units/physical/si/absorbed_dose.h
Normal file
58
src/include/units/physical/si/absorbed_dose.h
Normal file
@@ -0,0 +1,58 @@
|
||||
// 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 <units/physical/dimensions.h>
|
||||
#include <units/physical/si/energy.h>
|
||||
#include <units/physical/si/mass.h>
|
||||
#include <units/physical/si/prefixes.h>
|
||||
#include <units/quantity.h>
|
||||
|
||||
namespace units::si {
|
||||
|
||||
struct gray : named_unit<gray, "Gy", prefix> {};
|
||||
struct milligray : prefixed_unit<milligray, milli, gray> {};
|
||||
struct kilogray : prefixed_unit<kilogray, kilo, gray> {};
|
||||
|
||||
struct dim_absorbed_dose : physical::dim_absorbed_dose<dim_absorbed_dose, gray, dim_energy, dim_mass> {};
|
||||
|
||||
template<Unit U, Scalar Rep = double>
|
||||
using absorbed_dose = quantity<dim_absorbed_dose, U, Rep>;
|
||||
|
||||
inline namespace literals {
|
||||
|
||||
// G
|
||||
constexpr auto operator"" q_Gy(unsigned long long l) { return absorbed_dose<gray, std::int64_t>(l); }
|
||||
constexpr auto operator"" q_Gy(long double l) { return absorbed_dose<gray, long double>(l); }
|
||||
|
||||
// mGy
|
||||
constexpr auto operator"" q_mGy(unsigned long long l) { return absorbed_dose<milligray, std::int64_t>(l); }
|
||||
constexpr auto operator"" q_mGy(long double l) { return absorbed_dose<milligray, long double>(l); }
|
||||
|
||||
// kGy
|
||||
constexpr auto operator"" q_kGy(unsigned long long l) { return absorbed_dose<kilogray, std::int64_t>(l); }
|
||||
constexpr auto operator"" q_kGy(long double l) { return absorbed_dose<kilogray, long double>(l); }
|
||||
|
||||
} // namespace literals
|
||||
|
||||
} // namespace units::si
|
@@ -44,6 +44,7 @@
|
||||
#include "units/physical/si/inductance.h"
|
||||
#include "units/physical/si/conductance.h"
|
||||
#include "units/physical/si/catalytic_activity.h"
|
||||
#include "units/physical/si/absorbed_dose.h"
|
||||
#include "units/format.h"
|
||||
#include <catch2/catch.hpp>
|
||||
|
||||
@@ -236,6 +237,13 @@ TEST_CASE("fmt::format on synthesized unit symbols", "[text][fmt]")
|
||||
CHECK(fmt::format("{}", 1q_U) == "1 U");
|
||||
}
|
||||
|
||||
SECTION("absorbed dose")
|
||||
{
|
||||
CHECK(fmt::format("{}", 1q_Gy) == "1 Gy");
|
||||
CHECK(fmt::format("{}", 1q_kGy) == "1 kGy");
|
||||
CHECK(fmt::format("{}", 1q_mGy) == "1 mGy");
|
||||
}
|
||||
|
||||
SECTION("addition with common ratio")
|
||||
{
|
||||
CHECK(fmt::format("{}", 1q_in + 1q_yd) == "37 in");
|
||||
|
@@ -45,6 +45,7 @@
|
||||
#include <units/physical/si/inductance.h>
|
||||
#include <units/physical/si/conductance.h>
|
||||
#include <units/physical/si/catalytic_activity.h>
|
||||
#include <units/physical/si/absorbed_dose.h>
|
||||
#include <utility>
|
||||
|
||||
namespace {
|
||||
@@ -242,6 +243,18 @@ static_assert(nanosiemens::symbol == "nS");
|
||||
static_assert(1q_kat == 1q_mol / 1q_s);
|
||||
static_assert(1'000'000q_U == 1q_mol / 1q_min);
|
||||
|
||||
static_assert(katal::symbol == "kat");
|
||||
static_assert(enzyme_unit::symbol == "U");
|
||||
|
||||
// absorbed dose
|
||||
|
||||
static_assert(1q_Gy == 1q_J / 1q_kg);
|
||||
static_assert(9.q_W * 3q_s / 60q_kg == 450q_mGy);
|
||||
|
||||
static_assert(gray::symbol == "Gy");
|
||||
static_assert(milligray::symbol == "mGy");
|
||||
static_assert(kilogray::symbol == "kGy");
|
||||
|
||||
/* ************** DERIVED DIMENSIONS IN TERMS OF BASE UNITS **************** */
|
||||
|
||||
// velocity
|
||||
|
Reference in New Issue
Block a user