forked from mpusz/mp-units
Added heat capacity and specific heat capacity
This commit is contained in:
@@ -143,6 +143,12 @@ struct dim_luminance : derived_dimension<Child, U, exp<I, 1>, exp<L, -2>> {};
|
||||
template<typename Child, Unit U, DimensionOf<dim_pressure> P, DimensionOf<dim_time> T>
|
||||
struct dim_dynamic_viscosity : derived_dimension<Child, U, exp<P, 1>, exp<T, 1>> {};
|
||||
|
||||
template<typename Child, Unit U, DimensionOf<dim_energy> E, DimensionOf<dim_thermodynamic_temperature> T>
|
||||
struct dim_heat_capacity : derived_dimension<Child, U, exp<E, 1>, exp<T, -1>> {};
|
||||
|
||||
template<typename Child, Unit U, DimensionOf<dim_heat_capacity> C, DimensionOf<dim_mass> M>
|
||||
struct dim_specific_heat_capacity : derived_dimension<Child, U, exp<C, 1>, exp<M, -1>> {};
|
||||
|
||||
} // namespace physical
|
||||
|
||||
template<typename T>
|
||||
@@ -241,4 +247,10 @@ concept Luminance = physical::QuantityOf<T, physical::dim_luminance>;
|
||||
template<typename T>
|
||||
concept DynamicViscosity = physical::QuantityOf<T, physical::dim_dynamic_viscosity>;
|
||||
|
||||
template<typename T>
|
||||
concept HeatCapacity = physical::QuantityOf<T, physical::dim_heat_capacity>;
|
||||
|
||||
template<typename T>
|
||||
concept SpecificHeatCapacity = physical::QuantityOf<T, physical::dim_specific_heat_capacity>;
|
||||
|
||||
} // namespace units
|
||||
|
||||
@@ -33,6 +33,7 @@
|
||||
#include "si/density.h"
|
||||
#include "si/dynamic_viscosity.h"
|
||||
#include "si/frequency.h"
|
||||
#include "si/heat_capacity.h"
|
||||
#include "si/inductance.h"
|
||||
#include "si/luminance.h"
|
||||
#include "si/magnetic_flux.h"
|
||||
|
||||
@@ -0,0 +1,58 @@
|
||||
// The MIT License (MIT)
|
||||
//
|
||||
// Copyright (c) 2018 Mateusz Pusz
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in all
|
||||
// copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <units/physical/dimensions.h>
|
||||
#include <units/physical/si/temperature.h>
|
||||
#include <units/physical/si/energy.h>
|
||||
#include <units/physical/si/mass.h>
|
||||
#include <units/quantity.h>
|
||||
|
||||
namespace units::si {
|
||||
|
||||
struct joule_per_kelvin : unit<joule_per_kelvin> {};
|
||||
struct joule_per_kilogram_kelvin : unit<joule_per_kilogram_kelvin> {};
|
||||
|
||||
struct dim_heat_capacity : physical::dim_heat_capacity<dim_heat_capacity, joule_per_kelvin, dim_energy, dim_thermodynamic_temperature> {};
|
||||
struct dim_specific_heat_capacity : physical::dim_specific_heat_capacity<dim_specific_heat_capacity, joule_per_kilogram_kelvin, dim_heat_capacity, dim_mass> {};
|
||||
|
||||
template<Unit U, Scalar Rep = double>
|
||||
using heat_capacity = quantity<dim_heat_capacity, U, Rep>;
|
||||
|
||||
template<Unit U, Scalar Rep = double>
|
||||
using specific_heat_capacity = quantity<dim_specific_heat_capacity, U, Rep>;
|
||||
|
||||
inline namespace literals {
|
||||
|
||||
// J/K
|
||||
constexpr auto operator"" q_J_per_K(unsigned long long l) { return heat_capacity<joule_per_kelvin, std::int64_t>(l); }
|
||||
constexpr auto operator"" q_J_per_K(long double l) { return heat_capacity<joule_per_kelvin, long double>(l); }
|
||||
|
||||
// J/(kg·K)
|
||||
constexpr auto operator"" q_J_per_kg_K(unsigned long long l) { return specific_heat_capacity<joule_per_kilogram_kelvin, std::int64_t>(l); }
|
||||
constexpr auto operator"" q_J_per_kg_K(long double l) { return specific_heat_capacity<joule_per_kilogram_kelvin, long double>(l); }
|
||||
|
||||
} // namespace literals
|
||||
|
||||
} // namespace units::si
|
||||
|
||||
Reference in New Issue
Block a user