-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathP2PTES
8602 lines (7927 loc) · 618 KB
/
P2PTES
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
$Title: Biodiesel TES Model - 2/3/2017
$ontext
Modified: 5/3/2016
Design 1: Maximizing NPV for the plant alone, without ABR or Wetland
Amount of biodiesel is fixed at 5 Million Gals. annually
$offtext
$OFFSYMXREF
$OFFSYMLIST
Options LimRow = 70, LimCol = 0;
Set
*Global settings
* Define units: Src=source, Snk=sink, Mix=mixer, Spl=splitter
* Str=storage, HX = Heat exchangers
unit units
/Reactor3, Reactor4, Sep2*Sep3, Mix2*Mix3, Col3*Col5,
Snk3*Snk7, Src3, Src5, Src6, Spl3, Src, HX10*HX23, HX45, Src7, CHP, SrcWa/
* Define subsets of units
HX(unit) heat exchangers
/HX10*HX23, HX45 /
Mix(unit) mixers
/Mix2*Mix3/
Spl(unit) splitter
/Spl3/
Src(unit) sources
/Src3, Src5, Src6, Src, Src7/
Snk(unit) sinks
/Snk3*Snk7/
Sep(unit) separators
/Sep2*Sep3/
Column(unit) distillation columns
/Col3*Col5/
* Define Components
J components
/Wa, MeOH, Glycerol, KOH, Oil, FFA, FAME, PhosA, PotPhos/
* Define Reactions: KOH_Neut - neutralization reaction of KOH with phosphoric acid
react
/KOH_neut/
* running variable for vapor pressure correlation
l /1*3/
Alias(unit, unit1)
Alias (J,h)
Parameters
* individual liquid heat capacity of a component (average in a range 20 C - 100 C)
* in kJ/(kg*C), assume: constant heat capacities and c_p_ind('CellM')=c_p_ind('Wa')
c_p_ind(J)
/Wa 4.19
MeOH 2.534
Glycerol 2.409
KOH 1.179
Oil 2.000
FFA 2.07
FAME 2.01
PhosA 1.758
PotPhos 4.07/
* Molecular weight in g/mol
MW(J)
/Wa 18.015
MeOH 32.04
Glycerol 92.093
KOH 56.1056
Oil 920
FFA 280.5
FAME 292.2
PhosA 98
PotPhos 174.18/
* Standard heats of vapourization Kj/Kg
dH_vap_0(J)
/Wa 2254
MeOH 1000
Glycerol 974
Oil 170.137
FAME 460/;
Table
* vapor pressure coefficients: mmHq, T= C
* 750 mmHq = 1bar, 760mmHq = 1atm
* ln(p_k)j= coef_p(h,1)-coef_p(h,2)/(T+coef_p(h,3))
coef_p(J,l)
1 2 3
Wa 5.0768 1659.73 -45.854
MeOH 5.20409 1581.341 -33.50
Oil 11.4785 -708.72 -167.48
FAME 8.2175 1450.62 88.03
Glycerol 41.9806 6024.4 10.3272
KOH 7.06223 6300.48 172.76
FFA 3.82846 2066.995 -116.87;
*FAME in K, MeOH in K, Oil in K, Wa in K, KOH in C, FFA in K
*MeOH in bar, FAME in Pa, Oil in Pa, glycerol in Torr, Wa in bar, KOH in mmHg, FFA in bar;
*** NOTE ANTOINE EQUATION FOR OIL AND GLYCEROL ARE SLIGHTLY DIFF FROM THE ORIGINAL EQUATION **
*Vp for KOH is coming to zero now
* KOH - KOH 4.02783 5854.906 144.113
SET Arc(unit,unit1) stream matrix;
*setting entries in stream matrix
***Arc is unknown symbol***
Arc(unit, unit1)=No;
*Define all existing streams Arc('1','2') is stream from unit 1 to unit 2
*Feed to reactors
Arc('Mix2','Mix3') = Yes;
Arc('Src','Mix3') = Yes;
Arc('Col3','Mix2') = Yes;
Arc('Src3','Mix2') = Yes;
Arc('Mix3','HX45') = Yes;
Arc('Src5','Mix3') = Yes;
*Reaction transesterification unit
Arc('HX45','Reactor3') = Yes;
Arc('Mix3','HX45') = Yes;
Arc('Reactor3','HX10') = Yes;
*MeOH distillation unit
Arc('HX10','Col3') = Yes;
Arc('Col3','HX13') = Yes;
Arc('Col3','Mix2') = Yes;
*Washing
Arc('HX13','Sep2') = Yes;
Arc('Src6','Sep2') = Yes;
Arc('Sep2','Reactor4') = Yes;
Arc('Sep2','HX19') = Yes;
Arc('SrcWa','Src6') = Yes;
*Neutralization alkali
Arc('Reactor4','HX14') = Yes;
Arc('Src7','Reactor4') = Yes;
Arc('Reactor4','Snk3') = Yes;
*FAME Distillation
Arc('HX19','Col5') = Yes;
Arc('Col5','HX22') = Yes;
Arc('Col5','HX23') = Yes;
*Glycerol distillation
Arc('HX14','Col4') = Yes;
Arc('Col4','HX17') = Yes;
Arc('Col4','HX18') = Yes;
*CHP
Arc('SrcWa','Src6') = Yes;
Arc('Src6','CHP') = Yes;
Positive Variables
* streams and mass fractions: all in kg/s
F(unit,unit1) total streams in kg s^-1
fc(J,unit,unit1) individual components streams
x(J,unit,unit1) mass fraction of comp J in stream
* heat of evaporation
dH_v(J,unit,unit1) individual heat of vap. (KJ per kg)
* vapor pressure
p_v(J,unit,unit1) vapor pressure in bar
* temperatures in C
T(unit,unit1) temperature of stream in C
* Separation efficiencies
Separation(J) Separation efficiencies
Variables
* heat
Q(Unit) heat produced or consumed in unit (efficiency included)
* Q_cond(column) heat load of condenser of column
* Q_reb(column) heat load of reboiler of column
Z objective function value ;
*Defining global bounds and fixing some variables
*mass fractions
x.UP(J,unit,unit1)$Arc(unit,unit1)=1;
*Total streams. #Setting this at 1000 but look into Python code for changing value#
F.up(unit,unit1)$Arc(unit,unit1)=200;
F.lo(unit,unit1)$Arc(unit,unit1) = 0.0000001;
*Component streams #Setting this at 1000 but look into Python code for changing value#
fc.up(J,unit,unit1)$Arc(unit,unit1)=200;
fc.lo(J,unit,unit1)$Arc(unit,unit1)=0.000001;
F.up(unit,unit1)$(not Arc(unit,unit1)) = 0;
fc.up(J,unit,unit1)$(not Arc(unit,unit1)) = 0;
*Heat consumption of certain units
Q.Fx('Sep2') = 0;
Q.Fx('Mix2') = 0;
Q.Fx('Mix3') = 0;
Q.Fx('Col3') = 0;
Q.Fx('Col4') = 0;
Q.Fx('Col5') = 0;
Q.Fx('Snk3') = 0;
Q.Fx('Snk4') = 0;
Q.Fx('Snk5') = 0;
Q.Fx('Snk6') = 0;
Q.Fx('Snk7') = 0;
Q.Fx('Src3') = 0;
Q.Fx('Src5') = 0;
Q.Fx('Src7') = 0;
Q.Fx('Spl3') = 0;
Q.Fx('Src') = 0;
*Global bounds for separation efficiencies of components
*MeOH
Separation.lo('MeOH') = 0.5;
Separation.up('MeOH') = 0.9999;
Separation.l('MeOH') = (Separation.up('MeOH') + Separation.lo('MeOH'))/2;
*Water
Separation.lo('Wa') = 0.5;
Separation.up('Wa') = 0.9999;
Separation.l('Wa') = (Separation.up('Wa') + Separation.lo('Wa'))/2;
*Separation of water is always 0.5, so giving it a higher value makes this equation infeasible.
*Glycerol
Separation.lo('Glycerol') = 0.5;
Separation.up('Glycerol') = 0.9999;
Separation.l('Glycerol') = (Separation.up('Glycerol') + Separation.lo('Glycerol'))/2;
*Oil
Separation.lo('Oil') = 0.1;
Separation.up('Oil') = 0.5;
Separation.l('Oil') = (Separation.up('Oil') + Separation.lo('Oil'))/2;
*FFA
Separation.lo('FFA') = 0.1;
Separation.up('FFA') = 0.5;
Separation.l('FFA') = (Separation.up('FFA') + Separation.lo('FFA'))/2;
*KOH
Separation.lo('KOH') = 0.5;
Separation.up('KOH') = 0.9999;
Separation.l('KOH') = (Separation.up('KOH') + Separation.lo('KOH'))/2;
*FAME
Separation.lo('FAME') = 0.1;
Separation.up('FAME') = 0.5;
Separation.l('FAME') = (Separation.up('FAME') + Separation.lo('FAME'))/2;
Scalar
dp pressure loss in the column /0.1/
alpha_c4 relative volatility in column 4 /3.8/
alpha_c3 relative volatility in column 3 /4.5/
dhreactn Neutralization heat Kj per mol /-200.18/
dhreactneu Neutralization heat in Kh per mol /-173/
washing_wa Water washing recovery /0.01/
Temp_cooldown Cooldown temperature of FAME /25/
T_amb Ambient teperature /25/;
*recover_oil recovery of Oil that is fixed /0.997/
*recover_FAME recovery of FAME that is fixed /0.997/
*global temperature bounds - bounds get redefined for specific streams
T.lo(unit,unit1)=0.01;
*Set the lowest temp to be a value greater than zero
T.up(unit,unit1)=300;
T.l(unit, unit1) = (T.lo(unit, unit1) + T.up(unit, unit1))/2;
*Specifying temperatures in C
T.Fx('Src3','Spl3') = 25;
T.Fx('Spl3','Mix2') = 25;
T.Fx('Src','Mix3') = 60;
T.Fx('Mix3','HX45') = 37.23;
T.Fx('HX11','Mix2') = 28.2;
T.Fx('Src5','Mix3') = 25;
T.Fx('HX45','Reactor3') = 60;
T.Fx('Reactor3','HX10') = 60;
T.Fx('HX10','Col3') = 80;
*T.Fx('Col3','HX13') = 145;
T.Fx('HX13','Sep2') = 60;
T.Fx('Src7','Reactor4') = 60;
T.Fx('Reactor4','Snk3') = 60;
*Temp value from HX14 to Col 4 value needs to be checked again
T.Fx('HX14','Col4') = 60;
T.Fx('HX17','Snk4') = 42.8;
T.Fx('HX16','HX18') = 112;
T.Fx('HX18','Snk5') = 148.6;
T.Fx('Sep2','Reactor4') = 60;
T.Fx('HX19','Col5') = 80;
T.Fx('HX22','Snk6') = 167.8;
T.Fx('Src6','Sep2') = 20;
*Inlet temperature of water
$ontext
This section describes all src streams that have a pre-fixed value. In this model,
mass flow of methanol stream entering from src3 to mix2, oil from src to mix3, KOH from src5 to mix3
and Wa from src6 to Sep2 are decision variables
$offtext
*################################################*************
*fc.up('MeOH','Src3','Mix2') = 0.059137;
*fc.lo('MeOH','Src3','Mix2') = 0.038382;
*################################################*************
fc.up('MeOH','Src3','Mix2') = 10;
fc.lo('MeOH','Src3','Mix2') = 0.01;
fc.l('MeOH','Src3','Mix2') = (fc.lo('MeOH','Src3','Mix2') + fc.up('MeOH','Src3','Mix2'))/2;
*fc.L = inital point will be min max of this
fc.FX('Wa','Src3','Mix2') = 0;
fc.FX('Glycerol','Src3','Mix2') = 0;
fc.FX('KOH','Src3','Mix2') = 0;
fc.FX('Oil','Src3','Mix2') = 0;
fc.FX('FFA','Src3','Mix2') = 0;
fc.FX('FAME','Src3','Mix2') = 0;
fc.FX('PhosA','Src3','Mix2') = 0;
fc.FX('PotPhos','Src3','Mix2') = 0;
x.FX('MeOH','Src3','Mix2') = 1;
x.FX('Wa','Src3','Mix2') = 0;
x.FX('Glycerol','Src3','Mix2') = 0;
x.FX('KOH','Src3','Mix2') = 0;
x.FX('Oil','Src3','Mix2') = 0;
x.FX('FFA','Src3','Mix2') = 0;
x.FX('FAME','Src3','Mix2') = 0;
x.FX('PhosA','Src3','Mix2') = 0;
x.FX('PotPhos','Src3','Mix2') = 0;
****************
fc.FX('Wa','Src5','Mix3') = 0;
fc.FX('MeOH','Src5','Mix3') = 0;
fc.FX('Glycerol','Src5','Mix3') = 0;
fc.FX('Oil','Src5','Mix3') = 0;
fc.FX('FFA','Src5','Mix3') = 0;
fc.FX('FAME','Src5','Mix3') = 0;
fc.FX('PhosA','Src5','Mix3') = 0;
fc.FX('PotPhos','Src5','Mix3') = 0;
x.FX('KOH','Src5','Mix3') = 1;
x.FX('Wa','Src5','Mix3') = 0;
x.FX('MeOH','Src5','Mix3') = 0;
x.FX('Glycerol','Src5','Mix3') = 0;
x.FX('Oil','Src5','Mix3') = 0;
x.FX('FFA','Src5','Mix3') = 0;
x.FX('FAME','Src5','Mix3') = 0;
x.FX('PhosA','Src5','Mix3') = 0;
x.FX('PotPhos','Src5','Mix3') = 0;
*Src has only Oil as the input which is a variable
*################################################*************
*fc.up('Oil','Src','Mix3') = 0.59222947;
*fc.lo('Oil','Src','Mix3') = 0.3947620;
*################################################*************
fc.up('Oil','Src','Mix3') = 8;
fc.lo('Oil','Src','Mix3') = 0.01;
fc.l('Oil','Src','Mix3') = (fc.lo('Oil','Src','Mix3') + fc.up('Oil','Src','Mix3'))/2;
*fc.L
fc.FX('Wa','Src','Mix3') = 0;
fc.FX('MeOH','Src','Mix3') = 0;
fc.FX('Glycerol','Src','Mix3') = 0;
fc.FX('KOH','Src','Mix3') = 0;
fc.FX('FFA','Src','Mix3') = 0;
fc.FX('FAME','Src','Mix3') = 0;
fc.FX('PhosA','Src','Mix3') = 0;
fc.FX('PotPhos','Src','Mix3') = 0;
x.FX('Oil','Src','Mix3') = 1;
x.FX('Wa','Src','Mix3') = 0;
x.FX('MeOH','Src','Mix3') = 0;
x.FX('Glycerol','Src','Mix3') = 0;
x.FX('KOH','Src','Mix3') = 0;
x.FX('FFA','Src','Mix3') = 0;
x.FX('FAME','Src','Mix3') = 0;
x.FX('PhosA','Src','Mix3') = 0;
x.FX('PotPhos','Src','Mix3') = 0;
************* Water to washing stream ******
fc.FX('MeOH','Src6','Sep2') = 0;
fc.FX('Glycerol','Src6','Sep2') = 0;
fc.FX('KOH','Src6','Sep2') = 0;
fc.FX('Oil','Src6','Sep2') = 0;
fc.FX('FFA','Src6','Sep2') = 0;
fc.FX('FAME','Src6','Sep2') = 0;
fc.FX('PhosA','Src6','Sep2') = 0;
fc.FX('PotPhos','Src6','Sep2') = 0;
x.FX('Wa','Src6','Sep2') = 1;
x.FX('MeOH','Src6','Sep2') = 0;
x.FX('Glycerol','Src6','Sep2') = 0;
x.FX('KOH','Src6','Sep2') = 0;
x.FX('Oil','Src6','Sep2') = 0;
x.FX('FFA','Src6','Sep2') = 0;
x.FX('FAME','Src6','Sep2') = 0;
x.FX('PhosA','Src6','Sep2') = 0;
x.FX('PotPhos','Src6','Sep2') = 0;
*Src7 has PhosA as input which can be
*fc.up('PhosA','Src7','Reactor4') = 200;
*fc.lo('PhosA','Src7','Reactor4') = 0.001;
*fc.l('PhosA','Src7','Reactor4') = (fc.lo('PhosA','Src7','Reactor4') + fc.up('PhosA','Src7','Reactor4'))/2;
fc.Fx('Wa','Src7','Reactor4') = 0;
fc.Fx('MeOH','Src7','Reactor4') = 0;
fc.Fx('Glycerol','Src7','Reactor4') = 0;
fc.Fx('KOH','Src7','Reactor4') = 0;
fc.Fx('Oil','Src7','Reactor4') = 0;
fc.Fx('FFA','Src7','Reactor4') = 0;
fc.Fx('FAME','Src7','Reactor4') = 0;
fc.Fx('PotPhos','Src7','Reactor4') = 0;
x.Fx('PhosA','Src7','Reactor4') = 1;
x.Fx('Wa','Src7','Reactor4') = 0;
x.Fx('MeOH','Src7','Reactor4') = 0;
x.Fx('Glycerol','Src7','Reactor4') = 0;
x.Fx('KOH','Src7','Reactor4') = 0;
x.Fx('Oil','Src7','Reactor4') = 0;
x.Fx('FFA','Src7','Reactor4') = 0;
x.Fx('FAME','Src7','Reactor4') = 0;
x.Fx('PotPhos','Src7','Reactor4') = 0;
**------- Fixing flow streams for Phosphoric Acid ---- **
fc.Fx('PhosA','Reactor4','HX14') =0;
fc.Fx('PhosA','Sep2','Reactor4') =0;
fc.Fx('PhosA','Mix2','Mix3') =0;
fc.Fx('PhosA','Mix3','HX45') =0;
fc.Fx('PhosA','HX10','Col3') =0;
fc.Fx('PhosA','HX45','Reactor3') =0;
x.Fx('PhosA','Reactor4','HX14') =0;
x.Fx('PhosA','Sep2','Reactor4') =0;
x.Fx('PhosA','Mix2','Mix3') =0;
x.Fx('PhosA','Mix3','HX45') =0;
x.Fx('PhosA','HX10','Col3') =0;
x.Fx('PhosA','HX45','Reactor3') =0;
**------- Fixing flow streams for Potassium Phosphate ---- **
fc.Fx('PotPhos','Mix2','Mix3') = 0;
fc.Fx('PotPhos','Mix3','HX45') = 0;
fc.Fx('PotPhos','HX10','Col3') = 0;
fc.Fx('PotPhos','HX45','Reactor3') = 0;
x.Fx('PotPhos','Mix2','Mix3') = 0;
x.Fx('PotPhos','Mix3','HX45') = 0;
x.Fx('PotPhos','HX10','Col3') = 0;
x.Fx('PotPhos','HX45','Reactor3') = 0;
** ------ Fixing flow of FFA ---- **
fc.Fx('FFA','Col5','HX23') = 0;
x.FX('FFA','Col5','HX23') = 0;
** ----------- Fixing glycerol flow stream ---- **
fc.Fx('Glycerol','Mix2','Mix3') = 0;
x.Fx('Glycerol','Mix2','Mix3') = 0;
fc.Fx('Glycerol','Mix3','HX45') = 0;
x.Fx('Glycerol','Mix3','HX45') = 0;
fc.Fx('Glycerol','HX45','Reactor3') = 0;
x.Fx('Glycerol','HX45','Reactor3') = 0;
** ------ Fixing FAME flow streams ---**
fc.Fx('FAME','Mix2','Mix3') = 0;
x.Fx('FAME','Mix2','Mix3') = 0;
fc.Fx('FAME','Mix3','HX45') = 0;
x.Fx('FAME','Mix3','HX45') = 0;
fc.Fx('FAME','HX45','Reactor3')= 0;
x.Fx('FAME','HX45','Reactor3') = 0;
Positive variables
Tmp_reactor Temperature of reactor 4
cat Catalyst ratio in input
ratio_met_alk Ratio of methanol to alkali
Op Output
conver conversion rate;
Tmp_reactor.lo = 45;
Tmp_reactor.up = 65;
Tmp_reactor.l = (Tmp_reactor.lo + Tmp_reactor.up)/2;
cat.lo = 0.005;
cat.up = 0.015;
cat.l = (cat.lo + cat.up)/2;
ratio_met_alk.lo = 4.5;
ratio_met_alk.up = 7.5;
ratio_met_alk.l = (ratio_met_alk.lo + ratio_met_alk.up)/2;
*Src5 has only KOH as the input which is a variable
*################################################*************
*fc.up('KOH','Src5','Mix3') = 0.005827;
*fc.lo('KOH','Src5','Mix3') = 0.001847;
*################################################*************
*fc.up('KOH','Src5','Mix3') = 10;
fc.lo('KOH','Src5','Mix3') = 0.01;
*fc.l('KOH','Src5','Mix3') = (fc.up('KOH','Src5','Mix3') + fc.lo('KOH','Src5','Mix3'))/2;
*fc.L will be 0.5(min + max)
** Defininte scalars for Cost of different materials **
Scalar
Cost_FAME Cost of biodiesel /1.4/
Cost_Glycerol Cost of glycerol /0.6/
Cost_PotPhos Cost of potassium phosphate /1.76/
Cost_KOH Cost of KOH /1.6/
Cost_MeOH Cost of Methanol /0.28/
Cost_PhosA Cost of Phosphoric acid /0.34/
Cost_Steam Cost of steam /0.019/
Cost_Wa Cost of process water /0.0105/
Cost_Oil Cost of soybean oil /0.682/
Annual Factor for converting Kg per s to kg per year /31536000/;
*All costs are in $/kg. Check notes for references
* Rel_1, Rel_2;
*Obj.. Z =E= Q('Hx1') + Q('Jet1') + Q('Hx4') + Q('Hx6') + Q('Hx7') + Q('Hx8') + Q('Dry1') + Q_reb('BC1') + Q_reb('Rec1') + Q('Hx3');
*Rel_1(J,unit,unit1)$Arc(unit,unit1)..
* fc(J,unit,unit1) =e= F(unit,unit1)*x(J,unit,unit1);
*Rel_2(unit,unit1)$Arc(unit,unit1)..
* Sum(J,fc(J,unit,unit1)) =e= F(unit,unit1);
Equations
Feed_1, Feed_2, Admixing_1;
Feed_1..
fc('MeOH','Mix2','Mix3') =e= ratio_met_alk*(MW('MeOH')/MW('Oil'))*fc('Oil','Src','Mix3');
*Calculating flow of methanol between the mix streams
Feed_2..
fc('MeOH','Col3','Mix2') =e= fc('MeOH','Mix2','Mix3') - fc('MeOH','Src3','Mix2');
*Calculating recycle stream flow
Admixing_1(J)..
fc(J,'Mix3','HX45') =e= fc(J,'Mix2','Mix3') + fc(J,'Src','Mix3') + fc(J,'Src5','Mix3');
fc.UP('KOH','Mix2','Mix3') = 0.01;
*Reaction transesterification
Equations
Reactran_1, HX45_1, Yield, Convert, Reactran_2, Reactran_3, Reactran_4, Reactran_5, Reactran_6, Reactran_7, Reactran_8, Reactran_9, React3_1;
HX45_1..
Q('HX45') =E= Sum(J,fc(J,'Mix3','HX45')*c_p_ind(J))*(T('HX45','Reactor3')-T('Mix3','HX45'));
Reactran_1(J)..
fc(J,'HX45','Reactor3') =E= fc(J,'Mix3','HX45');
*Op refers to yield here
Yield..
Op =E= (74.6301 + (0.4209*Tmp_reactor) + (15.1582*cat) + (3.1561*ratio_met_alk)
-(0.0019*sqr(Tmp_reactor)) - (0.2022*Tmp_reactor*cat)
-(0.01925*Tmp_reactor*ratio_met_alk) - (4.0143*sqr(cat))
-(0.3400*cat*ratio_met_alk) - (0.1459*sqr(ratio_met_alk)));
Convert..
conver =E= Op*0.01;
Reactran_2..
fc('FAME','Reactor3','HX10') =E= fc('FAME','HX45','Reactor3')
+ 3*(MW('FAME')/MW('Oil'))*conver*fc('Oil','HX45','Reactor3')
+ (MW('FAME')/MW('FFA'))*conver*fc('FFA','HX45','Reactor3');
Reactran_3..
fc('Oil','Reactor3','HX10') =E=(1-conver)*fc('Oil','HX45','Reactor3');
Reactran_4..
fc('FFA','Reactor3','HX10') =E=(1-conver)*fc('FFA','HX45','Reactor3');
Reactran_5..
fc('MeOH','Reactor3','HX10') =E= fc('MeOH','HX45','Reactor3')
-(conver*fc('Oil','HX45','Reactor3'))*3*(MW('MeOH')/MW('Oil'))
-(conver*fc('FFA','HX45','Reactor3'))*(MW('MeOH')/MW('FFA'));
Reactran_6..
fc('Glycerol','Reactor3','HX10') =E= conver*fc('Oil','HX45','Reactor3')*(MW('Glycerol')/MW('Oil'));
Reactran_7..
fc('Wa','Reactor3','HX10') =E= fc('Wa','HX45','Reactor3')
+ conver*fc('FFA','HX45','Reactor3')*(MW('Wa')/MW('FFA'));
Reactran_8..
fc('KOH','Reactor3','HX10') =E= fc('KOH','HX45','Reactor3');
Reactran_9..
T('Reactor3','HX10') =E= T('HX45','Reactor3');
React3_1..
Q('Reactor3') =E= 469*(fc('FAME','Reactor3','HX10') - fc('FAME','HX45','Reactor3'));
*****************************
*Methanol Distillation*
*****************************
Positive variables
m_frac_c3(J,unit,unit1) mol fraction of components in Column3
recover_c3_MeOH Recovery of methanol in column 3
Reflux Intermediate: Reflux ratio in column 3
R_Col3 Reflux ratio in column 3
P_Col3 Pressure at feed tray in col3
VpMeOH_1 Vp of methanol in MD
VpGlycerol_1 Vp of glycerol in MD
VpKOH_1 Vp of KOH in MD
VpWa_1 Vp of water in MD
VpFAME_1 Vp of FAME in MD
P_Col3_Temp Calculating pressure in col3
Col3Mix2Temp Temperature of stream Col3 to Mix2
VpOil_1 Vapor pressure of oil
recover_c3_Wa Recovery of water in col3
recover_c3_FAME Recovery of FAME in Col3
recover_c3_Glycerol Recovery of glycerol in Col3
recover_c3_KOH Recovery of KOH in col3
recover_c3_Oil Recovery of oil in col3
recover_c3_FFA Recovery of FFA in Col3
R_Col3_Temp Temp factor for R_Col3;
Equations
MD_1,MD_2,MD_3,MD_4,MD_5, MD_6, MD_7, MD_8,MD_9, MD_10, MD_11, MD_12, MD_13, MD_14, MD_15, MD_16, MD_17, MD_31, MD_32,MD_33,MD_34, MD_35, MD_36
MD_18, MD_19, MD_20, MD_21, MD_23, MD_24, MD_25, MD_26 , HX11_1, HX12_1, MD_27, MD_28, MD_29, MD_30,MD_37, MD_38;
*Scalar
* dp Pressure loss in column /0.1/
* alpha_c3 Relative volatility in column /4.5/;
recover_c3_MeOH.lo = 0.75;
recover_c3_MeOH.up = 0.99;
recover_c3_MeOH.l = (recover_c3_MeOH.lo + recover_c3_MeOH.up)/2;
P_Col3_Temp.lo = 0.01;
recover_c3_Wa.lo = 0.01;
recover_c3_Wa.up = 0.99;
recover_c3_Wa.l = (recover_c3_Wa.lo + recover_c3_Wa.up)/2;
recover_c3_FAME.lo = 0.01;
recover_c3_FAME.up = 0.99;
recover_c3_FAME.l = (recover_c3_FAME.up + recover_c3_FAME.lo)/2;
recover_c3_Glycerol.lo = 0.75;
recover_c3_Glycerol.up = 0.99;
recover_c3_Glycerol.l = (recover_c3_Glycerol.lo + recover_c3_Glycerol.up)/2;
recover_c3_KOH.lo = 0.75;
recover_c3_KOH.up = 0.99;
recover_c3_KOH.L = (recover_c3_KOH.lo + recover_c3_KOH.up)/2;
recover_c3_Oil.lo = 0.75;
recover_c3_Oil.up = 0.99;
recover_c3_Oil.l = (recover_c3_Oil.lo + recover_c3_Oil.up)/2;
recover_c3_FFA.lo = 0.01;
recover_c3_FFA.up = 0.99;
recover_c3_FFA.l = (recover_c3_FFA.lo + recover_c3_FFA.up)/2;
*for all components J in Wa,MeOH,Glycerol,KOH
MD_1..
fc('Wa','HX10','Col3') =E= fc('Wa','Reactor3','HX10');
MD_2..
fc('MeOH','HX10','Col3')=E= fc('MeOH','Reactor3','HX10');
MD_3..
fc('Glycerol','HX10','Col3')=E= fc('Glycerol','Reactor3','HX10');
MD_4..
fc('KOH','HX10','Col3')=E= fc('KOH','Reactor3','HX10');
MD_5..
fc('Oil','HX10','Col3')=E= fc('Oil','Reactor3','HX10');
MD_6..
fc('FAME','HX10','Col3')=E= fc('FAME','Reactor3','HX10');
MD_38..
fc('FFA','HX10','Col3') =E= fc('FFA','Reactor3','HX10');
MD_7..
F('HX10','Col3') =E= fc('MeOH','HX10','Col3') + fc('Glycerol','HX10','Col3')
+ fc('KOH','HX10','Col3') + fc('Wa','HX10','Col3') ;
MD_8(J)$((ord(J) ne 8) and (ord(J) ne 9) and (ord(J) ne 5) and (ord(J) ne 6) and (ord(J) ne 7))..
m_frac_c3(J,'HX10','Col3') =E= ((fc(J,'HX10','Col3')/F('HX10','Col3')/MW(J)))
/(((fc('MeOH','HX10','Col3')/F('HX10','Col3'))/MW('MeOH'))
+ ((fc('Glycerol','HX10','Col3')/F('HX10','Col3'))/MW('Glycerol'))
+ ((fc('KOH','HX10','Col3')/F('HX10','Col3'))/MW('KOH'))
+ ((fc('Wa','HX10','Col3')/F('HX10','Col3'))/MW('Wa')));
*+ ((fc('Oil','HX10','Col3')/F('HX10','Col3'))/MW('Oil')));
MD_9..
VpFAME_1 =E= (10**(coef_p('FAME','1')-(coef_p('FAME','2')/
(coef_p('FAME','3')+T('HX10','Col3')+273))))*0.0075;
*Conversion from Pa to mmHG
MD_10..
VpWa_1 =E= (10**(coef_p('Wa','1')-(coef_p('Wa','2')/
(coef_p('Wa','3')+(T('HX10','Col3')+273)))))*750.06;
*Conversion from Bar to mmHg
MD_11..
VpGlycerol_1 =E= 10**(coef_p('Glycerol','1')-(coef_p('Glycerol','2')/T('HX10','Col3')) -
(coef_p('Glycerol','3')*log((T('HX10','Col3')+273))));
*Torr and mmhg are almost equal
*** NOTE ANTOINE EQUATION FOR OIL AND GLYCEROL ARE SLIGHTLY DIFF FROM THE ORIGINAL EQUATION **
MD_12..
VpMeOH_1 =E= (10**(coef_p('MeOH','1')-(coef_p('MeOH','2')/
(coef_p('MeOH','3')+(T('HX10','Col3')+273)))))*750.06;
*Conversion from Bar to mmHg
MD_13..
VpKOH_1 =E= (10**(coef_p('KOH','1')-(coef_p('KOH','2')/
(coef_p('KOH','3')+(T('HX10','Col3'))))));
*T in C and Vp in mmHG
MD_14..
VpOil_1 =E= (exp(coef_p('Oil','1')+ (coef_p('Oil','2')/
(coef_p('Oil','3')+(T('HX10','Col3')+273)))))*750.06;
*** NOTE ANTOINE EQUATION FOR OIL AND GLYCEROL ARE SLIGHTLY DIFF FROM THE ORIGINAL EQUATION **
*Oil is in kPA, Temp is in K
MD_15..
P_Col3 =E= VpFAME_1
+ (m_frac_c3('Wa','HX10','Col3')*VpWa_1)
+ (m_frac_c3('MeOH','HX10','Col3')*VpMeOH_1)
+ (m_frac_c3('Glycerol','HX10','Col3')*VpGlycerol_1)
+ (m_frac_c3('KOH','HX10','Col3')*VpKOH_1);
*+ (m_frac_c3('Oil','HX10','Col3')*VpOil_1);
* + (m_frac_c3('MeOH','HX10','Col3')*exp(coef_p('MeOH','1')-(coef_p('MeOH','2')/(coef_p('MeOH','3')+T('HX10','Col3')))))
* + (m_frac_c3('Glycerol','HX10','Col3')*exp(coef_p('Glycerol','1')-(coef_p('Glycerol','2')/(coef_p('Glycerol','3')+T('HX10','Col3')))))
* + (m_frac_c3('KOH','HX10','Col3')*exp(coef_p('KOH','1')-(coef_p('KOH','2')/(coef_p('KOH','3')+T('HX10','Col3')))));
*P_Col3 in mmhg
MD_16(J)..
Q('HX10') =E= sum(h,fc(h,'HX10','Col3')*c_p_ind(h))*(T('HX10','Col3')-T('Reactor3','HX10'));
*This has highest energy/heat consumption. Does not make any sense!
$ontext
This part is slighlty modified than the python code. In python, using flow of each individual components through
reactros for the mass balance. In GAMS, using "J" of all components to do mass balance, same as what is there in the supporting information
Also, using recovery of MeOH alone since there is no recovery factor given for the rest of the components.
$offtext
MD_17..
fc('Wa','Col3','HX13') =E= recover_c3_Wa*fc('Wa','HX10','Col3');
MD_37..
fc('MeOH','Col3','HX13') =E= (1-recover_c3_MeOH)*fc('MeOH','HX10','Col3');
MD_32..
fc('Glycerol','Col3','HX13') =E= recover_c3_Glycerol*fc('Glycerol','HX10','Col3');
MD_33..
fc('KOH','Col3','HX13') =E= recover_c3_KOH*fc('KOH','HX10','Col3');
MD_34..
fc('Oil','Col3','HX13') =E= recover_c3_Oil*fc('Oil','HX10','Col3');
MD_35..
fc('FFA','Col3','HX13') =E= recover_c3_FFA*fc('FFA','HX10','Col3');
MD_36..
fc('FAME','Col3','HX13') =E= recover_c3_FAME*fc('FAME','HX10','Col3');
MD_18..
fc('MeOH','Col3','Mix2') =E= recover_c3_MeOH*fc('MeOH','HX10','Col3');
MD_19..
(P_Col3_Temp) =E= (1-0.5*dp)*P_Col3*0.0013332239;
*P_Col3_Temp is mmhg. Convert to bar "x" b'Col3'y 0.0013332239 since coef of MeOH are in bar and K
MD_20..
Col3Mix2Temp =E= (1581.341/(5.20409 - log10(P_Col3_Temp))) - (-33.50);
MD_21..
T('Col3','Mix2') =E= Col3Mix2Temp - 273;
*Temp is in C
*(coef_p('MeOH','2')/((coef_p('MeOH','1') - log((1 - 0.5*dp)*P_Col3)))) - coef_p('MeOH','3');
*log((1 - 0.5*dp)*P_Col3) =E= coef_p('MeOH','1') - ((coef_p('MeOH','2')/(coef_p('MeOH','3') + T('Col3','Mix2'))));
*T('Col3','Mix2') =e= -(coef_p('MeOH','3')) + (-coef_p('MeOH','2')/(log((1-(0.5*dp))*P_Col3)) - coef_p('MeOH','1'));
MD_23..
F('Col3','HX13') =E= fc('MeOH','Col3','HX13') + fc('Glycerol','Col3','HX13') + fc('KOH','Col3','HX13') + fc('Wa','Col3','HX13') ;
MD_24(J)$((ord(J) ne 8) and (ord(J) ne 9) and (ord(J) ne 6) and (ord(J) ne 5) and (ord(J) ne 7))..
m_frac_c3(J,'Col3','HX13') =E= ((fc(J,'Col3','HX13')/F('Col3','HX13')/MW(J)))
/(((fc('MeOH','Col3','HX13')/F('Col3','HX13'))/MW('MeOH'))
+ ((fc('Glycerol','Col3','HX13')/F('Col3','HX13'))/MW('Glycerol'))
+ ((fc('KOH','Col3','HX13')/F('Col3','HX13'))/MW('KOH'))
+ ((fc('Wa','Col3','HX13')/F('Col3','HX13'))/MW('Wa')));
*+ ((fc('Oil','Col3','HX13')/F('Col3','HX13'))/MW('Oil'))
*+ ((fc('FAME','Col3','HX13')/F('Col3','HX13'))/MW('FAME')));
MD_25..
*(J)$((ord(J) ne 8) and (ord(J) ne 9) and (ord(J) ne 1) and (ord(J) ne 6))..
P_Col3_Temp =E= (10**(coef_p('FAME','1')-coef_p('FAME','2')/
(coef_p('FAME','3')+T('Col3','HX13'))))*0.0075
+ (m_frac_c3('MeOH','Col3','HX13')*(10**(coef_p('MeOH','1')-(coef_p('MeOH','2')/(coef_p('MeOH','3')+T('Col3','HX13')))))*750.06)
+ (m_frac_c3('KOH','Col3','HX13')*(10**(coef_p('KOH','1')-coef_p('KOH','2')/(coef_p('KOH','3')+(T('Col3','HX13') + 273)))))
+ (m_frac_c3('Wa','Col3','HX13')*(10**(coef_p('Wa','1')-(coef_p('Wa','2')/(coef_p('Wa','3')+(T('Col3','HX13'))))))*750.06)
+ (m_frac_c3('Glycerol','Col3','HX13')*(10**(coef_p('Glycerol','1')-(coef_p('Glycerol','2')/T('Col3','HX13')) - (coef_p('Glycerol','3')*log(T('Col3','HX13'))))));
*** NOTE ANTOINE EQUATION FOR OIL AND GLYCEROL ARE SLIGHTLY DIFF FROM THE ORIGINAL EQUATION **
**** Check this line. Probably calculating summation this way may not be right ***
MD_26..
R_Col3 =E= 1.5*(1/(alpha_c3 - 1))*((0.9999/(m_frac_c3('MeOH','HX10','Col3')+0.001))- (alpha_c3*((1-0.999)/(1-m_frac_c3('MeOH','HX10','Col3')))));
R_Col3.lo = 1;
R_Col3.up = 3;
*R_Col3.l = (R_Col3.lo + R_Col3.up)/2;
HX11_1..
Q('HX11') =E= -fc('MeOH','Col3','Mix2')*(R_Col3 + 1)*dH_vap_0('MeOH');
*Only methanol is recycled
MD_27..
x('Wa','Col3','HX13') =E= fc('Wa','Col3','HX13')/F('Col3','HX13');
MD_28..
x('Glycerol','Col3','HX13') =E= fc('Glycerol','Col3','HX13')/F('Col3','HX13');
MD_29..
x('MeOH','Col3','HX13') =E= fc('MeOH','Col3','HX13')/F('Col3','HX13');
MD_30..
x('FAME','Col3','HX13') =E= fc( 'FAME','Col3','HX13')/F('Col3','HX13');
MD_31..
x('Oil','Col3','HX13') =E= fc('Oil','Col3','HX13')/F('Col3','HX13');
HX12_1..
Q('HX12') =E= F('Col3','HX13')*(R_Col3 + 1)*((x('Wa','Col3','HX13')*dH_vap_0('Wa')) +
(x('Glycerol','Col3','HX13')*dH_vap_0('Glycerol')) +
(x('MeOH','Col3','HX13')*dH_vap_0('MeOH')) +
(x('FAME','Col3','HX13')*dH_vap_0('FAME')) +
(x('Oil','Col3','HX13')*dH_vap_0('Oil')));
*The stream temperature here is here is T('Col3','HX12')
* SI has F('Col3',Mix2') here rest of the streams flow through the condenser
*****************************
********** WASHING **********
*****************************
*Src6 has water as input which is a variable
**##################################################****
*fc.lo('Wa','Src6','Sep2') = 0.01;
*fc.up('Wa','Src6','Sep2') = 10;
**##################################################****
*fc.lo('Wa','SrcWa','Src6') = 0.01;
*fc.up('Wa','SrcWa','Src6') = 10;
*fc.l('Wa','SrcWa','Src6') = (fc.lo('Wa','SrcWa','Src6') + fc.up('Wa','SrcWa','Src6'))/2;
*fc.L
Positive variable
water_req Water input required;
Equations
Wash_1, Wash_2, HX13_1 ,Wash_3, Wash_4, Wash_5, Wash_6, Wash_7, Wash_8, Wash_9, Wash_10, Wash_11, Wash_12, Wash_14, Wash_15, Wash_16, Wash_17, Wash_18, Wash_19
Wash_20, Wash_21, Wash_22, Wash_23, Wash_13,Wash_25, Wash_26 ;
Wash_1..
fc('Wa','HX13','Sep2') =E= fc('Wa','Col3','HX13');
Wash_2..
fc('MeOH','HX13','Sep2') =E= fc('MeOH','Col3','HX13');
Wash_3..
fc('Glycerol','HX13','Sep2') =E= fc('Glycerol','Col3','HX13');
Wash_4..
fc('KOH','HX13','Sep2') =E= fc('KOH','Col3','HX13');
Wash_5..
fc('Oil','HX13','Sep2') =E= fc('Oil','Col3','HX13');
Wash_6..
fc('FAME','HX13','Sep2') =E= fc('FAME','Col3','HX13');
Wash_7..
fc('FFA','HX13','Sep2') =E= fc('FFA','Col3','HX13');
Wash_9..
F('HX13','Sep2') =E= fc('Wa','Col3','HX13') + fc('MeOH','Col3','HX13')+ fc('Glycerol','Col3','HX13')+ fc('KOH','Col3','HX13')+ fc('Oil','Col3','HX13')+
fc('FAME','Col3','HX13') + fc('FFA','Col3','HX13');
**** THIS LINE IS NOT WORKING. NOT ABLE TO ASSIGN A VARIABLE TP FC.UP. CHECK HOW THIS CAN BE FIXED *****
*Value of F('HX13','Sep2') is 21.15 so fix water input max as 10
*fc.UP('Wa','Src6','Sep2') = 0.01*F.l('HX13','Sep2');
Wash_8..
water_req =E= 0.01*F('HX13','Sep2');
Wash_26..
fc('Wa','Src6','Sep2') =E= water_req;
HX13_1..
Q('HX13') =E=(fc('Wa','Col3','HX13')*c_p_ind('Wa') + fc('MeOH','Col3','HX13')*c_p_ind('MeOH') +
fc('Glycerol','Col3','HX13')*c_p_ind('Glycerol') + fc('KOH','Col3','HX13')*c_p_ind('KOH') +
fc('FAME','Col3','HX13')*c_p_ind('FAME') + fc('FFA','Col3','HX13')*c_p_ind('FFA') + fc('Oil','Col3','HX13')*c_p_ind('Oil'))*(T('HX13','Sep2')-(T('Col3','HX13')));
Wash_10..
T('Sep2','HX19') =E= T('Sep2','Reactor4');
Wash_11..
fc('Wa','Sep2','Reactor4') =E= Separation('Wa')*(fc('Wa','HX13','Sep2') +fc('Wa','Src6','Sep2'));
Wash_12..
fc('MeOH','Sep2','Reactor4') =E= Separation('MeOH')*(fc('MeOH','HX13','Sep2') + fc('MeOH','Src6','Sep2'));
Wash_13..
fc('Glycerol','Sep2','Reactor4') =E= Separation('Glycerol')*(fc('Glycerol','HX13','Sep2') + fc('Glycerol','Src6','Sep2'));
Wash_14..
fc('KOH','Sep2','Reactor4') =E= Separation('KOH')*(fc('KOH','HX13','Sep2') + fc('KOH','Src6','Sep2'));
Wash_25..
fc('Oil','Sep2','Reactor4') =E= Separation('Oil')*(fc('Oil','HX13','Sep2') + fc('Oil','Src6','Sep2'));
Wash_15..