1 | using "stage_separators/batch_dist"; |
---|

2 | using "controllers/PIDs"; |
---|

3 | |
---|

4 | FlowSheet TesteBatch_PID |
---|

5 | |
---|

6 | PARAMETERS |
---|

7 | PP as CalcObject(Brief="Physical Properties",File="vrpp"); |
---|

8 | NComp as Integer; |
---|

9 | P_max as pressure(Brief="Maximum Pressure on distillator"); |
---|

10 | P_min as pressure(Brief="Minimum Pressure on distillator"); |
---|

11 | |
---|

12 | VARIABLES |
---|

13 | P_ad as fraction(Brief="Dimensionless pressure"); |
---|

14 | P_set as pressure(Brief="Minimum Pressure on distillator"); |
---|

15 | |
---|

16 | SET |
---|

17 | PP.Components = [ "isobutane", "n-pentane" ]; |
---|

18 | PP.LiquidModel = "PR"; |
---|

19 | PP.VapourModel = "PR"; |
---|

20 | NComp = PP.NumberOfComponents; |
---|

21 | |
---|

22 | DEVICES |
---|

23 | batch as Diff_Dist; |
---|

24 | reflux as stream_therm; |
---|

25 | feed as stream_therm; |
---|

26 | pidP as PID_Ideal_AWBT; |
---|

27 | |
---|

28 | CONNECTIONS |
---|

29 | reflux to batch.InletL; |
---|

30 | feed to batch.Inlet; |
---|

31 | |
---|

32 | EQUATIONS |
---|

33 | if batch.Level > 1E-3 then |
---|

34 | batch.Q = 3.7743e6 * "kJ/h"; |
---|

35 | else |
---|

36 | batch.Q = 0 * "kJ/h"; |
---|

37 | end |
---|

38 | |
---|

39 | "Pressure Controller" |
---|

40 | pidP.Parameters.tau = 0*"s"; |
---|

41 | pidP.Parameters.tauSet = 0*"s"; |
---|

42 | pidP.Parameters.alpha = 0.3; |
---|

43 | pidP.Parameters.bias = 0; |
---|

44 | pidP.Parameters.gamma = 1; |
---|

45 | pidP.Parameters.beta = 1; |
---|

46 | pidP.Options.action = -1; |
---|

47 | pidP.Options.clip = 1; |
---|

48 | pidP.Options.autoMan = 0; |
---|

49 | pidP.Parameters.intTime = 0.1*"min"; |
---|

50 | pidP.Parameters.gain = 1; |
---|

51 | pidP.Parameters.derivTime = 0.02*"min"; |
---|

52 | pidP.Ports.setPoint = (P_set-P_min)/(P_max-P_min); |
---|

53 | pidP.Ports.input = P_ad; |
---|

54 | P_ad = (batch.P-P_min)/(P_max-P_min); |
---|

55 | batch.OutletV.F = 500 * "kmol/h" * pidP.Ports.output; |
---|

56 | |
---|

57 | SPECIFY |
---|

58 | reflux.F = 0 * "kmol/h"; |
---|

59 | reflux.T = 328 * "K"; |
---|

60 | reflux.P = 180 * "kPa"; |
---|

61 | reflux.z = [0.5, 0.5]; |
---|

62 | reflux.v = 0; |
---|

63 | |
---|

64 | feed.F = 0 * "kmol/h"; |
---|

65 | feed.T = 328 * "K"; |
---|

66 | feed.P = 180 * "kPa"; |
---|

67 | feed.z = [0.5, 0.5]; |
---|

68 | feed.v = 0; |
---|

69 | |
---|

70 | P_set = 300 * "kPa"; |
---|

71 | |
---|

72 | SET |
---|

73 | batch.V = 3 * "m^3"; |
---|

74 | batch.Across = 1 * "m^2"; |
---|

75 | P_max = 500 * "kPa"; |
---|

76 | P_min = 100 * "kPa"; |
---|

77 | |
---|

78 | INITIAL |
---|

79 | batch.T = 298 *"K"; |
---|

80 | batch.Level = 2.5 * "m"; |
---|

81 | batch.x(2) = 0.2; |
---|

82 | |
---|

83 | OPTIONS |
---|

84 | relativeAccuracy = 1e-5; |
---|

85 | outputLevel = "high"; |
---|

86 | |
---|

87 | time = [0:0.01:20]*"min"; |
---|

88 | end |
---|