Added dynamic viscosity

This commit is contained in:
rbrugo
2020-04-07 23:56:00 +02:00
committed by Mateusz Pusz
parent 4b4cc70764
commit 07b5364c97
5 changed files with 65 additions and 0 deletions

View File

@@ -140,6 +140,9 @@ struct dim_concentration : derived_dimension<Child, U, exp<M, 1>, exp<L, -3>> {}
template<typename Child, Unit U, DimensionOf<dim_luminous_intensity> I, DimensionOf<dim_length> L>
struct dim_luminance : derived_dimension<Child, U, exp<I, 1>, exp<L, -2>> {};
template<typename Child, Unit U, DimensionOf<dim_pressure> P, DimensionOf<dim_time> T>
struct dim_dynamic_viscosity : derived_dimension<Child, U, exp<P, 1>, exp<T, 1>> {};
} // namespace physical
template<typename T>
@@ -235,4 +238,7 @@ concept Concentration = physical::QuantityOf<T, physical::dim_concentration>;
template<typename T>
concept Luminance = physical::QuantityOf<T, physical::dim_luminance>;
template<typename T>
concept DynamicViscosity = physical::QuantityOf<T, physical::dim_dynamic_viscosity>;
} // namespace units

View File

@@ -31,6 +31,7 @@
#include "si/constants.h"
#include "si/current_density.h"
#include "si/density.h"
#include "si/dynamic_viscosity.h"
#include "si/frequency.h"
#include "si/inductance.h"
#include "si/luminance.h"

View File

@@ -0,0 +1,47 @@
// 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 <units/physical/dimensions.h>
#include <units/physical/si/time.h>
#include <units/physical/si/pressure.h>
#include <units/quantity.h>
namespace units::si {
struct pascal_second : unit<pascal_second> {};
struct dim_dynamic_viscosity : physical::dim_dynamic_viscosity<dim_dynamic_viscosity, pascal_second, dim_pressure, dim_time> {};
template<Unit U, Scalar Rep = double>
using dynamic_viscosity = quantity<dim_dynamic_viscosity, U, Rep>;
inline namespace literals {
// Pa·s
constexpr auto operator"" q_Pa_s(unsigned long long l) { return dynamic_viscosity<pascal_second, std::int64_t>(l); }
constexpr auto operator"" q_Pa_s(long double l) { return dynamic_viscosity<pascal_second, long double>(l); }
} // namespace literals
} // namespace units::si

View File

@@ -251,6 +251,12 @@ TEST_CASE("fmt::format on synthesized unit symbols", "[text][fmt]")
CHECK(fmt::format("{:%Q %Aq}", 1q_cd_per_m2) == "1 cd/m^2");
}
SECTION("dynamic viscosity")
{
CHECK(fmt::format("{}", 1q_Pa_s) == "1 Pa ⋅ s");
CHECK(fmt::format("{:%Q %Aq}", 1q_Pa_s) == "1 Pa s");
}
SECTION("incoherent units with powers")
{
CHECK(fmt::format("{}", 1q_mi * 1q_mi * 1q_mi) == "1 [15900351812136/3814697265625 × 10⁹] m³");

View File

@@ -309,4 +309,9 @@ static_assert(detail::unit_text<dim_concentration, ampere_per_metre_sq>() == bas
static_assert(1q_cd_per_m2 == 1q_cd / 1q_m2);
static_assert(detail::unit_text<dim_luminance, candela_per_metre_sq>() == basic_symbol_text("cd/m²", "cd/m^2"));
// dynamic viscosity
static_assert(1q_Pa_s == 1q_N * 1q_s / 1q_m2);
static_assert(detail::unit_text<dim_dynamic_viscosity, pascal_second>() == basic_symbol_text("Pa ⋅ s", "Pa s"));
} // namespace