Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 42 additions & 0 deletions source/bind/python/tests/test_abort_recovery.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,3 +50,45 @@ def test_rocket_abort_raises_runtimeerror_and_python_continues():
assert result.returncode == 0, combined
assert "CAUGHT_RUNTIME_ERROR" in result.stdout, combined
assert "CONTINUED_AFTER_ERROR" in result.stdout, combined


@pytest.mark.smoke
def test_detonation_frozen_raises_runtimeerror_and_python_continues():
code = textwrap.dedent(
"""
import numpy as np
import cea

reac_names = ["H2", "O2"]
reac = cea.Mixture(reac_names)
prod = cea.Mixture(reac_names, products_from_reactants=True)
solver = cea.DetonationSolver(prod, reactants=reac)
soln = cea.DetonationSolution(solver)

weights = np.array([0.0, 1.0], dtype=np.float64)

try:
solver.solve(soln, weights, 298.15, 1.0, frozen=True)
except RuntimeError as exc:
message = str(exc)
assert "CEA_FORTRAN_ABORT" in message
assert "frozen composition not supported yet" in message
print("CAUGHT_RUNTIME_ERROR")
else:
raise AssertionError("Expected DetonationSolver.solve to raise RuntimeError")

print("CONTINUED_AFTER_ERROR")
"""
)
result = subprocess.run(
[sys.executable, "-c", code],
capture_output=True,
text=True,
check=False,
timeout=20,
)
combined = result.stdout + result.stderr

assert result.returncode == 0, combined
assert "CAUGHT_RUNTIME_ERROR" in result.stdout, combined
assert "CONTINUED_AFTER_ERROR" in result.stdout, combined
3 changes: 1 addition & 2 deletions source/detonation.f90
Original file line number Diff line number Diff line change
Expand Up @@ -298,8 +298,7 @@ function DetonSolver_solve(self, reactant_weights, t1, p1, frozen) result(soln)

! Call the solver
if (frozen_) then
call log_info('DetonSolver: frozen composition not supported yet')
! call self%solve_frozen(soln, reactant_weights, t1, p1)
call abort('DetonSolver: frozen composition not supported yet')
else
call self%solve_eq(soln, reactant_weights, t1, p1)
end if
Expand Down
Loading