Folks,
You can obtain negative concentration values during time integration even with a sophisticated ODE solver, both in python and MATLAB. I have also observed this in the past when the using CHEMKIN and backward difference solvers with adaptive step size control. It is a generic problem with time integration of stiff problems that have internal boundary layers, regions of large rates of decrease of one variable embedded in a slowly varying base flow.
In chemical kinetics, the problem often takes place when computing flow or batch reactions without diffusion. One or species rapidly decreases at the end of the reaction exothermic reaction region and the solver time-control algorithm has been taking increasing large steps up until this point. The algorithm is unable to sufficiently decrease the step size to avoid overpredicting the species concentration, which then becomes negative. This is a particular problem with certain fuel-oxidizer computations. For example, computing the ZND model of methane-oxygen reaction using almost any mechanism (GRI for example) will result in this issue unless the maximum step size and tolerances are tweaked to prevent this. These is an extremely rapid drop in mass fraction from O(E-1) to < O(E-13) in in CH3O, CH3, and CH2 at the end of the energy release reaction zone. In flame or flow reactor computations with diffusion, this same change would happen over a sufficiently large time or distance that the usual integrator can adjust over multiple time steps to avoid creating negative concentrations, but this doesn't happen in simple flow reactor models. The consequence can be that the simulation will throw an error which originates from Cantera attempting to evaluate log(concentration) or similar action that is a numerical crime with negative concentrations. Superficially the problem appears to be with Cantera but it is a solver issue. The same sort of symptom can happen in some cases with the equilibrate function when using certain options that involve entropy and can be fixed by careful attention to the tolerances and choice of equilibrium solver. VCS tends to be more robust than Gibbs minimization in this regard.
The solution is to monitor the species concentrations and adjust the maximum step size and tolerances to enable the solver to resolve these internal boundary layers of species.
Best,
Joe
You can see the implementations of all these cases in the StoichManager.h <
https://nam04.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2FCantera%2Fcantera%2Fblob%2Fmain%2Finclude%2Fcantera%2Fkinetics%2FStoichManager.h&data=04%7C01%7Cdecaluwe%40mines.edu%7C880e1f8cd9ff4aeb1ee708d902a79d27%7C997209e009b346239a4d76afa44a675c%7C0%7C0%7C637543750513947715%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=E%2FJoO764ZpoI6b36UEMfS%2Fx5HIjyeyd1hNsKuH1FskM%3D&reserved=0> header file.
Regards,
Ray
On Sunday, April 18, 2021 at 2:28:51 PM UTC-4 Weiqi Ji wrote:
Hi Steven
I thought the concentration is not clipped to be >= 0 as the clipping may induce numerically issue, according to Ray's discussion above.
Below is the suggestion that Ray refers to
>
1. The user's RHS function should never change a negative value in the solution vector y to a non-negative value, as a "solution" to this problem. This can cause instability. If the RHS routine cannot tolerate a zero or negative value (e.g. because there is a square root or log of it), then the offending value should be changed to zero or a tiny positive number in a temporary variable (not in the input y vector) for the purposes of computing f(t,y). [
http://sundials.wikidot.com/integrating-over-discontinuities <
https://nam04.safelinks.protection.outlook.com/?url=http%3A%2F%2Fsundials.wikidot.com%2Fintegrating-over-discontinuities&data=04%7C01%7Cdecaluwe%40mines.edu%7C880e1f8cd9ff4aeb1ee708d902a79d27%7C997209e009b346239a4d76afa44a675c%7C0%7C0%7C637543750513957717%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=fp5swGDrw2b%2BmqrAQ6oL87zJYHhWNZR0CsxyxkKSaUQ%3D&reserved=0> ]
To view this discussion on the web visit
https://groups.google.com/d/msgid/cantera-users/2dd64519-780f-423f-878c-003718e805f0n%40googlegroups.com <
https://nam04.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgroups.google.com%2Fd%2Fmsgid%2Fcantera-users%2F2dd64519-780f-423f-878c-003718e805f0n%2540googlegroups.com%3Futm_medium%3Demail%26utm_source%3Dfooter&data=04%7C01%7Cdecaluwe%40mines.edu%7C880e1f8cd9ff4aeb1ee708d902a79d27%7C997209e009b346239a4d76afa44a675c%7C0%7C0%7C637543750513967710%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=r0yaqb07UAS61urfii366%2FTx4DdR0H8XHbC%2FoibxLS8%3D&reserved=0> .
--
You received this message because you are subscribed to the Google Groups "Cantera Users' Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to
cantera-user...@googlegroups.com.
To view this discussion on the web visit
https://groups.google.com/d/msgid/cantera-users/f099fd48-f8a7-4b9d-986d-beeaec2d2433n%40googlegroups.com <
https://nam04.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgroups.google.com%2Fd%2Fmsgid%2Fcantera-users%2Ff099fd48-f8a7-4b9d-986d-beeaec2d2433n%2540googlegroups.com%3Futm_medium%3Demail%26utm_source%3Dfooter&data=04%7C01%7Cdecaluwe%40mines.edu%7C880e1f8cd9ff4aeb1ee708d902a79d27%7C997209e009b346239a4d76afa44a675c%7C0%7C0%7C637543750513977705%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=QDpm5gl%2Fqe%2FsohBdI8Hxrwux3yJnZUwtz3M%2BY1NvXuw%3D&reserved=0> .
--
You received this message because you are subscribed to the Google Groups "Cantera Users' Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to
cantera-user...@googlegroups.com.
To view this discussion on the web visit
https://groups.google.com/d/msgid/cantera-users/254b7bd5-ec33-4697-b8c7-f06c8cd38a9en%40googlegroups.com <
https://nam04.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgroups.google.com%2Fd%2Fmsgid%2Fcantera-users%2F254b7bd5-ec33-4697-b8c7-f06c8cd38a9en%2540googlegroups.com%3Futm_medium%3Demail%26utm_source%3Dfooter&data=04%7C01%7Cdecaluwe%40mines.edu%7C880e1f8cd9ff4aeb1ee708d902a79d27%7C997209e009b346239a4d76afa44a675c%7C0%7C0%7C637543750513987699%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=bTc0c66NmXj92eMV9Z%2Bmsf9c64k2OLb6Wy5NHDwselk%3D&reserved=0> .
--
You received this message because you are subscribed to the Google Groups "Cantera Users' Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to
cantera-user...@googlegroups.com <mailto:
cantera-user...@googlegroups.com> .
To view this discussion on the web visit
https://groups.google.com/d/msgid/cantera-users/b5123624-8d2c-4f9e-8032-f56430145973n%40googlegroups.com <
https://groups.google.com/d/msgid/cantera-users/b5123624-8d2c-4f9e-8032-f56430145973n%40googlegroups.com?utm_medium=email&utm_source=footer> .