-
Notifications
You must be signed in to change notification settings - Fork 60
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
Out-of-bounds temperature treatment for NASA polynomials #255
Comments
Good evening, I am trying to shift the reference temperature from 25°C to 0°C. Do you think this is related to the issue you are describing? Thanks |
Hi @mgoodson-cvd. That would be an interesting addition. I can review the merge request. I wonder whether adding an option to choose the default behavior is important, to avoid breaking other codes. Even though yours is the most natural choice, it is not what people always do. @domilanza2002 Probably these two issues are indeed related. |
@domilanza2002 That is precisely the issue, because @grgbellasvki The switch is an interesting idea, though I can't imagine ever running without it on. I would certainly want this to be the default behavior to avoid issues like @domilanza2002. What other choices for out-of-bounds treatment are there? |
Thank you for explaining. When do you think you will be able to push the new version? Thanks DL |
@domilanza2002 I don't have a timetable at this point. It will depend on how @grgbellasvki and others want to proceed. I will try to push at least a working version to my fork in the next week or so, though with no tests or options to turn off. |
@mgoodson-cvd Thank you for letting me know. |
@mgoodson-cvd I was thinking more of throwing an error if the temperature is out-of-bounds as the default behavior and the switch would enable extrapolation. I agree that what you recommend is a significant improvement compared to what it is now in the code. If you push a merge request, I can review the code and try a few LTE and B' calculations which are of interest for many users. As far as alternatives, it really depends on the application. I know for example a team which freezes enthalpy below a certain value to assist chemistry thermodynamics. Another approach would be extrapolating at low Ts using RR. Warning the user to provide more data is often the best and safest choice. Thanks! |
When the temperature is out-of-bounds with the NASA polynomials, hold the Cp constant and adjust the enthalpy and entropy accordingly. Note: this code was mostly authored by Alireza Mazaheri of NASA LaRC. See mutationpp#255. Closes mutationpp#255.
@grgbellasvki @domilanza2002 I've opened #257 with an initial draft of the code. @grgbellasvki I don't think erroring out when out-of-bounds would be desired. For one thing, some elements like electrons have a lower temperature bound of 298.15 K; yet the Cp is already constant for electrons so there really isn't a "lower" bound. Also, the polynomials aren't that bad for some range of temperatures outside of the bounds; e.g., for air, NASA-9 is still sane at 160 K, but then gets bad very quickly as the polynomials go haywire. In regards to warning the user, it sounds like a good idea but in practice could get extremely verbose, such as for the electron case mentioned above. I guess the best path forward would be to add a flag to the mixture inputs to control the out-of-bounds behavior, e.g.,
where the two current options for |
@mgoodson-cvd Thank you! Thank you and sorry for the bothering |
Add Matthew Goodson and Alireza Mazaheri to the contributors list. See mutationpp#255.
Update the version to 1.2.0. See mutationpp#255.
@domilanza2002 Yes, you will have to rebuild using my branch, https://github.com/mgoodson-cvd/Mutationpp/tree/255-out-of-bounds-treatment-for-nasa-polynomials You have a few options. You can just manually update the NasaDB.h file in your repo and replace it with mine. Or you can add my fork as a remote and checkout my branch. Or you could download my fork directly as a new folder. |
@mgoodson-cvd Thank you! Thanks |
@mgoodson-cvd If you are adding an option I would suggest to use one that is more descriptive than |
Hey All, just to add my two cents. I agree that cp clipping is probably the "right" solution and I also agree that having an option for the user is also desired. I see three possibilities that would be useful:
Option 1 is the cp clipping described by @mgoodson-cvd. Option 2 is the current behavior. Option 3 is to explicitly crash by raising an exception. I would call this option "when_outside_temperature_range" in the mixture file. Putting this together with any of the three options is pretty clear IMO. Ideally, this could be implemented with a strategy pattern that doesn't require a bunch of if statements every time you hit this decision point. |
@AlirezaMazaheri @jbscoggi Thanks both of y'all for the feedback here. I will give this a shot when I get a chance. I was already thinking about how to handle the "if" statements, either through templating or multiple versions of the NasaDB class. I'll let you know when I have something working. |
@mgoodson-cvd, I think there are probably two approaches that work well. One is using the decorator pattern in which you have the NasaDB class as it is (this represents the |
The current behavior with the NASA thermodynamic polynomials is to use them directly, even if the temperature is out-of-bounds. This can be extremely problematic as the polynomials go wild outside of the bounds. (This issue was already partially raised in #117). Note that each NASA-9 table entry provides its own temperature bounds, though most of the McBride data is 200 K - 6000 K (or 20,000 K).
The common treatment for out-of-bounds temperature with NASA polynomials is to hold Cp constant at the last in-bounds temperature, e.g., from the FUN3D version 13.4 manual:
@AlirezaMazaheri provided me with his initial implementation of this in Mutation++ and his permission to share it. I have updated it to work with the latest version of Mutation++ and am currently testing it. I hope to be able to push it soon.
The text was updated successfully, but these errors were encountered: