Files
MeanField/extension_example/tests/rotating_stellar_model.cpp
2026-09-06 10:15:00 -04:00

68 lines
3.2 KiB
C++

#include <concepts>
#include <type_traits>
#include <catch2/catch_test_macros.hpp>
import mean_field;
import mean_field_extension_example.rotating_stellar_model;
TEST_CASE("The example EOS composes with existing stellar specifications",
"[extension-example][model][type]") {
using namespace mean_field;
namespace example = mean_field::extension_example;
const auto stellarModel = example::makeRotatingStellarModel({
.equationOfState = {
.meanMolecularWeight = 0.62,
.boltzmannConstant = 1.380649e-16,
.atomicMassUnit = 1.66053906660e-24,
.radiationConstant = 7.5657e-15
},
.surfacePressure = dimensions::PressureValue{0.0},
.totalMass = dimensions::MassValue{1.75},
.totalAngularMomentum = dimensions::AngularMomentumValue{0.3},
.rotationAxis = {0.0, 0.0, 4.0},
.rotationCenter = {0.1, -0.2, 0.3}
});
using Model = std::remove_cvref_t<decltype(stellarModel)>;
STATIC_CHECK(std::same_as<Model, example::RotatingStellarModel>);
STATIC_CHECK(model::StellarModelType<Model>);
STATIC_CHECK(Model::symbolicallySquare);
STATIC_CHECK(Model::specificationCount == 4);
STATIC_CHECK(std::same_as<model::EquationOfStateType<Model>, example::IdealGasRadiation>);
STATIC_CHECK(Model::template containsSpecification<integral::FixedTotalMass>);
STATIC_CHECK(Model::template containsSpecification<integral::FixedAngularMomentum>);
STATIC_CHECK(Model::template specificationRoleCount<models::SpecificationRole::constitutive_law> == 1);
STATIC_CHECK(Model::template specificationRoleCount<models::SpecificationRole::boundary_condition> == 1);
STATIC_CHECK(Model::template specificationRoleCount<models::SpecificationRole::invariant> == 2);
CHECK(stellarModel.equationOfState().parameters().meanMolecularWeight == 0.62);
CHECK(stellarModel.surfaceCondition().targetPressure() == dimensions::PressureValue{0.0});
CHECK(stellarModel.specification<integral::FixedTotalMass>().targetMass() == dimensions::MassValue{1.75});
const auto &angularMomentum = stellarModel.specification<integral::FixedAngularMomentum>();
CHECK(angularMomentum.targetAngularMomentum() == dimensions::AngularMomentumValue{0.3});
CHECK(angularMomentum.axis()[0] == 0.0);
CHECK(angularMomentum.axis()[1] == 0.0);
CHECK(angularMomentum.axis()[2] == 1.0);
CHECK(angularMomentum.center()[0] == 0.1);
CHECK(angularMomentum.center()[1] == -0.2);
CHECK(angularMomentum.center()[2] == 0.3);
CHECK(stellarModel.runtimeSpecificationDescriptors().size() == 4);
}
TEST_CASE("The example states the current thermal-runtime boundary explicitly",
"[extension-example][model][capability]") {
using Model = mean_field::extension_example::RotatingStellarModel;
/*
* This is not a failure of model composition. It is the intended
* compile-time rejection of a thermal EOS by a currently barotropic
* numerical core. See the manual section 'What compiles today'.
*/
STATIC_CHECK(mean_field::model::StellarModelType<Model>);
STATIC_CHECK_FALSE(mean_field::extension_example::currentEquilibriumBackendSupportsIdealGasRadiation);
STATIC_CHECK_FALSE(mean_field::equilibrium::StellarEquilibriumModel<Model>);
}