PYroMat icon indicating copy to clipboard operation
PYroMat copied to clipboard

Easily capable to handle a simple inverse arg case for Ideal Gases

Open jranalli opened this issue 1 year ago • 5 comments

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:

T = np.full_like(y, 0.5*(self.data['Tlim'][0] + self.data['Tlim'][-1]))
I = np.ones_like(y,dtype=bool)
...
self._iter1(invfn, 'T', y, T, I, self.data['Tlim'][0], self.data['Tlim'][-1])

So I propose we insert this code in the initial argument setup of _argparse, similarly to how we deal with v. If h or e 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.

jranalli avatar Apr 13 '23 19:04 jranalli