diff --git a/toolchain/mfc/case_validator.py b/toolchain/mfc/case_validator.py index de2394cdd..9ad95ec03 100644 --- a/toolchain/mfc/case_validator.py +++ b/toolchain/mfc/case_validator.py @@ -645,12 +645,17 @@ def check_phase_change(self): relax = self.get("relax", "F") == "T" relax_model = self.get("relax_model") model_eqns = self.get("model_eqns") + num_fluids = self.get("num_fluids") palpha_eps = self.get("palpha_eps") ptgalpha_eps = self.get("ptgalpha_eps") if not relax: return + self.prohibit( + num_fluids is None or num_fluids < 2, + "phase change requires num_fluids >= 2 (liquid = 1, vapor = 2)", + ) self.prohibit( (model_eqns not in (2, 3) or (model_eqns == 2 and relax_model not in (5, 6)) or (model_eqns == 3 and relax_model not in (1, 4, 5, 6))), "phase change requires model_eqns==2 with relax_model in [5,6] or model_eqns==3 with relax_model in [1,4,5,6]", diff --git a/toolchain/mfc/test_case_validator.py b/toolchain/mfc/test_case_validator.py index 922da1580..4cb7fe6c9 100644 --- a/toolchain/mfc/test_case_validator.py +++ b/toolchain/mfc/test_case_validator.py @@ -242,6 +242,36 @@ def test_accepts_valid_configuration(self): self.assertAccepts(REACTIVE_BURN) +class TestPhaseChangeFluidPairing(ConstraintTestCase): + MSG = "phase change requires num_fluids >= 2 (liquid = 1, vapor = 2)" + + def test_rejects_single_fluid(self): + self.assertRejects({**BASE, "relax": "T", "relax_model": 5}, self.MSG) + + def test_rejects_unset_num_fluids(self): + params = {k: v for k, v in TWO_FLUID.items() if k != "num_fluids"} + self.assertRejects({**params, "relax": "T", "relax_model": 5}, self.MSG) + + def test_accepts_two_fluids(self): + self.assertAccepts({**TWO_FLUID, "relax": "T", "relax_model": 5}) + + def test_accepts_three_fluids(self): + params = { + **TWO_FLUID, + "num_fluids": 3, + "fluid_pp(3)%gamma": 0.4, + "fluid_pp(3)%pi_inf": 0.0, + "patch_icpp(1)%alpha_rho(3)": 0.0, + "patch_icpp(1)%alpha(3)": 0.0, + "relax": "T", + "relax_model": 5, + } + self.assertAccepts(params) + + def test_not_checked_when_disabled(self): + self.assertAccepts({**BASE, "relax": "F"}) + + class TestSyntheticTurbulence(ConstraintTestCase): """A 2D case with one fully specified forcing zone."""