perf(jacobian-action): major updates to jacobian action application by removing redudant quadrature work. ~5x increase in speed
This commit is contained in:
119
tests/physics/dimensional_quantities.cpp
Normal file
119
tests/physics/dimensional_quantities.cpp
Normal file
@@ -0,0 +1,119 @@
|
||||
#include <concepts>
|
||||
#include <string_view>
|
||||
#include <type_traits>
|
||||
|
||||
#include <catch2/catch_test_macros.hpp>
|
||||
|
||||
import mean_field;
|
||||
import test_helpers;
|
||||
|
||||
namespace {
|
||||
template <typename Left, typename Right>
|
||||
concept Addable = requires(const Left left, const Right right) { left + right; };
|
||||
|
||||
template <typename Left, typename Right>
|
||||
concept EqualityComparable = requires(const Left left, const Right right) {
|
||||
{ left == right } -> std::convertible_to<bool>;
|
||||
};
|
||||
} // namespace
|
||||
|
||||
TEST_CASE(
|
||||
"Physical Quantity Values Are Strong Scalar Types",
|
||||
tags::dimensional_quantities
|
||||
) {
|
||||
using namespace mean_field;
|
||||
|
||||
STATIC_CHECK(dimensions::PhysicalQuantityType<dimensions::quantity::Mass>);
|
||||
STATIC_CHECK(dimensions::PhysicalQuantityType<dimensions::quantity::Length>);
|
||||
STATIC_CHECK(dimensions::PhysicalQuantityType<dimensions::quantity::AngularMomentum>);
|
||||
STATIC_CHECK(dimensions::ThermodynamicQuantityType<dimensions::quantity::Density>);
|
||||
STATIC_CHECK(dimensions::ThermodynamicQuantityType<dimensions::quantity::Pressure>);
|
||||
STATIC_CHECK(dimensions::ThermodynamicQuantityType<dimensions::quantity::SpecificEnthalpy>);
|
||||
STATIC_CHECK_FALSE(dimensions::ThermodynamicQuantityType<dimensions::quantity::Mass>);
|
||||
|
||||
STATIC_CHECK(dimensions::QuantityValueType<dimensions::MassValue>);
|
||||
STATIC_CHECK(dimensions::QuantityValueType<dimensions::AngularMomentumValue>);
|
||||
STATIC_CHECK(std::same_as<dimensions::QuantityOfT<dimensions::MassValue>, dimensions::quantity::Mass>);
|
||||
STATIC_CHECK(
|
||||
std::same_as<dimensions::QuantityOfT<dimensions::AngularMomentumValue>, dimensions::quantity::AngularMomentum>
|
||||
);
|
||||
|
||||
STATIC_CHECK(std::constructible_from<dimensions::MassValue, double>);
|
||||
STATIC_CHECK_FALSE(std::convertible_to<double, dimensions::MassValue>);
|
||||
STATIC_CHECK_FALSE(std::constructible_from<dimensions::MassValue, dimensions::LengthValue>);
|
||||
STATIC_CHECK_FALSE(Addable<dimensions::MassValue, dimensions::LengthValue>);
|
||||
STATIC_CHECK_FALSE(EqualityComparable<dimensions::MassValue, dimensions::LengthValue>);
|
||||
|
||||
constexpr dimensions::MassValue mass{2.0};
|
||||
constexpr dimensions::MassValue correction{0.5};
|
||||
STATIC_CHECK((mass + correction).value() == 2.5);
|
||||
STATIC_CHECK((mass - correction).value() == 1.5);
|
||||
STATIC_CHECK((3.0 * mass).value() == 6.0);
|
||||
STATIC_CHECK((mass / 4.0).value() == 0.5);
|
||||
STATIC_CHECK(mass > correction);
|
||||
}
|
||||
|
||||
TEST_CASE(
|
||||
"Dimensions Partition Provides A Broad Stellar Physics Catalog",
|
||||
tags::dimensional_quantities
|
||||
) {
|
||||
using namespace mean_field::dimensions;
|
||||
|
||||
STATIC_CHECK(QuantityValueType<DimensionlessValue>);
|
||||
STATIC_CHECK(QuantityValueType<MassValue>);
|
||||
STATIC_CHECK(QuantityValueType<LengthValue>);
|
||||
STATIC_CHECK(QuantityValueType<TimeValue>);
|
||||
STATIC_CHECK(QuantityValueType<AreaValue>);
|
||||
STATIC_CHECK(QuantityValueType<VolumeValue>);
|
||||
STATIC_CHECK(QuantityValueType<DensityValue>);
|
||||
STATIC_CHECK(QuantityValueType<SurfaceDensityValue>);
|
||||
STATIC_CHECK(QuantityValueType<NumberDensityValue>);
|
||||
STATIC_CHECK(QuantityValueType<PressureValue>);
|
||||
STATIC_CHECK(QuantityValueType<TemperatureValue>);
|
||||
STATIC_CHECK(QuantityValueType<EntropyValue>);
|
||||
STATIC_CHECK(QuantityValueType<SpecificEntropyValue>);
|
||||
STATIC_CHECK(QuantityValueType<ChemicalPotentialValue>);
|
||||
STATIC_CHECK(QuantityValueType<EnergyValue>);
|
||||
STATIC_CHECK(QuantityValueType<InternalEnergyValue>);
|
||||
STATIC_CHECK(QuantityValueType<SpecificEnergyValue>);
|
||||
STATIC_CHECK(QuantityValueType<SpecificInternalEnergyValue>);
|
||||
STATIC_CHECK(QuantityValueType<SpecificEnthalpyValue>);
|
||||
STATIC_CHECK(QuantityValueType<EnergyDensityValue>);
|
||||
STATIC_CHECK(QuantityValueType<GravitationalPotentialValue>);
|
||||
STATIC_CHECK(QuantityValueType<VelocityValue>);
|
||||
STATIC_CHECK(QuantityValueType<AccelerationValue>);
|
||||
STATIC_CHECK(QuantityValueType<FrequencyValue>);
|
||||
STATIC_CHECK(QuantityValueType<AngularVelocityValue>);
|
||||
STATIC_CHECK(QuantityValueType<MomentumValue>);
|
||||
STATIC_CHECK(QuantityValueType<AngularMomentumValue>);
|
||||
STATIC_CHECK(QuantityValueType<MomentOfInertiaValue>);
|
||||
STATIC_CHECK(QuantityValueType<ForceValue>);
|
||||
STATIC_CHECK(QuantityValueType<TorqueValue>);
|
||||
STATIC_CHECK(QuantityValueType<PowerValue>);
|
||||
STATIC_CHECK(QuantityValueType<LuminosityValue>);
|
||||
STATIC_CHECK(QuantityValueType<MassFlowRateValue>);
|
||||
STATIC_CHECK(QuantityValueType<OpacityValue>);
|
||||
STATIC_CHECK(QuantityValueType<DynamicViscosityValue>);
|
||||
STATIC_CHECK(QuantityValueType<KinematicViscosityValue>);
|
||||
STATIC_CHECK(QuantityValueType<MagneticFluxDensityValue>);
|
||||
|
||||
STATIC_CHECK(quantity::Mass::identifier == std::string_view{"mass"});
|
||||
STATIC_CHECK(quantity::AngularMomentum::identifier == std::string_view{"angular_momentum"});
|
||||
STATIC_CHECK(quantity::SpecificEnthalpy::identifier == std::string_view{"specific_enthalpy"});
|
||||
}
|
||||
|
||||
TEST_CASE(
|
||||
"EOS Quantity Names Are Exact Transitional Aliases Of Dimensions Types",
|
||||
tags::dimensional_quantities
|
||||
) {
|
||||
using namespace mean_field;
|
||||
|
||||
STATIC_CHECK(std::same_as<eos::quantity::Density, dimensions::quantity::Density>);
|
||||
STATIC_CHECK(std::same_as<eos::quantity::Pressure, dimensions::quantity::Pressure>);
|
||||
STATIC_CHECK(std::same_as<eos::quantity::SpecificEnthalpy, dimensions::quantity::SpecificEnthalpy>);
|
||||
STATIC_CHECK(std::same_as<eos::DensityValue, dimensions::DensityValue>);
|
||||
STATIC_CHECK(std::same_as<eos::PressureValue, dimensions::PressureValue>);
|
||||
STATIC_CHECK(std::same_as<eos::SpecificEnthalpyValue, dimensions::SpecificEnthalpyValue>);
|
||||
STATIC_CHECK(eos::ThermodynamicQuantityType<dimensions::quantity::Density>);
|
||||
STATIC_CHECK(eos::QuantityValueType<dimensions::DensityValue>);
|
||||
}
|
||||
Reference in New Issue
Block a user