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
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"
37
38namespace PhQ {
39
40// Forward declaration for class PhQ::SpecificIsobaricHeatCapacity.
41template <typename NumericType>
43
44// Forward declaration for class PhQ::SpecificIsobaricHeatCapacity.
45template <typename NumericType>
46class MassDensity;
47
48// Forward declaration for class PhQ::SpecificIsobaricHeatCapacity.
49template <typename NumericType>
50class PrandtlNumber;
51
52// Forward declaration for class PhQ::SpecificIsobaricHeatCapacity.
53template <typename NumericType>
54class ScalarThermalConductivity;
55
56// Forward declaration for class PhQ::SpecificIsobaricHeatCapacity.
57template <typename NumericType>
58class 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.
63template <typename NumericType = double>
65 : public DimensionalScalar<Unit::SpecificHeatCapacity, NumericType> {
66public:
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>
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 {
191 }
192
194 return IsobaricHeatCapacity<NumericType>{*this, mass};
195 }
196
197 constexpr SpecificIsobaricHeatCapacity<NumericType> operator/(const NumericType number) const {
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
235private:
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
242template <typename NumericType>
244 const SpecificIsobaricHeatCapacity<NumericType>& right) noexcept {
245 return left.Value() == right.Value();
246}
247
248template <typename NumericType>
250 const SpecificIsobaricHeatCapacity<NumericType>& right) noexcept {
251 return left.Value() != right.Value();
252}
253
254template <typename NumericType>
255inline constexpr bool operator<(const SpecificIsobaricHeatCapacity<NumericType>& left,
256 const SpecificIsobaricHeatCapacity<NumericType>& right) noexcept {
257 return left.Value() < right.Value();
258}
259
260template <typename NumericType>
261inline constexpr bool operator>(const SpecificIsobaricHeatCapacity<NumericType>& left,
262 const SpecificIsobaricHeatCapacity<NumericType>& right) noexcept {
263 return left.Value() > right.Value();
264}
265
266template <typename NumericType>
268 const SpecificIsobaricHeatCapacity<NumericType>& right) noexcept {
269 return left.Value() <= right.Value();
270}
271
272template <typename NumericType>
274 const SpecificIsobaricHeatCapacity<NumericType>& right) noexcept {
275 return left.Value() >= right.Value();
276}
277
278template <typename NumericType>
279inline 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
286template <typename NumericType>
288 const NumericType number,
289 const SpecificIsobaricHeatCapacity<NumericType>& specific_isobaric_heat_capacity) {
290 return specific_isobaric_heat_capacity * number;
291}
292
293template <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
300template <typename NumericType>
301inline 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
306template <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
312template <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
319template <typename NumericType>
321 const SpecificIsobaricHeatCapacity<NumericType>& specific_isobaric_heat_capacity) const {
322 return IsobaricHeatCapacity<NumericType>{specific_isobaric_heat_capacity, *this};
323}
324
325template <typename NumericType>
328 const SpecificIsochoricHeatCapacity<NumericType>& specific_isochoric_heat_capacity) const {
329 return SpecificIsobaricHeatCapacity<NumericType>{*this, specific_isochoric_heat_capacity};
330}
331
332template <typename NumericType>
335 const HeatCapacityRatio<NumericType>& heat_capacity_ratio) const {
336 return SpecificIsobaricHeatCapacity<NumericType>{heat_capacity_ratio, *this};
337}
338
339template <typename NumericType>
344
345template <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
353namespace std {
354
355template <typename NumericType>
356struct 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...
NumericType value
Value of this physical quantity expressed in its standard unit of measure.
constexpr NumericType Value() const noexcept
Value of this physical quantity expressed in its standard unit of measure.
static constexpr UnitType 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.
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 HeatCapacityRatio< NumericType > operator/(const SpecificIsochoricHeatCapacity< NumericType > &specific_isochoric_heat_capacity) const
constexpr SpecificIsobaricHeatCapacity< NumericType > & operator=(const SpecificIsobaricHeatCapacity< NumericType > &other)=default
Copy assignment operator. Assigns this specific isobaric heat capacity by copying another one.
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=(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 > &specific_isobaric_heat_capacity) const
constexpr IsobaricHeatCapacity< NumericType > operator*(const Mass< NumericType > &mass) 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 SpecificIsochoricHeatCapacity< NumericType > operator/(const HeatCapacityRatio< NumericType > &heat_capacity_ratio) const
constexpr void operator/=(const NumericType number) noexcept
constexpr SpecificIsobaricHeatCapacity< NumericType > operator+(const SpecificIsobaricHeatCapacity< NumericType > &specific_isobaric_heat_capacity) const
constexpr SpecificIsobaricHeatCapacity< NumericType > operator/(const NumericType number) const
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 NumericType number) const
static constexpr SpecificIsobaricHeatCapacity< NumericType > Zero()
Statically creates a specific isobaric heat capacity of zero.
~SpecificIsobaricHeatCapacity() noexcept=default
Destructor. Destroys this specific isobaric heat capacity.
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 > Create(const NumericType value)
Statically creates a specific isobaric heat capacity with a given value expressed in a given specific...
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,...
SpecificIsochoricHeatCapacity()=default
Default constructor. Constructs a specific isochoric heat capacity with an uninitialized value.
constexpr SpecificIsochoricHeatCapacity< NumericType > operator*(const NumericType number) const
Thermal diffusivity of a material. Measures the rate of heat transfer inside a material....
DynamicViscosity
Dynamic viscosity units.
MassDensity
Mass density units.
SpecificHeatCapacity
Mass-specific heat capacity units.
Namespace that encompasses all of the Physical Quantities library's content.
std::ostream & operator<<(std::ostream &stream, 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 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