sets heatx exchanger /ex1*ex7/ t temperature /thi, tho, tci, tco/ f cost function /a,b,c/ ; table et(t,heatx) "heatx and temperature" ex1 ex2 ex3 ex4 ex5 ex6 ex7 thi 410 20 500 500 570 570 400 tho 110 10 270 130 150 150 320 tci 0 0 40 40 50 0 120 tco 360 10 195 180 150 200 330 ; table cf(f,heatx) "cost function" ex1 ex2 ex3 ex4 ex5 ex6 ex7 a 8600 8600 0 0 0 0 40000 b 670 670 7000 7000 7000 7000 2300 c 0.83 0.83 0.65 0.65 0.65 0.65 1.0 ; *EX7 is a special case with a linear cost function, so it is an unbounded solution. *because of c = 1 parameters r heat capacity ratio p thermal effectiveness tlm1 log mean temperature r ne 1 tlm2 log mean temperature r eq 1 nsmin1 minimum number of exchanger r ne 1 nsmin2 minimum number of exchanger r eq 1 ; r(heatx) = ([et('thi',heatx)] - [et('tho',heatx)])/ ([et('tco',heatx)] - [et('tci',heatx)]); p(heatx) = ([et('tco',heatx)] - [et('tci',heatx)])/ ([et('thi',heatx)] - [et('tci',heatx)]); nsmin1(heatx)$[r(heatx) ne 1] = [log([1-r(heatx)*p(heatx)]/[1-p(heatx)])]/[log([1-r(heatx)+sqrt(r(heatx)**2+1)]/[r(heatx)-1+sqrt(r(heatx)**2+1)])]; nsmin2(heatx)$(r(heatx) eq 1) = (sqrt(2)/2)*(p(heatx)/1-p(heatx)); tlm1(heatx)$(r(heatx) ne 1) = [([et('thi',heatx)]-[et('tco',heatx)])-([et('tho',heatx)]-[et('tci',heatx)])]/[log(([et('thi',heatx)]-[et('tco',heatx)])/([et('tho',heatx)]-[et('tci',heatx)]))]; tlm2(heatx)$(r(heatx) eq 1) = [et('thi',heatx)] - [et('tco',heatx)]; scalars q heat duty /2000/ u overall heat coefficient /0.1/ ; display r,p,nsmin1,nsmin2,tlm1,tlm2; variables ft1(heatx) correction fator r ne 1 ft2(heatx) correction fator r eq 1 p121(heatx) effctive p12 r ne 1 p122(heatx) effctive p12 r eq 1 a1(heatx) heat exchanger area a2(heatx) heat exchanger area c1(heatx) cost r ne 1 c2(heatx) cost r eq 1 z z1 z2 ; integer variables ns1(heatx) number of exchanger for nsmin1 ns2(heatx) number of exchanger for nsmin2 ; equations eq_ft1(heatx) correction fator r ne 1 eq_ft2(heatx) correction fator r eq 1 eq_ns1(heatx) number of exchanger for nsmin1 eq_ns2(heatx) number of exchanger for nsmin2 eq_p121(heatx) effctive p12 r ne 1 eq_p122(heatx) effctive p12 r eq 1 eq_a1(heatx) heat exchanger area eq_a2(heatx) heat exchanger area eq_c1(heatx) cost r ne 1 eq_c2(heatx) cost r eq 1 eq_z eq_z1 eq_z2 ; eq_ns1(heatx)$(r(heatx) ne 1).. ns1(heatx) =g= nsmin1(heatx); eq_ns2(heatx)$(r(heatx) eq 1).. ns2(heatx) =g= nsmin2(heatx); eq_p121(heatx)$(r(heatx) ne 1).. p121(heatx) =e= (1-((1-r(heatx)*p(heatx))/(1-p(heatx)))**(1/ns1(heatx)))/((r(heatx)-((1-r(heatx)*p(heatx))/(1-p(heatx)))**(1/ns1(heatx)))); eq_p122(heatx)$(r(heatx) eq 1).. p122(heatx) =e= p(heatx)/(p(heatx)-ns2(heatx)*p(heatx)+ns2(heatx)); eq_ft1(heatx)$(r(heatx) ne 1).. ft1(heatx) =e= [sqrt(r(heatx)**2+1)*log([1-r(heatx)*p121(heatx)]/[1-p121(heatx)])]/((r(heatx)-1)*log((2-p121(heatx)*(r(heatx)+1+sqrt(r(heatx)**2+1)))/(2-p121(heatx)*(r(heatx)+1-sqrt(r(heatx)**2+1))))); eq_ft2(heatx)$(r(heatx) eq 1).. ft2(heatx) =e= (sqrt(2)*p122(heatx))/((1-p122(heatx))*log((2-p122(heatx)*(2-sqrt(2)))/(2-p122(heatx)*(2+sqrt(2))))) ; eq_a1(heatx)$(r(heatx) ne 1).. a1(heatx) =e= q/(u*ft1(heatx)*tlm1(heatx)); eq_a2(heatx)$(r(heatx) eq 1).. a2(heatx) =e= q/(u*ft2(heatx)*tlm2(heatx)); eq_c1(heatx)$(r(heatx) ne 1).. c1(heatx) =e= [cf('a',heatx)]+[cf('b',heatx)]*ns1(heatx)*[(a1(heatx)/ns1(heatx))**([cf('c',heatx)])] ; eq_c2(heatx)$(r(heatx) eq 1).. c2(heatx) =e= [cf('a',heatx)]+[cf('b',heatx)]*ns2(heatx)*[(a2(heatx)/ns2(heatx))**([cf('c',heatx)])] ; eq_z.. z =e= sum[heatx,c1(heatx)]+sum[heatx,c2(heatx)]; eq_z1.. z1 =e= sum[heatx,c1(heatx)]; eq_z2.. z2 =e= sum[heatx,c2(heatx)]; model exchanger /all/; model exchanger1 /eq_ft1,eq_ns1,eq_p121,eq_a1,eq_c1,eq_z1/; model exchanger2 /eq_ft2,eq_ns2,eq_p122,eq_a2,eq_c2,eq_z2/; ns1.lo(heatx) = 1; ns2.lo(heatx) = 1; p121.l(heatx) =0.001; p122.l(heatx) =0.001; ft1.lo(heatx) = 0.8; ft1.up(heatx) = 1; ft2.lo(heatx) = 0.8; ft2.up(heatx) = 1; c1.lo(heatx) = 0; c2.lo(heatx) = 0; option optcr=0.000001; solve exchanger using minlp minimizing z ; *solve exchanger1 using minlp minimizing z1 ; *solve exchanger2 using minlp minimizing z2 ; option decimals = 4; display ns1.l,p121.l,ft1.l,a1.l,c1.l; display ns2.l,p122.l,ft2.l,a2.l,c2.l;