Closed jranalli closed 1 month ago
Ok, branch issue83 has the methods and all ig tests pass. The big changes are as follows:
1) Change the inverse_args check to only error on the h&e combo.
2) Immediately error if T & h/e are specified in the initial arg unit conversion
3) Replace h/e with T in the unit conversion similarly to how v
is handled.
4) cleanup the inverse_args codes, because the only remaining inverse_arg possible is entropy.
Still needs doing:
5) Improve comments on the algorithm, now that the rules for inverse_args are changed.
6) Consider a more elegant way to do this. For example, we could call T, h and e calorific args
and only allow one of those to be passed in. FWIW I like this a lot and would implement if you like, because it cleans up the way that 1,2 & 3 are handled to be more straightforward.
Thoughts appreciated. Since this was done in a branch, we can easily pull request when we're ready to consider whether it belongs in the main branch.
I agree. This is worth implementing. It would still be nice to see this problem solved well for multi-phase substances, but you make the point well - it's easy for gases, so let's do it. Give me some time to work through it all, and I'll fold it in to the master branch with the next release.
Do you want me to take a crack at update 6) to clean up my proposal or give you a chance to dig into it and rework it your own way? Either way is fine by me.
OK, I fell off the edge of the planet for a while. I'm piecing together bits and bobs for the next release now. I don't think this will take me long to just do this; it's pretty easy.
I just pushed https://github.com/chmarti1/PYroMat/commit/09044f27a615f0ea882ed7e6569e7c3a6e0a8e40 to the igtools
branch. It implements this functionality in all three ideal gas classes.
It isn't fully capable yet, but there's also the draft framework for a new dynamic mixture class in the new igtools
module.
from pyromat import igtools as igt
# Make mixtures algebraically
ch4 = igt.IGTMix('CH4')
o2 = igt.IGTMix('O2')
fun = ch4 +2 * o2
# or from format strings
fun = igt.IGTMix('CH4 + 2 O2')
# Deal with big arrays of mixtures
y = np.linspace(0,1,101)
fun = igt.IGTMix({'CH4': y, 'O2':1-y})
The ability to pass enthalpy, internal energy, and temperature along with entropy has been added to v2.2.5.
Via a conversation with Jacob, some diffuser problems lead to a desire to handle h&s. For example, for a known inlet velocity, pressure and temperature, and an outlet condition of zero velocity, the outlet state can be computed from the first law (yielding h) and the isentropic assumption for an ideal diffuser.
This is probably possible for any substances via some type of iteration. But for ideal gases it's nearly trivial, due to the dependence of h/e on T only.
Looking at program flow in argparse (e.g. for ig.py: 234), every time you're given h or e, T is always directly calculated by iteration and doesn't depend on any of the other basic properties:
So I propose we insert this code in the initial argument setup of _argparse, similarly to how we deal with
v
. Ifh
ore
are in the args, replace them with T by iterating immediately and then continue with the algorithm (this is what you're actually doing anyway, you're just blocking that case). I changed the tests to allow for h&s and e&s, and then made an implementation that passes all those tests, which I will link in a comment.