From 9ec5c7760203483f2d4e1919a50463121dbd09cc Mon Sep 17 00:00:00 2001 From: rbrugo Date: Thu, 9 Apr 2020 19:33:00 +0200 Subject: [PATCH] Added molar heat capacity --- src/include/units/physical/dimensions.h | 6 ++++++ src/include/units/physical/si/heat_capacity.h | 10 ++++++++++ test/unit_test/runtime/fmt_units_test.cpp | 6 ++++++ test/unit_test/static/si_test.cpp | 3 ++- 4 files changed, 24 insertions(+), 1 deletion(-) diff --git a/src/include/units/physical/dimensions.h b/src/include/units/physical/dimensions.h index 01b15270..4f7edf5f 100644 --- a/src/include/units/physical/dimensions.h +++ b/src/include/units/physical/dimensions.h @@ -149,6 +149,9 @@ struct dim_heat_capacity : derived_dimension, exp> {} template C, DimensionOf M> struct dim_specific_heat_capacity : derived_dimension, exp> {}; +template C, DimensionOf M> +struct dim_molar_heat_capacity : derived_dimension, exp> {}; + template P, DimensionOf L, DimensionOf T> struct dim_thermal_conductivity : derived_dimension, exp, exp> {}; @@ -280,6 +283,9 @@ concept HeatCapacity = physical::QuantityOf; template concept SpecificHeatCapacity = physical::QuantityOf; +template +concept MolarHeatCapacity = physical::QuantityOf; + template concept ThermalConductivity = physical::QuantityOf; diff --git a/src/include/units/physical/si/heat_capacity.h b/src/include/units/physical/si/heat_capacity.h index 4baf04dd..d9ad90c7 100644 --- a/src/include/units/physical/si/heat_capacity.h +++ b/src/include/units/physical/si/heat_capacity.h @@ -26,15 +26,18 @@ #include #include #include +#include #include namespace units::si { struct joule_per_kelvin : unit {}; struct joule_per_kilogram_kelvin : unit {}; +struct joule_per_mole_kelvin : unit {}; struct dim_heat_capacity : physical::dim_heat_capacity {}; struct dim_specific_heat_capacity : physical::dim_specific_heat_capacity {}; +struct dim_molar_heat_capacity : physical::dim_molar_heat_capacity {}; template using heat_capacity = quantity; @@ -42,6 +45,9 @@ using heat_capacity = quantity; template using specific_heat_capacity = quantity; +template +using molar_heat_capacity = quantity; + inline namespace literals { // J/K @@ -52,6 +58,10 @@ constexpr auto operator"" q_J_per_K(long double l) { return heat_capacity(l); } constexpr auto operator"" q_J_per_kg_K(long double l) { return specific_heat_capacity(l); } +// J/(mol·K) +constexpr auto operator"" q_J_per_mol_K(unsigned long long l) { return molar_heat_capacity(l); } +constexpr auto operator"" q_J_per_mol_K(long double l) { return molar_heat_capacity(l); } + } // namespace literals } // namespace units::si diff --git a/test/unit_test/runtime/fmt_units_test.cpp b/test/unit_test/runtime/fmt_units_test.cpp index a362bb97..474ecff3 100644 --- a/test/unit_test/runtime/fmt_units_test.cpp +++ b/test/unit_test/runtime/fmt_units_test.cpp @@ -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⁻¹"); diff --git a/test/unit_test/static/si_test.cpp b/test/unit_test/static/si_test.cpp index 8f3f84c2..817130e0 100644 --- a/test/unit_test/static/si_test.cpp +++ b/test/unit_test/static/si_test.cpp @@ -314,10 +314,11 @@ static_assert(detail::unit_text() == basic_ static_assert(1q_Pa_s == 1q_N * 1q_s / 1q_m2); static_assert(detail::unit_text() == 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() == "J/K"); static_assert(detail::unit_text() == basic_symbol_text("J ⋅ K⁻¹ ⋅ kg⁻¹", "J kg^-1 K^-1"));