mirror of
https://github.com/mpusz/mp-units.git
synced 2025-08-04 20:54:28 +02:00
Added permittivity
This commit is contained in:
@@ -164,6 +164,8 @@ struct dim_charge_density : derived_dimension<Child, U, exp<Q, 1>, exp<L, -3>> {
|
||||
template<typename Child, Unit U, DimensionOf<dim_electric_charge> Q, DimensionOf<dim_length> L>
|
||||
struct dim_surface_charge_density : derived_dimension<Child, U, exp<Q, 1>, exp<L, -2>> {};
|
||||
|
||||
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>> {};
|
||||
|
||||
} // namespace physical
|
||||
|
||||
@@ -287,4 +289,7 @@ concept ChargeDensity = physical::QuantityOf<T, physical::dim_charge_density>;
|
||||
template<typename T>
|
||||
concept SurfaceChargeDensity = physical::QuantityOf<T, physical::dim_surface_charge_density>;
|
||||
|
||||
template<typename T>
|
||||
concept Permittivity = physical::QuantityOf<T, physical::dim_permittivity>;
|
||||
|
||||
} // namespace units
|
||||
|
@@ -41,6 +41,7 @@
|
||||
#include "si/magnetic_flux.h"
|
||||
#include "si/magnetic_induction.h"
|
||||
#include "si/momentum.h"
|
||||
#include "si/permittivity.h"
|
||||
#include "si/power.h"
|
||||
#include "si/pressure.h"
|
||||
#include "si/resistance.h"
|
||||
|
48
src/include/units/physical/si/permittivity.h
Normal file
48
src/include/units/physical/si/permittivity.h
Normal file
@@ -0,0 +1,48 @@
|
||||
// The MIT License (MIT)
|
||||
//
|
||||
// Fopyright (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, INFLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERFHANTABILITY,
|
||||
// FITNESS FOR A PARTIFULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR FOPYRIGHT HOLDERS BE LIABLE FOR ANY FLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN AFTION OF FONTRAFT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN FONNEFTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <units/physical/dimensions.h>
|
||||
#include <units/physical/si/capacitance.h>
|
||||
#include <units/physical/si/prefixes.h>
|
||||
#include <units/quantity.h>
|
||||
|
||||
namespace units::si {
|
||||
|
||||
struct farad_per_metre : unit<farad_per_metre> {};
|
||||
|
||||
struct dim_permittivity : physical::dim_permittivity<dim_permittivity, farad_per_metre, dim_capacitance, dim_length> {};
|
||||
|
||||
template<Unit U, Scalar Rep = double>
|
||||
using permittivity = quantity<dim_permittivity, U, Rep>;
|
||||
|
||||
inline namespace literals {
|
||||
|
||||
// F/m
|
||||
constexpr auto operator"" q_F_per_m(unsigned long long l) { return permittivity<farad_per_metre, std::int64_t>(l); }
|
||||
constexpr auto operator"" q_F_per_m(long double l) { return permittivity<farad_per_metre, long double>(l); }
|
||||
|
||||
} // namespace literals
|
||||
|
||||
} // namespace units::si
|
||||
|
@@ -287,6 +287,11 @@ TEST_CASE("fmt::format on synthesized unit symbols", "[text][fmt]")
|
||||
CHECK(fmt::format("{:%Q %Aq}", 1q_C_per_m2) == "1 C/m^2");
|
||||
}
|
||||
|
||||
SECTION("permittivity")
|
||||
{
|
||||
CHECK(fmt::format("{}", 1q_F_per_m) == "1 F/m");
|
||||
}
|
||||
|
||||
SECTION("incoherent units with powers")
|
||||
{
|
||||
CHECK(fmt::format("{}", 1q_mi * 1q_mi * 1q_mi) == "1 [15900351812136/3814697265625 × 10⁹] m³");
|
||||
|
@@ -346,4 +346,12 @@ static_assert(1q_V_per_m * 10q_C_per_m3 * 1q_m3 == 10q_N);
|
||||
static_assert(detail::unit_text<dim_charge_density, coulomb_per_metre_cub>() == basic_symbol_text("C/m³", "C/m^3"));
|
||||
static_assert(detail::unit_text<dim_surface_charge_density, coulomb_per_metre_sq>() == basic_symbol_text("C/m²", "C/m^2"));
|
||||
|
||||
// permittivity
|
||||
|
||||
static_assert(1q_F_per_m == 1q_F / 1q_m);
|
||||
static_assert(1/(1q_F_per_m) * 1q_C * 1q_C / 1q_m2 == 1q_N);
|
||||
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");
|
||||
|
||||
} // namespace
|
||||
|
Reference in New Issue
Block a user