Physical Quantities  v1.0.0
C++ library of physical quantities, physical models, and units of measure for scientific computing. https://github.com/acodcha/phq
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 
48 namespace PhQ {
49 
50 namespace Unit {
51 
52 /// \brief Thermal conductivity units.
53 enum 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).
67 template <>
68 inline constexpr const Unit::ThermalConductivity Standard<Unit::ThermalConductivity>{
70 
71 /// \brief Physical dimension set of thermal conductivity units.
72 template <>
73 inline constexpr const Dimensions RelatedDimensions<Unit::ThermalConductivity>{
74  Dimensions{Dimension::Time{-3}, Dimension::Length{1}, Dimension::Mass{1},
76  Dimension::SubstanceAmount{0}, Dimension::LuminousIntensity{0}}
77 };
78 
79 inline std::ostream& operator<<(std::ostream& stream, const Unit::ThermalConductivity unit) {
80  stream << Abbreviation(unit);
81  return stream;
82 }
83 
84 namespace Internal {
85 
86 template <>
87 inline const std::map<UnitSystem, Unit::ThermalConductivity>
88  ConsistentUnits<Unit::ThermalConductivity>{
94 };
95 
96 template <>
97 inline const std::map<Unit::ThermalConductivity, UnitSystem>
98  RelatedUnitSystems<Unit::ThermalConductivity>{
102 };
103 
104 // clang-format off
105 
106 template <>
107 inline const std::map<Unit::ThermalConductivity, std::string_view>
108  Abbreviations<Unit::ThermalConductivity>{
112 };
113 
114 template <>
115 inline const std::unordered_map<std::string_view, Unit::ThermalConductivity> Spellings<
149  {"kg·m/(s^3·degK)", Unit::ThermalConductivity::WattPerMetrePerKelvin },
152  {"kg·m/(s^3·degC)", Unit::ThermalConductivity::WattPerMetrePerKelvin },
237 };
238 
239 // clang-format on
240 
241 template <>
242 template <typename NumericType>
243 inline constexpr void
244 Conversion<Unit::ThermalConductivity, Unit::ThermalConductivity::WattPerMetrePerKelvin>::
245  FromStandard(NumericType& /*value*/) noexcept {}
246 
247 template <>
248 template <typename NumericType>
249 inline constexpr void
250 Conversion<Unit::ThermalConductivity, Unit::ThermalConductivity::WattPerMetrePerKelvin>::ToStandard(
251  NumericType& /*value*/) noexcept {}
252 
253 template <>
254 template <typename NumericType>
255 inline constexpr void
256 Conversion<Unit::ThermalConductivity, Unit::ThermalConductivity::NanowattPerMillimetrePerKelvin>::
257  FromStandard(NumericType& value) noexcept {
258  value *= static_cast<NumericType>(1.0E6L);
259 }
260 
261 template <>
262 template <typename NumericType>
263 inline constexpr void
264 Conversion<Unit::ThermalConductivity, Unit::ThermalConductivity::NanowattPerMillimetrePerKelvin>::
265  ToStandard(NumericType& value) noexcept {
266  value *= static_cast<NumericType>(1.0E-6L);
267 }
268 
269 template <>
270 template <typename NumericType>
271 inline constexpr void
272 Conversion<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 
278 template <>
279 template <typename NumericType>
280 inline constexpr void
281 Conversion<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 
287 template <typename NumericType>
288 inline 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,
293  Unit::ThermalConductivity::WattPerMetrePerKelvin>::FromStandard<NumericType> },
295  Conversions<
299  Conversions<
301  Unit::ThermalConductivity::PoundPerSecondPerRankine>::FromStandard<NumericType> },
302 };
303 
304 template <typename NumericType>
305 inline const std::map<Unit::ThermalConductivity,
306  std::function<void(NumericType* const values, const std::size_t size)>>
307  MapOfConversionsToStandard<Unit::ThermalConductivity, NumericType>{
309  Conversions<Unit::ThermalConductivity,
310  Unit::ThermalConductivity::WattPerMetrePerKelvin>::ToStandard<NumericType> },
312  Conversions<
316  Conversions<Unit::ThermalConductivity,
317  Unit::ThermalConductivity::PoundPerSecondPerRankine>::ToStandard<NumericType> },
318 };
319 
320 } // namespace Internal
321 
322 } // namespace PhQ
323 
324 #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.
ElectricCurrent
Electric current units.
Mass
Mass units.
Definition: Mass.hpp:53
Length
Length units.
Definition: Length.hpp:53
SubstanceAmount
Amount of substance units.
Temperature
Temperature units. Not to be confused with temperature difference units. For example,...
Definition: Temperature.hpp:55
Time
Time units.
Definition: Time.hpp:53
Namespace that encompasses all of the Physical Quantities library's content.
@ 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
std::ostream & operator<<(std::ostream &stream, const Acceleration< NumericType > &acceleration)