dwsim icon indicating copy to clipboard operation
dwsim copied to clipboard

[Bug]

Open cbkiyanda opened this issue 3 years ago • 3 comments

Simulating a simple, 4-component, rankine cycle using water and coolprop, there is a thermodynamic state inconsistency in the output of the turbine. The turbine output state has the correct entropy, pressure, and temperature, however, the vapour fraction and enthalpy are not consistent. In my example, DWSIM returns the output of the turbine state as: T = 45.8063 C P = 10 kPa s = 6.64826 kJ/kg.K Vapor mole Frac = 0.7488996 h = 1931.22 kJ/kg.K Using coolprop directly, for example from https://ibell.pythonanywhere.com/next?_formkey=9fd8f9b8-0e43-489a-846a-4695f45035ad&_formname=default&fluid=Water&name1=Pressure+%5BPa%5D&name2=Entropy+%5BJ%2Fkg%2FK%5D&unit_system=Mass-based&value1=10000&value2=6648.26499189 the state corresponding to P = 10 kPa and s = 6.64826 kJ/kg.K is T = 318.9563 K (consistent) vapour quality = 0.799915957 (inconsistent) h = 2105.247 kJ/kg.K (inconsistent)

Using CoolProp 6.4.0, I find that the saturation properties return different values s(x = 0, P = 10kPa) = 0.6491956 J/kg.K (dwsim returns 0.650075) s(x = 1, P = 10kPa) = 8148.82 J/kg.K (dwsim returns 8659.45, this seems to be the largest change) h(x = 0, P = 10kPa) = 191.805945 kJ/kg (dwsim returns 191.804) h(x = 1, P = 10kPa) = 2583.858672 kJ/kg (dwsim returns 2514.44)

From that data, it seems that dwsim optimizes the cycle correctly, but has the wrong EOS data. I can't tell if coolprop updated their water EOS between versions 6.0.0 (which dwsim uses) and 6.4.0. However, the thermodynamic state returned by coolprop 6.4.0 match calculations using legacy tools and thermodynamic tables.

It seems to me that dwsim is optimizing correctly, but needs to link against a newer version of coolprop instead of 6.0.0. I have not tested coolprop 6.0.0 to see if it matches the dwsim output and verify whether the error is undoubtedly a coolprop bug vs a dwsim bug.

Steps to reproduce the behavior:

  1. Assemble a pump, heater, turbine, cooler and recycle block
  2. Set the output pressure of turbine to 10 kPa
  3. Set output vapour fraction of cooler to 0
  4. Set output pressure of pump to 5 MPa
  5. Set all devices to 0 pressure drop/adiabatic efficiencies of 100% (no losses)
  6. run simulations

Expected behavior vapour fraction downstream of turbine should be 0.799

Desktop:

  • OS: linux ubuntu 20.04.4
  • dwsim Version 8.0.4 OS Info: Unix 5.15.0.46 CLR Info: Mono Framework v6.8.0.105

basic_rankine_cycle.zip

cbkiyanda avatar Aug 16 '22 18:08 cbkiyanda

@cbkiyanda this seems to have been fixed in https://github.com/DanWBR/dwsim/commit/3ccb050f1bfafd017eb9b4ac76d3e5fe126a8d2e (post v8.0.4)

Captura de Tela 2022-08-16 às 15 21 54

DanWBR avatar Aug 16 '22 19:08 DanWBR

Do you have an idea when a release will include https://github.com/DanWBR/dwsim/commit/3ccb050f1bfafd017eb9b4ac76d3e5fe126a8d2e ? (We plan to use dwsim for class, so just need to devise a plan for distributing a usable version to students.)

cbkiyanda avatar Aug 16 '22 20:08 cbkiyanda

@cbkiyanda very soon! in the meantime, you could try Steam Tables for this specific case.

DanWBR avatar Aug 16 '22 20:08 DanWBR

Thank you very much!

cbkiyanda avatar Aug 17 '22 15:08 cbkiyanda

@cbkiyanda I've switched to a rational interpolation over a very small range, but there will always be some error, unfortunately.

https://github.com/DanWBR/dwsim/blob/0002ac692750ef6a10b8e3c02fe868062d8a7c8f/DWSIM.Thermodynamics/PropertyPackages/CoolProp.vb#L1370-L1387

DanWBR avatar Aug 22 '22 20:08 DanWBR