mirror of
https://github.com/mpusz/mp-units.git
synced 2025-08-04 20:54:28 +02:00
Added thermal conductivity
This commit is contained in:
@@ -149,6 +149,9 @@ struct dim_heat_capacity : derived_dimension<Child, U, exp<E, 1>, exp<T, -1>> {}
|
||||
template<typename Child, Unit U, DimensionOf<dim_heat_capacity> C, DimensionOf<dim_mass> M>
|
||||
struct dim_specific_heat_capacity : derived_dimension<Child, U, exp<C, 1>, exp<M, -1>> {};
|
||||
|
||||
template<typename Child, Unit U, DimensionOf<dim_power> P, DimensionOf<dim_length> L, DimensionOf<dim_thermodynamic_temperature> T>
|
||||
struct dim_thermal_conductivity : derived_dimension<Child, U, exp<P, 1>, exp<L, -1>, exp<T, -1>> {};
|
||||
|
||||
} // namespace physical
|
||||
|
||||
template<typename T>
|
||||
@@ -253,4 +256,7 @@ concept HeatCapacity = physical::QuantityOf<T, physical::dim_heat_capacity>;
|
||||
template<typename T>
|
||||
concept SpecificHeatCapacity = physical::QuantityOf<T, physical::dim_specific_heat_capacity>;
|
||||
|
||||
template<typename T>
|
||||
concept ThermalConductivity = physical::QuantityOf<T, physical::dim_thermal_conductivity>;
|
||||
|
||||
} // namespace units
|
||||
|
@@ -43,6 +43,7 @@
|
||||
#include "si/pressure.h"
|
||||
#include "si/resistance.h"
|
||||
#include "si/surface_tension.h"
|
||||
#include "si/thermal_conductivity.h"
|
||||
#include "si/velocity.h"
|
||||
#include "si/voltage.h"
|
||||
#include "si/volume.h"
|
||||
|
47
src/include/units/physical/si/thermal_conductivity.h
Normal file
47
src/include/units/physical/si/thermal_conductivity.h
Normal 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/power.h>
|
||||
#include <units/physical/si/temperature.h>
|
||||
#include <units/quantity.h>
|
||||
|
||||
namespace units::si {
|
||||
|
||||
struct watt_per_metre_kelvin : unit<watt_per_metre_kelvin> {};
|
||||
|
||||
struct dim_thermal_conductivity : physical::dim_thermal_conductivity<dim_thermal_conductivity, watt_per_metre_kelvin, dim_power, dim_length, dim_thermodynamic_temperature> {};
|
||||
|
||||
template<Unit U, Scalar Rep = double>
|
||||
using thermal_conductivity = quantity<dim_thermal_conductivity, U, Rep>;
|
||||
|
||||
inline namespace literals {
|
||||
|
||||
// J/K
|
||||
constexpr auto operator"" q_W_per_m_K(unsigned long long l) { return thermal_conductivity<watt_per_metre_kelvin, std::int64_t>(l); }
|
||||
constexpr auto operator"" q_W_per_m_K(long double l) { return thermal_conductivity<watt_per_metre_kelvin, long double>(l); }
|
||||
|
||||
} // namespace literals
|
||||
|
||||
} // namespace units::si
|
@@ -268,6 +268,12 @@ TEST_CASE("fmt::format on synthesized unit symbols", "[text][fmt]")
|
||||
CHECK(fmt::format("{:%Q %Aq}", 1q_J_per_kg_K) == "1 J K^-1 kg^-1");
|
||||
}
|
||||
|
||||
SECTION("thermal conductivity")
|
||||
{
|
||||
CHECK(fmt::format("{}", 1q_W_per_m_K) == "1 W ⋅ m⁻¹ ⋅ K⁻¹");
|
||||
CHECK(fmt::format("{:%Q %Aq}", 1q_W_per_m_K) == "1 W m^-1 K^-1");
|
||||
}
|
||||
|
||||
SECTION("incoherent units with powers")
|
||||
{
|
||||
CHECK(fmt::format("{}", 1q_mi * 1q_mi * 1q_mi) == "1 [15900351812136/3814697265625 × 10⁹] m³");
|
||||
|
@@ -322,4 +322,9 @@ static_assert(1q_J_per_K * 1q_K == 1q_s * 1q_N * 1q_m_per_s);
|
||||
static_assert(detail::unit_text<dim_heat_capacity, joule_per_kelvin>() == "J/K");
|
||||
static_assert(detail::unit_text<dim_specific_heat_capacity, joule_per_kilogram_kelvin>() == basic_symbol_text("J ⋅ K⁻¹ ⋅ kg⁻¹", "J kg^-1 K^-1"));
|
||||
|
||||
// thermal conductivity
|
||||
|
||||
static_assert(20q_W_per_m_K * 10q_m * 300q_K == 60'000q_W);
|
||||
static_assert(detail::unit_text<dim_thermal_conductivity, watt_per_metre_kelvin>() == basic_symbol_text("W ⋅ m⁻¹ ⋅ K⁻¹", "W m^-1 K^-1"));
|
||||
|
||||
} // namespace
|
||||
|
Reference in New Issue
Block a user