DanWBR / dwsim

DWSIM is a Steady-State and Dynamic Sequential Modular Chemical Process Simulator for Windows, Linux and macOS.
https://dwsim.org
GNU General Public License v3.0
296 stars 95 forks source link

[Bug] Property Override in Heat Exchangers with saltwater is very slow #646

Closed magnuscarlsen closed 4 months ago

magnuscarlsen commented 5 months ago

I need to model water saltier than 12% by mass. At lower salinities I have dealt with this with the seawater module, for higher salinities have added property overrides for density and heat capacity in "overallLiquid" based on pressure, temperature and salinity of the water. The water temp is up to 90 degC. If I run a model without a HX, the calculation takes a few seconds. If I add a heat exchanger to the model, then DWSIM freezes for 20-30 minutes, then it wakes up and calculates the flow sheet in a few seconds. Same flow sheet without property overrrides is also very fast. I think there is a bug in the HX with property overrides.

You can replicate the error if you: Run the flow sheet to see the time it takes, if you remove the HX and the streams associated you'll see that it takes a few seconds. If there is an error in the code for the property override or in the flow sheet (like 0 flowrate, which causes the pipe calc to fial) the sheet calculates very quickly).

I would have expected the flow sheet to be calculated in roughly the same amount of time as a flowsheet without exchangers. But I might have done something wrong in the setup?

Desktop:

andr1976 commented 5 months ago

@DanWBR would you have time to look at this - highly appreciated :-)

DanWBR commented 4 months ago

@magnuscarlsen create a new script and do this

image

andr1976 commented 4 months ago

@magnuscarlsen can you confirm that this is a fix ?

magnuscarlsen commented 4 months ago

yes, it seems to work 👍 Thanks very much!