Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
jranalli opened this issue Apr 13, 2023 · 3 comments
Open

Comments

@jranalli
Copy link
Collaborator

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
Copy link
Collaborator Author

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.

@chmarti1
Copy link
Owner

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.

@jranalli
Copy link
Collaborator Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants