Skip to content

Commit

Permalink
feat: some light and radiation ISQ quantities added
Browse files Browse the repository at this point in the history
  • Loading branch information
mpusz committed Feb 24, 2024
1 parent f1639a0 commit 10ee4cc
Show file tree
Hide file tree
Showing 4 changed files with 84 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/systems/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions src/systems/include/mp-units/systems/isq/isq.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
#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/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>
Expand Down
59 changes: 59 additions & 0 deletions src/systems/include/mp-units/systems/isq/light_and_radiation.h
Original file line number Diff line number Diff line change
@@ -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 <mp-units/bits/module_macros.h>
#include <mp-units/systems/isq/base_quantities.h>
#include <mp-units/systems/isq/electromagnetism.h>
#include <mp-units/systems/isq/space_and_time.h>

#ifndef MP_UNITS_IN_MODULE_INTERFACE
#include <mp-units/quantity_spec.h>
#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
23 changes: 23 additions & 0 deletions test/static/isq_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down

0 comments on commit 10ee4cc

Please sign in to comment.