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
ReciprocalTemperature.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_RECIPROCAL_TEMPERATURE_HPP
26#define PHQ_UNIT_RECIPROCAL_TEMPERATURE_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 Reciprocal temperature units. Reciprocal temperature is the inverse of temperature.
53enum class ReciprocalTemperature : int8_t {
54 /// \brief Per kelvin (/K) reciprocal temperature unit.
56
57 /// \brief Per degree Celsius (/°C) reciprocal temperature unit.
59
60 /// \brief Per degree Rankine (/°R) reciprocal temperature unit.
62
63 /// \brief Per degree Fahrenheit (/°F) reciprocal temperature unit.
65};
66
67} // namespace Unit
68
69/// \brief Standard reciprocal temperature unit: per kelvin (/K).
70template <>
71inline constexpr const Unit::ReciprocalTemperature Standard<Unit::ReciprocalTemperature>{
73
74/// \brief Physical dimension set of reciprocal temperature units.
75template <>
76inline constexpr const Dimensions RelatedDimensions<Unit::ReciprocalTemperature>{
77 Dimensions{Dimension::Time{0}, Dimension::Length{0}, Dimension::Mass{0},
78 Dimension::ElectricCurrent{0}, Dimension::Temperature{-1},
79 Dimension::SubstanceAmount{0}, Dimension::LuminousIntensity{0}}
80};
81
82inline std::ostream& operator<<(std::ostream& stream, const Unit::ReciprocalTemperature unit) {
83 stream << Abbreviation(unit);
84 return stream;
85}
86
87namespace Internal {
88
89template <>
90inline const std::map<UnitSystem, Unit::ReciprocalTemperature>
91 ConsistentUnits<Unit::ReciprocalTemperature>{
96};
97
98template <>
99inline const std::map<Unit::ReciprocalTemperature, UnitSystem>
100 RelatedUnitSystems<Unit::ReciprocalTemperature>{};
101
102// clang-format off
103
104template <>
105inline const std::map<Unit::ReciprocalTemperature, std::string_view>
106 Abbreviations<Unit::ReciprocalTemperature>{
111};
112
113template <>
114inline const std::unordered_map<std::string_view, Unit::ReciprocalTemperature>
115 Spellings<Unit::ReciprocalTemperature>{
140};
141
142// clang-format on
143
144template <>
145template <typename NumericType>
146inline constexpr void
147Conversion<Unit::ReciprocalTemperature, Unit::ReciprocalTemperature::PerKelvin>::FromStandard(
148 NumericType& /*value*/) noexcept {}
149
150template <>
151template <typename NumericType>
152inline constexpr void
153Conversion<Unit::ReciprocalTemperature, Unit::ReciprocalTemperature::PerKelvin>::ToStandard(
154 NumericType& /*value*/) noexcept {}
155
156template <>
157template <typename NumericType>
158inline constexpr void
159Conversion<Unit::ReciprocalTemperature, Unit::ReciprocalTemperature::PerCelsius>::FromStandard(
160 NumericType& /*value*/) noexcept {}
161
162template <>
163template <typename NumericType>
164inline constexpr void
165Conversion<Unit::ReciprocalTemperature, Unit::ReciprocalTemperature::PerCelsius>::ToStandard(
166 NumericType& /*value*/) noexcept {}
167
168template <>
169template <typename NumericType>
170inline constexpr void
171Conversion<Unit::ReciprocalTemperature, Unit::ReciprocalTemperature::PerRankine>::FromStandard(
172 NumericType& value) noexcept {
173 value /= static_cast<NumericType>(1.8L);
174}
175
176template <>
177template <typename NumericType>
178inline constexpr void
179Conversion<Unit::ReciprocalTemperature, Unit::ReciprocalTemperature::PerRankine>::ToStandard(
180 NumericType& value) noexcept {
181 value *= static_cast<NumericType>(1.8L);
182}
183
184template <>
185template <typename NumericType>
186inline constexpr void
187Conversion<Unit::ReciprocalTemperature, Unit::ReciprocalTemperature::PerFahrenheit>::FromStandard(
188 NumericType& value) noexcept {
189 value /= static_cast<NumericType>(1.8L);
190}
191
192template <>
193template <typename NumericType>
194inline constexpr void
195Conversion<Unit::ReciprocalTemperature, Unit::ReciprocalTemperature::PerFahrenheit>::ToStandard(
196 NumericType& value) noexcept {
197 value *= static_cast<NumericType>(1.8L);
198}
199
200template <typename NumericType>
201inline const std::map<Unit::ReciprocalTemperature,
202 std::function<void(NumericType* values, const std::size_t size)>>
203 MapOfConversionsFromStandard<Unit::ReciprocalTemperature, NumericType>{
205 Conversions<Unit::ReciprocalTemperature, Unit::ReciprocalTemperature::PerKelvin>::
206 FromStandard<NumericType>},
208 Conversions<Unit::ReciprocalTemperature, Unit::ReciprocalTemperature::PerCelsius>::
209 FromStandard<NumericType>},
211 Conversions<Unit::ReciprocalTemperature, Unit::ReciprocalTemperature::PerRankine>::
212 FromStandard<NumericType>},
214 Conversions<Unit::ReciprocalTemperature, Unit::ReciprocalTemperature::PerFahrenheit>::
215 FromStandard<NumericType>},
216};
217
218template <typename NumericType>
219inline const std::map<Unit::ReciprocalTemperature,
220 std::function<void(NumericType* const values, const std::size_t size)>>
221 MapOfConversionsToStandard<Unit::ReciprocalTemperature, NumericType>{
223 Conversions<Unit::ReciprocalTemperature, Unit::ReciprocalTemperature::PerKelvin>::
224 ToStandard<NumericType>},
226 Conversions<Unit::ReciprocalTemperature, Unit::ReciprocalTemperature::PerCelsius>::
227 ToStandard<NumericType>},
229 Conversions<Unit::ReciprocalTemperature, Unit::ReciprocalTemperature::PerRankine>::
230 ToStandard<NumericType>},
232 Conversions<Unit::ReciprocalTemperature, Unit::ReciprocalTemperature::PerFahrenheit>::
233 ToStandard<NumericType>},
234};
235
236} // namespace Internal
237
238} // namespace PhQ
239
240#endif // PHQ_UNIT_RECIPROCAL_TEMPERATURE_HPP
ReciprocalTemperature
Reciprocal temperature units. Reciprocal temperature is the inverse of temperature.
@ PerKelvin
Per kelvin (/K) reciprocal temperature unit.
@ PerCelsius
Per degree Celsius (/°C) reciprocal temperature unit.
@ PerFahrenheit
Per degree Fahrenheit (/°F) reciprocal temperature unit.
@ PerRankine
Per degree Rankine (/°R) reciprocal temperature 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