From 10ee4cc13ca999b3623a1f632341d734d704035b Mon Sep 17 00:00:00 2001 From: Mateusz Pusz Date: Sat, 24 Feb 2024 09:32:58 +0100 Subject: [PATCH] feat: some light and radiation ISQ quantities added --- src/systems/CMakeLists.txt | 1 + .../include/mp-units/systems/isq/isq.h | 1 + .../systems/isq/light_and_radiation.h | 59 +++++++++++++++++++ test/static/isq_test.cpp | 23 ++++++++ 4 files changed, 84 insertions(+) create mode 100644 src/systems/include/mp-units/systems/isq/light_and_radiation.h diff --git a/src/systems/CMakeLists.txt b/src/systems/CMakeLists.txt index b1582f67a..2f85cc2ed 100644 --- a/src/systems/CMakeLists.txt +++ b/src/systems/CMakeLists.txt @@ -42,6 +42,7 @@ add_mp_units_module( 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/light_and_radiation.h include/mp-units/systems/isq/mechanics.h include/mp-units/systems/isq/si_quantities.h include/mp-units/systems/isq/space_and_time.h diff --git a/src/systems/include/mp-units/systems/isq/isq.h b/src/systems/include/mp-units/systems/isq/isq.h index e2d31c7b7..f14522635 100644 --- a/src/systems/include/mp-units/systems/isq/isq.h +++ b/src/systems/include/mp-units/systems/isq/isq.h @@ -26,6 +26,7 @@ #include #include #include +#include #include #include #include diff --git a/src/systems/include/mp-units/systems/isq/light_and_radiation.h b/src/systems/include/mp-units/systems/isq/light_and_radiation.h new file mode 100644 index 000000000..b558a12bf --- /dev/null +++ b/src/systems/include/mp-units/systems/isq/light_and_radiation.h @@ -0,0 +1,59 @@ +// 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 + +#ifndef MP_UNITS_IN_MODULE_INTERFACE +#include +#endif + +MP_UNITS_EXPORT +namespace mp_units::isq { + +QUANTITY_SPEC(speed_of_light_in_a_medium, speed); +QUANTITY_SPEC(refractive_index, dimensionless, speed_of_light_in_vacuum / speed_of_light_in_a_medium); +QUANTITY_SPEC(radiant_energy, energy); +QUANTITY_SPEC(spectral_radiant_energy, radiant_energy / wavelength); +QUANTITY_SPEC(radiant_energy_density, radiant_energy / volume); +QUANTITY_SPEC(spectral_radiant_energy_density_in_terms_of_wavelength, radiant_energy_density / wavelength); +QUANTITY_SPEC(spectral_radiant_energy_density_in_terms_of_wavenumber, radiant_energy_density / wavenumber); +QUANTITY_SPEC(radiant_flux, power, radiant_energy / time); +inline constexpr auto radiant_power = radiant_flux; +QUANTITY_SPEC(spectral_radiant_flux, radiant_flux / wavelength); +inline constexpr auto spectral_radiant_power = spectral_radiant_flux; +QUANTITY_SPEC(radiant_intensity, radiant_flux / solid_angular_measure); +QUANTITY_SPEC(spectral_radiant_intensity, radiant_intensity / wavelength); +QUANTITY_SPEC(radiance, radiant_intensity / area); +QUANTITY_SPEC(spectral_radiance, radiance / wavelength); +QUANTITY_SPEC(irradiance, radiant_flux / area); +QUANTITY_SPEC(spectral_irradiance, irradiance / wavelength); +QUANTITY_SPEC(radiant_exitance, radiant_flux / area); +QUANTITY_SPEC(spectral_radiant_exitance, radiant_exitance / wavelength); +QUANTITY_SPEC(radiant_exposure, radiant_energy / area); +QUANTITY_SPEC(spectral_radiant_exposure, radiant_exposure / wavelength); + +} // namespace mp_units::isq diff --git a/test/static/isq_test.cpp b/test/static/isq_test.cpp index 4d7333f22..41cd4ec5e 100644 --- a/test/static/isq_test.cpp +++ b/test/static/isq_test.cpp @@ -326,6 +326,29 @@ static_assert(verify(isq::reactive_power, scalar, V* A)); static_assert(verify(isq::non_active_power, scalar, V* A)); static_assert(verify(isq::active_energy, scalar, J, W* h)); +// light and radiation +static_assert(verify(isq::speed_of_light_in_a_medium, scalar, m / s)); +static_assert(verify(isq::refractive_index, scalar, one)); +static_assert(verify(isq::radiant_energy, scalar, J, kg* m2 / s2)); +static_assert(verify(isq::spectral_radiant_energy, scalar, J / nm, kg* m / s2)); +static_assert(verify(isq::radiant_energy_density, scalar, J / m3, kg / m / s2)); +static_assert(verify(isq::spectral_radiant_energy_density_in_terms_of_wavelength, scalar, J / (m3 * nm), kg / m2 / s2)); +static_assert(verify(isq::spectral_radiant_energy_density_in_terms_of_wavenumber, scalar, J / m2, kg / s2)); +static_assert(verify(isq::radiant_flux, scalar, W, kg* m2 / s3)); +static_assert(verify(isq::radiant_power, scalar, W, kg* m2 / s3)); +static_assert(verify(isq::spectral_radiant_flux, scalar, W / nm, kg* m / s3)); +static_assert(verify(isq::spectral_radiant_power, scalar, W / nm, kg* m / s3)); +static_assert(verify(isq::radiant_intensity, scalar, W / sr, kg* m2 / s3 / sr)); +static_assert(verify(isq::spectral_radiant_intensity, scalar, W / (sr * nm), kg* m / s3 / sr)); +static_assert(verify(isq::radiance, scalar, W / (sr * m2), kg / s3 / sr)); +static_assert(verify(isq::spectral_radiance, scalar, W / (sr * m2 * nm), kg / m / s3 / sr)); +static_assert(verify(isq::irradiance, scalar, W / m2, kg / s3)); +static_assert(verify(isq::spectral_irradiance, scalar, W / (m2 * nm), kg / m / s3)); +static_assert(verify(isq::radiant_exitance, scalar, W / m2, kg / s3)); +static_assert(verify(isq::spectral_radiant_exitance, scalar, W / (m2 * nm), kg / m / s3)); +static_assert(verify(isq::radiant_exposure, scalar, J / m2, kg / s2)); +static_assert(verify(isq::spectral_radiant_exposure, scalar, J / (m2 * nm), kg / m / s2)); + // atomic and nuclear physics static_assert(verify(isq::activity, scalar, Bq, one / s)); static_assert(verify(isq::absorbed_dose, scalar, Gy, J / kg, m2 / s2));