Physical Quantities  v1.0.0
C++ library of physical quantities, physical models, and units of measure for scientific computing. https://github.com/acodcha/phq
Loading...
Searching...
No Matches
ThermalConductivity.hpp
Go to the documentation of this file.
1// Copyright © 2020-2024 Alexandre Coderre-Chabot
2//
3// This file is part of Physical Quantities (PhQ), a C++ library of physical quantities, physical
4// models, and units of measure for scientific computing.
5//
6// Physical Quantities is hosted at:
7// https://github.com/acodcha/phq
8//
9// Physical Quantities is licensed under the MIT License:
10// https://mit-license.org
11//
12// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
13// associated documentation files (the "Software"), to deal in the Software without restriction,
14// including without limitation the rights to use, copy, modify, merge, publish, distribute,
15// sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
16// furnished to do so, subject to the following conditions:
17// - The above copyright notice and this permission notice shall be included in all copies or
18// substantial portions of the Software.
19// - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
20// BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
21// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
22// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM
23// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24
25#ifndef PHQ_UNIT_THERMAL_CONDUCTIVITY_HPP
26#define PHQ_UNIT_THERMAL_CONDUCTIVITY_HPP
27
28#include <cstddef>
29#include <cstdint>
30#include <functional>
31#include <map>
32#include <ostream>
33#include <string_view>
34#include <unordered_map>
35
36#include "../Base.hpp"
37#include "../Dimension/ElectricCurrent.hpp"
38#include "../Dimension/Length.hpp"
39#include "../Dimension/LuminousIntensity.hpp"
40#include "../Dimension/Mass.hpp"
41#include "../Dimension/SubstanceAmount.hpp"
42#include "../Dimension/Temperature.hpp"
43#include "../Dimension/Time.hpp"
44#include "../Dimensions.hpp"
45#include "../Unit.hpp"
46#include "../UnitSystem.hpp"
47
48namespace PhQ {
49
50namespace Unit {
51
52/// \brief Thermal conductivity units.
53enum class ThermalConductivity : int8_t {
54 /// \brief Watt per metre per kelvin (W/m/K) thermal conductivity unit.
56
57 /// \brief Nanowatt per millimetre per kelvin (nW/mm/K) thermal conductivity unit.
59
60 /// \brief Pound per second per degree Rankine (lbf/s/°R) thermal conductivity unit.
62};
63
64} // namespace Unit
65
66/// \brief Standard thermal conductivity unit: watt per metre per kelvin (W/m/K).
67template <>
68inline constexpr const Unit::ThermalConductivity Standard<Unit::ThermalConductivity>{
70
71/// \brief Physical dimension set of thermal conductivity units.
72template <>
73inline constexpr const Dimensions RelatedDimensions<Unit::ThermalConductivity>{
74 Dimensions{Dimension::Time{-3}, Dimension::Length{1}, Dimension::Mass{1},
75 Dimension::ElectricCurrent{0}, Dimension::Temperature{-1},
76 Dimension::SubstanceAmount{0}, Dimension::LuminousIntensity{0}}
77};
78
79inline std::ostream& operator<<(std::ostream& stream, const Unit::ThermalConductivity unit) {
80 stream << Abbreviation(unit);
81 return stream;
82}
83
84namespace Internal {
85
86template <>
87inline const std::map<UnitSystem, Unit::ThermalConductivity>
88 ConsistentUnits<Unit::ThermalConductivity>{
94};
95
96template <>
97inline const std::map<Unit::ThermalConductivity, UnitSystem>
98 RelatedUnitSystems<Unit::ThermalConductivity>{
102};
103
104// clang-format off
105
106template <>
107inline const std::map<Unit::ThermalConductivity, std::string_view>
108 Abbreviations<Unit::ThermalConductivity>{
112};
113
114template <>
115inline const std::unordered_map<std::string_view, Unit::ThermalConductivity> Spellings<
237};
238
239// clang-format on
240
241template <>
242template <typename NumericType>
243inline constexpr void
244Conversion<Unit::ThermalConductivity, Unit::ThermalConductivity::WattPerMetrePerKelvin>::
245 FromStandard(NumericType& /*value*/) noexcept {}
246
247template <>
248template <typename NumericType>
249inline constexpr void
250Conversion<Unit::ThermalConductivity, Unit::ThermalConductivity::WattPerMetrePerKelvin>::ToStandard(
251 NumericType& /*value*/) noexcept {}
252
253template <>
254template <typename NumericType>
255inline constexpr void
256Conversion<Unit::ThermalConductivity, Unit::ThermalConductivity::NanowattPerMillimetrePerKelvin>::
257 FromStandard(NumericType& value) noexcept {
258 value *= static_cast<NumericType>(1.0E6L);
259}
260
261template <>
262template <typename NumericType>
263inline constexpr void
264Conversion<Unit::ThermalConductivity, Unit::ThermalConductivity::NanowattPerMillimetrePerKelvin>::
265 ToStandard(NumericType& value) noexcept {
266 value *= static_cast<NumericType>(1.0E-6L);
267}
268
269template <>
270template <typename NumericType>
271inline constexpr void
272Conversion<Unit::ThermalConductivity, Unit::ThermalConductivity::PoundPerSecondPerRankine>::
273 FromStandard(NumericType& value) noexcept {
274 value /= (static_cast<NumericType>(0.45359237L) * static_cast<NumericType>(9.80665L)
275 * static_cast<NumericType>(1.8L));
276}
277
278template <>
279template <typename NumericType>
280inline constexpr void
281Conversion<Unit::ThermalConductivity, Unit::ThermalConductivity::PoundPerSecondPerRankine>::
282 ToStandard(NumericType& value) noexcept {
283 value *= static_cast<NumericType>(0.45359237L) * static_cast<NumericType>(9.80665L)
284 * static_cast<NumericType>(1.8L);
285}
286
287template <typename NumericType>
288inline const std::map<Unit::ThermalConductivity,
289 std::function<void(NumericType* values, const std::size_t size)>>
290 MapOfConversionsFromStandard<Unit::ThermalConductivity, NumericType>{
292 Conversions<Unit::ThermalConductivity, Unit::ThermalConductivity::WattPerMetrePerKelvin>::
293 FromStandard<NumericType>},
295 Conversions<Unit::ThermalConductivity,
297 FromStandard<NumericType> },
299 Conversions<Unit::ThermalConductivity, Unit::ThermalConductivity::PoundPerSecondPerRankine>::
300 FromStandard<NumericType>},
301};
302
303template <typename NumericType>
304inline const std::map<Unit::ThermalConductivity,
305 std::function<void(NumericType* const values, const std::size_t size)>>
306 MapOfConversionsToStandard<Unit::ThermalConductivity, NumericType>{
308 Conversions<Unit::ThermalConductivity, Unit::ThermalConductivity::WattPerMetrePerKelvin>::
309 ToStandard<NumericType>},
311 Conversions<Unit::ThermalConductivity,
313 ToStandard<NumericType> },
315 Conversions<Unit::ThermalConductivity, Unit::ThermalConductivity::PoundPerSecondPerRankine>::
316 ToStandard<NumericType>},
317};
318
319} // namespace Internal
320
321} // namespace PhQ
322
323#endif // PHQ_UNIT_THERMAL_CONDUCTIVITY_HPP
ThermalConductivity
Thermal conductivity units.
@ NanowattPerMillimetrePerKelvin
Nanowatt per millimetre per kelvin (nW/mm/K) thermal conductivity unit.
@ WattPerMetrePerKelvin
Watt per metre per kelvin (W/m/K) thermal conductivity unit.
@ PoundPerSecondPerRankine
Pound per second per degree Rankine (lbf/s/°R) thermal conductivity unit.
Namespace that encompasses all of the Physical Quantities library's content.
std::ostream & operator<<(std::ostream &stream, const Acceleration< NumericType > &acceleration)
@ FootPoundSecondRankine
Foot-pound-second-rankine (ft·lbf·s·°R) system.
@ MillimetreGramSecondKelvin
Millimetre-gram-second-kelvin (mm·g·s·K) system.
@ MetreKilogramSecondKelvin
Metre-kilogram-second-kelvin (m·kg·s·K) system.
@ InchPoundSecondRankine
Inch-pound-second-rankine (in·lbf·s·°R) system.
std::string_view Abbreviation(const Enumeration enumeration)
Returns the abbreviation of a given enumeration value. For example, PhQ::Abbreviation(PhQ::Unit::Time...
Definition Base.hpp:89