Skip to content

Commit

Permalink
feat: isq::activity added and becquerel definition updated to ben…
Browse files Browse the repository at this point in the history
…efit from it
  • Loading branch information
mpusz committed Sep 26, 2023
1 parent 4bde31e commit bfbc178
Show file tree
Hide file tree
Showing 6 changed files with 56 additions and 19 deletions.
10 changes: 7 additions & 3 deletions src/systems/isq/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,11 @@ cmake_minimum_required(VERSION 3.19)
add_units_module(
isq
DEPENDENCIES mp-units::core
HEADERS include/mp-units/systems/isq/base_quantities.h include/mp-units/systems/isq/electromagnetism.h
include/mp-units/systems/isq/isq.h include/mp-units/systems/isq/mechanics.h
include/mp-units/systems/isq/space_and_time.h include/mp-units/systems/isq/thermodynamics.h
HEADERS include/mp-units/systems/isq/atomic_and_nuclear_physics.h
include/mp-units/systems/isq/base_quantities.h
include/mp-units/systems/isq/electromagnetism.h
include/mp-units/systems/isq/isq.h
include/mp-units/systems/isq/mechanics.h
include/mp-units/systems/isq/space_and_time.h
include/mp-units/systems/isq/thermodynamics.h
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
// 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 <mp-units/quantity_spec.h>
#include <mp-units/systems/isq/base_quantities.h>
#include <mp-units/systems/isq/space_and_time.h>

namespace mp_units::isq {

// TODO Add all the remaining ISQ definitions
QUANTITY_SPEC(activity, 1 / duration);

} // namespace mp_units::isq
1 change: 1 addition & 0 deletions src/systems/isq/include/mp-units/systems/isq/isq.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
#pragma once

// IWYU pragma: begin_exports
#include <mp-units/systems/isq/atomic_and_nuclear_physics.h>
#include <mp-units/systems/isq/base_quantities.h>
#include <mp-units/systems/isq/electromagnetism.h>
#include <mp-units/systems/isq/mechanics.h>
Expand Down
3 changes: 2 additions & 1 deletion src/systems/si/include/mp-units/systems/si/units.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@

#pragma once

#include <mp-units/systems/isq/atomic_and_nuclear_physics.h>
#include <mp-units/systems/isq/base_quantities.h>
#include <mp-units/systems/isq/space_and_time.h>
#include <mp-units/systems/si/prefixes.h>
Expand Down Expand Up @@ -73,7 +74,7 @@ inline constexpr struct lumen : named_unit<"lm", candela * steradian> {} lumen;
inline constexpr struct lux : named_unit<"lx", lumen / square(metre)> {} lux;
// TODO add when isq::activity will be supported
// inline constexpr struct becquerel : named_unit<"Bq", 1 / second, kind_of<isq::activity>> {} becquerel;
inline constexpr struct becquerel : named_unit<"Bq", 1 / second> {} becquerel;
inline constexpr struct becquerel : named_unit<"Bq", 1 / second, kind_of<isq::activity>> {} becquerel;
inline constexpr struct gray : named_unit<"Gy", joule / kilogram> {} gray;
inline constexpr struct sievert : named_unit<"Sv", joule / kilogram> {} sievert;
inline constexpr struct katal : named_unit<"kat", mole / second> {} katal;
Expand Down
19 changes: 9 additions & 10 deletions test/unit_test/static/quantity_point_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ inline constexpr struct zero : absolute_point_origin<dimensionless> {
} zero;

QUANTITY_SPEC(special_height, isq::height);
QUANTITY_SPEC(activity, 1 / isq::time);

/////////////////////
// class invariants
Expand Down Expand Up @@ -1203,18 +1202,18 @@ consteval bool invalid_subtraction(Ts... ts)
return !requires { (... - ts); };
}

