Download Modeling, Simulation and Control with Modelica 3.0 and Dymola 7
Transcript
Draft, Jan. 21, 2009 7.4 Time synchronization (multi-rate, delays, range-limited sampling) 125 would like to apply these very basic definitions as a function call, such as, // wrong Modelica code slowSampling = Counter(fastSampling, samplingFactor); y = InertialDelay(u, delayTime); pressButtons = B1 and B2 and not OnDelay(B1 or B2, 0.5); This is not possible, because the functionality was implemented as a block and therefore requires to first instantiate the block and then connect input and output signals: // correct Modelica code Counter counter(samplingFactor = samplingFactor); InertialDelay inertialDelay(delayTime = delayTime); OnDelay onDelay(delayTime = 0.5); equation counter.u = fastSampling; counter.y = slowSampling; inertialDelay.u = u; inertialDelay.y = y; onDelay.u = u; pressButtons = B1 and B2 and not onDelay.y; This might be improved in a future Modelica version by introducing syntax to call a block as a function. 7.5 Algebraic loops between continuous and instantaneous equations As already mentioned, the Modelica language allows algebraic loops between continuous and instantaneous equations. However, this feature is not supported by Dymola (Dynasim 2008). Usually, this is not a critical issue because models can be rewritten so that an algebraic loop is removed and is replaced by event iteration. In many cases this is a better model of the physical world and should be performed, even if a tool would support algebraic loops. The basic idea is explained on the basis of some examples: Let us reconsider the simple digital controller that is connected to a continuous plant. The only difference is that the output equation of the plant shall now be explicitly a function of its input signal uc (this was not the case previously): // Equations of continuous plant der(xc) = f(xc, uc) yc = g(xc, uc); // Equations of discrete controller when sample(0,T) then yd = a*pre(yd) + b*ud; end when; // Equations that connect plant and controller together uc = yd; ud = yc_ref - yc; It is not possible to sort the equations of this system in an explicit forward sequence as it was possible previously. In order to make this clearer, the equations that are active at a sample instant are shown and the two simple connection equations at the end are substituted: // Equations at an event instant with input: yc_ref, xc, pre(uc); der(xc) := f(xc, uc); yc := g(xc, uc); uc := a*pre(uc) + b*(yc_ref - yc); The last two equations are a non-linear system of equations to compute “yc” and “uc” from “xc”, “pre(uc)”, “yc_ref”. This algebraic loop is a result of an over-idealization of the digital controller, because the computing time of the controller is not taken into account. Even if we want to model an idealized controller where the comput-