Hi,

I am trying to design an optimum heat exchanger network with the lowest total annualised cost. To do so, I need to calculate 'LMTD' (log-mean temperature difference). This is using the inlet and outlet temperatures of the hot 'i' and cold 'j' streams within a block 'k'. I have defined these temperatures within tables, like so:

THin(i,k) "hot stream i inlet temperature in block k / degC"

1 2 3

H1 200 61.38 40

H2 200 61.38 40

HO 230 0 0 ;

There is a zero value for temperature, when the stream does not exist in block k.

I calculate LMTD using the following equation:

LMTD(i,j,k) = 2/3 * (dT1(i,j,k) * dT2(i,j,k))**0.5 + 1/3 * (dT1(i,j,k) + dT2(i,j,k))/2

where:

dT1(i,j,k) = THin(i,k) - TCout(j,k)

dT2(i,j,k) = THout(i,k) - TCin(j,k)

The problem I have is that when a stream does not exist, i.e. when temperature inlet and/or outlet value = 0, I may get an undefined LMTD or zero value. This causes issues when calculating heat exchanger area:

hexarea(i,j,k).. area(i,j,k) =e= q(i,j,k) / (U(i,j) * LMTD(i,j,k)) ;

If LMTD = 0, I get the following error:

*** Error at line 138: division by zero (0)

**** Exec Error at line 138: division by zero (0)

---- hexarea =E= HEX surface area / m2

hexarea(H1,C1,1).. area(H1,C1,1) - q(H1,C1,1) =E= UNDF ; (LHS = UNDF)

What I would like to have is LMTD(i,j,k) set to an arbitrary value, say 0.00001, if any of my temperature values for (i,j,k) = 0. Also, I would like to have a binary parameter that makes area(i,j,k) = 0 if any of the temperature values for (i,j,k) = 0. I tried implementing this like so:

Parameters:

adjLMTD(i,j,k) $ (THin(i,k) = 0) = 0.00001 ;

adjLMTD(i,j,k) $ (THout(i,k) = 0) = 0.00001 ;

adjLMTD(i,j,k) $ (TCin(j,k) = 0) = 0.00001 ;

adjLMTD(i,j,k) $ (TCout(j,k) = 0) = 0.00001 ;

zfeas(i,j,k) $ (THin(i,k) = 0) = 0 ;

zfeas(i,j,k) $ (THout(i,k) = 0) = 0 ;

zfeas(i,j,k) $ (TCin(j,k) = 0) = 0 ;

zfeas(i,j,k) $ (TCout(j,k) = 0) = 0 ;

zfeas(i,j,k) $ (THin(i,k) <> 0 and THout(i,k) <> 0 and TCin(j,k) <> 0 and TCout(j,k) <> 0) = 1 ;

Equation:

hexarea(i,j,k).. area(i,j,k) =e= zfeas(i,j,k) * q(i,j,k) / (U(i,j) * adjLMTD(i,j,k)) ;

Any suggestions as to why I still get the divison by 0 error when calculating hexarea(i,j,k) using the above code would be greatly appreciated.

I have also attached my file.

Many thanks.

## Preventing divison by zero

### Re: Preventing divison by zero

You can use following second equation to avoid 'divided by zero' error.

LMTD = (ΔT2 - ΔT1)/ Ln(ΔT2/ΔT1)

LMTD = ((ΔT1^1/3 + ΔT2^1/3)/ 2)^3

Maximum 0.3% error to be considered.

LMTD = (ΔT2 - ΔT1)/ Ln(ΔT2/ΔT1)

LMTD = ((ΔT1^1/3 + ΔT2^1/3)/ 2)^3

Maximum 0.3% error to be considered.

### Re: Preventing divison by zero

Hi,

If all other calculations are working well, one can do the following adjustment:

hexarea(i,j,k)$LMTD(i,j,k).. area(i,j,k) =e= q(i,j,k) / (U(i,j) * LMTD(i,j,k)) ;

This should prevent any constraint from being generated if LMTD(i,j,k) == 0

Sincerely.

If all other calculations are working well, one can do the following adjustment:

hexarea(i,j,k)$LMTD(i,j,k).. area(i,j,k) =e= q(i,j,k) / (U(i,j) * LMTD(i,j,k)) ;

This should prevent any constraint from being generated if LMTD(i,j,k) == 0

Sincerely.