Hi,
What version of Cantera are you using? I wasn’t able to run your code using either the latest release (Cantera 3.1) or the current development version without first making several modifications to the input file. Specifically:
Following that, there is then an issue with your integration loop, which boils down to:
t = 0.0 dt = 0.01 while t<2: sim.advance(dt) t = t+ dtThe argument to the advance method should not be the time step but rather that absolute time that the integrator should reach. As written, the loop will integrate to 0.01 second, and then the subsequent calls will do nothing except increase the value of t.
The integrator errors that you get after turning on the energy equation are a bit more complex to resolve. For reasons I don’t quite understand, the integrator occasionally tries to evaluate the equations with enthalpy values that correspond to temperatures that are out of bounds for the liquid water equation of state. There is currently an issue with this situation, where setting invalid values on the phase object once makes it impossible to set a valid state afterwards, resulting in these unrecoverable errors. I’ve put together a pull request which should resolve the issue. If you can build Cantera from source, you can try this after it’s been merged into the main branch.
More broadly, I think you’re on the right track with representing the mass transfer between the liquid and the gas using “reactions” on the surface. You may need to think a bit about the meaning of the “site density” that Cantera applies in the calculation of these rates and whether you’re getting the rates you expect. For handling rates that vary as a function of other parameters in your system, you may also want to look at using the ExtensibleRate and/or ExtensibleReactor classes to implement your custom behavior.
I’m not sure I follow your last question. Do you have a definition for the terms that you want to compute?
Regards,
Ray
Thankyou very much for your reply!!!
I am sorry for not reviewing my modeling work carefully before submitting codes, which contained obvious errors. I’m using Cantera 3.0 and I ‘ve followed your advice and corrected the mistakes.
Again, thank you for the thorough feedback—and for taking the extra help of reporting the problem I met!!!
I did model gas–liquid mass transfer by treated it as a reaction in Cantera and found that simply overlaying an Arrhenius expression worked very well.But I have a follow-up question: if I switch to the ExtensibleReactor module from a “tricky” reaction to model the mass-transfer, how do I deal with a multiphase interface? For example, how to get gas component in a liquid phase reactor?
And what if I use the ExtensibleReaction class instead? I’d like to implement a surface-renewal model, but that theory needs time parameter t as an explicit variable, which ExtensibleReaction Module cannot achieve.
My another goal is to couple Cantera to a CFD solver via its chemical source terms. I see two possible routes:
It’s the second route that confuses me. Cantera exposes a handful of gradient-related Methods: Reactor.finite_difference_jacobian, ReactorNet. get_derivative(), Many derivative terms in Kinetics modules, even and ThermoPhase.netProductionRates, etc.I tried to use Reactor.finite_difference_jacobian and ReactorNet. get_derivative() accordingly (see the new codes I submitted). Is my model correct?