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
SpecificHeatCapacity.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_SPECIFIC_HEAT_CAPACITY_HPP
26#define PHQ_UNIT_SPECIFIC_HEAT_CAPACITY_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 Mass-specific heat capacity units.
53enum class SpecificHeatCapacity : int8_t {
54 /// \brief Joule per kilogram per kelvin (J/kg/K) specific heat capacity unit.
56
57 /// \brief Nanojoule per gram per kelvin (nJ/g/K) specific heat capacity unit.
59
60 /// \brief Foot-pound per slug per degree Rankine (ft·lbf/slug/°R) specific heat capacity unit.
62
63 /// \brief Inch-pound per slinch per degree Rankine (in·lbf/slinch/°R) specific heat capacity
64 /// unit.
66};
67
68} // namespace Unit
69
70/// \brief Standard mass-specific heat capacity unit: joule per kilogram per kelvin (J/kg/K).
71template <>
72inline constexpr const Unit::SpecificHeatCapacity Standard<Unit::SpecificHeatCapacity>{
74
75/// \brief Physical dimension set of mass-specific heat capacity units.
76template <>
77inline constexpr const Dimensions RelatedDimensions<Unit::SpecificHeatCapacity>{
78 Dimensions{Dimension::Time{-2}, Dimension::Length{2}, Dimension::Mass{0},
79 Dimension::ElectricCurrent{0}, Dimension::Temperature{-1},
80 Dimension::SubstanceAmount{0}, Dimension::LuminousIntensity{0}}
81};
82
83inline std::ostream& operator<<(std::ostream& stream, const Unit::SpecificHeatCapacity unit) {
84 stream << Abbreviation(unit);
85 return stream;
86}
87
88namespace Internal {
89
90template <>
91inline const std::map<UnitSystem, Unit::SpecificHeatCapacity> ConsistentUnits<
97};
98
99template <>
100inline const std::map<Unit::SpecificHeatCapacity, UnitSystem> RelatedUnitSystems<
106};
107
108// clang-format off
109
110template <>
111inline const std::map<Unit::SpecificHeatCapacity, std::string_view>
112 Abbreviations<Unit::SpecificHeatCapacity>{
117};
118
119template <>
120inline const std::unordered_map<std::string_view, Unit::SpecificHeatCapacity> Spellings<
424};
425
426// clang-format on
427
428template <>
429template <typename NumericType>
430inline constexpr void
431Conversion<Unit::SpecificHeatCapacity, Unit::SpecificHeatCapacity::JoulePerKilogramPerKelvin>::
432 FromStandard(NumericType& /*value*/) noexcept {}
433
434template <>
435template <typename NumericType>
436inline constexpr void
437Conversion<Unit::SpecificHeatCapacity, Unit::SpecificHeatCapacity::JoulePerKilogramPerKelvin>::
438 ToStandard(NumericType& /*value*/) noexcept {}
439
440template <>
441template <typename NumericType>
442inline constexpr void
443Conversion<Unit::SpecificHeatCapacity, Unit::SpecificHeatCapacity::NanojoulePerGramPerKelvin>::
444 FromStandard(NumericType& value) noexcept {
445 value *= static_cast<NumericType>(1000000.0L);
446}
447
448template <>
449template <typename NumericType>
450inline constexpr void
451Conversion<Unit::SpecificHeatCapacity, Unit::SpecificHeatCapacity::NanojoulePerGramPerKelvin>::
452 ToStandard(NumericType& value) noexcept {
453 value *= static_cast<NumericType>(0.000001L);
454}
455
456template <>
457template <typename NumericType>
458inline constexpr void
459Conversion<Unit::SpecificHeatCapacity, Unit::SpecificHeatCapacity::FootPoundPerSlugPerRankine>::
460 FromStandard(NumericType& value) noexcept {
461 value /= static_cast<NumericType>(1.8L) * static_cast<NumericType>(0.3048L)
462 * static_cast<NumericType>(0.3048L);
463}
464
465template <>
466template <typename NumericType>
467inline constexpr void
468Conversion<Unit::SpecificHeatCapacity, Unit::SpecificHeatCapacity::FootPoundPerSlugPerRankine>::
469 ToStandard(NumericType& value) noexcept {
470 value *= static_cast<NumericType>(1.8L) * static_cast<NumericType>(0.3048L)
471 * static_cast<NumericType>(0.3048L);
472}
473
474template <>
475template <typename NumericType>
476inline constexpr void
477Conversion<Unit::SpecificHeatCapacity, Unit::SpecificHeatCapacity::InchPoundPerSlinchPerRankine>::
478 FromStandard(NumericType& value) noexcept {
479 value /= static_cast<NumericType>(1.8L) * static_cast<NumericType>(0.0254L)
480 * static_cast<NumericType>(0.0254L);
481}
482
483template <>
484template <typename NumericType>
485inline constexpr void
486Conversion<Unit::SpecificHeatCapacity, Unit::SpecificHeatCapacity::InchPoundPerSlinchPerRankine>::
487 ToStandard(NumericType& value) noexcept {
488 value *= static_cast<NumericType>(1.8L) * static_cast<NumericType>(0.0254L)
489 * static_cast<NumericType>(0.0254L);
490}
491
492template <typename NumericType>
493inline const std::map<Unit::SpecificHeatCapacity,
494 std::function<void(NumericType* values, const std::size_t size)>>
495 MapOfConversionsFromStandard<Unit::SpecificHeatCapacity, NumericType>{
497 Conversions<Unit::SpecificHeatCapacity,
499 FromStandard<NumericType>},
501 Conversions<Unit::SpecificHeatCapacity,
503 FromStandard<NumericType>},
505 Conversions<Unit::SpecificHeatCapacity,
507 FromStandard<NumericType>},
509 Conversions<Unit::SpecificHeatCapacity,
511 FromStandard<NumericType>},
512};
513
514template <typename NumericType>
515inline const std::map<Unit::SpecificHeatCapacity,
516 std::function<void(NumericType* const values, const std::size_t size)>>
517 MapOfConversionsToStandard<Unit::SpecificHeatCapacity, NumericType>{
519 Conversions<Unit::SpecificHeatCapacity,
522 Conversions<Unit::SpecificHeatCapacity,
525 Conversions<Unit::SpecificHeatCapacity,
527 ToStandard<NumericType> },
529 Conversions<Unit::SpecificHeatCapacity,
531 ToStandard<NumericType> },
532};
533
534} // namespace Internal
535
536} // namespace PhQ
537
538#endif // PHQ_UNIT_SPECIFIC_HEAT_CAPACITY_HPP
SpecificHeatCapacity
Mass-specific heat capacity units.
@ NanojoulePerGramPerKelvin
Nanojoule per gram per kelvin (nJ/g/K) specific heat capacity unit.
@ InchPoundPerSlinchPerRankine
Inch-pound per slinch per degree Rankine (in·lbf/slinch/°R) specific heat capacity unit.
@ JoulePerKilogramPerKelvin
Joule per kilogram per kelvin (J/kg/K) specific heat capacity unit.
@ FootPoundPerSlugPerRankine
Foot-pound per slug per degree Rankine (ft·lbf/slug/°R) specific heat capacity 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