portyanikhin / PyFluids

Simple, full-featured, lightweight CoolProp wrapper for Python
https://pypi.org/project/pyfluids
MIT License
51 stars 2 forks source link

An error occurred while calculating the gas mixture #30

Closed funzeng closed 1 year ago

funzeng commented 1 year ago

from pyfluids import Mixture, Fluid, FluidsList, Input

mix = Mixture([FluidsList.Methane,FluidsList.Hydrogen],[60, 40]).with_state(Input.pressure(200e+03), Input.temperature(30),) print(mix.specific_heat) print(mix.compressibility)

ValueError: One stationary point (not good) for T=303.15,p=200000,z=[ 0.228681059385, 0.771318940615 ]

minger88 commented 1 year ago

I'm also having this issue.

` from pyfluids import Fluid, FluidsList, Input

air = Mixture([FluidsList.Nitrogen, FluidsList.Oxygen], [60, 40]).with_state( \ Input.pressure(25.3e5), Input.temperature(500) ) print(air.as_json())`

`

ValueError Traceback (most recent call last) /tmp/ipykernel_31964/3330669777.py in 1 from pyfluids import Fluid, FluidsList, Input 2 ----> 3 air = Mixture([FluidsList.Nitrogen, FluidsList.Oxygen], [60, 40]).with_state( \ 4 Input.pressure(25.3e5), Input.temperature(500) ) 5 print(air.as_json())

~/.local/lib/python3.8/site-packages/pyfluids/fluids/abstract_fluid.py in with_state(self, first_input, second_input) 322 """ 323 fluid = self.factory() --> 324 fluid.update(first_input, second_input) 325 return fluid 326

~/.local/lib/python3.8/site-packages/pyfluids/fluids/abstract_fluid.py in update(self, first_input, second_input) 336 raise ValueError("Need to define 2 unique inputs!") 337 self.reset() --> 338 self._backend.update( 339 *generate_update_pair( 340 first_input.coolprop_key,

CoolProp/AbstractState.pyx in CoolProp.CoolProp.AbstractState.update()

CoolProp/AbstractState.pyx in CoolProp.CoolProp.AbstractState.update()

ValueError: One stationary point (not good) for T=773.15,p=2.53e+06,z=[ 0.660344557162, 0.339655442838 ] `

Doing either Nitrogen or Oxygen as a pure fluid works just fine `from pyfluids import Fluid, FluidsList, Input

air = Fluid(FluidsList.Oxygen).with_state( \ Input.pressure(25.3e5), Input.temperature(500) ) print(air.as_json())`

portyanikhin commented 1 year ago

Hello, @funzeng, @minger88!

You are facing the error of CoolProp itself, not PyFluids.

Judging by the error message, this is due to the fact that the calculations did not converge. As far as I understand, the equations of state for mixtures have much more restrictions than the equations of state for pure fluids.

I think you can recreate this error using pure CoolProp (because CoolProp developers are most likely not familiar with PyFluids), and open an issue in the CoolProp repository. CoolProp developers will be able to answer in more detail.