inline constexpr struct zero_Bq : absolute_point_origin<kind_of<activity>> {
inline constexpr struct zero_Bq : absolute_point_origin<kind_of<isq::activity>> {
} zero_Bq;

static_assert(invalid_addition(zero_Bq + 5 * activity[Bq], 5 * isq::frequency[Hz]));
static_assert(invalid_addition(5 * activity[Bq], zero_Hz + 5 * isq::frequency[Hz]));
static_assert(invalid_subtraction(zero_Bq + 5 * activity[Bq], 5 * isq::frequency[Hz]));
static_assert(invalid_subtraction(zero_Bq + 5 * activity[Bq], zero_Hz + 5 * isq::frequency[Hz]));
static_assert(invalid_addition(zero_Bq + 5 * isq::activity[Bq], 5 * isq::frequency[Hz]));
static_assert(invalid_addition(5 * isq::activity[Bq], zero_Hz + 5 * isq::frequency[Hz]));
static_assert(invalid_subtraction(zero_Bq + 5 * isq::activity[Bq], 5 * isq::frequency[Hz]));
static_assert(invalid_subtraction(zero_Bq + 5 * isq::activity[Bq], zero_Hz + 5 * isq::frequency[Hz]));

static_assert(invalid_addition(zero_Bq + 5 * activity[Bq], 10 / (2 * isq::time[s]), 5 * isq::frequency[Hz]));
static_assert(invalid_addition(5 * activity[Bq], zero_Hz + 10 / (2 * isq::time[s]), 5 * isq::frequency[Hz]));
static_assert(invalid_addition(5 * activity[Bq], 10 / (2 * isq::time[s]), zero_Hz + 5 * isq::frequency[Hz]));
static_assert(invalid_subtraction(zero_Bq + 5 * activity[Bq], 10 / (2 * isq::time[s]), 5 * isq::frequency[Hz]));
static_assert(invalid_addition(zero_Bq + 5 * isq::activity[Bq], 10 / (2 * isq::time[s]), 5 * isq::frequency[Hz]));
static_assert(invalid_addition(5 * isq::activity[Bq], zero_Hz + 10 / (2 * isq::time[s]), 5 * isq::frequency[Hz]));
static_assert(invalid_addition(5 * isq::activity[Bq], 10 / (2 * isq::time[s]), zero_Hz + 5 * isq::frequency[Hz]));
static_assert(invalid_subtraction(zero_Bq + 5 * isq::activity[Bq], 10 / (2 * isq::time[s]), 5 * isq::frequency[Hz]));


/////////////////////////
Expand Down
8 changes: 3 additions & 5 deletions test/unit_test/static/quantity_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,6 @@ namespace {
using namespace mp_units;
using namespace mp_units::si::unit_symbols;

QUANTITY_SPEC(activity, 1 / isq::time);

//////////////////////////////
// quantity class invariants
//////////////////////////////
Expand Down Expand Up @@ -695,8 +693,8 @@ consteval bool invalid_arithmetic(Ts... ts)
{
return !requires { (... + ts); } && !requires { (... - ts); };
}
static_assert(invalid_arithmetic(5 * activity[Bq], 5 * isq::frequency[Hz]));
static_assert(invalid_arithmetic(5 * activity[Bq], 10 / (2 * isq::time[s]), 5 * isq::frequency[Hz]));
static_assert(invalid_arithmetic(5 * isq::activity[Bq], 5 * isq::frequency[Hz]));
static_assert(invalid_arithmetic(5 * isq::activity[Bq], 10 / (2 * isq::time[s]), 5 * isq::frequency[Hz]));

// Physical constants
static_assert(1 * si::si2019::speed_of_light_in_vacuum + 10 * isq::speed[m / s] == 299'792'468 * isq::speed[m / s]);
Expand Down Expand Up @@ -817,7 +815,7 @@ static_assert(1 * si::si2019::speed_of_light_in_vacuum == 299'792'458 * isq::spe
// Different named dimensions
template</*Reference*/ auto R1, /*Reference*/ auto R2> // TODO Use `Reference` when Clang supports it.
concept invalid_comparison = !requires { 2 * R1 == 2 * R2; } && !requires { 2 * R2 == 2 * R1; };
static_assert(invalid_comparison<activity[Bq], isq::frequency[Hz]>);
static_assert(invalid_comparison<isq::activity[Bq], isq::frequency[Hz]>);


///////////////////////
Expand Down

0 comments on commit bfbc178

Please sign in to comment.