1 | using "controllers/PIDs"; |
---|
2 | |
---|
3 | const_valv as positive(Brief = "Valve Constant", Default=1,Lower=0,Upper=100, Unit="m^2.5/h"); |
---|
4 | |
---|
5 | Model corrente |
---|
6 | VARIABLES |
---|
7 | Ca as conc_mol; |
---|
8 | F as flow_vol; |
---|
9 | T as temperature; |
---|
10 | end |
---|
11 | |
---|
12 | Model CSTR |
---|
13 | |
---|
14 | PARAMETERS |
---|
15 | ko as frequency (Unit="1/h"); |
---|
16 | A as area; |
---|
17 | At as area; |
---|
18 | Ea as energy_mol (Unit="kJ/kmol"); |
---|
19 | R as Real (Unit="kJ/mol/K"); |
---|
20 | ro as dens_mol (Unit="kmol/m^3"); |
---|
21 | Cp as cp_mol (Unit="kJ/kmol/K"); |
---|
22 | U as heat_trans_coeff (Unit="kW/m^2/K"); |
---|
23 | Hr as heat_reaction (Unit="kJ/kmol"); |
---|
24 | |
---|
25 | VARIABLES |
---|
26 | Cv as const_valv; |
---|
27 | T as temperature; |
---|
28 | Tw as temperature; |
---|
29 | V as volume; |
---|
30 | Ca as conc_mol; |
---|
31 | h as length; |
---|
32 | tau as time_h; |
---|
33 | rA as reaction_mol; |
---|
34 | k as frequency (Unit="1/h"); |
---|
35 | in Inlet as corrente; |
---|
36 | out Outlet as corrente; |
---|
37 | |
---|
38 | EQUATIONS |
---|
39 | |
---|
40 | "Balanço de Massa Global" |
---|
41 | diff(V) = Inlet.F - Outlet.F; |
---|
42 | |
---|
43 | "Balanço de Massa por Componente" |
---|
44 | tau * diff(Ca) = (Inlet.Ca - Ca) - (-rA) * tau; |
---|
45 | |
---|
46 | "Mistura perfeita" |
---|
47 | Outlet.Ca = Ca; |
---|
48 | Outlet.T = T; |
---|
49 | |
---|
50 | "Taxa de reação" |
---|
51 | -rA = k * Ca; |
---|
52 | |
---|
53 | "Equação de Arrhenius" |
---|
54 | k = ko * exp(-Ea/(R*T)); |
---|
55 | |
---|
56 | "Tempo de residência médio" |
---|
57 | tau * Inlet.F = V; |
---|
58 | |
---|
59 | "Geometria" |
---|
60 | A * h = V; |
---|
61 | |
---|
62 | "Equação da válvula" |
---|
63 | Outlet.F = Cv * sqrt(h); |
---|
64 | |
---|
65 | "Balanço de energia" |
---|
66 | tau * diff(T) = (Inlet.T - T) - U*At*(T-Tw)/(ro*V*Cp)*tau + (-Hr)*(-rA)*tau/(ro*Cp); |
---|
67 | |
---|
68 | end |
---|
69 | |
---|
70 | # processo com 1 CSTR controlado |
---|
71 | FlowSheet CSTR_controller |
---|
72 | |
---|
73 | DEVICES |
---|
74 | FEED as corrente; |
---|
75 | CSTR as CSTR; |
---|
76 | PIDL as PID_Ideal_AWBT; |
---|
77 | PIDT as PID_Ideal_AWBT; |
---|
78 | |
---|
79 | VARIABLES |
---|
80 | L_ad as Real; |
---|
81 | Lmin as length; |
---|
82 | Lmax as length; |
---|
83 | T_ad as Real; |
---|
84 | Tmin as temperature; |
---|
85 | Tmax as temperature; |
---|
86 | |
---|
87 | CONNECTIONS |
---|
88 | FEED to CSTR.Inlet; |
---|
89 | |
---|
90 | SET |
---|
91 | # Parâmetros do CSTR" |
---|
92 | CSTR.R = 8.3144 * "kJ/kmol/K"; |
---|
93 | CSTR.U = 300 * "kJ/h/m^2/K"; |
---|
94 | CSTR.ro = 55.56 * "kmol/m^3"; |
---|
95 | CSTR.Cp = 70*"kJ/kmol/K"; |
---|
96 | CSTR.Hr = -7000 * "kJ/kmol"; |
---|
97 | CSTR.Ea = 6e4 * "kJ/kmol"; |
---|
98 | CSTR.ko = 89 * "1/s"; |
---|
99 | CSTR.A = 8 * "m^2"; |
---|
100 | CSTR.At = 25 * "m^2"; |
---|
101 | |
---|
102 | EQUATIONS |
---|
103 | |
---|
104 | "Equações do PID para controle de nível" |
---|
105 | L_ad*(Lmax-Lmin)=CSTR.h-Lmin; |
---|
106 | PIDL.Ports.input=L_ad; |
---|
107 | |
---|
108 | "Equações do PID para controle de temperatura" |
---|
109 | T_ad*(Tmax-Tmin)=CSTR.T-Tmin; |
---|
110 | PIDT.Ports.input=T_ad; |
---|
111 | |
---|
112 | "Variáveis manipulada" |
---|
113 | CSTR.Cv = 2.2136 * "m^2.5/h" * (1 - PIDL.Ports.output); |
---|
114 | CSTR.Tw = PIDT.Ports.output*(Tmax-Tmin)+Tmin; |
---|
115 | |
---|
116 | #distúrbio regulatório |
---|
117 | if time<1.6e5 then |
---|
118 | FEED.T = 300 * "K"; |
---|
119 | else |
---|
120 | FEED.T = 285 * "K"; |
---|
121 | end |
---|
122 | |
---|
123 | |
---|
124 | #Parâmetros do PID de nível |
---|
125 | PIDL.Parameters.bias=0; |
---|
126 | PIDL.Parameters.alpha=0.1; |
---|
127 | PIDL.Options.action=1; |
---|
128 | PIDL.Parameters.gamma=1; |
---|
129 | PIDL.Parameters.beta=1; |
---|
130 | PIDL.Options.clip=1; |
---|
131 | PIDL.Options.autoMan=0; |
---|
132 | PIDL.Parameters.gain=20; |
---|
133 | PIDL.Parameters.intTime=5*"h"; |
---|
134 | PIDL.Parameters.derivTime=0*"s"; |
---|
135 | PIDL.Ports.setPoint=0.55; |
---|
136 | PIDL.Parameters.tau=1*"s"; |
---|
137 | PIDL.Parameters.tauSet=1*"s"; |
---|
138 | |
---|
139 | PIDT.Parameters.bias = 0; |
---|
140 | PIDT.Parameters.alpha=0.1; |
---|
141 | PIDT.Options.action=1; |
---|
142 | PIDT.Parameters.gamma=1; |
---|
143 | PIDT.Parameters.beta=1; |
---|
144 | PIDT.Options.clip=1; |
---|
145 | PIDT.Options.autoMan=0; |
---|
146 | PIDT.Parameters.gain=40; |
---|
147 | PIDT.Parameters.intTime=5*"h"; |
---|
148 | PIDT.Parameters.derivTime=1*"h"; |
---|
149 | PIDT.Ports.setPoint=0.85; |
---|
150 | PIDT.Parameters.tau=1*"s"; |
---|
151 | PIDT.Parameters.tauSet=1*"s"; |
---|
152 | |
---|
153 | "Valores limites para normalizações" |
---|
154 | Lmax=5*"m"; |
---|
155 | Lmin=0*"m"; |
---|
156 | Tmax=700*"K"; |
---|
157 | Tmin=230*"K"; |
---|
158 | |
---|
159 | "Variáveís da corrente de alimentação" |
---|
160 | FEED.Ca = 300 * "kmol/m^3"; |
---|
161 | FEED.F = 3.5 * "m^3/h"; |
---|
162 | |
---|
163 | INITIAL |
---|
164 | CSTR.Ca = 50 * "kmol/m^3"; |
---|
165 | CSTR.h = 2.5 * "m"; |
---|
166 | CSTR.T = 650 * "K"; |
---|
167 | |
---|
168 | OPTIONS |
---|
169 | time = [0:0.1:1 1:1:100] * "h"; |
---|
170 | outputLevel = "high"; |
---|
171 | end |
---|