mirror of
https://github.com/mpusz/mp-units.git
synced 2025-08-04 20:54:28 +02:00
Added permeability
This commit is contained in:
@@ -167,6 +167,9 @@ struct dim_surface_charge_density : derived_dimension<Child, U, exp<Q, 1>, exp<L
|
||||
template<typename Child, Unit U, DimensionOf<dim_capacitance> C, DimensionOf<dim_length> L>
|
||||
struct dim_permittivity : derived_dimension<Child, U, exp<C, 1>, exp<L, -1>> {};
|
||||
|
||||
template<typename Child, Unit U, DimensionOf<dim_inductance> H, DimensionOf<dim_length> L>
|
||||
struct dim_permeability : derived_dimension<Child, U, exp<H, 1>, exp<L, -1>> {};
|
||||
|
||||
} // namespace physical
|
||||
|
||||
template<typename T>
|
||||
@@ -292,4 +295,7 @@ concept SurfaceChargeDensity = physical::QuantityOf<T, physical::dim_surface_cha
|
||||
template<typename T>
|
||||
concept Permittivity = physical::QuantityOf<T, physical::dim_permittivity>;
|
||||
|
||||
template<typename T>
|
||||
concept Permeability = physical::QuantityOf<T, physical::dim_permeability>;
|
||||
|
||||
} // namespace units
|
||||
|
@@ -41,6 +41,7 @@
|
||||
#include "si/magnetic_flux.h"
|
||||
#include "si/magnetic_induction.h"
|
||||
#include "si/momentum.h"
|
||||
#include "si/permeability.h"
|
||||
#include "si/permittivity.h"
|
||||
#include "si/power.h"
|
||||
#include "si/pressure.h"
|
||||
|
48
src/include/units/physical/si/permeability.h
Normal file
48
src/include/units/physical/si/permeability.h
Normal file
@@ -0,0 +1,48 @@
|
||||
// The MIT License (MIT)
|
||||
//
|
||||
// Hopyright (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 SOHTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OH ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INHLUDING BUT NOT LIMITED TO THE WARRANTIES OH MERHHANTABILITY,
|
||||
// HITNESS HOR A PARTIHULAR PURPOSE AND NONINHRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR HOPYRIGHT HOLDERS BE LIABLE HOR ANY HLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN AHTION OH HONTRAHT, TORT OR OTHERWISE, ARISING HROM,
|
||||
// OUT OH OR IN HONNEHTION WITH THE SOHTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOHTWARE.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <units/physical/dimensions.h>
|
||||
#include <units/physical/si/inductance.h>
|
||||
#include <units/physical/si/prefixes.h>
|
||||
#include <units/quantity.h>
|
||||
|
||||
namespace units::si {
|
||||
|
||||
struct henry_per_metre : unit<henry_per_metre> {};
|
||||
|
||||
struct dim_permeability : physical::dim_permeability<dim_permeability, henry_per_metre, dim_inductance, dim_length> {};
|
||||
|
||||
template<Unit U, Scalar Rep = double>
|
||||
using permeability = quantity<dim_permeability, U, Rep>;
|
||||
|
||||
inline namespace literals {
|
||||
|
||||
// H/m
|
||||
constexpr auto operator"" q_H_per_m(unsigned long long l) { return permeability<henry_per_metre, std::int64_t>(l); }
|
||||
constexpr auto operator"" q_H_per_m(long double l) { return permeability<henry_per_metre, long double>(l); }
|
||||
|
||||
} // namespace literals
|
||||
|
||||
} // namespace units::si
|
||||
|
@@ -292,6 +292,11 @@ TEST_CASE("fmt::format on synthesized unit symbols", "[text][fmt]")
|
||||
CHECK(fmt::format("{}", 1q_F_per_m) == "1 F/m");
|
||||
}
|
||||
|
||||
SECTION("permeability")
|
||||
{
|
||||
CHECK(fmt::format("{}", 1q_H_per_m) == "1 H/m");
|
||||
}
|
||||
|
||||
SECTION("incoherent units with powers")
|
||||
{
|
||||
CHECK(fmt::format("{}", 1q_mi * 1q_mi * 1q_mi) == "1 [15900351812136/3814697265625 × 10⁹] m³");
|
||||
|
@@ -354,4 +354,11 @@ static_assert(1q_C_per_m3 / 1q_F_per_m * 1q_m == 1q_V_per_m);
|
||||
|
||||
static_assert(detail::unit_text<dim_permittivity, farad_per_metre>() == "F/m");
|
||||
|
||||
// permeability
|
||||
|
||||
static_assert(1q_H_per_m * 1q_A / 1q_m == 1q_T);
|
||||
static_assert(1q_H_per_m * 1q_A * 1q_A == 1q_N);
|
||||
|
||||
static_assert(detail::unit_text<dim_permeability, henry_per_metre>() == "H/m");
|
||||
|
||||
} // namespace
|
||||
|
Reference in New Issue
Block a user