-
Notifications
You must be signed in to change notification settings - Fork 0
/
UnitOperationsWOMS.mo
999 lines (972 loc) · 75.5 KB
/
UnitOperationsWOMS.mo
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
package UnitOperationsWOMS
model parameters
constant Integer noc = 4;
constant Chemsep_Database.Toluene comp1;
constant Chemsep_Database.Hydrogen comp2;
constant Chemsep_Database.Benzene comp3;
constant Chemsep_Database.Methane comp4;
constant Chemsep_Database.General_Properties components[noc] = {comp1, comp2, comp3, comp4};
end parameters;
model compounds
parameter Integer NOC = 4;
parameter Chemsep_Database.Toluene comp1;
parameter Chemsep_Database.Hydrogen comp2;
parameter Chemsep_Database.Benzene comp3;
parameter Chemsep_Database.Methane comp4;
parameter Chemsep_Database.General_Properties comp[NOC] = {comp1, comp2, comp3, comp4};
end compounds;
connector sensor
Real var;
annotation(Diagram(graphics = {Ellipse(origin = {-1, 1}, fillColor = {65, 252, 255}, fillPattern = FillPattern.Solid, extent = {{-67, 65}, {67, -65}}, endAngle = 360)}), Icon(graphics = {Ellipse(origin = {-4, -1}, fillColor = {255, 85, 0}, fillPattern = FillPattern.Solid, extent = {{-60, 61}, {60, -61}}, endAngle = 360)}, coordinateSystem(initialScale = 0.1)));
end sensor;
connector port
parameter Integer NOC = 4;
Real moleflow;
Real pressure;
Real temperature;
Real molefrac[NOC];
Real liquidmoleflow, vapormoleflow;
Real liquidmolefrac[NOC], vapormolefrac[NOC];
Real enthalpy;
annotation(Diagram(graphics = {Ellipse(origin = {-1, 1}, fillColor = {65, 252, 255}, fillPattern = FillPattern.Solid, extent = {{-67, 65}, {67, -65}}, endAngle = 360)}), Icon(graphics = {Ellipse(origin = {-4, -1}, fillColor = {81, 253, 248}, fillPattern = FillPattern.Solid, extent = {{-60, 61}, {60, -61}}, endAngle = 360)}));
end port;
model valve
parameter Real coeff(fixed = false) "Coeff for valve", valveCv = 0.4 "valve Cv if not control valve";
parameter Boolean Control = false;
parameter Boolean OutletPfixed = false;
parameter Real OutletPressure = 1e5 "used only when OutletPfixed is true";
Real flowrate, Cv, outletP, delP;
UnitOperationsWOMS.sensor sensor1 annotation(Placement(visible = true, transformation(origin = {1, 77}, extent = {{-19, -19}, {19, 19}}, rotation = 0), iconTransformation(origin = {2, 56}, extent = {{-18, -18}, {18, 18}}, rotation = 0)));
UnitOperationsWOMS.port port1 annotation(Placement(visible = true, transformation(origin = {-80, -4}, extent = {{-18, -18}, {18, 18}}, rotation = 0), iconTransformation(origin = {-82, -2}, extent = {{-16, -16}, {16, 16}}, rotation = 0)));
UnitOperationsWOMS.port port2 annotation(Placement(visible = true, transformation(origin = {79, 1}, extent = {{-17, -17}, {17, 17}}, rotation = 0), iconTransformation(origin = {82, 2}, extent = {{-18, -18}, {18, 18}}, rotation = 0)));
equation
if Control == false then
sensor1.var = 0;
end if;
if Control == true then
Cv = sensor1.var;
else
Cv = valveCv;
end if;
flowrate = coeff * Cv * delP ^ 0.5;
port1.moleflow = flowrate;
port1.moleflow = port2.moleflow;
if OutletPfixed == true then
outletP = OutletPressure;
port2.pressure = outletP;
end if;
if OutletPfixed == false then
outletP = 0;
end if;
delP = port1.pressure - port2.pressure;
port2.temperature = port1.temperature;
port2.molefrac[:] = port1.molefrac[:];
port2.liquidmoleflow = port1.liquidmoleflow;
port2.vapormoleflow = port1.vapormoleflow;
port2.liquidmolefrac[:] = port1.liquidmolefrac[:];
port2.vapormolefrac[:] = port1.vapormolefrac[:];
port2.enthalpy = port1.enthalpy;
annotation(Icon(graphics = {Polygon(origin = {-48.26, -2.99}, fillColor = {85, 170, 255}, fillPattern = FillPattern.Solid, points = {{-47.7381, 48.9887}, {-47.7381, -49.0113}, {48.2619, 2.98874}, {48.2619, 2.98874}, {-47.7381, 48.9887}}), Polygon(origin = {49.25, -4.98}, fillColor = {85, 170, 255}, fillPattern = FillPattern.Solid, points = {{-47.2509, 4.98071}, {46.7491, 48.9807}, {46.7491, -49.0193}, {-47.2509, 4.98071}}), Rectangle(origin = {1, 35}, fillColor = {85, 170, 255}, fillPattern = FillPattern.Solid, extent = {{-15, 35}, {15, -35}})}, coordinateSystem(initialScale = 0.1)));
end valve;
model MaterialStream
parameter Integer NOC = 4;
parameter Chemsep_Database.Toluene comp1;
parameter Chemsep_Database.Hydrogen comp2;
parameter Chemsep_Database.Benzene comp3;
parameter Chemsep_Database.Methane comp4;
parameter String Name = "MS1";
parameter Chemsep_Database.General_Properties comp[NOC] = {comp1, comp2, comp3, comp4};
parameter Real Flowrate = 100, Pressure = 1e5, Temperature = 300, molefraction[NOC] = zeros(NOC);
parameter Boolean unspecified = true;
parameter Boolean stepchange = false;
parameter Real stepchangetime = 0.01;
parameter Real step_value = 1;
Real kf[NOC], zl[NOC](each min = 0, each max = 1, start = {0.5, 1e-18, 0.5, 0}), zv[NOC](each min = 0, each max = 1, start = {0, 0.25, 0, 0.75}), Fl(min = 0, start = 100), Fv(min = 0, start = 140), Tbf(start = 62), Tdf(start = 495.5), Psat_Tdf[NOC], Psat_Tbf[NOC], Psat_Tf[NOC], Pf, Tf, z[NOC], F;
Real Hvf[NOC], Hlf[NOC], H;
UnitOperationsWOMS.port port2 annotation(Placement(visible = true, transformation(origin = {80, -4}, extent = {{-18, -18}, {18, 18}}, rotation = 0), iconTransformation(origin = {85, 1}, extent = {{-21, -21}, {21, 21}}, rotation = 0)));
UnitOperationsWOMS.port port1 annotation(Placement(visible = true, transformation(origin = {-80, -4}, extent = {{-18, -18}, {18, 18}}, rotation = 0), iconTransformation(origin = {-82, 0}, extent = {{-20, -20}, {20, 20}}, rotation = 0)));
equation
if unspecified == false then
if stepchange == true then
if time < stepchangetime then
port1.moleflow = Flowrate;
else
port1.moleflow = Flowrate + step_value;
end if;
else
port1.moleflow = Flowrate;
end if;
port1.pressure = Pressure;
port1.temperature = Temperature;
port1.molefrac[:] = molefraction[:];
port1.liquidmolefrac[:] = zl[:];
port1.vapormolefrac[:] = zv[:];
port1.liquidmoleflow = Fl;
port1.vapormoleflow = Fv;
port1.enthalpy = H;
end if;
if unspecified == true then
port1.liquidmolefrac[:] = zl[:];
port1.vapormolefrac[:] = zv[:];
port1.liquidmoleflow = Fl;
port1.vapormoleflow = Fv;
port1.enthalpy = H;
end if;
if unspecified == false then
Pf = Pressure;
z[:] = molefraction[:];
Tf = Temperature;
F = port1.moleflow;
else
Pf = port1.pressure;
z[:] = port1.molefrac[:];
Tf = port1.temperature;
F = port1.moleflow;
end if;
//flash calculations
sum(Pf * z[:] ./ Psat_Tdf[:]) = 1;
sum(Psat_Tbf[:] ./ Pf .* z[:]) = 1;
if Tf < Tbf then
zl[:] = z[:];
zv = zeros(NOC);
Fl = F;
Fv = 0;
kf = zeros(NOC);
elseif Tf > Tdf then
zv[:] = z[:];
zl = zeros(NOC);
Fl = 0;
Fv = F;
kf = zeros(NOC);
else
sum(zl[:]) = 1;
sum(zv[:]) = 1;
zv[:] = kf[:] .* zl[:];
kf[:] = Psat_Tf[:] ./ Pf;
F = Fl + Fv;
for i in 1:NOC - 1 loop
F * z[i] = Fl * zl[i] + Fv * zv[i];
end for;
end if;
H = Fl * sum(zl[:] .* Hlf[:]) + Fv * sum(zv[:] .* Hvf[:]);
for i in 1:NOC loop
Psat_Tbf[i] = Functions.Psat(comp[i].VP, Tbf);
Psat_Tdf[i] = Functions.Psat(comp[i].VP, Tdf);
Psat_Tf[i] = Functions.Psat(comp[i].VP, Tf);
Hlf[i] = Functions.HLiqId(comp[i].VapCp, comp[i].HOV, comp[i].Tc, Tf);
Hvf[i] = Functions.HVapId(comp[i].VapCp, comp[i].HOV, comp[i].Tc, Tf);
end for;
port2.moleflow = F;
port2.pressure = port1.pressure;
port2.temperature = port1.temperature;
port2.molefrac[:] = port1.molefrac[:];
port2.liquidmolefrac[:] = zl[:];
port2.vapormolefrac[:] = zv[:];
port2.liquidmoleflow = Fl;
port2.vapormoleflow = Fv;
port2.enthalpy = H;
annotation(Icon(graphics = {Rectangle(origin = {-10, 3}, fillColor = {255, 0, 0}, fillPattern = FillPattern.Solid, extent = {{-90, 45}, {90, -45}}), Text(origin = {-17, -1}, extent = {{-51, 27}, {51, -27}}, textString = "MS1")}, coordinateSystem(initialScale = 0.1)));
end MaterialStream;
model materialtest
MaterialStream materialStream1(Flowrate = 100, Name = "MS2", Pressure = 5e5, Temperature = 350, molefraction = {0.5, 0, 0.5, 0}, unspecified = false) annotation(Placement(visible = true, transformation(origin = {-24, 22}, extent = {{-24, -24}, {24, 24}}, rotation = 0)));
end materialtest;
model CSTR
parameter Integer NOC = 4;
parameter Chemsep_Database.Toluene comp1;
parameter Chemsep_Database.Hydrogen comp2;
parameter Chemsep_Database.Benzene comp3;
parameter Chemsep_Database.Methane comp4;
parameter Chemsep_Database.General_Properties comp[NOC] = {comp1, comp2, comp3, comp4};
parameter Boolean Operation;
parameter Real s[NOC] = {-1, -1, 1, 1} "stoichiometric coefficients";
parameter Integer NOIS = 2 "No of input streams";
parameter Integer n = 1 "base compound identity in comp[n]";
parameter Real V_Total = 2.321 "Volume of reactor", P_init = 25e5 "Pressure at t = 0";
parameter Real R = 8.314, delH_r = 12.6e3 "Heat of reaction", T_iso = 650;
Real F_in[NOIS], z[NOIS, NOC], Hin[NOIS] "Feed values";
Real M_Total(start = 1.5), M[NOC], x[NOC], F_out, densityi[NOC], P;
Real r, kf, kb, c[NOC];
Real H_r, Hout, Q, T(start = 650);
UnitOperationsWOMS.port port1 annotation(Placement(visible = true, transformation(origin = {-82, 2}, extent = {{-18, -18}, {18, 18}}, rotation = 0), iconTransformation(origin = {-85, 1}, extent = {{-17, -17}, {17, 17}}, rotation = 0)));
UnitOperationsWOMS.port port2 annotation(Placement(visible = true, transformation(origin = {2, 84}, extent = {{-18, -18}, {18, 18}}, rotation = 0), iconTransformation(origin = {3, 83}, extent = {{-17, -17}, {17, 17}}, rotation = 0)));
UnitOperationsWOMS.port port3 annotation(Placement(visible = true, transformation(origin = {81, -77}, extent = {{-17, -17}, {17, 17}}, rotation = 0), iconTransformation(origin = {78, -74}, extent = {{-20, -20}, {20, 20}}, rotation = 0)));
initial equation
//calculates steady state solution at t=0
P = P_init;
der(M_Total) = 0;
for i in 1:NOC - 1 loop
der(M[i]) = 0;
end for;
equation
F_in[1] = port1.moleflow;
F_in[2] = port2.moleflow;
z[1, :] = port1.molefrac[:];
z[2, :] = port2.molefrac[:];
Hin[1] = port1.enthalpy;
Hin[2] = port2.enthalpy;
for i in 1:NOC loop
densityi[i] = Functions.Density(comp[i].LiqDen, comp[i].Tc, T, P);
end for;
for i in 1:NOC loop
x[i] = M[i] / M_Total;
c[i] = M[i] / V_Total;
end for;
//reaction rate
/*kf = 8.43 * exp(-27.5 * 1e3 / (R * T));
kb = 1.12 * exp(-31.3 * 1e3 / (R * T)); */
kf = 20;
kb = 0;
r = 20;
//kf * c[1] * c[2] - kb * c[3] * c[4];
//unsteady state mass balance
for i in 1:NOC - 1 loop
der(M[i]) = sum(z[:, i] .* F_in[:]) - x[i] * F_out + s[i] * r * V_Total / abs(s[n]);
end for;
der(M_Total) = sum(F_in[:]) - F_out;
//Pressure
M_Total = sum(M[:]);
P * V_Total = M_Total * R * T * 1000;
//Energy balance
if Operation == true then
T = T_iso;
else
Q = 0;
end if;
H_r = r * V_Total * delH_r;
sum(Hin[:]) + Q + H_r = Hout;
Hout = port3.enthalpy;
port3.moleflow = F_out;
port3.temperature = T;
port3.pressure = P;
port3.molefrac[:] = x[:];
annotation(Icon(graphics = {Rectangle(origin = {-1, 1}, fillColor = {255, 170, 0}, fillPattern = FillPattern.Solid, extent = {{-97, 95}, {97, -95}}), Text(origin = {2, 0}, extent = {{-80, 62}, {80, -62}}, textString = "CSTR")}, coordinateSystem(initialScale = 0.1)));
end CSTR;
model CSTR_DynamicTest
MaterialStream materialStream1(Flowrate = 100, Pressure = 24e5, Temperature = 600, molefraction = {0.9, 0, 0.1, 0}, step_value = 20, stepchange = false, stepchangetime = 0.01, unspecified = false) annotation(Placement(visible = true, transformation(origin = {-87, -1}, extent = {{-19, -19}, {19, 19}}, rotation = 0)));
MaterialStream materialStream2(Flowrate = 100, Pressure = 24e5, Temperature = 350, molefraction = {0, 0.9, 0, 0.1}, unspecified = false) annotation(Placement(visible = true, transformation(origin = {-45, 65}, extent = {{-17, -17}, {17, 17}}, rotation = 0)));
valve valve1(Control = false, OutletPfixed = true, OutletPressure = 5e5, valveCv = 0.4) annotation(Placement(visible = true, transformation(origin = {56, -20}, extent = {{-20, -20}, {20, 20}}, rotation = 0)));
MaterialStream materialStream3 annotation(Placement(visible = true, transformation(origin = {110, -22}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
CSTR cSTR1(Operation = true) annotation(Placement(visible = true, transformation(origin = {-14, -10}, extent = {{-22, -22}, {22, 22}}, rotation = 0)));
equation
connect(cSTR1.port3, valve1.port1) annotation(Line(points = {{4, -26}, {38, -26}, {38, -20}, {40, -20}}));
connect(materialStream2.port2, cSTR1.port2) annotation(Line(points = {{-30, 66}, {-14, 66}, {-14, 8}, {-14, 8}}));
connect(materialStream1.port2, cSTR1.port1) annotation(Line(points = {{-70, 0}, {-34, 0}, {-34, -10}, {-32, -10}}));
connect(valve1.port2, materialStream3.port1) annotation(Line(points = {{72, -20}, {102, -20}, {102, -22}, {102, -22}}));
end CSTR_DynamicTest;
model Flash "Generalized model for PT flash"
parameter Real R = 8.314"units = J/mol.K", A = 1.5"units = m^2", hset = 3.7"units = m", Pset = 5e5"units = Pa", V_Total = 8.11"units = m^3";
extends compounds;
parameter Boolean connectedToInput = false;
parameter Real Ti = 310;
Real z[NOC], Tf;
Real y[NOC], x[NOC](start = {0.7, 1e-18, 0.3, 0}), k[NOC], L(start = 100, min = 0), V(start = 140, min = 0), Psat_T[NOC], M[NOC], M_Total, ML(start = 50), MG(start = 0.5), VL, VG, Q, hv[NOC], hl[NOC], Hf, Hv, Hl, H_M_Total, F, densityi[NOC], P, h;
UnitOperationsWOMS.sensor sensor1 annotation(Placement(visible = true, transformation(origin = {2, 82}, extent = {{-16, -16}, {16, 16}}, rotation = 0), iconTransformation(origin = {8.88178e-16, 82}, extent = {{-16, -16}, {16, 16}}, rotation = 0)));
UnitOperationsWOMS.sensor sensor3 annotation(Placement(visible = true, transformation(origin = {82, -32}, extent = {{-16, -16}, {16, 16}}, rotation = 0), iconTransformation(origin = {77, -31}, extent = {{-19, -19}, {19, 19}}, rotation = 0)));
UnitOperationsWOMS.port port1 annotation(Placement(visible = true, transformation(origin = {1, -83}, extent = {{-17, -17}, {17, 17}}, rotation = 0), iconTransformation(origin = {-8.88178e-16, -74}, extent = {{-18, -18}, {18, 18}}, rotation = 0)));
UnitOperationsWOMS.port port2 annotation(Placement(visible = true, transformation(origin = {80, 48}, extent = {{-16, -16}, {16, 16}}, rotation = 0), iconTransformation(origin = {76, 52}, extent = {{-16, -16}, {16, 16}}, rotation = 0)));
UnitOperationsWOMS.port port3 annotation(Placement(visible = true, transformation(origin = {-84, 0}, extent = {{-18, -18}, {18, 18}}, rotation = 0), iconTransformation(origin = {-80, 4}, extent = {{-20, -20}, {20, 20}}, rotation = 0)));
initial equation
h = hset;
P = Pset;
for i in 1:NOC - 1 loop
der(M[i]) = 0;
end for;
der(M_Total) = 0;
//der(H_M_Total) = 0;
equation
F = port3.moleflow;
z[:] = port3.molefrac[:];
Tf = port3.temperature;
if connectedToInput == false then
port3.pressure = P;
end if;
for i in 1:NOC loop
Psat_T[i] = Functions.Psat(comp[i].VP, Ti);
hv[i] = Functions.HVapId(comp[i].VapCp, comp[i].HOV, comp[i].Tc, Ti);
hl[i] = Functions.HLiqId(comp[i].VapCp, comp[i].HOV, comp[i].Tc, Ti);
densityi[i] = Functions.Density(comp[i].LiqDen, comp[i].Tc, Ti, P);
end for;
/* Mass Blanace equations */
der(M_Total) = F - L - V;
//F - L - V = 0;
for i in 1:NOC - 1 loop
der(M[i]) = F * z[i] - L * x[i] - V * y[i];
//F * z[i] - L * x[i] - V * y[i] = 0;
M[i] = ML * x[i] + MG * y[i];
end for;
sum(M[:]) = M_Total;
M_Total = MG + ML;
VL = ML / sum(x[:] .* densityi[:]);
VG = V_Total - VL;
P * VG = MG * R * Ti * 1000;
//ideal gas law for gas phase
/*energy balance */
Hv = V * sum(y[:] .* hv[:]);
Hf = port3.enthalpy;
Hl = L * sum(x[:] .* hl[:]);
H_M_Total = ML * sum(x[:] .* hl[:]) + MG * sum(y[:] .* hv[:]);
//Hf - Hv - Hl = der(H_M_Total);
Hf - Hv - Hl + Q = 0 "This implies that Q is changing with time to keep temperature constant";
/*Thermodynamic equations */
sum(x[:]) = 1;
sum(y[:]) = 1;
y[:] = k[:] .* x[:];
k[:] = Psat_T[:] / P;
/* Control */
A * h = VL;
//connector equations
sensor1.var = P;
sensor3.var = h;
port1.moleflow = L;
port1.pressure = P;
port1.temperature = Ti;
port1.molefrac[:] = x[:];
port2.moleflow = V;
port2.pressure = P;
port2.temperature = Ti;
port2.molefrac[:] = y[:];
//port3.pressure = P;
annotation(Icon(graphics = {Text(origin = {-30, 86}, extent = {{-22, 32}, {22, -32}}, textString = "Pressure"), Text(origin = {56, 46}, extent = {{-10, 24}, {2, -2}}, textString = "V"), Text(origin = {60, -33}, extent = {{-12, 25}, {4, -3}}, textString = "h"), Text(origin = {-16, -82}, extent = {{-14, 26}, {2, -6}}, textString = "L"), Text(origin = {0, 15}, extent = {{-46, 41}, {46, -41}}, textString = "PT flash"), Rectangle(origin = {1, 0}, extent = {{-87, 96}, {87, -96}}), Text(origin = {-64, -21}, extent = {{-10, 17}, {10, -17}}, textString = "F")}, coordinateSystem(initialScale = 0.1)),Documentation(info = "<HTML> <p> This is a column with one inlet stream and two outlet streams. The outlet streams are liquid and vapor streams. The liquid level is <i>h</i>. Values of temperature and pressure can be used to control the column. These values can be taken from the ports given and can be connected to controllers. </p> <p> Equilibrium calculations are based on Raoult's and ideal gas laws for now. </p><p>Enthalpies are calculated in <i>J/mol</i> or <i>kJ/kmol</i><br>Note that equations for mass balance imply that mass balance integration depends on flowrate units hence care should be taken about integration step.</p></HTML>"));
end Flash;
model dynFlashtest
MaterialStream materialStream1(Flowrate = 100, Pressure = 10e5, Temperature = 350, molefraction = {0.25, 0.25, 0.25, 0.25}, stepchange = true, unspecified = false) annotation(Placement(visible = true, transformation(origin = {-78, -2}, extent = {{-18, -18}, {18, 18}}, rotation = 0)));
Flash flash1(connectedToInput = true) annotation(Placement(visible = true, transformation(origin = {-5, -1}, extent = {{-29, -29}, {29, 29}}, rotation = 0)));
MaterialStream materialStream2 annotation(Placement(visible = true, transformation(origin = {101, 27}, extent = {{-19, -19}, {19, 19}}, rotation = 0)));
MaterialStream materialStream3 annotation(Placement(visible = true, transformation(origin = {84, -38}, extent = {{-24, -24}, {24, 24}}, rotation = 0)));
valve valve1(OutletPfixed = true, OutletPressure = 1e5) annotation(Placement(visible = true, transformation(origin = {51, 25}, extent = {{-17, -17}, {17, 17}}, rotation = 0)));
valve valve2(OutletPfixed = true, OutletPressure = 1e5) annotation(Placement(visible = true, transformation(origin = {26, -48}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
equation
connect(materialStream1.port2, flash1.port3) annotation(Line(points = {{-62, -2}, {-28, -2}, {-28, 0}, {-28, 0}}));
connect(valve2.port2, materialStream3.port1) annotation(Line(points = {{34, -48}, {64, -48}, {64, -38}, {64, -38}}));
connect(flash1.port1, valve2.port1) annotation(Line(points = {{-4, -22}, {-4, -22}, {-4, -48}, {18, -48}, {18, -48}}));
connect(valve1.port2, materialStream2.port1) annotation(Line(points = {{64, 26}, {84, 26}, {84, 28}, {86, 28}}));
connect(flash1.port2, valve1.port1) annotation(Line(points = {{18, 14}, {36, 14}, {36, 24}, {38, 24}}));
end dynFlashtest;
model HeatExchanger
parameter Integer NOC = 4;
parameter Chemsep_Database.Toluene comp1;
parameter Chemsep_Database.Hydrogen comp2;
parameter Chemsep_Database.Benzene comp3;
parameter Chemsep_Database.Methane comp4;
parameter Chemsep_Database.General_Properties comp[NOC] = {comp1, comp2, comp3, comp4};
parameter Real Tout = 38 + 273;
parameter Real pressure_drop = 0.5e5;
Real Hin, Hout, Q "heat exchanger duty";
port port1 annotation(Placement(visible = true, transformation(origin = {-86, 2}, extent = {{-10, -10}, {10, 10}}, rotation = 0), iconTransformation(origin = {-86, 2}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
port port2 annotation(Placement(visible = true, transformation(origin = {88, 2}, extent = {{-10, -10}, {10, 10}}, rotation = 0), iconTransformation(origin = {88, 2}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
equation
Hin = port1.enthalpy;
Hout = port2.enthalpy;
Tout = port2.temperature;
port2.pressure = port1.pressure - pressure_drop;
port2.moleflow = port1.moleflow;
port2.molefrac[:] = port1.molefrac[:];
Hin = Hout + Q;
annotation(Icon(graphics = {Rectangle(origin = {1, 1}, fillColor = {255, 255, 0}, fillPattern = FillPattern.HorizontalCylinder, extent = {{-89, 47}, {89, -47}}), Text(origin = {6, 0}, extent = {{-58, 30}, {58, -30}}, textString = "HX")}));
end HeatExchanger;
model reactor_Flash_test
UnitOperationsWOMS.MaterialStream materialStream1(Flowrate = 100, Pressure = 25e5, Temperature = 600, molefraction = {0.9, 0, 0.1, 0}, stepchange = true, unspecified = false) annotation(Placement(visible = true, transformation(origin = {-445, -30}, extent = {{-40, -40}, {40, 40}}, rotation = 0)));
UnitOperationsWOMS.CSTR cSTR1(Operation = true) annotation(Placement(visible = true, transformation(origin = {-310, -30}, extent = {{-40, -40}, {40, 40}}, rotation = 0)));
UnitOperationsWOMS.MaterialStream materialStream2(Flowrate = 100, Pressure = 25e5, Temperature = 400, molefraction = {0, 0.9, 0, 0.1}, stepchange = false, unspecified = false) annotation(Placement(visible = true, transformation(origin = {-447.5, 77.5}, extent = {{-47.5, -47.5}, {47.5, 47.5}}, rotation = 0)));
UnitOperationsWOMS.valve valve1(OutletPfixed = false) annotation(Placement(visible = true, transformation(origin = {-200, -60}, extent = {{-30, -30}, {30, 30}}, rotation = 0)));
UnitOperationsWOMS.MaterialStream materialStream3 annotation(Placement(visible = true, transformation(origin = {-90, -60}, extent = {{-30, -30}, {30, 30}}, rotation = 0)));
UnitOperationsWOMS.Flash flash1 annotation(Placement(visible = true, transformation(origin = {132.5, -62.5}, extent = {{-52.5, -52.5}, {52.5, 52.5}}, rotation = 0)));
UnitOperationsWOMS.valve valve2(OutletPfixed = true, OutletPressure = 1e5) annotation(Placement(visible = true, transformation(origin = {262.5, 47.5}, extent = {{-37.5, -37.5}, {37.5, 37.5}}, rotation = 0)));
UnitOperationsWOMS.valve valve3(OutletPfixed = true, OutletPressure = 1e5) annotation(Placement(visible = true, transformation(origin = {215, -155}, extent = {{-35, -35}, {35, 35}}, rotation = 0)));
UnitOperationsWOMS.MaterialStream materialStream4 annotation(Placement(visible = true, transformation(origin = {367.5, 47.5}, extent = {{-47.5, -47.5}, {47.5, 47.5}}, rotation = 0)));
UnitOperationsWOMS.MaterialStream materialStream5 annotation(Placement(visible = true, transformation(origin = {375, -155}, extent = {{-30, -30}, {30, 30}}, rotation = 0)));
HeatExchanger heatExchanger1 annotation(Placement(visible = true, transformation(origin = {-22.5, -57.5}, extent = {{-22.5, -22.5}, {22.5, 22.5}}, rotation = 0)));
MaterialStream materialStream6(zl(start = {0.442, 7e-17, 0.5547, 0.0033}), zv(start = {0.0062, 0.424, 0.0245, 0.5453})) annotation(Placement(visible = true, transformation(origin = {45, -60}, extent = {{-20, -20}, {20, 20}}, rotation = 0)));
equation
connect(valve3.port2, materialStream5.port1) annotation(Line(points = {{244, -154}, {278.5, -154}, {278.5, -155}, {350, -155}}));
connect(materialStream6.port2, flash1.port3) annotation(Line(points = {{60, -60}, {95, -60}, {95, -60}, {90, -60}}));
connect(heatExchanger1.port2, materialStream6.port1) annotation(Line(points = {{-5, -55}, {25, -55}, {25, -60}, {30, -60}}));
connect(flash1.port1, valve3.port1) annotation(Line(points = {{132.5, -101}, {111.75, -101}, {111.75, -156}, {186, -156}}));
connect(flash1.port2, valve2.port1) annotation(Line(points = {{172, -35}, {178.5, -35}, {178.5, 47}, {232, 47}}));
connect(materialStream3.port2, heatExchanger1.port1) annotation(Line(points = {{-65, -60}, {-42, -60}, {-42, -57}}));
connect(valve1.port2, materialStream3.port1) annotation(Line(points = {{-175, -59}, {-178, -59}, {-178, -60}, {-115, -60}}));
connect(cSTR1.port3, valve1.port1) annotation(Line(points = {{-279, -60}, {-252.5, -60}, {-252.5, -61}, {-225, -61}}));
connect(materialStream2.port2, cSTR1.port2) annotation(Line(points = {{-407, 78}, {-309, 78}, {-309, 3}}));
connect(materialStream1.port2, cSTR1.port1) annotation(Line(points = {{-411, -30}, {-344, -30}}));
connect(valve2.port2, materialStream4.port1) annotation(Line(points = {{293, 48}, {243.5, 48}, {243.5, 47.5}, {329, 47.5}}));
annotation(Diagram(coordinateSystem(extent = {{-500, -200}, {500, 200}}, grid = {5, 5})), Icon(coordinateSystem(extent = {{-500, -200}, {500, 200}}, grid = {5, 5})), version = "", uses);
end reactor_Flash_test;
model CompoundSeperator
port port1 annotation(Placement(visible = true, transformation(origin = {-88, 2}, extent = {{-10, -10}, {10, 10}}, rotation = 0), iconTransformation(origin = {-88, 2}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
port port2 annotation(Placement(visible = true, transformation(origin = {90, 70}, extent = {{-10, -10}, {10, 10}}, rotation = 0), iconTransformation(origin = {90, 70}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
port port3 annotation(Placement(visible = true, transformation(origin = {92, -78}, extent = {{-10, -10}, {10, 10}}, rotation = 0), iconTransformation(origin = {92, -78}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
parameter Real P = 3e5;
Real M;
initial equation
der(M) = 0;
equation
der(M) = port1.moleflow - port2.moleflow - port3.moleflow;
(port1.molefrac[1] + port1.molefrac[3]) * port1.moleflow = port2.moleflow;
port2.molefrac[1] = port1.molefrac[1] * port1.moleflow / port2.moleflow;
port2.molefrac[3] = 1 - port2.molefrac[1];
port2.molefrac[2] = 0;
port2.molefrac[4] = 0;
port3.molefrac[2] = port1.molefrac[2] * port1.moleflow / port3.moleflow;
port3.molefrac[4] = 1 - port3.molefrac[2];
port3.molefrac[1] = 0;
port3.molefrac[3] = 0;
port1.temperature = port2.temperature;
port1.temperature = port3.temperature;
port1.pressure = port2.pressure;
port1.pressure = port3.pressure;
//port1.pressure = P;
annotation(Icon(graphics = {Polygon(origin = {3.29, -3.99}, fillColor = {255, 170, 0}, fillPattern = FillPattern.CrossDiag, points = {{-91.2946, 7.98643}, {88.7054, 73.9864}, {90.7054, -74.0136}, {-91.2946, 7.98643}})}));
end CompoundSeperator;
model Distillation
parameter Chemsep_Database.Benzene comp1;
parameter Chemsep_Database.Toluene comp2;
parameter Chemsep_Database.General_Properties comp[2] = {comp1, comp2};
parameter Integer N_Trays = 20, NOC = 2, N_Feed = 10;
parameter Real M_eff[N_Trays, NOC] = fill(0.99, N_Trays, NOC);
parameter Real Pressure_drop = 2432, P_condenser = 101350, R = 8.314;
parameter Real A_active = 1, h_weir = 0.01, d_weir = 0.8, taul = 0.062, Tray_volume = 0.1;
parameter Real pi1 = -12.55, pi2 = 0.91;
Real y[N_Trays, NOC](start = fill(0.5, N_Trays, NOC)), x[N_Trays, NOC](start = fill(0.5, N_Trays, NOC)), y_eq[N_Trays, NOC], Tf[N_Trays];
Real V[N_Trays](each start = 70), L[N_Trays](each start = 100);
Real T[N_Trays](start = linspace(381, 369, N_Trays)), TC(start = 368), TB(start = 377), L0(start = 50), VNT, D, B, xc[NOC], xr[NOC], QC, QB;
Real Keq[N_Trays, NOC], Psat[N_Trays, NOC], PsatC[NOC], PsatB[NOC];
Real yNT[NOC], M[N_Trays](each start = 1), den[N_Trays, NOC];
Real hv[N_Trays, NOC], hl[N_Trays, NOC], hf[N_Trays, NOC], hv_B[NOC], hl_B[NOC], hl_C[NOC];
Real P[N_Trays], Ks[N_Trays];
Real dx[N_Trays, NOC], dM[N_Trays], dhl[N_Trays, NOC];
Real F[N_Trays](each start = 0), z[N_Trays, NOC](start = fill(0.5, N_Trays, NOC));
port port1 annotation(Placement(visible = true, transformation(origin = {-88, 2}, extent = {{-10, -10}, {10, 10}}, rotation = 0), iconTransformation(origin = {-88, 2}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
port port2 annotation(Placement(visible = true, transformation(origin = {92, 80}, extent = {{-10, -10}, {10, 10}}, rotation = 0), iconTransformation(origin = {92, 80}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
port port3 annotation(Placement(visible = true, transformation(origin = {94, -74}, extent = {{-10, -10}, {10, 10}}, rotation = 0), iconTransformation(origin = {94, -74}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
initial equation
for i in 1:N_Trays loop
//M[i] = M0[i];
der(M[i]) = 0;
//der(x[i,1]) = 0;
//dM[i] = 0;
dhl[i, 1] = 0;
//dx[i,1] = 0;
end for;
equation
// port1.pressure = P[N_Feed]; "should be automatic"
for i in 1:N_Trays loop
if i == N_Feed then
F[i] = port1.moleflow;
else
F[i] = 0;
end if;
Tf[i] = port1.temperature;
z[i, 1] = port1.molefrac[3];
z[i, 2] = port1.molefrac[1];
end for;
//functions required
for i in 1:NOC loop
for j in 1:N_Trays loop
Psat[j, i] = Functions.Psat(comp[i].VP, T[j]);
hv[j, i] = Functions.HVapId(comp[i].VapCp, comp[i].HOV, comp[i].Tc, T[j]);
hl[j, i] = Functions.HLiqId(comp[i].VapCp, comp[i].HOV, comp[i].Tc, T[j]);
hf[j, i] = Functions.HLiqId(comp[i].VapCp, comp[i].HOV, comp[i].Tc, Tf[j]);
den[j, i] = Functions.Density(comp[i].LiqDen, comp[i].Tc, T[j], P[j]);
end for;
hv_B[i] = Functions.HVapId(comp[i].VapCp, comp[i].HOV, comp[i].Tc, TB);
hl_B[i] = Functions.HLiqId(comp[i].VapCp, comp[i].HOV, comp[i].Tc, TB);
hl_C[i] = Functions.HLiqId(comp[i].VapCp, comp[i].HOV, comp[i].Tc, TC);
PsatC[i] = Functions.Psat(comp[i].VP, TC);
PsatB[i] = Functions.Psat(comp[i].VP, TB);
end for;
for i in 1:N_Trays loop
Ks[i] = V[i] * R * T[i] / (A_active * P[i] * 10 ^ (-3)) * (P[i] * 10 ^ (-3) / (R * T[i] * (sum(x[i, :] .* den[i, :]) - P[i] * 10 ^ (-3) / (R * T[i]))));
end for;
//defining state variables!
for i in 1:N_Trays loop
dx[i, :] = der(x[i, :]);
dM[i] = der(M[i]);
dhl[i, :] = der(hl[i, :]);
end for;
//tray mass balance
xr[:] = x[1, :];
yNT[:] = xr[:];
L[1] - VNT - B = 0;
//when time>0 then
for i in 1:N_Trays loop
M[i] = A_active * sum(x[i, :] .* den[i, :]) * (exp(pi1 * Ks[i] ^ pi2) * h_weir + 44300 * 10 ^ (-3) * (L[i] / (sum(x[i, :] .* den[i, :]) * d_weir * 1000 * 3600)) ^ 0.704);
end for;
//end when;
M[1] * dx[1, :] + x[1, :] * dM[1] = VNT .* yNT[:] + L[2] .* x[2, :] - V[1] .* y[1, :] - L[1] .* x[1, :] + F[1] .* z[1, :];
//M0[1] = Tray_volume * sum(x[1,:].*den[1,:]);
//L[1] = L0 + (M[1]-M0[1])/taul;
//M[1] = A_active * sum(x[1,:].*den[1,:])*(exp(pi1*Ks[1]^pi2)*h_weir + 44300*(L[1]/(sum(x[1,:].*den[1,:]) * 0.5* d_weir))^0.704);
for i in 2:N_Trays - 1 loop
dM[i] * x[i, :] + dx[i, :] * M[i] = V[i - 1] .* y[i - 1, :] + L[i + 1] .* x[i + 1, :] - V[i] .* y[i, :] - L[i] .* x[i, :] + F[i] .* z[i, :];
//L[i] = L0 + (M[i]-M0[i])/taul;
//M0[i] = Tray_volume * sum(x[i,:].*den[i,:]);
end for;
M[N_Trays] * dx[N_Trays, :] + x[N_Trays, :] * dM[N_Trays] = V[N_Trays - 1] .* y[N_Trays - 1, :] + L0 .* xc[:] - V[N_Trays] .* y[N_Trays, :] - L[N_Trays] .* x[N_Trays, :] + F[N_Trays] .* z[N_Trays, :];
//M0[N_Trays] = Tray_volume * sum(x[N_Trays,:].*den[N_Trays,:]);
//L[N_Trays] = L0 + (M[N_Trays]-M0[N_Trays])/taul;
//M[N_Trays] = A_active * sum(x[N_Trays,:].*den[N_Trays,:])*(exp(pi1*Ks[N_Trays]^pi2)*h_weir + 44300*(L[N_Trays]/(sum(x[N_Trays,:].*den[N_Trays,:]) * 0.5* d_weir))^0.704);
V[N_Trays] - L0 - D = 0;
y[N_Trays, :] = xc[:];
//energy balance
VNT * sum(yNT[:] .* hv_B[:]) - V[1] * sum(y[1, :] .* hv[1, :]) + L[2] * sum(x[2, :] .* hl[2, :]) - L[1] * sum(x[1, :] .* hl[1, :]) + F[1] * sum(z[1, :] .* hf[1, :]) = M[1] * x[1, :] * dhl[1, :] + M[1] * dx[1, :] * hl[1, :] + dM[1] * x[1, :] * hl[1, :];
for i in 2:N_Trays - 1 loop
V[i - 1] * sum(y[i - 1, :] .* hv[i - 1, :]) - V[i] * sum(y[i, :] .* hv[i, :]) + L[i + 1] * sum(x[i + 1, :] .* hl[i + 1, :]) - L[i] * sum(x[i, :] .* hl[i, :]) + F[i] * sum(z[i, :] .* hf[i, :]) = M[i] * x[i, :] * dhl[i, :] + M[i] * dx[i, :] * hl[i, :] + dM[i] * x[i, :] * hl[i, :];
end for;
V[N_Trays - 1] * sum(y[N_Trays - 1, :] .* hv[N_Trays - 1, :]) - V[N_Trays] * sum(y[N_Trays, :] .* hv[N_Trays, :]) + L0 * sum(xc[:] .* hl_C[:]) - L[N_Trays] * sum(x[N_Trays, :] .* hl[N_Trays, :]) + F[N_Trays] * sum(z[N_Trays, :] .* hf[N_Trays, :]) = dM[N_Trays] * x[N_Trays, :] * hl[N_Trays, :] + M[N_Trays] * dx[N_Trays, :] * hl[N_Trays, :] + M[N_Trays] * x[N_Trays, :] * dhl[N_Trays, :];
V[N_Trays] * sum(y[N_Trays, :] .* hv[N_Trays, :]) - (L0 + D) * sum(xc[:] .* hl_C[:]) = QC;
L[1] * sum(x[1, :] .* hl[1, :]) - B * sum(xr[:] .* hl_B[:]) - VNT * sum(xr[:] .* hv_B[:]) = QB;
//pressure
for i in 1:N_Trays loop
P[i] = P_condenser + (N_Trays - i + 1) * Pressure_drop;
end for;
//Equilibrium
for i in 1:N_Trays loop
Keq[i, :] = Psat[i, :] ./ P[i];
y_eq[i, :] = Keq[i, :] .* x[i, :];
M_eff[i, :] = (y[i, :] - y[i - 1, :]) ./ (y_eq[i, :] - y[i - 1, :]);
sum(x[i, :]) = 1;
sum(y_eq[i, :]) = 1;
end for;
sum(y[N_Trays, :] .* PsatC[:] / P_condenser) = 1;
//sum(xc[:]) =1
sum(x[1, :] .* (P[1] + Pressure_drop) ./ PsatB[:]) = 1;
//sum(yNT[:]) =1;
D = 0.5 * L0;
B = 61.1;
port2.moleflow = D;
port2.molefrac = {xc[2], 0, xc[1], 0};
port2.temperature = TC;
port2.pressure = P_condenser;
port3.moleflow = B;
port3.molefrac = {xr[2], 0, xr[1], 0};
port3.temperature = TB;
port3.pressure = P_condenser + Pressure_drop * (N_Trays + 1);
annotation(Icon(graphics = {Rectangle(origin = {-2, -1}, fillColor = {0, 85, 127}, fillPattern = FillPattern.VerticalCylinder, extent = {{-94, 95}, {94, -95}})}));
end Distillation;
model reactor_Flash_Seperator
unitoperations.MaterialStream materialStream1(Flowrate = 100, Pressure = 25e5, Temperature = 600, molefraction = {0.9, 0, 0.1, 0}, stepchange = false, unspecified = false) annotation(Placement(visible = true, transformation(origin = {-445, -30}, extent = {{-40, -40}, {40, 40}}, rotation = 0)));
unitoperations.CSTR cSTR1(Operation = true) annotation(Placement(visible = true, transformation(origin = {-310, -30}, extent = {{-40, -40}, {40, 40}}, rotation = 0)));
unitoperations.MaterialStream materialStream2(Flowrate = 140, Pressure = 25e5, Temperature = 400, molefraction = {0, 0.9, 0, 0.1}, stepchange = false, unspecified = false) annotation(Placement(visible = true, transformation(origin = {-447.5, 77.5}, extent = {{-47.5, -47.5}, {47.5, 47.5}}, rotation = 0)));
unitoperations.valve valve1(Control = false, OutletPfixed = false, valveCv = 0.4) annotation(Placement(visible = true, transformation(origin = {-200, -60}, extent = {{-30, -30}, {30, 30}}, rotation = 0)));
unitoperations.MaterialStream materialStream3 annotation(Placement(visible = true, transformation(origin = {-90, -60}, extent = {{-30, -30}, {30, 30}}, rotation = 0)));
unitoperations.Flash flash1 annotation(Placement(visible = true, transformation(origin = {132.5, -62.5}, extent = {{-52.5, -52.5}, {52.5, 52.5}}, rotation = 0)));
unitoperations.valve valve2(Control = false, OutletPfixed = true, OutletPressure = 1e5) annotation(Placement(visible = true, transformation(origin = {262.5, 47.5}, extent = {{-37.5, -37.5}, {37.5, 37.5}}, rotation = 0)));
unitoperations.MaterialStream materialStream4 annotation(Placement(visible = true, transformation(origin = {367.5, 47.5}, extent = {{-47.5, -47.5}, {47.5, 47.5}}, rotation = 0)));
unitoperations.MaterialStream materialStream5 annotation(Placement(visible = true, transformation(origin = {212.5, -157.5}, extent = {{-32.5, -32.5}, {32.5, 32.5}}, rotation = 0)));
HeatExchanger heatExchanger1 annotation(Placement(visible = true, transformation(origin = {-22.5, -57.5}, extent = {{-22.5, -22.5}, {22.5, 22.5}}, rotation = 0)));
MaterialStream materialStream6(zl(start = {0.7, 1e-16, 0.3, 0.001}), zv(start = {0.01, 0.75, 0.0145, 0.23})) annotation(Placement(visible = true, transformation(origin = {45, -60}, extent = {{-20, -20}, {20, 20}}, rotation = 0)));
unitoperations.CompoundSeperator compoundSeperator1 annotation(Placement(visible = true, transformation(origin = {315, -160}, extent = {{-35, -35}, {35, 35}}, rotation = 0)));
unitoperations.MaterialStream materialStream7 annotation(Placement(visible = true, transformation(origin = {502.5, -47.5}, extent = {{-27.5, -27.5}, {27.5, 27.5}}, rotation = 0)));
unitoperations.MaterialStream materialStream8 annotation(Placement(visible = true, transformation(origin = {530, -180}, extent = {{-30, -30}, {30, 30}}, rotation = 0)));
unitoperations.valve valve4(Control = false, OutletPfixed = true, OutletPressure = 1e5) annotation(Placement(visible = true, transformation(origin = {435, -135}, extent = {{-30, -30}, {30, 30}}, rotation = 0)));
unitoperations.valve valve5(Control = false, OutletPfixed = true, OutletPressure = 1e5) annotation(Placement(visible = true, transformation(origin = {437.5, -182.5}, extent = {{-27.5, -27.5}, {27.5, 27.5}}, rotation = 0)));
equation
connect(valve5.port2, materialStream8.port1) annotation(Line(points = {{460, -182}, {500, -182}, {500, -180}, {505, -180}}));
connect(compoundSeperator1.port3, valve5.port1) annotation(Line(points = {{347, -187}, {360.875, -187}, {360.875, -182}, {387.5, -182}, {387.5, -183}, {415, -183}}));
connect(valve4.port2, materialStream7.port1) annotation(Line(points = {{460, -134}, {460, -47.5}, {480, -47.5}}));
connect(valve4.port1, compoundSeperator1.port2) annotation(Line(points = {{410, -136}, {410, -135.5}, {346.5, -135.5}}));
connect(materialStream5.port2, compoundSeperator1.port1) annotation(Line(points = {{240, -157}, {270.25, -157}, {270.25, -159}, {284, -159}}));
connect(flash1.port1, materialStream5.port1) annotation(Line(points = {{135, -100}, {135, -157.5}, {186, -157.5}}));
connect(materialStream6.port2, flash1.port3) annotation(Line(points = {{60, -60}, {95, -60}, {95, -60}, {90, -60}}));
connect(heatExchanger1.port2, materialStream6.port1) annotation(Line(points = {{-5, -55}, {25, -55}, {25, -60}, {30, -60}}));
connect(flash1.port2, valve2.port1) annotation(Line(points = {{172, -35}, {178.5, -35}, {178.5, 47}, {232, 47}}));
connect(materialStream3.port2, heatExchanger1.port1) annotation(Line(points = {{-65, -60}, {-42, -60}, {-42, -57}}));
connect(valve1.port2, materialStream3.port1) annotation(Line(points = {{-175, -59}, {-178, -59}, {-178, -60}, {-115, -60}}));
connect(cSTR1.port3, valve1.port1) annotation(Line(points = {{-279, -60}, {-252.5, -60}, {-252.5, -61}, {-225, -61}}));
connect(materialStream2.port2, cSTR1.port2) annotation(Line(points = {{-407, 78}, {-309, 78}, {-309, 3}}));
connect(materialStream1.port2, cSTR1.port1) annotation(Line(points = {{-411, -30}, {-344, -30}}));
connect(valve2.port2, materialStream4.port1) annotation(Line(points = {{293, 48}, {243.5, 48}, {243.5, 47.5}, {329, 47.5}}));
annotation(Diagram(coordinateSystem(extent = {{-500, -200}, {600, 200}}, grid = {5, 5})), Icon(coordinateSystem(extent = {{-500, -200}, {600, 200}}, grid = {5, 5})), version = "", uses);
end reactor_Flash_Seperator;
model separator_test
MaterialStream materialStream1(Flowrate = 100, Pressure = 5e5, Temperature = 310, molefraction = {0.5, 0.001, 0.4, 0.099}, stepchange = false, unspecified = false) annotation(Placement(visible = true, transformation(origin = {-68, 0}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
CompoundSeperator compoundSeperator1 annotation(Placement(visible = true, transformation(origin = {-26, 0}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
MaterialStream materialStream2 annotation(Placement(visible = true, transformation(origin = {54, 24}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
MaterialStream materialStream3 annotation(Placement(visible = true, transformation(origin = {16, -18}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
valve valve1(Control = false, OutletPfixed = true, OutletPressure = 2e5) annotation(Placement(visible = true, transformation(origin = {10, 24}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
equation
connect(valve1.port2, materialStream2.port1) annotation(Line(points = {{18, 24}, {44, 24}, {44, 24}, {46, 24}}));
connect(compoundSeperator1.port2, valve1.port1) annotation(Line(points = {{-16, 8}, {-14, 8}, {-14, 22}, {2, 22}, {2, 24}}));
connect(materialStream1.port2, compoundSeperator1.port1) annotation(Line(points = {{-60, 0}, {-34, 0}, {-34, 0}, {-34, 0}}));
connect(compoundSeperator1.port3, materialStream3.port1) annotation(Line(points = {{-16, -8}, {-16, -8}, {-16, -18}, {8, -18}, {8, -18}}));
end separator_test;
model Distillationtest
MaterialStream materialStream1(Flowrate = 98, Pressure = 1e5, Temperature = 365, molefraction = {0.45, 0, 0.55, 0}, unspecified = false) annotation(Placement(visible = true, transformation(origin = {-70, 4}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
MaterialStream materialStream3 annotation(Placement(visible = true, transformation(origin = {54, -34}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
MaterialStream materialStream2 annotation(Placement(visible = true, transformation(origin = {41, 27}, extent = {{-11, -11}, {11, 11}}, rotation = 0)));
Distillation distillation1 annotation(Placement(visible = true, transformation(origin = {-14, 6}, extent = {{-22, -22}, {22, 22}}, rotation = 0)));
equation
connect(materialStream1.port2, distillation1.port1) annotation(Line(points = {{-62, 4}, {-34, 4}, {-34, 6}, {-34, 6}}));
connect(distillation1.port2, materialStream2.port1) annotation(Line(points = {{6, 24}, {30, 24}, {30, 28}, {32, 28}}));
connect(materialStream3.port1, distillation1.port3) annotation(Line(points = {{46, -34}, {8, -34}, {8, -10}, {6, -10}}));
end Distillationtest;
model flowsheet
unitoperations.MaterialStream materialStream1(Flowrate = 100, Pressure = 25e5, Temperature = 600, molefraction = {0.9, 0, 0.1, 0}, step_value = 2, stepchange = true, stepchangetime = 0.01, unspecified = false) annotation(Placement(visible = true, transformation(origin = {-445, -30}, extent = {{-40, -40}, {40, 40}}, rotation = 0)));
unitoperations.CSTR cSTR1(Operation = true) annotation(Placement(visible = true, transformation(origin = {-310, -30}, extent = {{-40, -40}, {40, 40}}, rotation = 0)));
unitoperations.MaterialStream materialStream2(Flowrate = 140, Pressure = 25e5, Temperature = 400, molefraction = {0, 0.9, 0, 0.1}, stepchange = false, unspecified = false) annotation(Placement(visible = true, transformation(origin = {-447.5, 77.5}, extent = {{-47.5, -47.5}, {47.5, 47.5}}, rotation = 0)));
unitoperations.valve valve1(Control = false, OutletPfixed = false, valveCv = 0.4) annotation(Placement(visible = true, transformation(origin = {-200, -60}, extent = {{-30, -30}, {30, 30}}, rotation = 0)));
unitoperations.MaterialStream materialStream3 annotation(Placement(visible = true, transformation(origin = {-90, -60}, extent = {{-30, -30}, {30, 30}}, rotation = 0)));
unitoperations.Flash flash1 annotation(Placement(visible = true, transformation(origin = {132.5, -62.5}, extent = {{-52.5, -52.5}, {52.5, 52.5}}, rotation = 0)));
unitoperations.valve valve2(Control = false, OutletPfixed = true, OutletPressure = 1e5) annotation(Placement(visible = true, transformation(origin = {262.5, 47.5}, extent = {{-37.5, -37.5}, {37.5, 37.5}}, rotation = 0)));
unitoperations.MaterialStream materialStream4 annotation(Placement(visible = true, transformation(origin = {367.5, 47.5}, extent = {{-47.5, -47.5}, {47.5, 47.5}}, rotation = 0)));
unitoperations.MaterialStream materialStream5 annotation(Placement(visible = true, transformation(origin = {212.5, -157.5}, extent = {{-32.5, -32.5}, {32.5, 32.5}}, rotation = 0)));
HeatExchanger heatExchanger1 annotation(Placement(visible = true, transformation(origin = {-22.5, -57.5}, extent = {{-22.5, -22.5}, {22.5, 22.5}}, rotation = 0)));
MaterialStream materialStream6(zl(start = {0.7, 1e-16, 0.3, 0.001}), zv(start = {0.01, 0.75, 0.0145, 0.23})) annotation(Placement(visible = true, transformation(origin = {45, -60}, extent = {{-20, -20}, {20, 20}}, rotation = 0)));
unitoperations.CompoundSeperator compoundSeperator1 annotation(Placement(visible = true, transformation(origin = {315, -160}, extent = {{-35, -35}, {35, 35}}, rotation = 0)));
unitoperations.MaterialStream materialStream7 annotation(Placement(visible = true, transformation(origin = {502.5, -47.5}, extent = {{-27.5, -27.5}, {27.5, 27.5}}, rotation = 0)));
unitoperations.MaterialStream materialStream8 annotation(Placement(visible = true, transformation(origin = {530, -180}, extent = {{-30, -30}, {30, 30}}, rotation = 0)));
unitoperations.valve valve4(Control = false, OutletPfixed = false, OutletPressure = 1e5) annotation(Placement(visible = true, transformation(origin = {435, -135}, extent = {{-30, -30}, {30, 30}}, rotation = 0)));
unitoperations.valve valve5(Control = false, OutletPfixed = true, OutletPressure = 1e5) annotation(Placement(visible = true, transformation(origin = {437.5, -182.5}, extent = {{-27.5, -27.5}, {27.5, 27.5}}, rotation = 0)));
Distillation distillation1 annotation(Placement(visible = true, transformation(origin = {600, -40}, extent = {{-40, -40}, {40, 40}}, rotation = 0)));
MaterialStream materialStream9 annotation(Placement(visible = true, transformation(origin = {712.5, 7.5}, extent = {{-27.5, -27.5}, {27.5, 27.5}}, rotation = 0)));
MaterialStream materialStream10(Fl(start = 0), Fv(start = 50),Tbf(start = 392), Tdf(start = 395),zl(start = {0.9, 0, 0.1, 0}), zv(start = {0.86, 0, 0.14, 0})) annotation(Placement(visible = true, transformation(origin = {715, -85}, extent = {{-30, -30}, {30, 30}}, rotation = 0)));
equation
connect(distillation1.port2, materialStream9.port1) annotation(Line(points = {{635, -10}, {650, -10}, {650, 10}, {690, 10}, {690, 5}}));
connect(distillation1.port3, materialStream10.port1) annotation(Line(points = {{640, -70}, {660, -70}, {660, -85}, {690, -85}, {690, -85}}));
connect(materialStream7.port2, distillation1.port1) annotation(Line(points = {{525, -45}, {565, -45}, {565, -40}, {565, -40}}));
connect(valve5.port2, materialStream8.port1) annotation(Line(points = {{460, -182}, {500, -182}, {500, -180}, {505, -180}}));
connect(compoundSeperator1.port3, valve5.port1) annotation(Line(points = {{347, -187}, {360.875, -187}, {360.875, -182}, {387.5, -182}, {387.5, -183}, {415, -183}}));
connect(valve4.port2, materialStream7.port1) annotation(Line(points = {{460, -134}, {460, -47.5}, {480, -47.5}}));
connect(valve4.port1, compoundSeperator1.port2) annotation(Line(points = {{410, -136}, {410, -135.5}, {346.5, -135.5}}));
connect(materialStream5.port2, compoundSeperator1.port1) annotation(Line(points = {{240, -157}, {270.25, -157}, {270.25, -159}, {284, -159}}));
connect(flash1.port1, materialStream5.port1) annotation(Line(points = {{135, -100}, {135, -157.5}, {186, -157.5}}));
connect(materialStream6.port2, flash1.port3) annotation(Line(points = {{60, -60}, {95, -60}, {95, -60}, {90, -60}}));
connect(heatExchanger1.port2, materialStream6.port1) annotation(Line(points = {{-5, -55}, {25, -55}, {25, -60}, {30, -60}}));
connect(flash1.port2, valve2.port1) annotation(Line(points = {{172, -35}, {178.5, -35}, {178.5, 47}, {232, 47}}));
connect(materialStream3.port2, heatExchanger1.port1) annotation(Line(points = {{-65, -60}, {-42, -60}, {-42, -57}}));
connect(valve1.port2, materialStream3.port1) annotation(Line(points = {{-175, -59}, {-178, -59}, {-178, -60}, {-115, -60}}));
connect(cSTR1.port3, valve1.port1) annotation(Line(points = {{-279, -60}, {-252.5, -60}, {-252.5, -61}, {-225, -61}}));
connect(materialStream2.port2, cSTR1.port2) annotation(Line(points = {{-407, 78}, {-309, 78}, {-309, 3}}));
connect(materialStream1.port2, cSTR1.port1) annotation(Line(points = {{-411, -30}, {-344, -30}}));
connect(valve2.port2, materialStream4.port1) annotation(Line(points = {{293, 48}, {243.5, 48}, {243.5, 47.5}, {329, 47.5}}));
annotation(Diagram(coordinateSystem(extent = {{-500, -200}, {600, 200}}, grid = {5, 5})), Icon(coordinateSystem(extent = {{-500, -200}, {600, 200}}, grid = {5, 5})), version = "", uses);
end flowsheet;
model Distillation1
parameter Chemsep_Database.Benzene comp1;
parameter Chemsep_Database.Toluene comp2;
parameter Chemsep_Database.General_Properties comp[2] = {comp1, comp2};
parameter Integer N_Trays = 20, NOC = 2, N_Feed = 10;
parameter Real M_eff[N_Trays, NOC] = fill(0.99, N_Trays, NOC);
parameter Real Pressure_drop = 2432, P_condenser = 101350, R = 8.314;
parameter Real A_active = 1, h_weir = 0.01, d_weir = 0.8, taul = 0.062, Tray_volume = 0.1;
parameter Real pi1 = -12.55, pi2 = 0.91;
Real y[N_Trays, NOC](start = fill(0.5, N_Trays, NOC)), x[N_Trays, NOC](start = fill(0.5, N_Trays, NOC)), y_eq[N_Trays, NOC], Tf[N_Trays];
Real V[N_Trays](each start = 70), L[N_Trays](each start = 100);
Real T[N_Trays](start = linspace(381, 369, N_Trays)), TC(start = 368), TB(start = 377), L0(start = 50), VNT, D, B, xc[NOC], xr[NOC], QC, QB;
Real Keq[N_Trays, NOC], Psat[N_Trays, NOC], PsatC[NOC], PsatB[NOC];
Real yNT[NOC], M[N_Trays](each start = 1), den[N_Trays, NOC];
Real hv[N_Trays, NOC], hl[N_Trays, NOC], hf[N_Trays, NOC], hv_B[NOC], hl_B[NOC], hl_C[NOC];
Real P[N_Trays], Ks[N_Trays];
Real dx[N_Trays, NOC], dM[N_Trays], dhl[N_Trays, NOC];
Real F[N_Trays](each start = 0), z[N_Trays, NOC](start = fill(0.5, N_Trays, NOC));
port port1 annotation(Placement(visible = true, transformation(origin = {-88, 2}, extent = {{-10, -10}, {10, 10}}, rotation = 0), iconTransformation(origin = {-88, 2}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
port port2 annotation(Placement(visible = true, transformation(origin = {92, 80}, extent = {{-10, -10}, {10, 10}}, rotation = 0), iconTransformation(origin = {92, 80}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
port port3 annotation(Placement(visible = true, transformation(origin = {94, -74}, extent = {{-10, -10}, {10, 10}}, rotation = 0), iconTransformation(origin = {94, -74}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
initial equation
for i in 1:N_Trays loop
//M[i] = M0[i];
der(M[i]) = 0;
//der(x[i,1]) = 0;
//dM[i] = 0;
dhl[i, 1] = 0;
//dx[i,1] = 0;
end for;
equation
// port1.pressure = P[N_Feed];
for i in 1:N_Trays loop
if i == N_Feed then
F[i] = port1.moleflow;
else
F[i] = 0;
end if;
Tf[i] = port1.temperature;
z[i, 1] = port1.molefrac[3];
z[i, 2] = port1.molefrac[1];
end for;
//functions required
for i in 1:NOC loop
for j in 1:N_Trays loop
Psat[j, i] = Functions.Psat(comp[i].VP, T[j]);
hv[j, i] = Functions.HVapId(comp[i].VapCp, comp[i].HOV, comp[i].Tc, T[j]);
hl[j, i] = Functions.HLiqId(comp[i].VapCp, comp[i].HOV, comp[i].Tc, T[j]);
hf[j, i] = Functions.HLiqId(comp[i].VapCp, comp[i].HOV, comp[i].Tc, Tf[j]);
den[j, i] = Functions.Density(comp[i].LiqDen, comp[i].Tc, T[j], P[j]);
end for;
hv_B[i] = Functions.HVapId(comp[i].VapCp, comp[i].HOV, comp[i].Tc, TB);
hl_B[i] = Functions.HLiqId(comp[i].VapCp, comp[i].HOV, comp[i].Tc, TB);
hl_C[i] = Functions.HLiqId(comp[i].VapCp, comp[i].HOV, comp[i].Tc, TC);
PsatC[i] = Functions.Psat(comp[i].VP, TC);
PsatB[i] = Functions.Psat(comp[i].VP, TB);
end for;
for i in 1:N_Trays loop
Ks[i] = V[i] * R * T[i] / (A_active * P[i] * 10 ^ (-3)) * (P[i] * 10 ^ (-3) / (R * T[i] * (sum(x[i, :] .* den[i, :]) - P[i] * 10 ^ (-3) / (R * T[i]))));
end for;
//defining state variables!
for i in 1:N_Trays loop
dx[i, :] = der(x[i, :]);
dM[i] = der(M[i]);
dhl[i, :] = der(hl[i, :]);
end for;
//tray mass balance
xr[:] = x[1, :];
yNT[:] = xr[:];
L[1] - VNT - B = 0;
//when time>0 then
for i in 1:N_Trays loop
M[i] = A_active * sum(x[i, :] .* den[i, :]) * (exp(pi1 * Ks[i] ^ pi2) * h_weir + 44300 * 10 ^ (-3) * (L[i] / (sum(x[i, :] .* den[i, :]) * d_weir * 1000 * 3600)) ^ 0.704);
end for;
//end when;
M[1] * dx[1, :] + x[1, :] * dM[1] = VNT .* yNT[:] + L[2] .* x[2, :] - V[1] .* y[1, :] - L[1] .* x[1, :] + F[1] .* z[1, :];
//M0[1] = Tray_volume * sum(x[1,:].*den[1,:]);
//L[1] = L0 + (M[1]-M0[1])/taul;
//M[1] = A_active * sum(x[1,:].*den[1,:])*(exp(pi1*Ks[1]^pi2)*h_weir + 44300*(L[1]/(sum(x[1,:].*den[1,:]) * 0.5* d_weir))^0.704);
for i in 2:N_Trays - 1 loop
dM[i] * x[i, :] + dx[i, :] * M[i] = V[i - 1] .* y[i - 1, :] + L[i + 1] .* x[i + 1, :] - V[i] .* y[i, :] - L[i] .* x[i, :] + F[i] .* z[i, :];
//L[i] = L0 + (M[i]-M0[i])/taul;
//M0[i] = Tray_volume * sum(x[i,:].*den[i,:]);
end for;
M[N_Trays] * dx[N_Trays, :] + x[N_Trays, :] * dM[N_Trays] = V[N_Trays - 1] .* y[N_Trays - 1, :] + L0 .* xc[:] - V[N_Trays] .* y[N_Trays, :] - L[N_Trays] .* x[N_Trays, :] + F[N_Trays] .* z[N_Trays, :];
//M0[N_Trays] = Tray_volume * sum(x[N_Trays,:].*den[N_Trays,:]);
//L[N_Trays] = L0 + (M[N_Trays]-M0[N_Trays])/taul;
//M[N_Trays] = A_active * sum(x[N_Trays,:].*den[N_Trays,:])*(exp(pi1*Ks[N_Trays]^pi2)*h_weir + 44300*(L[N_Trays]/(sum(x[N_Trays,:].*den[N_Trays,:]) * 0.5* d_weir))^0.704);
V[N_Trays] - L0 - D = 0;
y[N_Trays, :] = xc[:];
//energy balance
VNT * sum(yNT[:] .* hv_B[:]) - V[1] * sum(y[1, :] .* hv[1, :]) + L[2] * sum(x[2, :] .* hl[2, :]) - L[1] * sum(x[1, :] .* hl[1, :]) + F[1] * sum(z[1, :] .* hf[1, :]) = M[1] * x[1, :] * dhl[1, :] + M[1] * dx[1, :] * hl[1, :] + dM[1] * x[1, :] * hl[1, :];
for i in 2:N_Trays - 1 loop
V[i - 1] * sum(y[i - 1, :] .* hv[i - 1, :]) - V[i] * sum(y[i, :] .* hv[i, :]) + L[i + 1] * sum(x[i + 1, :] .* hl[i + 1, :]) - L[i] * sum(x[i, :] .* hl[i, :]) + F[i] * sum(z[i, :] .* hf[i, :]) = M[i] * x[i, :] * dhl[i, :] + M[i] * dx[i, :] * hl[i, :] + dM[i] * x[i, :] * hl[i, :];
end for;
V[N_Trays - 1] * sum(y[N_Trays - 1, :] .* hv[N_Trays - 1, :]) - V[N_Trays] * sum(y[N_Trays, :] .* hv[N_Trays, :]) + L0 * sum(xc[:] .* hl_C[:]) - L[N_Trays] * sum(x[N_Trays, :] .* hl[N_Trays, :]) + F[N_Trays] * sum(z[N_Trays, :] .* hf[N_Trays, :]) = dM[N_Trays] * x[N_Trays, :] * hl[N_Trays, :] + M[N_Trays] * dx[N_Trays, :] * hl[N_Trays, :] + M[N_Trays] * x[N_Trays, :] * dhl[N_Trays, :];
V[N_Trays] * sum(y[N_Trays, :] .* hv[N_Trays, :]) - (L0 + D) * sum(xc[:] .* hl_C[:]) = QC;
L[1] * sum(x[1, :] .* hl[1, :]) - B * sum(xr[:] .* hl_B[:]) - VNT * sum(xr[:] .* hv_B[:]) = QB;
//pressure
for i in 1:N_Trays loop
P[i] = P_condenser + (N_Trays - i + 1) * Pressure_drop;
end for;
//Equilibrium
for i in 1:N_Trays loop
Keq[i, :] = Psat[i, :] ./ P[i];
y_eq[i, :] = Keq[i, :] .* x[i, :];
M_eff[i, :] = (y[i, :] - y[i - 1, :]) ./ (y_eq[i, :] - y[i - 1, :]);
sum(x[i, :]) = 1;
sum(y_eq[i, :]) = 1;
end for;
sum(y[N_Trays, :] .* PsatC[:] / P_condenser) = 1;
//sum(xc[:]) =1
sum(x[1, :] .* (P[1] + Pressure_drop) ./ PsatB[:]) = 1;
//sum(yNT[:]) =1;
D = 0.5 * L0;
B = 61.1;
port2.moleflow = D;
port2.molefrac = {xc[2], 0, xc[1], 0};
port2.temperature = TC;
port2.pressure = P_condenser;
port3.moleflow = B;
port3.molefrac = {xr[2], 0, xr[1], 0};
port3.temperature = TB;
port3.pressure = P_condenser + Pressure_drop * (N_Trays + 1);
/*
Real liquidmoleflow, vapormoleflow;
Real liquidmolefrac[NOC], vapormolefrac[NOC];
Real enthalpy; */
port2.liquidmoleflow = 0;
port2.vapormoleflow = 0;
port2.liquidmolefrac = zeros(4);
port2.vapormolefrac = zeros(4);
port2.enthalpy = 0;
port3.liquidmoleflow = 0;
port3.vapormoleflow = 0;
port3.liquidmolefrac = zeros(4);
port3.vapormolefrac = zeros(4);
port3.enthalpy = 0;
annotation(Icon(graphics = {Rectangle(origin = {-2, -1}, fillColor = {0, 85, 127}, fillPattern = FillPattern.VerticalCylinder, extent = {{-94, 95}, {94, -95}})}));
end Distillation1;
model flowsheet1
unitoperations.MaterialStream materialStream1(Flowrate = 100, Pressure = 25e5, Temperature = 600, molefraction = {0.9, 0, 0.1, 0}, step_value = 2, stepchange = true, stepchangetime = 0.01, unspecified = false) annotation(Placement(visible = true, transformation(origin = {-445, -30}, extent = {{-40, -40}, {40, 40}}, rotation = 0)));
unitoperations.CSTR cSTR1(Operation = true) annotation(Placement(visible = true, transformation(origin = {-310, -30}, extent = {{-40, -40}, {40, 40}}, rotation = 0)));
unitoperations.MaterialStream materialStream2(Flowrate = 140, Pressure = 25e5, Temperature = 400, molefraction = {0, 0.9, 0, 0.1}, stepchange = false, unspecified = false) annotation(Placement(visible = true, transformation(origin = {-447.5, 77.5}, extent = {{-47.5, -47.5}, {47.5, 47.5}}, rotation = 0)));
unitoperations.valve valve1(Control = false, OutletPfixed = false, valveCv = 0.4) annotation(Placement(visible = true, transformation(origin = {-200, -60}, extent = {{-30, -30}, {30, 30}}, rotation = 0)));
unitoperations.MaterialStream materialStream3 annotation(Placement(visible = true, transformation(origin = {-90, -60}, extent = {{-30, -30}, {30, 30}}, rotation = 0)));
unitoperations.Flash flash1 annotation(Placement(visible = true, transformation(origin = {132.5, -62.5}, extent = {{-52.5, -52.5}, {52.5, 52.5}}, rotation = 0)));
unitoperations.valve valve2(Control = false, OutletPfixed = true, OutletPressure = 1e5) annotation(Placement(visible = true, transformation(origin = {262.5, 47.5}, extent = {{-37.5, -37.5}, {37.5, 37.5}}, rotation = 0)));
unitoperations.MaterialStream materialStream4 annotation(Placement(visible = true, transformation(origin = {367.5, 47.5}, extent = {{-47.5, -47.5}, {47.5, 47.5}}, rotation = 0)));
unitoperations.MaterialStream materialStream5 annotation(Placement(visible = true, transformation(origin = {212.5, -157.5}, extent = {{-32.5, -32.5}, {32.5, 32.5}}, rotation = 0)));
HeatExchanger heatExchanger1 annotation(Placement(visible = true, transformation(origin = {-22.5, -57.5}, extent = {{-22.5, -22.5}, {22.5, 22.5}}, rotation = 0)));
MaterialStream materialStream6(zl(start = {0.7, 1e-16, 0.3, 0.001}), zv(start = {0.01, 0.75, 0.0145, 0.23})) annotation(Placement(visible = true, transformation(origin = {45, -60}, extent = {{-20, -20}, {20, 20}}, rotation = 0)));
unitoperations.CompoundSeperator compoundSeperator1 annotation(Placement(visible = true, transformation(origin = {315, -160}, extent = {{-35, -35}, {35, 35}}, rotation = 0)));
unitoperations.MaterialStream materialStream7 annotation(Placement(visible = true, transformation(origin = {502.5, -47.5}, extent = {{-27.5, -27.5}, {27.5, 27.5}}, rotation = 0)));
unitoperations.MaterialStream materialStream8 annotation(Placement(visible = true, transformation(origin = {530, -180}, extent = {{-30, -30}, {30, 30}}, rotation = 0)));
unitoperations.valve valve4(Control = false, OutletPfixed = false, OutletPressure = 1e5) annotation(Placement(visible = true, transformation(origin = {435, -135}, extent = {{-30, -30}, {30, 30}}, rotation = 0)));
unitoperations.valve valve5(Control = false, OutletPfixed = true, OutletPressure = 1e5) annotation(Placement(visible = true, transformation(origin = {437.5, -182.5}, extent = {{-27.5, -27.5}, {27.5, 27.5}}, rotation = 0)));
Distillation1 distillation11 annotation(Placement(visible = true, transformation(origin = {630, -55}, extent = {{-35, -35}, {35, 35}}, rotation = 0)));
equation
connect(materialStream7.port2, distillation11.port1) annotation(Line(points = {{525, -45}, {600, -45}, {600, -55}, {600, -55}}));
connect(valve5.port2, materialStream8.port1) annotation(Line(points = {{460, -182}, {500, -182}, {500, -180}, {505, -180}}));
connect(compoundSeperator1.port3, valve5.port1) annotation(Line(points = {{347, -187}, {360.875, -187}, {360.875, -182}, {387.5, -182}, {387.5, -183}, {415, -183}}));
connect(valve4.port2, materialStream7.port1) annotation(Line(points = {{460, -134}, {460, -47.5}, {480, -47.5}}));
connect(valve4.port1, compoundSeperator1.port2) annotation(Line(points = {{410, -136}, {410, -135.5}, {346.5, -135.5}}));
connect(materialStream5.port2, compoundSeperator1.port1) annotation(Line(points = {{240, -157}, {270.25, -157}, {270.25, -159}, {284, -159}}));
connect(flash1.port1, materialStream5.port1) annotation(Line(points = {{135, -100}, {135, -157.5}, {186, -157.5}}));
connect(materialStream6.port2, flash1.port3) annotation(Line(points = {{60, -60}, {95, -60}, {95, -60}, {90, -60}}));
connect(heatExchanger1.port2, materialStream6.port1) annotation(Line(points = {{-5, -55}, {25, -55}, {25, -60}, {30, -60}}));
connect(flash1.port2, valve2.port1) annotation(Line(points = {{172, -35}, {178.5, -35}, {178.5, 47}, {232, 47}}));
connect(materialStream3.port2, heatExchanger1.port1) annotation(Line(points = {{-65, -60}, {-42, -60}, {-42, -57}}));
connect(valve1.port2, materialStream3.port1) annotation(Line(points = {{-175, -59}, {-178, -59}, {-178, -60}, {-115, -60}}));
connect(cSTR1.port3, valve1.port1) annotation(Line(points = {{-279, -60}, {-252.5, -60}, {-252.5, -61}, {-225, -61}}));
connect(materialStream2.port2, cSTR1.port2) annotation(Line(points = {{-407, 78}, {-309, 78}, {-309, 3}}));
connect(materialStream1.port2, cSTR1.port1) annotation(Line(points = {{-411, -30}, {-344, -30}}));
connect(valve2.port2, materialStream4.port1) annotation(Line(points = {{293, 48}, {243.5, 48}, {243.5, 47.5}, {329, 47.5}}));
annotation(Diagram(coordinateSystem(extent = {{-500, -200}, {600, 200}}, grid = {5, 5})), Icon(coordinateSystem(extent = {{-500, -200}, {600, 200}}, grid = {5, 5})), version = "", uses);
end flowsheet1;
model MS_WO_Flash
parameter Integer NOC = 4;
parameter Chemsep_Database.Toluene comp1;
parameter Chemsep_Database.Hydrogen comp2;
parameter Chemsep_Database.Benzene comp3;
parameter Chemsep_Database.Methane comp4;
parameter String Name = "MS1";
parameter Chemsep_Database.General_Properties comp[NOC] = {comp1, comp2, comp3, comp4};
parameter Real Flowrate = 100, Pressure = 1e5, Temperature = 300, molefraction[NOC] = zeros(NOC);
parameter Boolean unspecified = true;
parameter Boolean stepchange = false;
parameter Real stepchangetime = 0.01;
parameter Real step_value = 1;
Real kf[NOC], zl[NOC](each min = 0, each max = 1, start = {0.5, 1e-18, 0.5, 0}), zv[NOC](each min = 0, each max = 1, start = {0, 0.25, 0, 0.75}), Fl(min = 0, start = 100), Fv(min = 0, start = 140), Tbf(start = 62), Tdf(start = 495.5), Psat_Tdf[NOC], Psat_Tbf[NOC], Psat_Tf[NOC], Pf, Tf, z[NOC], F;
Real Hvf[NOC], Hlf[NOC], H;
UnitOperationsWOMS.port port2 annotation(Placement(visible = true, transformation(origin = {80, -4}, extent = {{-18, -18}, {18, 18}}, rotation = 0), iconTransformation(origin = {85, 1}, extent = {{-21, -21}, {21, 21}}, rotation = 0)));
UnitOperationsWOMS.port port1 annotation(Placement(visible = true, transformation(origin = {-80, -4}, extent = {{-18, -18}, {18, 18}}, rotation = 0), iconTransformation(origin = {-82, 0}, extent = {{-20, -20}, {20, 20}}, rotation = 0)));
equation
if unspecified == false then
if stepchange == true then
if time < stepchangetime then
port1.moleflow = Flowrate;
else
port1.moleflow = Flowrate + step_value;
end if;
else
port1.moleflow = Flowrate;
end if;
port1.pressure = Pressure;
port1.temperature = Temperature;
port1.molefrac[:] = molefraction[:];
port1.liquidmolefrac[:] = zl[:];
port1.vapormolefrac[:] = zv[:];
port1.liquidmoleflow = Fl;
port1.vapormoleflow = Fv;
port1.enthalpy = H;
end if;
if unspecified == true then
port1.liquidmolefrac[:] = zl[:];
port1.vapormolefrac[:] = zv[:];
port1.liquidmoleflow = Fl;
port1.vapormoleflow = Fv;
port1.enthalpy = H;
end if;
if unspecified == false then
Pf = Pressure;
z[:] = molefraction[:];
Tf = Temperature;
F = port1.moleflow;
else
Pf = port1.pressure;
z[:] = port1.molefrac[:];
Tf = port1.temperature;
F = port1.moleflow;
end if;
zl = zeros(NOC);
zv = zeros(NOC);
H = 0;
Fl = 0;
Fv = 0;
kf = zeros(NOC);
Tbf = 0;
Tdf = 0;
Psat_Tbf = zeros(NOC);
Psat_Tdf = zeros(NOC);
Psat_Tf = zeros(NOC);
Hlf = zeros(NOC);
Hvf = zeros(NOC);
port2.moleflow = F;
port2.pressure = port1.pressure;
port2.temperature = port1.temperature;
port2.molefrac[:] = port1.molefrac[:];
port2.liquidmolefrac[:] = zl[:];
port2.vapormolefrac[:] = zv[:];
port2.liquidmoleflow = Fl;
port2.vapormoleflow = Fv;
port2.enthalpy = H;
annotation(Icon(graphics = {Rectangle(origin = {-10, 3}, fillColor = {255, 0, 0}, fillPattern = FillPattern.Solid, extent = {{-90, 45}, {90, -45}}), Text(origin = {-17, -1}, extent = {{-51, 27}, {51, -27}}, textString = "MS1")}, coordinateSystem(initialScale = 0.1)));
end MS_WO_Flash;
model flowsheet2
UnitOperationsWOMS.MS_WO_Flash materialStream1(Flowrate = 100, Pressure = 25e5, Temperature = 600, molefraction = {0.9, 0, 0.1, 0}, step_value = 2, stepchange = true, stepchangetime = 0.01, unspecified = false) annotation(Placement(visible = true, transformation(origin = {-445, -30}, extent = {{-40, -40}, {40, 40}}, rotation = 0)));
UnitOperationsWOMS.CSTR cSTR1(Operation = true) annotation(Placement(visible = true, transformation(origin = {-310, -30}, extent = {{-40, -40}, {40, 40}}, rotation = 0)));
UnitOperationsWOMS.MS_WO_Flash materialStream2(Flowrate = 140, Pressure = 25e5, Temperature = 400, molefraction = {0, 0.9, 0, 0.1}, stepchange = false, unspecified = false) annotation(Placement(visible = true, transformation(origin = {-447.5, 77.5}, extent = {{-47.5, -47.5}, {47.5, 47.5}}, rotation = 0)));
UnitOperationsWOMS.valve valve1(Control = false, OutletPfixed = false, valveCv = 0.4) annotation(Placement(visible = true, transformation(origin = {-200, -60}, extent = {{-30, -30}, {30, 30}}, rotation = 0)));
UnitOperationsWOMS.MS_WO_Flash materialStream3 annotation(Placement(visible = true, transformation(origin = {-450, -505}, extent = {{-30, -30}, {30, 30}}, rotation = 0)));
UnitOperationsWOMS.Flash flash1 annotation(Placement(visible = true, transformation(origin = {132.5, -62.5}, extent = {{-52.5, -52.5}, {52.5, 52.5}}, rotation = 0)));
UnitOperationsWOMS.valve valve2(Control = false, OutletPfixed = true, OutletPressure = 1e5) annotation(Placement(visible = true, transformation(origin = {262.5, 47.5}, extent = {{-37.5, -37.5}, {37.5, 37.5}}, rotation = 0)));
UnitOperationsWOMS.MS_WO_Flash materialStream4 annotation(Placement(visible = true, transformation(origin = {367.5, 47.5}, extent = {{-47.5, -47.5}, {47.5, 47.5}}, rotation = 0)));
UnitOperationsWOMS.MS_WO_Flash materialStream5 annotation(Placement(visible = true, transformation(origin = {212.5, -157.5}, extent = {{-32.5, -32.5}, {32.5, 32.5}}, rotation = 0)));
HeatExchanger heatExchanger1 annotation(Placement(visible = true, transformation(origin = {-22.5, -57.5}, extent = {{-22.5, -22.5}, {22.5, 22.5}}, rotation = 0)));
MS_WO_Flash materialStream6(zl(start = {0.7, 1e-16, 0.3, 0.001}), zv(start = {0.01, 0.75, 0.0145, 0.23})) annotation(Placement(visible = true, transformation(origin = {45, -60}, extent = {{-20, -20}, {20, 20}}, rotation = 0)));
UnitOperationsWOMS.CompoundSeperator compoundSeperator1 annotation(Placement(visible = true, transformation(origin = {315, -160}, extent = {{-35, -35}, {35, 35}}, rotation = 0)));
UnitOperationsWOMS.MS_WO_Flash materialStream7 annotation(Placement(visible = true, transformation(origin = {502.5, -47.5}, extent = {{-27.5, -27.5}, {27.5, 27.5}}, rotation = 0)));
UnitOperationsWOMS.MS_WO_Flash materialStream8 annotation(Placement(visible = true, transformation(origin = {530, -180}, extent = {{-30, -30}, {30, 30}}, rotation = 0)));
UnitOperationsWOMS.valve valve4(Control = false, OutletPfixed = false, OutletPressure = 1e5) annotation(Placement(visible = true, transformation(origin = {435, -135}, extent = {{-30, -30}, {30, 30}}, rotation = 0)));
UnitOperationsWOMS.valve valve5(Control = false, OutletPfixed = true, OutletPressure = 1e5) annotation(Placement(visible = true, transformation(origin = {437.5, -182.5}, extent = {{-27.5, -27.5}, {27.5, 27.5}}, rotation = 0)));
Distillation1 distillation11 annotation(Placement(visible = true, transformation(origin = {630, -55}, extent = {{-35, -35}, {35, 35}}, rotation = 0)));
equation
connect(valve1.port2, materialStream3.port1) annotation(Line(points = {{-175, -59}, {-178, -59}, {-178, -505}, {-475, -505}}));
connect(materialStream3.port2, heatExchanger1.port1) annotation(Line(points = {{-424.5, -505}, {-42, -505}, {-42, -57}}));
connect(materialStream7.port2, distillation11.port1) annotation(Line(points = {{525, -45}, {600, -45}, {600, -55}, {600, -55}}));
connect(valve5.port2, materialStream8.port1) annotation(Line(points = {{460, -182}, {500, -182}, {500, -180}, {505, -180}}));
connect(compoundSeperator1.port3, valve5.port1) annotation(Line(points = {{347, -187}, {360.875, -187}, {360.875, -182}, {387.5, -182}, {387.5, -183}, {415, -183}}));
connect(valve4.port2, materialStream7.port1) annotation(Line(points = {{460, -134}, {460, -47.5}, {480, -47.5}}));
connect(valve4.port1, compoundSeperator1.port2) annotation(Line(points = {{410, -136}, {410, -135.5}, {346.5, -135.5}}));
connect(materialStream5.port2, compoundSeperator1.port1) annotation(Line(points = {{240, -157}, {270.25, -157}, {270.25, -159}, {284, -159}}));
connect(flash1.port1, materialStream5.port1) annotation(Line(points = {{135, -100}, {135, -157.5}, {186, -157.5}}));
connect(materialStream6.port2, flash1.port3) annotation(Line(points = {{60, -60}, {95, -60}, {95, -60}, {90, -60}}));
connect(heatExchanger1.port2, materialStream6.port1) annotation(Line(points = {{-5, -55}, {25, -55}, {25, -60}, {30, -60}}));
connect(flash1.port2, valve2.port1) annotation(Line(points = {{172, -35}, {178.5, -35}, {178.5, 47}, {232, 47}}));
connect(cSTR1.port3, valve1.port1) annotation(Line(points = {{-279, -60}, {-252.5, -60}, {-252.5, -61}, {-225, -61}}));
connect(materialStream2.port2, cSTR1.port2) annotation(Line(points = {{-407, 78}, {-309, 78}, {-309, 3}}));
connect(materialStream1.port2, cSTR1.port1) annotation(Line(points = {{-411, -30}, {-344, -30}}));
connect(valve2.port2, materialStream4.port1) annotation(Line(points = {{293, 48}, {243.5, 48}, {243.5, 47.5}, {329, 47.5}}));
annotation(Diagram(coordinateSystem(extent = {{-500, -200}, {600, 200}}, grid = {5, 5})), Icon(coordinateSystem(extent = {{-500, -200}, {600, 200}}, grid = {5, 5})), version = "", uses);
end flowsheet2;
model reactor_Flash_SeperatorWOMS
UnitOperationsWOMS.MS_WO_Flash materialStream1(Flowrate = 100, Pressure = 25e5, Temperature = 600, molefraction = {0.9, 0, 0.1, 0}, stepchange = true, unspecified = false) annotation(Placement(visible = true, transformation(origin = {-445, -30}, extent = {{-40, -40}, {40, 40}}, rotation = 0)));
unitoperations.CSTR cSTR1(Operation = true) annotation(Placement(visible = true, transformation(origin = {-310, -30}, extent = {{-40, -40}, {40, 40}}, rotation = 0)));
UnitOperationsWOMS.MS_WO_Flash materialStream2(Flowrate = 140, Pressure = 25e5, Temperature = 400, molefraction = {0, 0.9, 0, 0.1}, stepchange = false, unspecified = false) annotation(Placement(visible = true, transformation(origin = {-447.5, 77.5}, extent = {{-47.5, -47.5}, {47.5, 47.5}}, rotation = 0)));
unitoperations.valve valve1(Control = false, OutletPfixed = false, valveCv = 0.4) annotation(Placement(visible = true, transformation(origin = {-200, -60}, extent = {{-30, -30}, {30, 30}}, rotation = 0)));
UnitOperationsWOMS.MS_WO_Flash materialStream3 annotation(Placement(visible = true, transformation(origin = {-90, -60}, extent = {{-30, -30}, {30, 30}}, rotation = 0)));
unitoperations.Flash flash1 annotation(Placement(visible = true, transformation(origin = {132.5, -62.5}, extent = {{-52.5, -52.5}, {52.5, 52.5}}, rotation = 0)));
unitoperations.valve valve2(Control = false, OutletPfixed = true, OutletPressure = 1e5) annotation(Placement(visible = true, transformation(origin = {262.5, 47.5}, extent = {{-37.5, -37.5}, {37.5, 37.5}}, rotation = 0)));
UnitOperationsWOMS.MS_WO_Flash materialStream4 annotation(Placement(visible = true, transformation(origin = {367.5, 47.5}, extent = {{-47.5, -47.5}, {47.5, 47.5}}, rotation = 0)));
UnitOperationsWOMS.MS_WO_Flash materialStream5 annotation(Placement(visible = true, transformation(origin = {212.5, -157.5}, extent = {{-32.5, -32.5}, {32.5, 32.5}}, rotation = 0)));
HeatExchanger heatExchanger1 annotation(Placement(visible = true, transformation(origin = {-22.5, -57.5}, extent = {{-22.5, -22.5}, {22.5, 22.5}}, rotation = 0)));
UnitOperationsWOMS.MS_WO_Flash materialStream6 annotation(Placement(visible = true, transformation(origin = {45, -60}, extent = {{-20, -20}, {20, 20}}, rotation = 0)));
unitoperations.CompoundSeperator compoundSeperator1 annotation(Placement(visible = true, transformation(origin = {315, -160}, extent = {{-35, -35}, {35, 35}}, rotation = 0)));
UnitOperationsWOMS.MS_WO_Flash materialStream7 annotation(Placement(visible = true, transformation(origin = {502.5, -47.5}, extent = {{-27.5, -27.5}, {27.5, 27.5}}, rotation = 0)));
UnitOperationsWOMS.MS_WO_Flash materialStream8 annotation(Placement(visible = true, transformation(origin = {530, -180}, extent = {{-30, -30}, {30, 30}}, rotation = 0)));
unitoperations.valve valve4(Control = false, OutletPfixed = true, OutletPressure = 1e5) annotation(Placement(visible = true, transformation(origin = {435, -135}, extent = {{-30, -30}, {30, 30}}, rotation = 0)));
unitoperations.valve valve5(Control = false, OutletPfixed = true, OutletPressure = 1e5) annotation(Placement(visible = true, transformation(origin = {437.5, -182.5}, extent = {{-27.5, -27.5}, {27.5, 27.5}}, rotation = 0)));
equation
connect(valve5.port2, materialStream8.port1) annotation(Line(points = {{460, -182}, {500, -182}, {500, -180}, {505, -180}}));
connect(compoundSeperator1.port3, valve5.port1) annotation(Line(points = {{347, -187}, {360.875, -187}, {360.875, -182}, {387.5, -182}, {387.5, -183}, {415, -183}}));
connect(valve4.port2, materialStream7.port1) annotation(Line(points = {{460, -134}, {460, -47.5}, {480, -47.5}}));
connect(valve4.port1, compoundSeperator1.port2) annotation(Line(points = {{410, -136}, {410, -135.5}, {346.5, -135.5}}));
connect(materialStream5.port2, compoundSeperator1.port1) annotation(Line(points = {{240, -157}, {270.25, -157}, {270.25, -159}, {284, -159}}));
connect(flash1.port1, materialStream5.port1) annotation(Line(points = {{135, -100}, {135, -157.5}, {186, -157.5}}));
connect(materialStream6.port2, flash1.port3) annotation(Line(points = {{60, -60}, {95, -60}, {95, -60}, {90, -60}}));
connect(heatExchanger1.port2, materialStream6.port1) annotation(Line(points = {{-5, -55}, {25, -55}, {25, -60}, {30, -60}}));
connect(flash1.port2, valve2.port1) annotation(Line(points = {{172, -35}, {178.5, -35}, {178.5, 47}, {232, 47}}));
connect(materialStream3.port2, heatExchanger1.port1) annotation(Line(points = {{-65, -60}, {-42, -60}, {-42, -57}}));
connect(valve1.port2, materialStream3.port1) annotation(Line(points = {{-175, -59}, {-178, -59}, {-178, -60}, {-115, -60}}));
connect(cSTR1.port3, valve1.port1) annotation(Line(points = {{-279, -60}, {-252.5, -60}, {-252.5, -61}, {-225, -61}}));
connect(materialStream2.port2, cSTR1.port2) annotation(Line(points = {{-407, 78}, {-309, 78}, {-309, 3}}));
connect(materialStream1.port2, cSTR1.port1) annotation(Line(points = {{-411, -30}, {-344, -30}}));
connect(valve2.port2, materialStream4.port1) annotation(Line(points = {{293, 48}, {243.5, 48}, {243.5, 47.5}, {329, 47.5}}));
annotation(Diagram(coordinateSystem(extent = {{-500, -200}, {600, 200}}, grid = {5, 5})), Icon(coordinateSystem(extent = {{-500, -200}, {600, 200}}, grid = {5, 5})), version = "", uses);
end reactor_Flash_SeperatorWOMS;
end UnitOperationsWOMS;