Closed oporras closed 1 year ago
Hello @oporras , thank you for trying pandapipes and getting in contact. As of the current implementation, the compressibility is just a function of the pressure (I did not find any reference to a call with the temperature, but if you can name one, I would be happy to make necessary corrections). We have been discussing properties depending on both pressure and temperature, but have never made it to implement any. I am not too sure about the impact of the temperature on the compressibility factor, but this aspect is certainly lacking. Still, I am wondering what the temperature spread of your data looks like, if you are willing to give some insights. Maybe there is a solution to your problem, even with little effort. In case of timeseries simulations, a very simple controller could do the job. Kind regards!
Hi @dlohmeier,
Thanks for your answer. I revised the code of pandapipes and I found effectively that the implementation of the compressibility factor depends only of pressure. My confusion came from the old documentation of the version 0.2.0. where the fluid.get_compressibility
is a function of temperature. With respect to a situation where temperature is important, consider the case of methane compression from 1 bar to 70 bar. If the temperature at 70 bar is considered to be 20°C, the generalized compressibility chart indicates that Z is 0.859 (pandapipes calculates 0.846). But if you consider the temperature increase that normally produces the compression of a gas, say up to 80°C, the compressibility factor should be 0.932, a quite different value.
Hi: Studying the complexity of compressibility factor computation as a function of temperature and pressure, I found that it is not very difficult to do the implementation. I am enclosing a simple Python code based on the Redlich-Kwong equation for methane. With a little more effort, the models based on the Soave-Redlich-Kwong or Peng-Robinson equations can be developed by including an additional parameter (the vapor pressure at 0.7*Tc) in order to calculate the acentric factor and improve the accuracy of Z. This model can be easily generalized with only three parameters (Tc, Pc, and Pv at 0.7Tc) to other gases.
Hi, just as a sidenote, there is also a related discussion on this topic. In Liu et al., 2020] this implementation is used
Thank you very much for your example, @oporras and the sidenote @jkisse ! I would like to emphasize that I believe that this is indeed a problem with the current implementation and that there are good solutions to getting a better approach for the compressibility calculation, which should be easy to implement. The tricky part is how to integrate this into our internal pandapipes simulation procedure. At the moment, we assume that all properties only have one dependent variable (in most cases, it is the temperature, but for the compressibility, it is the pressure). If we want to make respective changes, we need to consider the following:
As so often, this is mainly a question of time and resources that we all can spend on improving the code and making the required changes. If you are willing to contribute, you are most welcome to open your own Pull Request @oporras , and we will certainly take the time to review it. But I cannot promise that we will be able to implement these kinds of properties with the current pandapipes team at the moment.
Thank you for the explanation and the invitation @dlohmeier. Because I have neither enough experience as an application programmer within libraries like pandapipes nor free time, I don’t think I can contribute to the project now.
Hi, I´m a new user of pandapipes. I found it very useful. Congratulations and thanks to the developers!
The definition and calculation of compressibility for a new gas fluid are a bit confusing to me because, in some cases, this variable is only a function of the temperature (v.g.
fluid.get_compressibility(temperature)
). Still, in some examples, it appears to be only a function of the pressure (v.g.comp_fact = get_fluid(net).get_property("compressibility", p_bar)
).According to thermodynamics references, the compressibility factor is a function of both, pressure and temperature. How can I define the compressibility of a new gas as a function of pressure and temperature?