Physical Quantities  v1.0.0
C++ library of physical quantities, physical models, and units of measure for scientific computing. https://github.com/acodcha/phq
SpecificIsobaricHeatCapacity.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_SPECIFIC_ISOBARIC_HEAT_CAPACITY_HPP
26 #define PHQ_SPECIFIC_ISOBARIC_HEAT_CAPACITY_HPP
27 
28 #include <cstddef>
29 #include <functional>
30 #include <ostream>
31 
32 #include "DimensionalScalar.hpp"
33 #include "HeatCapacityRatio.hpp"
34 #include "IsobaricHeatCapacity.hpp"
37 
38 namespace PhQ {
39 
40 // Forward declaration for class PhQ::SpecificIsobaricHeatCapacity.
41 template <typename NumericType>
42 class DynamicViscosity;
43 
44 // Forward declaration for class PhQ::SpecificIsobaricHeatCapacity.
45 template <typename NumericType>
46 class MassDensity;
47 
48 // Forward declaration for class PhQ::SpecificIsobaricHeatCapacity.
49 template <typename NumericType>
50 class PrandtlNumber;
51 
52 // Forward declaration for class PhQ::SpecificIsobaricHeatCapacity.
53 template <typename NumericType>
54 class ScalarThermalConductivity;
55 
56 // Forward declaration for class PhQ::SpecificIsobaricHeatCapacity.
57 template <typename NumericType>
58 class ThermalDiffusivity;
59 
60 /// \brief Mass-specific isobaric heat capacity, also known as mass-specific heat capacity at
61 /// constant pressure, or isobaric heat capacity per unit mass; see PhQ::IsobaricHeatCapacity and
62 /// PhQ::Mass.
63 template <typename NumericType = double>
65  : public DimensionalScalar<Unit::SpecificHeatCapacity, NumericType> {
66 public:
67  /// \brief Default constructor. Constructs a specific isobaric heat capacity with an uninitialized
68  /// value.
70 
71  /// \brief Constructor. Constructs a specific isobaric heat capacity with a given value expressed
72  /// in a given specific heat capacity unit.
74  : DimensionalScalar<Unit::SpecificHeatCapacity, NumericType>(value, unit) {}
75 
76  /// \brief Constructor. Constructs a specific isobaric heat capacity from a given specific gas
77  /// constant and specific isochoric heat capacity using Mayer's relation.
79  const SpecificIsochoricHeatCapacity<NumericType>& specific_isochoric_heat_capacity,
80  const SpecificGasConstant<NumericType>& specific_gas_constant);
81 
82  /// \brief Constructor. Constructs a specific isobaric heat capacity from a given specific gas
83  /// constant and heat capacity ratio using the definition of the heat capacity ratio and Mayer's
84  /// relation.
86  const HeatCapacityRatio<NumericType>& heat_capacity_ratio,
87  const SpecificGasConstant<NumericType>& specific_gas_constant);
88 
89  /// \brief Constructor. Constructs a specific isobaric heat capacity from a given specific
90  /// isochoric heat capacity and heat capacity ratio using the definition of the heat capacity
91  /// ratio.
93  const HeatCapacityRatio<NumericType>& heat_capacity_ratio,
94  const SpecificIsochoricHeatCapacity<NumericType>& specific_isochoric_heat_capacity)
95  : SpecificIsobaricHeatCapacity<NumericType>(
96  heat_capacity_ratio.Value() * specific_isochoric_heat_capacity.Value()) {}
97 
98  /// \brief Constructor. Constructs a specific isobaric heat capacity from a given isobaric heat
99  /// capacity and mass using the definition of the specific isobaric heat capacity.
101  const IsobaricHeatCapacity<NumericType>& isobaric_heat_capacity,
102  const Mass<NumericType>& mass)
103  : SpecificIsobaricHeatCapacity<NumericType>(isobaric_heat_capacity.Value() / mass.Value()) {}
104 
105  /// \brief Constructor. Constructs a specific isobaric heat capacity from a given scalar thermal
106  /// conductivity mass density, and thermal diffusivity using the definition of the specific
107  /// isobaric heat capacity and Fourier's law of heat conduction.
109  const ScalarThermalConductivity<NumericType>& scalar_thermal_conductivity,
110  const MassDensity<NumericType>& mass_density,
111  const ThermalDiffusivity<NumericType>& thermal_diffusivity);
112 
113  /// \brief Constructor. Constructs a specific isobaric heat capacity from a given Prandtl number,
114  /// scalar thermal conductivity, and dynamic viscosity using the definition of the Prandtl number.
116  const PrandtlNumber<NumericType>& prandtl_number,
117  const ScalarThermalConductivity<NumericType>& scalar_thermal_conductivity,
118  const DynamicViscosity<NumericType>& dynamic_viscosity);
119 
120  /// \brief Destructor. Destroys this specific isobaric heat capacity.
121  ~SpecificIsobaricHeatCapacity() noexcept = default;
122 
123  /// \brief Copy constructor. Constructs a specific isobaric heat capacity by copying another one.
125  const SpecificIsobaricHeatCapacity<NumericType>& other) = default;
126 
127  /// \brief Copy constructor. Constructs a specific isobaric heat capacity by copying another one.
128  template <typename OtherNumericType>
129  explicit constexpr SpecificIsobaricHeatCapacity(
130  const SpecificIsobaricHeatCapacity<OtherNumericType>& other)
131  : SpecificIsobaricHeatCapacity(static_cast<NumericType>(other.Value())) {}
132 
133  /// \brief Move constructor. Constructs a specific isobaric heat capacity by moving another one.
135  SpecificIsobaricHeatCapacity<NumericType>&& other) noexcept = default;
136 
137  /// \brief Copy assignment operator. Assigns this specific isobaric heat capacity by copying
138  /// another one.
140  const SpecificIsobaricHeatCapacity<NumericType>& other) = default;
141 
142  /// \brief Copy assignment operator. Assigns this specific isobaric heat capacity by copying
143  /// another one.
144  template <typename OtherNumericType>
147  this->value = static_cast<NumericType>(other.Value());
148  return *this;
149  }
150 
151  /// \brief Move assignment operator. Assigns this specific isobaric heat capacity by moving
152  /// another one.
154  SpecificIsobaricHeatCapacity<NumericType>&& other) noexcept = default;
155 
156  /// \brief Statically creates a specific isobaric heat capacity of zero.
157  [[nodiscard]] static constexpr SpecificIsobaricHeatCapacity<NumericType> Zero() {
158  return SpecificIsobaricHeatCapacity<NumericType>{static_cast<NumericType>(0)};
159  }
160 
161  /// \brief Statically creates a specific isobaric heat capacity with a given value expressed in a
162  /// given specific heat capacity unit.
163  template <Unit::SpecificHeatCapacity Unit>
164  [[nodiscard]] static constexpr SpecificIsobaricHeatCapacity<NumericType> Create(
165  const NumericType value) {
167  ConvertStatically<Unit::SpecificHeatCapacity, Unit, Standard<Unit::SpecificHeatCapacity>>(
168  value)};
169  }
170 
172  const SpecificIsobaricHeatCapacity<NumericType>& specific_isobaric_heat_capacity) const {
174  this->value + specific_isobaric_heat_capacity.value};
175  }
176 
178  const SpecificIsobaricHeatCapacity<NumericType>& specific_isobaric_heat_capacity) const {
180  this->value - specific_isobaric_heat_capacity.value};
181  }
182 
184  const SpecificIsochoricHeatCapacity<NumericType>& specific_isochoric_heat_capacity) const;
185 
187  const SpecificGasConstant<NumericType>& specific_gas_constant) const;
188 
189  constexpr SpecificIsobaricHeatCapacity<NumericType> operator*(const NumericType number) const {
190  return SpecificIsobaricHeatCapacity<NumericType>{this->value * number};
191  }
192 
194  return IsobaricHeatCapacity<NumericType>{*this, mass};
195  }
196 
197  constexpr SpecificIsobaricHeatCapacity<NumericType> operator/(const NumericType number) const {
198  return SpecificIsobaricHeatCapacity<NumericType>{this->value / number};
199  }
200 
201  constexpr NumericType operator/(
202  const SpecificIsobaricHeatCapacity<NumericType>& specific_isobaric_heat_capacity)
203  const noexcept {
204  return this->value / specific_isobaric_heat_capacity.value;
205  }
206 
208  const SpecificIsochoricHeatCapacity<NumericType>& specific_isochoric_heat_capacity) const {
209  return HeatCapacityRatio<NumericType>{*this, specific_isochoric_heat_capacity};
210  }
211 
213  const HeatCapacityRatio<NumericType>& heat_capacity_ratio) const {
214  return SpecificIsochoricHeatCapacity<NumericType>{*this, heat_capacity_ratio};
215  }
216 
217  constexpr void operator+=(
218  const SpecificIsobaricHeatCapacity<NumericType>& specific_isobaric_heat_capacity) noexcept {
219  this->value += specific_isobaric_heat_capacity.value;
220  }
221 
222  constexpr void operator-=(
223  const SpecificIsobaricHeatCapacity<NumericType>& specific_isobaric_heat_capacity) noexcept {
224  this->value -= specific_isobaric_heat_capacity.value;
225  }
226 
227  constexpr void operator*=(const NumericType number) noexcept {
228  this->value *= number;
229  }
230 
231  constexpr void operator/=(const NumericType number) noexcept {
232  this->value /= number;
233  }
234 
235 private:
236  /// \brief Constructor. Constructs a specific isobaric heat capacity with a given value expressed
237  /// in the standard specific heat capacity unit.
238  explicit constexpr SpecificIsobaricHeatCapacity(const NumericType value)
239  : DimensionalScalar<Unit::SpecificHeatCapacity, NumericType>(value) {}
240 };
241 
242 template <typename NumericType>
243 inline constexpr bool operator==(const SpecificIsobaricHeatCapacity<NumericType>& left,
244  const SpecificIsobaricHeatCapacity<NumericType>& right) noexcept {
245  return left.Value() == right.Value();
246 }
247 
248 template <typename NumericType>
249 inline constexpr bool operator!=(const SpecificIsobaricHeatCapacity<NumericType>& left,
250  const SpecificIsobaricHeatCapacity<NumericType>& right) noexcept {
251  return left.Value() != right.Value();
252 }
253 
254 template <typename NumericType>
255 inline constexpr bool operator<(const SpecificIsobaricHeatCapacity<NumericType>& left,
256  const SpecificIsobaricHeatCapacity<NumericType>& right) noexcept {
257  return left.Value() < right.Value();
258 }
259 
260 template <typename NumericType>
261 inline constexpr bool operator>(const SpecificIsobaricHeatCapacity<NumericType>& left,
262  const SpecificIsobaricHeatCapacity<NumericType>& right) noexcept {
263  return left.Value() > right.Value();
264 }
265 
266 template <typename NumericType>
267 inline constexpr bool operator<=(const SpecificIsobaricHeatCapacity<NumericType>& left,
268  const SpecificIsobaricHeatCapacity<NumericType>& right) noexcept {
269  return left.Value() <= right.Value();
270 }
271 
272 template <typename NumericType>
273 inline constexpr bool operator>=(const SpecificIsobaricHeatCapacity<NumericType>& left,
274  const SpecificIsobaricHeatCapacity<NumericType>& right) noexcept {
275  return left.Value() >= right.Value();
276 }
277 
278 template <typename NumericType>
279 inline std::ostream& operator<<(
280  std::ostream& stream,
281  const SpecificIsobaricHeatCapacity<NumericType>& specific_isobaric_heat_capacity) {
282  stream << specific_isobaric_heat_capacity.Print();
283  return stream;
284 }
285 
286 template <typename NumericType>
288  const NumericType number,
289  const SpecificIsobaricHeatCapacity<NumericType>& specific_isobaric_heat_capacity) {
290  return specific_isobaric_heat_capacity * number;
291 }
292 
293 template <typename NumericType>
295  const SpecificIsobaricHeatCapacity<NumericType>& specific_isobaric_heat_capacity,
296  const SpecificIsochoricHeatCapacity<NumericType>& specific_isochoric_heat_capacity)
297  : HeatCapacityRatio<NumericType>(
298  specific_isobaric_heat_capacity.Value() / specific_isochoric_heat_capacity.Value()) {}
299 
300 template <typename NumericType>
301 inline constexpr Mass<NumericType>::Mass(
302  const IsobaricHeatCapacity<NumericType>& isobaric_heat_capacity,
303  const SpecificIsobaricHeatCapacity<NumericType>& specific_isobaric_heat_capacity)
304  : Mass<NumericType>(isobaric_heat_capacity.Value() / specific_isobaric_heat_capacity.Value()) {}
305 
306 template <typename NumericType>
308  const SpecificIsobaricHeatCapacity<NumericType>& specific_isobaric_heat_capacity,
309  const Mass<NumericType>& mass)
310  : IsobaricHeatCapacity<NumericType>(specific_isobaric_heat_capacity.Value() * mass.Value()) {}
311 
312 template <typename NumericType>
314  const SpecificIsobaricHeatCapacity<NumericType>& specific_isobaric_heat_capacity,
315  const HeatCapacityRatio<NumericType>& heat_capacity_ratio)
316  : SpecificIsochoricHeatCapacity<NumericType>(
317  specific_isobaric_heat_capacity.Value() / heat_capacity_ratio.Value()) {}
318 
319 template <typename NumericType>
321  const SpecificIsobaricHeatCapacity<NumericType>& specific_isobaric_heat_capacity) const {
322  return IsobaricHeatCapacity<NumericType>{specific_isobaric_heat_capacity, *this};
323 }
324 
325 template <typename NumericType>
326 inline constexpr SpecificIsobaricHeatCapacity<NumericType>
328  const SpecificIsochoricHeatCapacity<NumericType>& specific_isochoric_heat_capacity) const {
329  return SpecificIsobaricHeatCapacity<NumericType>{*this, specific_isochoric_heat_capacity};
330 }
331 
332 template <typename NumericType>
335  const HeatCapacityRatio<NumericType>& heat_capacity_ratio) const {
336  return SpecificIsobaricHeatCapacity<NumericType>{heat_capacity_ratio, *this};
337 }
338 
339 template <typename NumericType>
342  return SpecificIsobaricHeatCapacity<NumericType>{*this, mass};
343 }
344 
345 template <typename NumericType>
347  const SpecificIsobaricHeatCapacity<NumericType>& specific_isobaric_heat_capacity) const {
348  return Mass<NumericType>{*this, specific_isobaric_heat_capacity};
349 }
350 
351 } // namespace PhQ
352 
353 namespace std {
354 
355 template <typename NumericType>
356 struct hash<PhQ::SpecificIsobaricHeatCapacity<NumericType>> {
357  inline size_t operator()(
358  const PhQ::SpecificIsobaricHeatCapacity<NumericType>& specific_isobaric_heat_capacity) const {
359  return hash<NumericType>()(specific_isobaric_heat_capacity.Value());
360  }
361 };
362 
363 } // namespace std
364 
365 #endif // PHQ_SPECIFIC_ISOBARIC_HEAT_CAPACITY_HPP
Abstract base class that represents any dimensional scalar physical quantity. Such a physical quantit...
double value
Value of this physical quantity expressed in its standard unit of measure.
constexpr double Value() const noexcept
Value of this physical quantity expressed in its standard unit of measure.
static constexpr Unit::SpecificHeatCapacity Unit()
Standard unit of measure for this physical quantity. This physical quantity's value is stored interna...
std::string Print() const
Prints this physical quantity as a string. This physical quantity's value is expressed in its standar...
Dynamic viscosity, also known as molecular dynamic viscosity. Dynamic viscosity is the relationship b...
Heat capacity ratio, also known as ratio of specific heats, adiabatic index, or Laplace's coefficient...
constexpr HeatCapacityRatio< NumericType > operator*(const NumericType number) const
HeatCapacityRatio()=default
Default constructor. Constructs a heat capacity ratio ratio with an uninitialized value.
Isobaric heat capacity, also known as heat capacity at constant pressure. For the mass-specific isoba...
IsobaricHeatCapacity()=default
Default constructor. Constructs an isobaric heat capacity with an uninitialized value.
constexpr IsobaricHeatCapacity< NumericType > operator/(const NumericType number) const
Mass density. Mass per unit volume; see PhQ::Mass and PhQ::Volume.
Definition: MassDensity.hpp:83
Mass. For the time rate of change of mass, see PhQ::MassRate; see also PhQ::Time and PhQ::Frequency.
Definition: Mass.hpp:100
Mass()=default
Default constructor. Constructs a mass with an uninitialized value.
constexpr Mass< NumericType > operator*(const NumericType number) const
Definition: Mass.hpp:192
Prandtl number of a fluid. Represents the ratio of the momentum diffusivity to the thermal diffusivit...
Scalar component or resultant of a three-dimensional Euclidean thermal conductivity symmetric dyadic ...
Mass-specific gas constant of a gas. Gas constant per unit mass; see PhQ::GasConstant and PhQ::Mass....
Mass-specific isobaric heat capacity, also known as mass-specific heat capacity at constant pressure,...
SpecificIsobaricHeatCapacity()=default
Default constructor. Constructs a specific isobaric heat capacity with an uninitialized value.
constexpr SpecificIsobaricHeatCapacity(const NumericType value)
Constructor. Constructs a specific isobaric heat capacity with a given value expressed in the standar...
constexpr SpecificIsobaricHeatCapacity(const HeatCapacityRatio< NumericType > &heat_capacity_ratio, const SpecificIsochoricHeatCapacity< NumericType > &specific_isochoric_heat_capacity)
Constructor. Constructs a specific isobaric heat capacity from a given specific isochoric heat capaci...
constexpr SpecificIsobaricHeatCapacity< NumericType > operator/(const NumericType number) const
constexpr SpecificIsobaricHeatCapacity< NumericType > operator-(const SpecificIsobaricHeatCapacity< NumericType > &specific_isobaric_heat_capacity) const
constexpr IsobaricHeatCapacity< NumericType > operator*(const Mass< NumericType > &mass) const
constexpr SpecificIsobaricHeatCapacity(const IsobaricHeatCapacity< NumericType > &isobaric_heat_capacity, const Mass< NumericType > &mass)
Constructor. Constructs a specific isobaric heat capacity from a given isobaric heat capacity and mas...
constexpr SpecificIsobaricHeatCapacity< NumericType > & operator=(SpecificIsobaricHeatCapacity< NumericType > &&other) noexcept=default
Move assignment operator. Assigns this specific isobaric heat capacity by moving another one.
constexpr SpecificIsobaricHeatCapacity< NumericType > & operator=(const SpecificIsobaricHeatCapacity< OtherNumericType > &other)
Copy assignment operator. Assigns this specific isobaric heat capacity by copying another one.
constexpr void operator*=(const NumericType number) noexcept
constexpr NumericType operator/(const SpecificIsobaricHeatCapacity< NumericType > &specific_isobaric_heat_capacity) const noexcept
constexpr SpecificIsobaricHeatCapacity< NumericType > & operator=(const SpecificIsobaricHeatCapacity< NumericType > &other)=default
Copy assignment operator. Assigns this specific isobaric heat capacity by copying another one.
static constexpr SpecificIsobaricHeatCapacity< NumericType > Create(const NumericType value)
Statically creates a specific isobaric heat capacity with a given value expressed in a given specific...
constexpr SpecificIsochoricHeatCapacity< NumericType > operator/(const HeatCapacityRatio< NumericType > &heat_capacity_ratio) const
constexpr void operator-=(const SpecificIsobaricHeatCapacity< NumericType > &specific_isobaric_heat_capacity) noexcept
constexpr SpecificIsobaricHeatCapacity(SpecificIsobaricHeatCapacity< NumericType > &&other) noexcept=default
Move constructor. Constructs a specific isobaric heat capacity by moving another one.
constexpr void operator/=(const NumericType number) noexcept
constexpr HeatCapacityRatio< NumericType > operator/(const SpecificIsochoricHeatCapacity< NumericType > &specific_isochoric_heat_capacity) const
~SpecificIsobaricHeatCapacity() noexcept=default
Destructor. Destroys this specific isobaric heat capacity.
constexpr SpecificIsobaricHeatCapacity< NumericType > operator*(const NumericType number) const
SpecificIsobaricHeatCapacity(const NumericType value, const Unit::SpecificHeatCapacity unit)
Constructor. Constructs a specific isobaric heat capacity with a given value expressed in a given spe...
static constexpr SpecificIsobaricHeatCapacity< NumericType > Zero()
Statically creates a specific isobaric heat capacity of zero.
constexpr SpecificIsobaricHeatCapacity< NumericType > operator+(const SpecificIsobaricHeatCapacity< NumericType > &specific_isobaric_heat_capacity) const
constexpr void operator+=(const SpecificIsobaricHeatCapacity< NumericType > &specific_isobaric_heat_capacity) noexcept
Mass-specific isochoric heat capacity, also known as mass-specific heat capacity at constant volume,...
constexpr SpecificIsochoricHeatCapacity< NumericType > operator*(const NumericType number) const
SpecificIsochoricHeatCapacity()=default
Default constructor. Constructs a specific isochoric heat capacity with an uninitialized value.
Thermal diffusivity of a material. Measures the rate of heat transfer inside a material....
DynamicViscosity
Dynamic viscosity units.
MassDensity
Mass density units.
Definition: MassDensity.hpp:54
SpecificHeatCapacity
Mass-specific heat capacity units.
Namespace that encompasses all of the Physical Quantities library's content.
constexpr bool operator<(const Acceleration< NumericType > &left, const Acceleration< NumericType > &right) noexcept
constexpr bool operator<=(const Acceleration< NumericType > &left, const Acceleration< NumericType > &right) noexcept
constexpr Acceleration< NumericType > operator*(const NumericType number, const Acceleration< NumericType > &acceleration)
constexpr bool operator>(const Acceleration< NumericType > &left, const Acceleration< NumericType > &right) noexcept
constexpr bool operator==(const Acceleration< NumericType > &left, const Acceleration< NumericType > &right) noexcept
constexpr bool operator>=(const Acceleration< NumericType > &left, const Acceleration< NumericType > &right) noexcept
constexpr bool operator!=(const Acceleration< NumericType > &left, const Acceleration< NumericType > &right) noexcept
std::ostream & operator<<(std::ostream &stream, const Acceleration< NumericType > &acceleration)