Failure using Cantera's reactor model with modified governing equations

76 views
Skip to first unread message

Gandhali Kogekar

unread,
Jun 28, 2024, 1:38:26 PMJun 28
to Cantera Users' Group
surfDiff_ode.png

Ray Speth

unread,
Jun 28, 2024, 4:13:42 PMJun 28
to Cantera Users' Group
Hi Gandhali,

Can you please share your code? There isn't enough information here to speculate on why the solver is struggling or what is causing the density to go negative. The easiest way might be to push your changes to a branch on GitHub and share that link, along with a script for setting up and running the specific simulation in question.

Regards,
Ray

Gandhali Kogekar

unread,
Jul 8, 2024, 9:37:49 AMJul 8
to Cantera Users' Group
We are comparing two models - one that uses Cantera's reactor model (with modified equations) and another standalone python code solving the same governing equations. The modified Cantera source code is here. The Python script to run this model is reactor_ct.py. The standalone python notebook is 'surface_diffusion_ode'. Both models use the same yaml file. If we print (dtheta/dt) values in both models, initial values are exactly the same. But Cantera model fails afterward. The immediate jump in the solution at t=0 is mainly because of the rate coefficient value (which is correct). The model works fine if we reduce the rate coefficient value by a factor of 1e6 or so.
reactor_ct.py
Surface_diffusion_ode.ipynb
multifacet_ODE.yaml

Gandhali Kogekar

unread,
Jul 8, 2024, 9:48:17 AMJul 8
to Cantera Users' Group
Copying a reply from Ray from another channel: 

You're running into a version of https://github.com/Cantera/enhancements/issues/201. Before you calculate the edge reaction rates, you need to call syncState not only on the edge itself, but also all other surfaces that touch that edge. As long as those surfaces are all defined using independent ThermoPhase objects, it is safe to just do this ahead the other calculations in Reactor::evalSurfaces, for example by just writing:

for(auto S : m_surfaces) {
        S->syncState();
    }

I found this much, much easier to debug by using the lower-level ReactorNet.step method than using ReactorNet.advance . Part of the problem here is that the time scale that you're indicating there to the solver is completely different from the timescale introduced by the reactions. You have dtheta/dt values of around 1e10, giving timescales of ~0.1 ns, but are only asking for the solution at times that are many orders of magnitude larger. Are you sure you've got the units/dimensions of these rates worked out correctly?

UPDATE
Using the syncstate before all calculations fixed the issue. With above suggested changes, Cantera model too works perfectly fine using ReactorNet.advance. 

Thanks for your help. 
Reply all
Reply to author
Forward
0 new messages