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 190 2007-03-07 18:09:13Z rafael $ |
---|
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 | TimeStep = 0.1; |
---|
83 | TimeEnd = 30; |
---|
84 | TimeUnit = 'h'; |
---|
85 | end |
---|
86 | |
---|
87 | FlowSheet Tanque |
---|
88 | DEVICES |
---|
89 | Tanque1 as tank; |
---|
90 | PID as PID_Ideal_AWBT; |
---|
91 | |
---|
92 | PARAMETERS |
---|
93 | h_max as Real (Brief="Altura máxima do nível do tanque", Unit='m'); |
---|
94 | h_min as Real (Brief="Altura mínima do nível do tanque", Unit='m'); |
---|
95 | |
---|
96 | VARIABLES |
---|
97 | h_ad as Real (Brief="Altura adimensional do nível do tanque", Lower=0,Upper=1); |
---|
98 | |
---|
99 | CONNECTIONS |
---|
100 | |
---|
101 | SET |
---|
102 | Tanque1.A = 8 * 'm^2'; |
---|
103 | h_max = 2 * 'm'; |
---|
104 | h_min = 0 * 'm'; |
---|
105 | |
---|
106 | EQUATIONS |
---|
107 | PID.Parameters.tau = 1*'s'; |
---|
108 | PID.Parameters.tauSet = 1*'s'; |
---|
109 | PID.Parameters.alpha = 0.3; |
---|
110 | PID.Parameters.bias = 0; |
---|
111 | PID.Parameters.gamma = 1; |
---|
112 | PID.Parameters.beta = 1; |
---|
113 | PID.Parameters.intTime=5000*'s'; |
---|
114 | PID.Parameters.gain =3.5; |
---|
115 | PID.Parameters.derivTime=1*'s'; |
---|
116 | PID.Options.action = -1; |
---|
117 | PID.Options.clip=1; |
---|
118 | PID.Options.autoMan = 0; |
---|
119 | PID.Ports.input = h_ad; |
---|
120 | h_ad = (Tanque1.h-h_min)/(h_max-h_min); |
---|
121 | Tanque1.k = 8*'m^2.5/h'*PID.Ports.output; |
---|
122 | |
---|
123 | #Perturbação servo |
---|
124 | #Nível desejado=1*'m' |
---|
125 | PID.Ports.setPoint=0.5; |
---|
126 | |
---|
127 | #Perturbação regulatória |
---|
128 | if time<10*"h" then |
---|
129 | Tanque1.Fin= 3*'m^3/h'; |
---|
130 | else |
---|
131 | Tanque1.Fin= 1.5*'m^3/h'; |
---|
132 | end |
---|
133 | |
---|
134 | INITIAL |
---|
135 | "altura inicial" |
---|
136 | Tanque1.h = 0.2 * 'm'; |
---|
137 | |
---|
138 | OPTIONS |
---|
139 | NLASolver = "sundials"; |
---|
140 | TimeStep = 0.1; |
---|
141 | TimeEnd = 30; |
---|
142 | TimeUnit = 'h'; |
---|
143 | end |
---|
144 | |
---|
145 | |
---|
146 | |
---|