Good afternoon, all.
I am attempting to compute the H2-O2 detonation properties for a range of equivalence ratios (0.5 ≤ ϕ ≤ 2.0). For most of these values, I am getting no trouble, but for some of them I'm getting a range of types of failed convergences. Equivalence ratio is the only variable; upstream temperature and pressure are functionally constant*. I am using the CJspeed and PostShock_eq routines and the h2o2_highT mechanism from the Shock & Detonation Toolbox, and Cantera 2.2.1 in MATLAB.
I'm seeing three types of failed convergence behavior. Using sample equivalence ratios:
1. At ϕ = 0.518, the routine enters what appears to be an infinite regression somewhere inside CJspeed. (At least, close enough to infinite - after letting it sit for a half-hour and seeing no progress, I stopped the code.)
2. At ϕ = 0.660, the value of U_CJ computed by CJspeed (1588.1677 m/s) is approximately 40% too low, which causes PostShock_eq to fail to converge, and I get an error message stating "shk_eq_calc did not converge for U = 1588.1677", but the script continues to run.
3. At ϕ = 0.655, at some point in the computation of what I believe is the equation of state for the (upstream?) conditions, the iterated value of density goes negative, and the script crashes. The error message for this is given below**.
It is worth mentioning that ϕ =0.650 and ϕ = 0.665 both work fine. A friend suggested I try changing the solver used in the "equilibrate" routine from 0 to 1, to use the Gibbs-free-energy-minimization method [i.e. changing equilibrate(gas, 'TV') to equilibrate(gas, 'TV', 1)], but this did not solve the problem, and instead just moved around the points where convergence fails.
I have no idea why some conditions work and some do not. Does anyone have any insight into how I can correct this? I have attached a minimal example code, as requested. It is based on my full code, the relevant part of which is in turn based on the "demo_CJstate.m" example from the Shock and Detonation Toolbox.
Thank you very much.
-- Andrew Mizener
* The upstream conditions are actually choked flow through a nozzle, and the insentropic critical pressures and temperatures for which are a function of the ratio of specific heats, which varies slightly with equivalence ratio. However, the difference between - for example - ϕ = 0.65 and ϕ = 0.655 is on the order of 1e-3 percent in both pressure and temperature.
** Here is the error message given for example 3:
Error using ThermoPhase/setDensity (line 12)
The density must be positive.
Error in ThermoPhase/set (line 169)
setDensity(tp, 1.0/vval);
Error in eq_state (line 22)
set(gas, 'Density', r1, 'T', T1);
Error in CJ_calc (line 37)
[P, H] = eq_state(gas,r,T);
Error in CJspeed (line 55)
[gas, w1(i)] = CJ_calc(gas, gas1, ERRFT, ERRFV, x);
Error in Det_Min_Example (line 136)
[U_CJ] = CJspeed(P_I, T_I, Mixture, Mechanism, fig_num);