1 | #*------------------------------------------------------------------- |
---|
2 | * EMSO Model Library (EML) Copyright (C) 2004 - 2007 ALSOC. |
---|
3 | * |
---|
4 | * This LIBRARY is free software; you can distribute it and/or modify |
---|
5 | * it under the therms of the ALSOC FREE LICENSE as available at |
---|
6 | * http://www.enq.ufrgs.br/alsoc. |
---|
7 | * |
---|
8 | * EMSO Copyright (C) 2004 - 2007 ALSOC, original code |
---|
9 | * from http://www.rps.eng.br Copyright (C) 2002-2004. |
---|
10 | * All rights reserved. |
---|
11 | * |
---|
12 | * EMSO is distributed under the therms of the ALSOC LICENSE as |
---|
13 | * available at http://www.enq.ufrgs.br/alsoc. |
---|
14 | * |
---|
15 | * |
---|
16 | *------------------------------------------------------------------- |
---|
17 | * Sample file for tanks level control |
---|
18 | * |
---|
19 | *------------------------------------------------------------------- |
---|
20 | * Author: Tiago Osório |
---|
21 | * $Id: sample_tanks_pid.mso 84 2006-12-08 20:37:22Z paula $ |
---|
22 | *-----------------------------------------------------------------*# |
---|
23 | |
---|
24 | using "tanksmodel"; |
---|
25 | using "controllers/PIDs"; |
---|
26 | using "controllers/PIDIncr"; |
---|
27 | |
---|
28 | |
---|
29 | FlowSheet Tanque_inc |
---|
30 | DEVICES |
---|
31 | Tanque1 as tank; |
---|
32 | PID as PIDIncr_Ideal_AWBT; |
---|
33 | |
---|
34 | PARAMETERS |
---|
35 | h_max as Real (Brief="Altura máxima do nível do tanque", Unit="m"); |
---|
36 | h_min as Real (Brief="Altura mínima do nível do tanque", Unit="m"); |
---|
37 | |
---|
38 | VARIABLES |
---|
39 | h_ad as Real (Brief="Altura adimensional do nível do tanque", Lower=0,Upper=1); |
---|
40 | |
---|
41 | CONNECTIONS |
---|
42 | |
---|
43 | SET |
---|
44 | Tanque1.A = 8 * "m^2"; |
---|
45 | h_max = 2 * "m"; |
---|
46 | h_min = 0 * "m"; |
---|
47 | |
---|
48 | EQUATIONS |
---|
49 | PID.Parameters.tau = 1*"s"; |
---|
50 | PID.Parameters.tauSet = 1*"s"; |
---|
51 | PID.Parameters.alpha = 0.3; |
---|
52 | PID.Parameters.bias = 0; |
---|
53 | PID.Parameters.gamma = 1; |
---|
54 | PID.Parameters.beta = 1; |
---|
55 | PID.Options.action = -1; |
---|
56 | PID.Options.clip=1; |
---|
57 | PID.Options.autoMan = 0; |
---|
58 | PID.Parameters.intTime=5000*"s"; |
---|
59 | PID.Parameters.gain = 3.5; |
---|
60 | PID.Parameters.derivTime=1*"s"; |
---|
61 | PID.Ports.input = h_ad; |
---|
62 | h_ad = (Tanque1.h-h_min)/(h_max-h_min); |
---|
63 | Tanque1.k = 8*"m^2.5/h"*PID.Ports.output; |
---|
64 | |
---|
65 | #Perturbação servo |
---|
66 | #Nível desejado=1*"m" |
---|
67 | PID.Ports.setPoint=0.5; |
---|
68 | |
---|
69 | #Perturbação regulatória |
---|
70 | if time<10*"h" then |
---|
71 | Tanque1.Fin= 3*"m^3/h"; |
---|
72 | else |
---|
73 | Tanque1.Fin= 1.5*"m^3/h"; |
---|
74 | end |
---|
75 | |
---|
76 | INITIAL |
---|
77 | "altura inicial" |
---|
78 | Tanque1.h = 0.2 * "m"; |
---|
79 | |
---|
80 | OPTIONS |
---|
81 | DAESolver = "dassl"; |
---|
82 | time = [0:0.1:30] * "h" ; |
---|
83 | end |
---|
84 | |
---|
85 | FlowSheet Tanque |
---|
86 | DEVICES |
---|
87 | Tanque1 as tank; |
---|
88 | PID as PID_Ideal_AWBT; |
---|
89 | |
---|
90 | PARAMETERS |
---|
91 | h_max as Real (Brief="Altura máxima do nível do tanque", Unit="m"); |
---|
92 | h_min as Real (Brief="Altura mínima do nível do tanque", Unit="m"); |
---|
93 | |
---|
94 | VARIABLES |
---|
95 | h_ad as Real (Brief="Altura adimensional do nível do tanque", Lower=0,Upper=1); |
---|
96 | |
---|
97 | CONNECTIONS |
---|
98 | |
---|
99 | SET |
---|
100 | Tanque1.A = 8 * "m^2"; |
---|
101 | h_max = 2 * "m"; |
---|
102 | h_min = 0 * "m"; |
---|
103 | |
---|
104 | EQUATIONS |
---|
105 | PID.Parameters.tau = 1*"s"; |
---|
106 | PID.Parameters.tauSet = 1*"s"; |
---|
107 | PID.Parameters.alpha = 0.3; |
---|
108 | PID.Parameters.bias = 0; |
---|
109 | PID.Parameters.gamma = 1; |
---|
110 | PID.Parameters.beta = 1; |
---|
111 | PID.Parameters.intTime=5000*"s"; |
---|
112 | PID.Parameters.gain =3.5; |
---|
113 | PID.Parameters.derivTime=1*"s"; |
---|
114 | PID.Options.action = -1; |
---|
115 | PID.Options.clip=1; |
---|
116 | PID.Options.autoMan = 0; |
---|
117 | PID.Ports.input = h_ad; |
---|
118 | h_ad = (Tanque1.h-h_min)/(h_max-h_min); |
---|
119 | Tanque1.k = 8*"m^2.5/h"*PID.Ports.output; |
---|
120 | |
---|
121 | #Perturbação servo |
---|
122 | #Nível desejado=1*"m" |
---|
123 | PID.Ports.setPoint=0.5; |
---|
124 | |
---|
125 | #Perturbação regulatória |
---|
126 | if time<10*"h" then |
---|
127 | Tanque1.Fin= 3*"m^3/h"; |
---|
128 | else |
---|
129 | Tanque1.Fin= 1.5*"m^3/h"; |
---|
130 | end |
---|
131 | |
---|
132 | INITIAL |
---|
133 | "altura inicial" |
---|
134 | Tanque1.h = 0.2 * "m"; |
---|
135 | |
---|
136 | OPTIONS |
---|
137 | NLASolver = "sundials"; |
---|
138 | time = [0:0.1:30] * "h" ; |
---|
139 | end |
---|
140 | |
---|
141 | |
---|
142 | |
---|