chmarti1 / PYroMat

PYroMat thermodynamic properties in Python
http://pyromat.org
Other
71 stars 13 forks source link

General Inverse Property Lookup Functionality #87

Open DasFelthaus opened 6 months ago

DasFelthaus commented 6 months ago

Description:

Request for enhancement to add general inverse property lookup capabilities to Pyromat, enabling users to calculate properties like temperature or pressure based on other properties (e.g., entropy and quality). This feature would streamline calculations involving complex thermodynamic cycles by directly solving for states without iterative methods.

Benefits:

Implementation could involve creating a generalized framework for inverse lookups that can be extended to various properties and substances. This addition would significantly enhance Pyromat's functionality and its applicability in thermodynamic analyses.

Thank you for considering this suggestion.

chmarti1 commented 2 months ago

It took me a very long time to get to your request. Thank you for your patience, and thanks for your question!

I get this request a fair bit, so it deserves a good discussion. As of version 2.2.4, there is already quite a bit of flexibility in how states are defined, but it's true that some combinations are not supported. As of v2.2.4, here's what's allowed so far in the mp1 class:

e,T e,p e,d e,v e,x h,T h,p h,d h,v h,x s,T s,p s,d s,v s,x T,p T,d T,v T,x T,p,x (very special case) p,d p,v p,x d,x v,x

There are some combinations that are excluded for very good reasons. For example, the plot below shows enthalpy of steam as a function of temperature for x = [0.00,0.25,0.5,0.75,1.00]. In general, it is actually not theoretically correct to write T(h,x) because there are multiple temperatures that can give the same enthalpy and quality.
image

There are some more subtle issues as well. It is theoretically acceptable to specify enthalpy and temperature as a pair, but it is can be a numerical catastrophe because enthalpy is only a very weak function of density in the vapor phase.

Really there are only two kinds of valid combinations that are not currently supported:

  1. Pairs of non-basic properties (h,s or e,s)
  2. Properties not currently directly supported (like Gibbs energy of speed of sound) Both are absolutely "on the list" of things to do in the future.
chmarti1 commented 2 days ago

There is now a more thorough discussion of these ideas here and in the handbook. It really is a valid question.