MadsKirkFoged / SharpFluids

Lightweight CoolProp C# Wrapper - for easy fluid properties lookups
MIT License
30 stars 9 forks source link

Problem with Thermal Conductivity and Dynamic Viscosity for some refrigerants? #26

Closed mpiccoli-advantech closed 3 years ago

mpiccoli-advantech commented 3 years ago

I was performing some refrigerants mapping in order to evaluate the error of CoolProp correlations with respect to Refprop. For some refrigerants, like R134a and N-Propane, the results match is ok with differences in quantities like enthalpy, density, conductivity and viscosity that are below 1% for the entire subcritical area (i've evaluated the whole temperature field available with pressures up to critical pressure). On the other hand, for some other refrigerants, like R32, R407C, R410A and R1234ze(Z) i've found that:

For example let's consider saturation condition of R407C. In order to retrieve data, I used a for loop where for each iteration the thermo-physical state of the fluid is updated and data of my interest is stored in matrix:

fluid.UpdatePX(Pressure.FromPascals(P[i]), 0);

temperatureSat[i, 0] = fluid.Temperature.As(TemperatureUnit.Kelvin);
enthalpySat[i, 0] = fluid.Enthalpy.As(SpecificEnergyUnit.JoulePerKilogram);
densitySat[i, 0] = fluid.Density.As(DensityUnit.KilogramPerCubicMeter);
conductivitySat[i, 0] = fluid.Conductivity.As(ThermalConductivityUnit.WattPerMeterKelvin);
viscositySat[i, 0] = fluid.DynamicViscosity.As(DynamicViscosityUnit.PascalSecond);

In the code, P[i] is the i-th element of a pressure array ranging from min available pressure for the fluid and critical pressure, and 0 is the quality of the fluid (in this example is reported equal to 0 for saturated liquid curve, but I've done the same for gas phase imposing it to 1).

Performing a comparison between data obtained with the previous code and data retrieved from refprop i obtain the following results ( err X [%] = (value_Refprop - value_code) / (value_Refprop) * 100) where the refprop data is obtained with the same pressure and temperatures obtained from the previous code): immagine

I've tried to use also a different update approach specifing pressure and saturation temperature but the result is the same. In order to verify that it's not a CoolProp problem, I've also perform a comparison with data obtained with another wrapper (the one for matlab/octave). In this case the Refprop and Coolprop data are consistent in the whole temperature and pressure range considered.

Furthermore, for R1234ze(Z) conductivity and viscosity are always equal to 0, for any point considered (saturation, subcooled or superheated).

Am I doing something wrong or there's a problem? Thank you in advance

MadsKirkFoged commented 3 years ago

That is interesting.. This is also just a coolprop wrapper and at no point we intentionally change the data coming from the CoolProp dll.

Have you tried using the except same CoolProp.dll in this wrapper and the one from matlab/octave?

mpiccoli-advantech commented 3 years ago

No, I can't...We use Octave and unfortunately, for that there is a wrapper in .oct format that can't be used in c# code.

MadsKirkFoged commented 3 years ago

I have just updated the coolprop.dll we use in this wrapper. Could you update SharpFluids and run the test again?

mpiccoli-advantech commented 3 years ago

I've updated the wrapper, but the results didn't change

MadsKirkFoged commented 3 years ago

Can you post a single result (specific refrigerant, what you used to Updatexx(x,x)), and the corresponding result from Refprop/matlab? That way I can better help/test if there is something else going on

Also did you compare with the online version of CoolProp? https://ibell.pythonanywhere.com/

mpiccoli-advantech commented 3 years ago

Unfortunately Coolprop online don't calculate conductivity and dynamic viscosity values.

Consider R407C at saturated liquid conditions (quality = 0). I've used the following instruction:

Fluid fluid = new Fluid(FluidList.R407C);
fluid.UpdatePX(Pressure.FromMegapascals(4.022736), 0);
and these are the results: Sharpfluids Coolprop - Octave Refprop
temperature [K] 351.25 351.26 351.26
enthalpy [J/kg*K] 3.343E+05 3.353E+05 3.344E+05
density [kg/m3] 781.99 780.97 780.97
Conductivity [W/m*K] 5.61E-02 6.00E-02 6.00E-02
Dyn.Viscosity [Pa*s] 6.761E-05 6.383E-05 6.383E-05

If you consider the same refrigerant but with saturated vapour (quality = 1)

fluid.UpdatePX(Pressure.FromMegapascals(4.022736), 1);

Sharpfluids Coolprop - Octave Refprop
temperature [K] 353.62 353.62 353.62
enthalpy [J/kg*K] 4.132E+05 4.141E+05 4.132E+05
density [kg/m3] 256.23 256.21 256.21
Conductivity [W/m*K] 2.69E-02 3.72E-02 3.72E-02
Dyn.Viscosity [Pa*s] 2.302E-05 1.976E-05 1.976E-05
MadsKirkFoged commented 3 years ago

I have traced though the code and the above results are what the coolprop.dll is returning

I think if you wants to get to the bottom of this, you'll have to ask at CoolProp github https://github.com/CoolProp/CoolProp

mpiccoli-advantech commented 3 years ago

I've figured out why Octave wrapper gives me results that are more similar to Refprop with respect to CoolProp.dll. This is due to the possibility on Octave wrapper, to specify which correlations to use; if the user has installed Refprop, he can use its correlations (so the minor results diferrences in conductivity and viscosity).

I'll close the issue, thank you for the support!