Changeset 909 for branches/gui
- Timestamp:
- Feb 19, 2010, 7:08:11 PM (14 years ago)
- Location:
- branches/gui
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/gui/eml/controllers/PIDIncr.mso
r684 r909 37 37 38 38 PID_Select as Switcher (Brief="Type of PID Incremental", Valid=["Ideal","Parallel","Series","Ideal_AWBT","Parallel_AWBT","Series_AWBT","Ideal_AW","Parallel_AW","Series_AW"], Default = "Ideal"); 39 Action 40 Mode 41 Clip 42 43 alpha as positive(Brief="Derivative term filter constant", Default=1);44 beta as positive(Brief="Proportional term setPoint change filter");45 bias 46 derivTime as time_sec 47 intTime as time_sec 48 gain as positive(Brief="Controller gain", Default=0.5);49 gamma as positive 50 tau as time_sec(Brief="Input filter time constant");51 tauSet as time_sec 52 MinInput as control_signal (Default=-1000);39 Action as Switcher (Brief="Controller action", Valid=["Direct","Reverse"], Default = "Reverse"); 40 Mode as Switcher (Brief="Controller mode", Valid=["Automatic","Manual"], Default = "Automatic"); 41 Clip as Switcher (Brief="Controller mode", Valid=["Clipped","Unclipped"], Default = "Clipped"); 42 43 alpha as positive (Brief="Derivative term filter constant", Default=1); 44 beta as positive (Brief="Proportional term setPoint change filter"); 45 bias as control_signal (Brief="Previous scaled bias", Default=0.5); 46 derivTime as time_sec (Brief="Derivative time constant"); 47 intTime as time_sec (Brief="Integral time constant"); 48 gain as positive (Brief="Controller gain", Default=0.5); 49 gamma as positive (Brief="Derivative term SP change filter"); 50 tau as time_sec (Brief="Input filter time constant"); 51 tauSet as time_sec (Brief="Input filter time constant"); 52 MinInput as control_signal (Default=0); 53 53 MaxInput as control_signal (Default=1000); 54 MinOutput as control_signal (Default= -1000);55 MaxOutput as control_signal (Default=1 000);54 MinOutput as control_signal (Default=0); 55 MaxOutput as control_signal (Default=1); 56 56 57 57 VARIABLES 58 58 59 in 60 out Output as control_signal (Protected=true, PosX=0.54, PosY=1);61 SetPoint 59 in Input as control_signal (Protected=true, PosX=0, PosY=0.5); 60 out Output as control_signal (Protected=true, PosX=0.54, PosY=1); 61 SetPoint as control_signal; 62 62 63 63 #++++++++++++++++++++ PID Internal Variables ++++++++++++++++++++++++++++++++ 64 64 PID_dderivTerm as control_signal (Brief="Derivative term",Unit='1/s', Default=0, Hidden=true); 65 PID_dFilt 66 PID_error 67 PID_errorD 68 PID_errorI 69 PID_inputFilt 65 PID_dFilt as control_signal (Brief="Derivative term filtered", Default=0.5,Unit='1/s', Hidden=true); 66 PID_error as control_signal (Brief="Error definition for proportional term",Unit='1/s', Hidden=true); 67 PID_errorD as control_signal (Brief="Error definition for derivative term",Unit='1/s', Hidden=true); 68 PID_errorI as control_signal (Brief="Error definition for integral term", Hidden=true); 69 PID_inputFilt as control_signal (Brief="Filtered input", Hidden=true); 70 70 PID_dintTerm as control_signal (Brief="Integral term", Default=0,Unit='1/s', Hidden=true); 71 PID_doutp 72 PID_outps as control_signal (Brief="Variable outp scaled between -1 and 1", Hidden=true);73 PID_outp 71 PID_doutp as control_signal (Brief="Sum of proportional, integral and derivative terms",Unit='1/s', Hidden=true); 72 PID_outps as control_signal (Brief="Variable outp scaled between -1 and 1", Hidden=true, Default=0.5); 73 PID_outp as control_signal (Brief="Variable outp", Hidden=true); 74 74 PID_dpropTerm as control_signal (Brief="Proportional term", Default=0,Unit='1/s', Hidden=true); 75 75 PID_setPointFilt as control_signal (Brief="Filtered setPoint", Default=0, Hidden=true); 76 PID_input 77 PID_output 76 PID_input as control_signal (Brief="Previous scaled input signal", Default=0.5, Hidden=true); 77 PID_output as control_signal (Brief="Scaled output signal", Default=0.5, Hidden=true); 78 78 PID_setPoint as control_signal (Brief="Scaled setPoint",Default=0.5, Hidden=true); 79 PID_AWFactor as Real 80 PID_action as Real(Hidden=true);79 PID_AWFactor as Real (Brief="Integral term multiplier used in anti-reset windup", Hidden=true); 80 PID_action as Real (Hidden=true); 81 81 #++++++++++++++++++++ ++++++++++++++++++++++++++++++++++++++++++++++++ 82 82 … … 87 87 88 88 "Output " 89 Output = PID_output*(MaxOutput -MinOutput) +MinOutput;89 Output = PID_output*(MaxOutput - MinOutput) + MinOutput; 90 90 91 91 "Set Point " 92 92 PID_setPoint*(MaxInput - MinInput) = SetPoint - MinInput; 93 93 94 if (tau < 1e- 6) then94 if (tau < 1e-3*'s') then 95 95 "Input first order filter" 96 96 (tau + 1e-3*'s')*diff(PID_inputFilt)= PID_input - PID_inputFilt; … … 100 100 end 101 101 102 if (tauSet < 1e- 6) then102 if (tauSet < 1e-3*'s') then 103 103 "setPoint first order filter" 104 104 (tauSet + 1e-3*'s')*diff(PID_setPointFilt)= PID_setPoint - PID_setPointFilt; … … 128 128 PID_dpropTerm=PID_error; 129 129 130 if (derivTime equal 0) then130 if (derivTime < 1e-3*'s') then 131 131 "Derivative term filter" 132 132 alpha*(derivTime + 1e-3*'s')*diff(PID_dFilt) = PID_errorD - PID_dFilt; … … 147 147 switch Clip 148 148 case "Clipped": 149 #if abs(PID_outps)>1 then150 # "Calculate clipped output when it'ssaturated"151 # Ports.output=(sign(PID_outps)*1+1)/2;152 #else153 # "Calculate clipped output when it'snot saturated"154 # Ports.output=PID_outps;155 #end156 PID_output = max([0, PID_outp]);149 if abs(PID_outps)>1 then 150 "Calculate clipped output when saturated" 151 PID_output=(sign(PID_outps)+1)/2; 152 else 153 "Calculate clipped output when not saturated" 154 PID_output=PID_outp; 155 end 156 #PID_output = max([0, PID_outp]); 157 157 case "Unclipped": 158 158 "Calculate unclipped output" -
branches/gui/eml/controllers/PIDs.mso
r771 r909 28 28 29 29 PID_Select as Switcher (Brief="Type of PID Incremental", Valid=["Ideal","Parallel","Series","Ideal_AWBT","Parallel_AWBT","Series_AWBT","Ideal_AW","Parallel_AW","Series_AW"], Default = "Ideal"); 30 Action 31 Mode 32 Clip 33 34 alpha as positive(Brief="Derivative term filter constant", Default=1);35 beta as positive(Brief="Proportional term setPoint change filter");36 bias 37 derivTime as time_sec 38 intTime as time_sec 39 gain as positive(Brief="Controller gain", Default=0.5);40 gamma as positive 41 tau as time_sec(Brief="Input filter time constant");42 tauSet as time_sec 43 MinInput as control_signal (Default=-1000);30 Action as Switcher (Brief="Controller action", Valid=["Direct","Reverse"], Default = "Reverse"); 31 Mode as Switcher (Brief="Controller mode", Valid=["Automatic","Manual"], Default = "Automatic"); 32 Clip as Switcher (Brief="Controller mode", Valid=["Clipped","Unclipped"], Default = "Clipped"); 33 34 alpha as positive (Brief="Derivative term filter constant", Default=1); 35 beta as positive (Brief="Proportional term setPoint change filter"); 36 bias as control_signal (Brief="Previous scaled bias", Default=0.5); 37 derivTime as time_sec (Brief="Derivative time constant"); 38 intTime as time_sec (Brief="Integral time constant"); 39 gain as positive (Brief="Controller gain", Default=0.5); 40 gamma as positive (Brief="Derivative term SP change filter"); 41 tau as time_sec (Brief="Input filter time constant"); 42 tauSet as time_sec (Brief="Input filter time constant"); 43 MinInput as control_signal (Default=0); 44 44 MaxInput as control_signal (Default=1000); 45 MinOutput as control_signal (Default= -1000);46 MaxOutput as control_signal (Default=1 000);47 45 MinOutput as control_signal (Default=0); 46 MaxOutput as control_signal (Default=1); 47 48 48 VARIABLES 49 in 50 out Output as control_signal (Protected=true, PosX=0.54, PosY=1);51 SetPoint 49 in Input as control_signal (Protected=true, PosX=0, PosY=0.5); 50 out Output as control_signal (Protected=true, PosX=0.54, PosY=1); 51 SetPoint as control_signal; 52 52 53 53 #++++++++++++++++++++ PID Internal Variables ++++++++++++++++++++++++++++++++ 54 54 PID_derivTerm as control_signal (Brief="Derivative term", Hidden =true , Default=0); 55 PID_dFilt 56 PID_error 55 PID_dFilt as control_signal (Brief="Derivative term filtered", Hidden =true ,Default=0.5); 56 PID_error as control_signal (Brief="Error definition for proportional term",Hidden =true ); 57 57 PID_errorD as control_signal (Brief="Error definition for derivative term", Hidden =true ); 58 PID_errorI 59 PID_inputFilt 58 PID_errorI as control_signal (Brief="Error definition for integral term", Hidden =true); 59 PID_inputFilt as control_signal (Brief="Filtered input", Hidden =true); 60 60 PID_intTerm as control_signal (Brief="Integral term", Hidden =true , Default=0); 61 PID_outp 62 PID_outps 61 PID_outp as control_signal (Brief="Sum of proportional, integral and derivative terms", Hidden =true ); 62 PID_outps as control_signal (Brief="Variable outp scaled between -1 and 1",Hidden =true); 63 63 PID_propTerm as control_signal (Brief="Proportional term", Default=0 , Hidden =true ); 64 PID_setPointFilt as control_signal 65 PID_AWFactor as Real 66 PID_action as Real(Protected=true, Hidden=true);64 PID_setPointFilt as control_signal (Brief="Filtered setPoint", Default=0, Hidden =true); 65 PID_AWFactor as Real (Brief="Integral term multiplier used in anti-reset windup", Hidden=true); 66 PID_action as Real (Protected=true, Hidden=true); 67 67 68 68 PID_input as control_signal (Brief="Previous scaled input signal", Default=0.5, Hidden=true); 69 69 PID_output as control_signal (Brief="Scaled output signal", Default=0.5, Hidden=true); 70 PID_setPoint as control_signal (Brief="Scaled setPoint",Default=0.5, Hidden=true);70 PID_setPoint as control_signal (Brief="Scaled setPoint",Default=0.5, Hidden=true); 71 71 #++++++++++++++++++++++++++++++++++++++++++++++++++++ 72 72 … … 77 77 78 78 "Output " 79 Output = PID_output*(MaxOutput -MinOutput) +MinOutput;79 Output = PID_output*(MaxOutput - MinOutput) + MinOutput; 80 80 81 81 "Set Point " … … 94 94 EQUATIONS 95 95 96 if (tau equal 0) then96 if (tau < 1e-3*'s') then 97 97 "Input first order filter" 98 98 (tau + 1e-3*'s')*diff(PID_inputFilt)= PID_input - PID_inputFilt; … … 102 102 end 103 103 104 if (tauSet equal 0) then104 if (tauSet < 1e-3*'s') then 105 105 "setPoint first order filter" 106 106 (tauSet + 1e-3*'s')*diff(PID_setPointFilt)= PID_setPoint - PID_setPointFilt; … … 130 130 PID_propTerm=PID_error; 131 131 132 if (derivTime equal 0) then132 if (derivTime < 1e-3*'s') then 133 133 "Derivative term filter" 134 134 alpha*(derivTime + 1e-3*'s')*diff(PID_dFilt) = PID_errorD - PID_dFilt; … … 147 147 case "Clipped": 148 148 if abs(PID_outps)>1 then 149 "Calculate clipped output when it´ssaturated"150 PID_output=(sign(PID_outps) *1+1)/2;149 "Calculate clipped output when saturated" 150 PID_output=(sign(PID_outps)+1)/2; 151 151 else 152 "Calculate clipped output when it´snot saturated"152 "Calculate clipped output when not saturated" 153 153 PID_output=PID_outp; 154 154 end -
branches/gui/eml/pressure_changers/valve.mso
r808 r909 90 90 (1-Inlet.v)*PP.LiquidVolume((Inlet.T+Outlet.T)/2, (Inlet.P+Outlet.P)/2, Outlet.z); 91 91 92 if Pdrop > 0 then92 if Pdrop > 0 * 'atm' then 93 93 "Flow" 94 94 Outlet.F * v = k*x*sqrt(Pdrop * rho_ref / rho ) ; … … 242 242 case "Liquid-Only": 243 243 244 if Pdrop > 0 then244 if Pdrop > 0 * 'atm' then 245 245 246 246 "Valve Equation - Liquid Flow" … … 270 270 case "Vapour-Only": 271 271 272 if Pdrop > 0 then #Update for gas flow !!!!272 if Pdrop > 0 * 'atm' then #Update for gas flow !!!! 273 273 274 274 "Liquid-gas Coefficient Ratio" -
branches/gui/sample/controllers/CSTR_noniso_pid.mso
r735 r909 18 18 * Author: Argimiro R. Secchi 19 19 * $Id$ 20 *-------------------------------------------------------------------- #20 *--------------------------------------------------------------------*# 21 21 22 22 using "controllers/PIDs"; … … 113 113 114 114 VARIABLES 115 L_ad as Real;116 Lmin as length;117 Lmax as length;118 T_ad as Real;119 Tmin as temperature;120 Tmax as temperature;121 115 Lsp as length; 122 116 Tsp as temperature; 123 117 out LI as control_signal (Brief="Level Indicator"); 118 out TI as control_signal (Brief="Temperature Indicator"); 119 124 120 CONNECTIONS 125 121 FEED to CSTR1.Inlet; 122 LI to PIDL.Input; 123 TI to PIDT.Input; 126 124 127 125 SET … … 140 138 PIDT.PID_Select = "Ideal_AWBT"; 141 139 140 # Level control: PID parameters 141 PIDL.bias=0; 142 PIDL.alpha=0.1; 143 PIDL.Action="Direct"; 144 PIDL.gamma=1; 145 PIDL.beta=1; 146 PIDL.Clip="Clipped"; 147 PIDL.Mode="Automatic"; 148 PIDL.gain=1; 149 PIDL.intTime=2.5*'h'; 150 PIDL.derivTime=0*'s'; 151 PIDL.tau=1*'s'; 152 PIDL.tauSet=1*'s'; 153 154 # Temperature control: PID parameters 155 PIDT.bias = 0; 156 PIDT.alpha=0.1; 157 PIDT.Action="Reverse"; 158 PIDT.gamma=1; 159 PIDT.beta=1; 160 PIDT.Clip="Clipped"; 161 PIDT.Mode="Automatic"; 162 PIDT.gain=1; 163 PIDT.intTime=2.5*'h'; 164 PIDT.derivTime=1*'h'; 165 PIDT.tau=1*'s'; 166 PIDT.tauSet=1*'s'; 167 168 # Operating range for control variables 169 PIDL.MaxInput=5; 170 PIDL.MinInput=0; 171 PIDT.MaxInput=700; 172 PIDT.MinInput=230; 173 PIDT.MaxOutput=700; 174 PIDT.MinOutput=230; 175 142 176 EQUATIONS 143 177 144 "Dimensionless level to connect PID" 145 L_ad*(Lmax-Lmin)=CSTR1.h-Lmin; 146 PIDL.Ports.input=L_ad; 147 148 "Dimensionless temperature to connect PID" 149 T_ad*(Tmax-Tmin)=CSTR1.T-Tmin; 150 PIDT.Ports.input=T_ad; 151 178 "Level sensor" 179 LI * 'm' = CSTR1.h; 180 181 "Temperature sensor" 182 TI * 'K' = CSTR1.T; 183 184 "Setpoints" 185 PIDL.SetPoint * 'm' = Lsp; 186 PIDT.SetPoint * 'K' = Tsp; 187 152 188 "Manipulated Variables" 153 CSTR1.x = PIDL.Ports.output; 154 CSTR1.Tw = PIDT.Ports.output*(Tmax-Tmin)+Tmin; 155 156 # Level control: PID parameters 157 PIDL.Parameters.bias=0; 158 PIDL.Parameters.alpha=0.1; 159 PIDL.Options.action=-1; 160 PIDL.Parameters.gamma=1; 161 PIDL.Parameters.beta=1; 162 PIDL.Options.clip=1; 163 PIDL.Options.autoMan=0; 164 PIDL.Parameters.gain=1; 165 PIDL.Parameters.intTime=2.5*'h'; 166 PIDL.Parameters.derivTime=0*'s'; 167 PIDL.Ports.setPoint=(Lsp - Lmin)/(Lmax - Lmin); 168 PIDL.Parameters.tau=1*'s'; 169 PIDL.Parameters.tauSet=1*'s'; 170 171 # Temperature control: PID parameters 172 PIDT.Parameters.bias = 0; 173 PIDT.Parameters.alpha=0.1; 174 PIDT.Options.action=1; 175 PIDT.Parameters.gamma=1; 176 PIDT.Parameters.beta=1; 177 PIDT.Options.clip=1; 178 PIDT.Options.autoMan=0; 179 PIDT.Parameters.gain=1; 180 PIDT.Parameters.intTime=2.5*'h'; 181 PIDT.Parameters.derivTime=1*'h'; 182 PIDT.Ports.setPoint=(Tsp - Tmin)/(Tmax - Tmin); 183 PIDT.Parameters.tau=1*'s'; 184 PIDT.Parameters.tauSet=1*'s'; 185 186 "Operating range for control variables" 187 Lmax=5*'m'; 188 Lmin=0*'m'; 189 Tmax=700*'K'; 190 Tmin=230*'K'; 189 CSTR1.x = PIDL.Output; 190 CSTR1.Tw = PIDT.Output * 'K'; 191 191 192 192 "Feed Stream" -
branches/gui/sample/controllers/Sample_flash_pid.mso
r735 r909 22 22 * Author: Rafael de Pelegrini Soares 23 23 * $Id$ 24 *------------------------------------------------------------------ #24 *------------------------------------------------------------------*# 25 25 26 26 using "stage_separators/flash"; 27 using "pressure_changers/valve.mso"; 27 28 using "controllers/PIDIncr"; 28 29 … … 35 36 VapourModel = "PR"); 36 37 NComp as Integer; 37 #Maximum and minimum vapor and liquid flow rates38 FVMin as flow_mol;39 FVMax as flow_mol;40 FLMax as flow_mol;41 FLMin as flow_mol;42 #Maximum and minimum pressure43 PMin as pressure;44 PMax as pressure;45 #Maximum and minimum level46 LMax as length;47 LMin as length;48 38 49 39 VARIABLES 50 L_ad as Real (Brief="Dimensionless level");51 P_ad as Real (Brief="Dimensionless pressure");52 40 Q as energy_source (Brief="Heat supplied"); 53 41 … … 57 45 fl as flash; 58 46 s1 as source; 59 47 valve_top as valve_flow; 48 valve_bot as valve_flow; 49 60 50 SET 61 51 NComp = PP.NumberOfComponents; … … 65 55 66 56 #Flash model parameters 67 fl. V = 10 * 'm^3';68 fl. diameter = 0.5* 'm';69 fl. orientation = "vertical";57 fl.Geometry.Lenght = 10 * 'm'; 58 fl.Geometry.Diameter = 1 * 'm'; 59 fl.Geometry.Orientation = "vertical"; 70 60 71 61 #Maximum and minimum values 72 PMax=2.36 *'atm';73 PMin=0 *'atm';74 LMax=2 *'m';75 LMin=0 *'m';76 FVMax=300*'kmol/h';77 FVMin=0*'kmol/h';78 FLMax=692.7*'kmol/h';79 FLMin=0*'kmol/h';62 pidP.MaxInput=2.36; 63 pidP.MinInput=0; 64 pidL.MaxInput=2; 65 pidL.MinInput=0; 66 valve_top.MaxFlow=300*'kmol/h'; 67 valve_top.MinFlow=0*'kmol/h'; 68 valve_bot.MaxFlow=692.7*'kmol/h'; 69 valve_bot.MinFlow=0*'kmol/h'; 80 70 81 71 CONNECTIONS 82 72 s1.Outlet to fl.Inlet; 83 73 Q.OutletQ to fl.InletQ; 74 fl.OutletLiquid to valve_bot.Inlet; 75 fl.OutletVapour to valve_top.Inlet; 76 fl.LI to pidL.Input; 77 fl.PI to pidP.Input; 78 pidP.Output to valve_top.FlowFraction; 79 pidL.Output to valve_bot.FlowFraction; 84 80 85 81 SET … … 108 104 pidP.beta =1; 109 105 pidP.gamma =1; 110 #Pressure controller configuration111 106 pidP.Mode = "Automatic"; 112 107 pidP.Clip = "Clipped"; 113 108 pidP.Action = "Direct"; 109 110 #Initial conditions 111 fl.Levelpercent_Initial = 0.5; 112 fl.Temperature_Initial = 340 * 'K'; 113 fl.Composition_Initial = [0.1, 0.1, 0.8]; 114 114 115 115 SPECIFY … … 118 118 119 119 #Level controller parameters 120 pidL.Ports.setPoint=0.5; 121 120 pidL.SetPoint=0.5; 122 121 123 122 EQUATIONS … … 134 133 s1.F = 450 * 'kmol/h'; 135 134 end 136 137 #Control variables: fl.Level and fl.OutletV.P138 #Normalized control variables139 L_ad*(LMax-LMin)=fl.Level-LMin;140 P_ad*(PMax-PMin)=fl.OutletV.P-PMin;141 142 #Controllers input ports143 pidL.Ports.input=L_ad;144 pidP.Ports.input=P_ad;145 135 146 136 #Setpoint change 147 137 if time < 2*'h' then 148 pidP. Ports.setPoint=0.501822;138 pidP.SetPoint=1; 149 139 else 150 pidP. Ports.setPoint=0.8474576;140 pidP.SetPoint=2; 151 141 end 152 142 153 #Controllers output ports154 #Manipulated variables: fl.OutletV.F (pressure control) and fl.OutletL.F (level control)155 fl.OutletV.F = pidP.Ports.output*(FVMax-FVMin)+FVMin;156 fl.OutletL.F = pidL.Ports.output*(FLMax-FLMin)+FLMin;157 158 INITIAL159 fl.OutletL.T = 340 *'K';160 fl.Level = 1* 'm';161 fl.OutletL.z(1) = 0.1;162 fl.OutletL.z(2) = 0.1;163 164 143 OPTIONS 165 144 TimeStep = 0.02; -
branches/gui/sample/stage_separators/sample_flash.mso
r796 r909 4 4 5 5 using "pressure_changers/valve"; 6 using "streams";7 6 using "controllers/PIDs"; 8 7 using "stage_separators/flash"; … … 173 172 174 173 SET 175 F101. Orientation = "vertical";176 F101. Heads = "hemispherical";177 F101. Diameter = 2 * 'm';178 F101. Lenght = 5 * 'm';174 F101.Geometry.Orientation = "vertical"; 175 F101.Geometry.Heads = "hemispherical"; 176 F101.Geometry.Diameter = 2 * 'm'; 177 F101.Geometry.Lenght = 5 * 'm'; 179 178 F101.Levelpercent_Initial = 0.80; 180 179 F101.Temperature_Initial = 373 * 'K';
Note: See TracChangeset
for help on using the changeset viewer.