lbl-srg / modelica-buildings

Modelica Buildings library
247 stars 155 forks source link

Heat pump calibration gives different results #2151

Open dhblum opened 3 years ago

dhblum commented 3 years ago

When running Buildings/Resources/src/fluid/heatpumps/calibration/Examples/example_calibration.py

with Python 3.8.3 and Scipy 1.4.1 (using conda, and in Ubuntu 18.04), the results of the calibration are as follows, which DO NOT match the associated paper reference results:

----------------------------------------------------------------

Compressor:
-----------
Volume ratio : 2.4210078663001307 
Volume flow rate : 0.0029032198473937115 m3/s
Leakage coefficient : 0.004035070990860917 kg/s
Electro-mechanical efficiency : 0.9055536321252343 
Constant part of power losses : 368.55265254394965 W
Amplitude of superheating : 10.0 K

Condenser:
-----------
Thermal conductance of the heat exchanger : 27717.453413139985 W/K

Evaporator:
-----------
Thermal conductance of the heat exchanger : 57594.87589055987 W/K

----------------------------------------------------------------

Number of invalid points : 0.0
Sum of square errors : 0.0011476729267717112 

However, with Python 2.7.17 and Scipy 0.19.1 (in Ubuntu 18.04), the results of the calibration are as follows, which DO match the associated paper reference results:

Compressor:
-----------
Volume ratio : 2.361819087115291 
Volume flow rate : 0.0028707768622828135 m3/s
Leakage coefficient : 0.004080668928790932 kg/s
Electro-mechanical efficiency : 0.9223071179047239 
Constant part of power losses : 398.69717480876596 W
Amplitude of superheating : 6.491631952026269 K

Condenser:
-----------
Thermal conductance of the heat exchanger : 7014.543643779111 W/K

Evaporator:
-----------
Thermal conductance of the heat exchanger : 49137.09588316078 W/K

----------------------------------------------------------------

Number of invalid points : 0.0
Sum of square errors : 6.810128120540024e-07 

I wanted to report this behavior in case other users find the same thing. @MassimoCimmino Do you find the same thing? Could it be just due to the different version of Scipy?

MassimoCimmino commented 3 years ago

@dhblum I get similar results to yours on Python 3 with Scipy 1.4.1.

I tend to remember that there has been significant updates to scipy.optimize.

Some default options may have changed since 0.19, causing the issue. I will look into it.

MassimoCimmino commented 3 years ago

I am able to obtain the correct results by using less restrictive bounds for the compressor parameters (such as the ones commented out here).

I have not yet been able to compare Python 2 vs 3 and Scipy 0.19 vs 1.4.

sjchakra commented 3 years ago

@MassimoCimmino I collaborate with Dave on the same project and I am catching up on python/modelica models.

Thanks for looking into the issue. I also get better results with Python 3.7 and Scipy 1.4 when the bounds are made larger, which is counter-intuitive to me.

MassimoCimmino commented 3 years ago

@sjchakra I was able to test out the script in Python 2.7 and compare scipy 0.19 and scipy 1.0.

It seems the issue was introduced by scipy 1.0 and does not have to do with Python 3. Il will try to find what change in scipy.optimize caused the issue.

Updating the bounds for the calibration may very well be the proper fix.