chmarti1 / PYroMat

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

Incorrect Pressure-Density Relationship for Multiphase Oxygen #90

Closed LeoBanach closed 4 months ago

LeoBanach commented 4 months ago

I encountered a suspicious behaviour when dealing with multiphase oxygen in pyromat. If I understood correctly, when providing a temperature and density, this should result in only one temperature when moving in the phase diagram. When I then use this pressure with the same temperature like before, it should result in the identical density. But as can be found in the example code below, this is not the case for the values I tried.

I also used the NIST Database as a reference, showing that for a temperature of T = 80 K and a density of d = 1190.6 kg/m³ a pressure of p = 1 bar should be the result. If it helps, they use the equation of state from Schmidt and Wagner(1985) as a reference.

Unfortunately, I am not very experienced with the handling of equation of states, which is why I may have made another mistake here, which you are welcome to point out to me.

Python 3.9.13 (main, Aug 25 2022, 23:51:50) [MSC v.1916 64 bit (AMD64)] on win32
import pyromat as pm
pm.__version__
Out[3]: '2.2.4'
pm.config['unit_pressure']
Out[4]: 'bar'
pm.config['unit_matter']
Out[5]: 'kg'
pm.config['unit_volume']
Out[6]: 'm3'
pm.config['unit_temperature']
Out[7]: 'K'
oxygen = pm.get('mp.O2')
oxygen.p(T=80, d=1190.6)
Out[9]: array([0.30085456])
oxygen.d(T=80, p=1)
Out[10]: array([1190.58625754])
oxygen.d(T=80, p=0.3)
Out[11]: array([1.46231959])
jranalli commented 4 months ago

Thanks for using pyromat!

What you're seeing here is that your initial state is a liquid that happens to be very very close to the steam dome. So even the small change you're making to pressure leads to you transitioning from liquid to vapor, which causes a very large, sudden change in density. You can see the dots on the opposite side of the dome in the attached figure.

So, the solution is you need to be a bit careful working that close to the steam dome how you're specifying your states to make sure you don't accidentally make that transition. In general, specifying p&T in those situations is a bit iffy and it's much more consistent to use p or T with a different property.


From: Leopold @.> Sent: Wednesday, May 22, 2024 3:57:35 AM To: chmarti1/PYroMat @.> Cc: Subscribed @.***> Subject: [chmarti1/PYroMat] Incorrect Pressure-Density Relationship for Multiphase Oxygen (Issue #90)

I encountered a suspicious behaviour when dealing with multiphase oxygen in pyromat. If I understood correctly, when providing a temperature and density, this should result in only one temperature when moving in the phase diagram. When I then use this pressure with the same temperature like before, it should result in the identical density. But as can be found in the example code below, this is not the case for the values I tried.

I also used the NIST Databasehttps://webbook.nist.gov/ as a reference, showing that for a temperature of T = 80 K and a density of d = 1190.6 kg/m³ a pressure of p = 1 bar should be the result. If it helps, they use the equation of state from Schmidt and Wagner(1985)https://doi.org/10.1016/0378-3812(85)87016-3 as a reference.

Unfortunately, I am not very experienced with the handling of equation of states, which is why I may have made another mistake here, which you are welcome to point out to me.

Python 3.9.13 (main, Aug 25 2022, 23:51:50) [MSC v.1916 64 bit (AMD64)] on win32 import pyromat as pm pm.version Out[3]: '2.2.4' pm.config['unit_pressure'] Out[4]: 'bar' pm.config['unit_matter'] Out[5]: 'kg' pm.config['unit_volume'] Out[6]: 'm3' pm.config['unit_temperature'] Out[7]: 'K' oxygen = pm.get('mp.O2') oxygen.p(T=80, d=1190.6) Out[9]: array([0.30085456]) oxygen.d(T=80, p=1) Out[10]: array([1190.58625754]) oxygen.d(T=80, p=0.3) Out[11]: array([1.46231959])

— Reply to this email directly, view it on GitHubhttps://github.com/chmarti1/PYroMat/issues/90, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AB4ABDDW4TTVH2NSITDKNBDZDRFW7AVCNFSM6AAAAABIDCMF2CVHI2DSMVQWIX3LMV43ASLTON2WKOZSGMYDSOBUGIYTMNI. You are receiving this because you are subscribed to this thread.Message ID: @.***>

jranalli commented 4 months ago

Whoops nevermind, I missed part of what you were showing there. Let me look a little longer at it.

jranalli commented 4 months ago

Alright, so my statement is correct, but the explanation is a bit unclear. I put your three states in and looked at all the properties. The issue is that your first two states are essentially the same state to within the decimal resolution we're representing. Here's a table of the values. You can see that states 1 and 2 both have the same density to within rounding accuracy. You can see slight variation in the volume though. So what's happening is it comes up with state 1 as a saturated state at the saturation pressure of 0.3008 bar, but a very low quality. State 2 at 1bar you can see us a higher pressure, and thus a liquid, but is so close to state 1 as to be indistinguishable on all the properties. State 3 is, as I said, barely below the saturation pressure but just enough to make it a vapor, and that explains the big difference you see.

LeoBanach commented 4 months ago

Thank you very much for your quick response and all the work you put into the tool!

While I don't see the table you mentioned, I think I understood the problem. I will look more closley into my usecase and work more carefully around this regime. So the problem was on my side afterall. Thanks for the explanation 😄