Hi Raphael,
Similarly, I looked over the script (I do not have Matlab, so this is the best I can do, for now). There are of course some language barriers, but I think I understand the big idea of what you are doing.
Along the lines of what Ingmar has suggested, I think any suggestion here will likely have you adding more functionality to track the state of your water. For example, I’m not quite certain: is water injected at a different state (T and P) than the reactor contents? If so, you would need to model the heat transfer between the reactor contents and injected water (would you assume that pressure equilibrates immediately?). In my “mind’s eye” picture, you would have the water’s internal energy as a state variable, and so you can implement an equation to predict the evolution, du/dt. If you do this, then yes, you can set the water state using `setState_UP`, and then print out the quality for any given state via `vaporFraction(gas)`.
I will note, of course, that you are assuming no reactions between any water vapor produced and the other contents of your reactor.
Now, for implementation. Cantera’s current reactors seem like they cannot handle injecting one phase of matter into a reactor whose contents are an entirely other phase. My two initial thoughts:
2. Define two reactors—one for gas, one for water—with a wall between them to transfer heat between the two phases. I am not adept as using Cantera’s reactor models, but this seems the fasted and most straight-forward approach (again, assuming you do not want to enable chemical reactions between the two phases).
Best,
Steven