[Python/1D] Disallow redundant grid specification

Fixes #1693
This commit is contained in:
Ray Speth 2024-06-06 12:38:27 -04:00 committed by Ingmar Schoegl
parent add82cfe14
commit da9e29ba7d
2 changed files with 18 additions and 0 deletions

View File

@ -561,6 +561,8 @@ class FreeFlame(FlameBase):
self.flame = FreeFlow(gas, name='flame')
if width is not None:
if grid is not None:
raise ValueError("'grid' and 'width' arguments are mutually exclusive")
grid = np.array([0.0, 0.2, 0.3, 0.4, 0.5, 0.6, 0.8, 1.0]) * width
super().__init__((self.inlet, self.flame, self.outlet), gas, grid)
@ -757,6 +759,8 @@ class BurnerFlame(FlameBase):
self.flame = UnstrainedFlow(gas, name='flame')
if width is not None:
if grid is not None:
raise ValueError("'grid' and 'width' arguments are mutually exclusive")
grid = np.array([0.0, 0.1, 0.2, 0.3, 0.5, 0.7, 1.0]) * width
super().__init__((self.burner, self.flame, self.outlet), gas, grid)
@ -893,6 +897,8 @@ class CounterflowDiffusionFlame(FlameBase):
self.flame = AxisymmetricFlow(gas, name='flame')
if width is not None:
if grid is not None:
raise ValueError("'grid' and 'width' arguments are mutually exclusive")
grid = np.array([0.0, 0.2, 0.4, 0.6, 0.8, 1.0]) * width
super().__init__((self.fuel_inlet, self.flame, self.oxidizer_inlet), gas, grid)
@ -1219,6 +1225,8 @@ class ImpingingJet(FlameBase):
self.flame.set_axisymmetric_flow()
if width is not None:
if grid is not None:
raise ValueError("'grid' and 'width' arguments are mutually exclusive")
grid = np.array([0.0, 0.2, 0.4, 0.6, 0.8, 1.0]) * width
if surface is None:
@ -1308,6 +1316,8 @@ class CounterflowPremixedFlame(FlameBase):
self.flame = AxisymmetricFlow(gas, name='flame')
if width is not None:
if grid is not None:
raise ValueError("'grid' and 'width' arguments are mutually exclusive")
# Create grid points aligned with initial guess profile
grid = np.array([0.0, 0.3, 0.5, 0.7, 1.0]) * width
@ -1406,6 +1416,8 @@ class CounterflowTwinPremixedFlame(FlameBase):
self.products = SymmetryPlane1D(name='products', phase=gas)
if width is not None:
if grid is not None:
raise ValueError("'grid' and 'width' arguments are mutually exclusive")
# Create grid points aligned with initial guess profile
grid = np.array([0.0, 0.2, 0.4, 0.5, 0.6, 0.8, 1.0]) * width

View File

@ -149,6 +149,12 @@ class TestOnedim(utilities.CanteraTest):
with pytest.raises(ct.CanteraError, match="Invalid Transport model"):
gas.transport_model = 'none'
def test_width_grid(self):
gas = ct.Solution('h2o2.yaml')
for cls in ct.FlameBase.__subclasses__():
with pytest.raises(ValueError, match="mutually exclusive"):
sim = cls(gas, grid=[0, 0.1, 0.2], width=0.4)
class TestFreeFlame(utilities.CanteraTest):
tol_ss = [1.0e-5, 1.0e-14] # [rtol atol] for steady-state problem