Hi,
I am new to GAMS and I am trying to solve a problem in which I use block decomposition to solve a heat exchanger network optimization problem using MLP. I am getting a sqrt error in which when calculating TLM(i,j,k) it is becoming the square root of a negative. Is there a way to fix TLM so it only calculates if the square root is positive. Thanks in advance and sorry if this isn’t fully clear.
Sets
i hot streams / H1, H2 /
j cold streams / C1, C2, C3 /
k block / B1, B2, B3 /
Parameters
T1hot(i,k) entering temperature of hot stream i in block k (k)
/ H1.B1 473.15, H2.B1 473.15,
H1.B2 334.53, H2.B2 334.53,
H1.B3 313.15, H2.B3 313.15 /
T2hot(i,k) leaving temperature of hot stream i in block k (k)
/ H1.B1 334.53, H2.B1 334.53,
H1.B2 313.15, H2.B2 313.15
H1.B3 308.15, H2.B3 293.15 /
T1cold(j,k) entering temperature of cold stream j in block k (k)
/C1.B1 453.15, C2.B1 324.15, C3.B1 453.15,
C1.B2 323.15, C2.B2 323.15, C3.B2 323.15,
C1.B3 303.15, C3.B3 303.15/
T2cold(j,k) leaving temperature of cold stream j in block k (k)
/ C1.B1 323.15, C2.B1 323.15, C3.B1 323.15,
C1.B2 303.15, C3.B2 303.15,
C1.B3 303.15, C3.B3 283.15 /
CPhot(i) flowrate heat capacity for cold stream i (kW per K)
/ H1 3.8, H2 2 /
CPcold(j) flowrate heat capacity for hot stream j (kW per K)
/ C1 4, C2 532, C3 2.2 /
U Overall heat transfer coefficient (kW per m^2K) / 1 /
;
Parameter TLM(i,j,k) log mean temperature (pattersons approximation);
TLM(i,j,k) = (2/3*(sqrt(((T1hot(i,k)-T1cold(j,k))(T2hot(i,k)-T2cold(j,k)))))) + (1/3((T1hot(i,k)-T1cold(j,k))+(T2hot(i,k)-T2cold(j,k))/2)) ;
Variables
q(i,j,k) heat load for match for hot stream i in cold stream j in block k
y(i,j,k) binary variable to activate or deactivate match. 1 if activated 0 otherwise
z objective
;
Positive Variable
q(i,j,k)
;
Binary Variable
y(i,j,k)
;
Equations
hotduty(i,k) duty on hot stream i in block k
coldduty(j,k) duty on cold stream j in block k
hotbinary(i,j,k) binary constraint on hot stream i
coldbinary(i,j,k) binary constraint on cold stream j
obj objective function to minimize total annualised cost of HEN
;
hotduty(i,k)… (T1hot(i,k) - T2hot(i,k))CPhot(i) =e= sum(j,q(i,j,k));
coldduty(j,k)… (T1cold(j,k)-T2cold(j,k))CPcold(j) =e= sum(i, q(i,j,k));
hotbinary(i,j,k)… 10 =l= (T1hot(i,k)-T1cold(j,k)) + (1-y(i,j,k));
coldbinary(i,j,k)… 10 =l= (T2hot(i,k)-T2cold(j,k)) + (1-y(i,j,k));
obj… z =e= sum((k,i,j), (2000y(i,j,k)) + 84(q(i,j,k)/(TLM(i,j,k))));
;
option MIP = CPLEX;
option optcr = 0;
Model verticalcoursework /ALL/;
Solve verticalcoursework minimizing z using MIP;
Display z.l, y.l, q.l;