#include #include #include #include import mean_field; import test_helpers; TEST_CASE( "Isobaric Surface Resolves Zero Pressure To Zero Enthalpy", tags::barotrope &tags::unit &tags::surface ) { const mean_field::eos::Polytrope equationOfState(3.0, 0.25); const mean_field::surface::Isobaric surface; const mean_field::surface::ResolvedSurfaceCondition resolved = surface.resolve(equationOfState); CHECK(surface.targetPressure() == 0.0); CHECK(resolved.targetEnthalpy == 0.0); CHECK(resolved.residual(0.0) == 0.0); CHECK(resolved.residual(0.37) == 0.37); CHECK(resolved.jacobianAction(-0.19) == -0.19); } TEST_CASE( "Isobaric Surface Resolves Positive Pressure Through The EOS", tags::barotrope &tags::unit &tags::surface ) { const mean_field::eos::Polytrope equationOfState(3.0, 0.25); constexpr double targetPressure = 0.03125; const mean_field::surface::Isobaric surface(targetPressure); const mean_field::surface::ResolvedSurfaceCondition resolved = surface.resolve(equationOfState); const double recoveredPressure = equationOfState.pressure_from_enthalpy(resolved.targetEnthalpy); INFO("Resolved surface enthalpy = " << resolved.targetEnthalpy); INFO("Recovered surface pressure = " << recoveredPressure); CHECK(resolved.targetEnthalpy > 0.0); CHECK(std::abs(recoveredPressure - targetPressure) < 64.0 * std::numeric_limits::epsilon()); CHECK(resolved.residual(resolved.targetEnthalpy) == 0.0); } TEST_CASE( "Isobaric Surface Rejects Invalid Pressure Targets", tags::barotrope &tags::unit &tags::surface ) { CHECK_THROWS_AS(mean_field::surface::Isobaric(-1.0), std::invalid_argument); CHECK_THROWS_AS(mean_field::surface::Isobaric(std::numeric_limits::infinity()), std::invalid_argument); CHECK_THROWS_AS(mean_field::surface::Isobaric(std::numeric_limits::quiet_NaN()), std::invalid_argument); } TEST_CASE( "Surface Base Dispatch Preserves The Isobaric Prescription", tags::barotrope &tags::unit &tags::surface ) { const mean_field::eos::Polytrope equationOfState(3.0, 0.25); const mean_field::surface::Isobaric isobaric(0.02); const mean_field::surface::SurfaceBase &surface = isobaric; surface.validate(equationOfState); const mean_field::surface::ResolvedSurfaceCondition resolved = surface.resolve(equationOfState); CHECK(resolved.targetEnthalpy > 0.0); CHECK(resolved.residual(resolved.targetEnthalpy) == 0.0); }