Numeric solver runaway using ReactorNet.advance_to_steady_state
@hasin4 is already working on this.
Since Oct 11, 2026.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 35/100
Research direction
Start by running the supplied Python example with Cantera 2.5 and focus on ReactorNet.advance_to_steady_state with IdealGasConstPressureReactor. Compare the failing cases with ConstPressureReactor and IdealGasReactor, recording reactor mass and volume; done means the reproduced cases no longer generate invalid values or CanteraErrors, or the limitation is clearly documented.
Written by the indexing model from the issue text.
Description
I want to simulate burning methane in an IdealGasConstPressureReactor. I use different mass-flows and equivalence-ratios using two vectors you can see in my example code below. However, using ReactorNet.advance_to_steady_state breaks the solver at certain points, leading to huge reactor masses and volumes and therefore CanteraErrors. If I varying the equivalence-ratio leads to different combustors failing, varying the mass-flows to each reactor has no effect on this. Using a ConstPressureReactor also leads to the same results, using an IdealGasReactor eliminates the error while the pressure before and after the reactor stays about the same (0.1% differences).
Steps to reproduce
My example code:
import cantera as ct
import numpy as np
# Initial constants
inlet_temperature = 712 # K
inlet_pressure = 2171756.0738435777 # Pa
inlet_density = 10.529 # kg/m³
phi_mean = 0.3
phi_std = 0.25
mdot = 350 # kg/s
# Vectors for phi and mass flow ratio
x=[0.1125, 0.1375, 0.1625, 0.1875, 0.2125, 0.2375, 0.2625, 0.2875, 0.3125, 0.3375,
0.3625, 0.3875, 0.4125, 0.4375, 0.4625, 0.4875]
y_norm=[0.05223705, 0.05602466, 0.05948904, 0.0625391, 0.06509137, 0.0670737,
0.06842868, 0.0691164, 0.0691164, 0.06842868, 0.0670737, 0.06509137,
0.0625391, 0.05948904, 0.05602466, 0.05223705]
psr_exhaust_gases = []
# Run Combustors for each Massflow/Phi
n = 0
for phi, ratio in zip(x,y_norm):
gas = ct.Solution("gri30.xml")
gas.TP = inlet_temperature, inlet_pressure
print(f"{n} Combustor using phi={phi} and mass flow {ratio*mdot}")
gas.set_equivalence_ratio(phi, 'CH4:1.0', 'O2:1.0, N2:3.76')
gas.equilibrate("HP")
inlet = ct.Reservoir(gas)
exhaust = ct.Reservoir(gas)
reactor = ct.IdealGasConstPressureReactor(gas)
reactor.volume = 1
inlet_mfc = ct.MassFlowController(inlet, reactor, mdot=mdot*ratio)
outlet_mfc = ct.PressureController(reactor, exhaust, master=inlet_mfc, K=0.98)
# Perform simulation
sim = ct.ReactorNet([reactor])
try:
sim.advance_to_steady_state()
except Exception:
print(f"Reactor {n} failed")
print(f"Reactor Mass: {reactor.mass}")
psr_exhaust_gases.append(gas)
n+=1
Behavior
0 Combustor using phi=0.1125 and mass flow 18.2829675
Reactor Mass: 7.509287323526787
1 Combustor using phi=0.1375 and mass flow 19.608631
Reactor 1 failed
Reactor Mass: -31989052.24073112
2 Combustor using phi=0.1625 and mass flow 20.821164
Reactor Mass: 6.698140629935816
3 Combustor using phi=0.1875 and mass flow 21.888685
Reactor Mass: 6.363181017677751
4 Combustor using phi=0.2125 and mass flow 22.7819795
Reactor 4 failed
Reactor Mass: 5706937067178.77
5 Combustor using phi=0.2375 and mass flow 23.475795
Reactor 5 failed
Reactor Mass: -503360543931.0006
6 Combustor using phi=0.2625 and mass flow 23.950038000000003
Reactor Mass: 5.5565265127696755
7 Combustor using phi=0.2875 and mass flow 24.190739999999998
Reactor 7 failed
Reactor Mass: -1743850606.9494267
8 Combustor using phi=0.3125 and mass flow 24.190739999999998
Reactor Mass: 5.139242033695134
9 Combustor using phi=0.3375 and mass flow 23.950038000000003
Reactor Mass: 4.957399144199033
10 Combustor using phi=0.3625 and mass flow 23.475795
Reactor 10 failed
Reactor Mass: -1583462983.9286568
11 Combustor using phi=0.3875 and mass flow 22.7819795
Reactor 11 failed
Reactor Mass: -1327952461.4260874
12 Combustor using phi=0.4125 and mass flow 21.888685
Reactor Mass: 4.4945519221887915
13 Combustor using phi=0.4375 and mass flow 20.821164
Reactor 13 failed
Reactor Mass: 1025354594.860802
14 Combustor using phi=0.4625 and mass flow 19.608631
Reactor 14 failed
Reactor Mass: -6298273.947422755
15 Combustor using phi=0.4875 and mass flow 18.2829675
Reactor 15 failed
Reactor Mass: -2568280.108493603
System information
- Cantera version: 2.5
- OS: Windows 10
- Python software version: 3.8.5
- Dominant language
- C++
- Stars
- 883
- Forks
- 436
- Avg merge
- 3h 41m
- Merged PRs (30d)
- 1
Getting set up
- No Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from Cantera/cantera
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
Incorrect reference state in some of the YAML files.Possibly taken @hazalkoom claimed this 54 days ago. OpenInput
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
-
Difficulty 3/5 1-2 days Newbie friendliness 62/100
-
[Bug]`ReactorNet.advance()` is not reproducible when an advance limit is set (root-finding arrays left uninitialized when `CVodeRootInit` is toggled per call)Possibly taken @kimurap claimed this 40 days ago. Open
Difficulty 4/5 3-5 days Newbie friendliness 55/100
-
CI
Difficulty 4/5 3-5 days Newbie friendliness 48/100
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
-
status:needs-triage
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
PX4/PX4-Autopilot#29698 ·
Maintainers usually reply within 1 day
-
go perft exits when EvalFile is unavailablePossibly taken @Muawiya-contact claimed this today. Open
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
official-stockfish/Stockfish#7292 · 2 comments ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 77/100
arvidn/libtorrent#9149 ·
Maintainers usually reply within 1 day
-
Upstream report: MSVC rejects a designated initializer in a dependent template argument (C2131)Open
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
rhalbersma/tabula#72 ·