Added molar heat capacity

This commit is contained in:
rbrugo
2020-04-09 19:33:00 +02:00
committed by Mateusz Pusz
parent 7dda8319a2
commit 9ec5c77602
4 changed files with 24 additions and 1 deletions

View File

@@ -149,6 +149,9 @@ 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>> {};
template<typename Child, Unit U, DimensionOf<dim_heat_capacity> C, DimensionOf<dim_substance> M>
struct dim_molar_heat_capacity : derived_dimension<Child, U, exp<C, 1>, exp<M, -1>> {};
template<typename Child, Unit U, DimensionOf<dim_power> P, DimensionOf<dim_length> L, DimensionOf<dim_thermodynamic_temperature> T>
struct dim_thermal_conductivity : derived_dimension<Child, U, exp<P, 1>, exp<L, -1>, exp<T, -1>> {};
@@ -280,6 +283,9 @@ concept HeatCapacity = physical::QuantityOf<T, physical::dim_heat_capacity>;
template<typename T>
concept SpecificHeatCapacity = physical::QuantityOf<T, physical::dim_specific_heat_capacity>;
template<typename T>
concept MolarHeatCapacity = physical::QuantityOf<T, physical::dim_molar_heat_capacity>;
template<typename T>
concept ThermalConductivity = physical::QuantityOf<T, physical::dim_thermal_conductivity>;

View File

@@ -26,15 +26,18 @@
#include <units/physical/si/temperature.h>
#include <units/physical/si/energy.h>
#include <units/physical/si/mass.h>
#include <units/physical/si/substance.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 joule_per_mole_kelvin : unit<joule_per_mole_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> {};
struct dim_molar_heat_capacity : physical::dim_molar_heat_capacity<dim_molar_heat_capacity, joule_per_mole_kelvin, dim_heat_capacity, dim_substance> {};
template<Unit U, Scalar Rep = double>
using heat_capacity = quantity<dim_heat_capacity, U, Rep>;
@@ -42,6 +45,9 @@ 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>;
template<Unit U, Scalar Rep = double>
using molar_heat_capacity = quantity<dim_molar_heat_capacity, U, Rep>;
inline namespace literals {
// J/K
@@ -52,6 +58,10 @@ constexpr auto operator"" q_J_per_K(long double l) { return heat_capacity<joule_
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); }
// J/(mol·K)
constexpr auto operator"" q_J_per_mol_K(unsigned long long l) { return molar_heat_capacity<joule_per_mole_kelvin, std::int64_t>(l); }
constexpr auto operator"" q_J_per_mol_K(long double l) { return molar_heat_capacity<joule_per_mole_kelvin, long double>(l); }
} // namespace literals
} // namespace units::si

View File

@@ -268,6 +268,12 @@ TEST_CASE("fmt::format on synthesized unit symbols", "[text][fmt]")
CHECK(fmt::format("{:%Q %Aq}", 1q_J_per_kg_K) == "1 J K^-1 kg^-1");
}
SECTION("molar heath capacity")
{
CHECK(fmt::format("{}", 1q_J_per_mol_K) == "1 J ⋅ K⁻¹ ⋅ mol⁻¹");
CHECK(fmt::format("{:%Q %Aq}", 1q_J_per_mol_K) == "1 J K^-1 mol^-1");
}
SECTION("thermal conductivity")
{
CHECK(fmt::format("{}", 1q_W_per_m_K) == "1 W ⋅ m⁻¹ ⋅ K⁻¹");

View File

@@ -314,10 +314,11 @@ static_assert(detail::unit_text<dim_luminance, candela_per_metre_sq>() == basic_
static_assert(1q_Pa_s == 1q_N * 1q_s / 1q_m2);
static_assert(detail::unit_text<dim_dynamic_viscosity, pascal_second>() == basic_symbol_text("Pa ⋅ s", "Pa s"));
// [specific] heath capacity
// [specific|molar] heath capacity
static_assert(1q_J_per_K == 1q_J_per_kg_K * 1q_kg);
static_assert(1q_J_per_K * 1q_K == 1q_s * 1q_N * 1q_m_per_s);
static_assert(1q_J_per_mol_K == 1q_J_per_K / 1q_mol);
static_assert(detail::unit_text<dim_heat_capacity, joule_per_kelvin>() == "J/K");
static_assert(detail::unit_text<dim_specific_heat_capacity, joule_per_kilogram_kelvin>() == basic_symbol_text("J ⋅ K⁻¹ ⋅ kg⁻¹", "J kg^-1 K^-1"));