Modelica - A Unified Object-Oriented Language for Systems

Modelica Change Proposal MCP-0024
Initialization of Clocked Discrete States
(Status: Under Evaluation)
Proposed Changes to the Modelica Language Specification
Version 3.3 Revision 1
Table of Contents
Preface ................................................................................................................................................. 3
Chapter 1
Introduction ................................................................................................................ 3
Chapter 2
Lexical Structure ........................................................................................................ 3
Chapter 3
Operators and Expressions ....................................................................................... 3
Chapter 4
Classes, Predefined Types, and Declarations .......................................................... 3
Chapter 5
Scoping, Name Lookup, and Flattening ................................................................... 3
Chapter 6
Interface or Type Relationships................................................................................ 4
Chapter 7
Inheritance, Modification, and Redeclaration ........................................................ 4
Chapter 8
Equations .................................................................................................................... 4
Chapter 9
Connectors and Connections..................................................................................... 4
Chapter 10
Arrays .......................................................................................................................... 4
Chapter 11
Statements and Algorithm Sections.......................................................................... 5
Chapter 12
Functions ..................................................................................................................... 5
Chapter 13
Packages ...................................................................................................................... 5
Chapter 14
Overloaded Operators ............................................................................................... 5
Chapter 15
Stream Connectors ..................................................................................................... 5
Chapter 16
Synchronous Language Elements ............................................................................. 6
Chapter 17
State Machines............................................................................................................ 8
Chapter 18
Annotations ................................................................................................................. 8
Chapter 19
Unit Expressions......................................................................................................... 8
Chapter 20
The Modelica Standard Library ............................................................................... 8
Appendix A
Glossary................................................................................................................... 8
Appendix B
Modelica Concrete Syntax..................................................................................... 8
Appendix C
Modelica DAE Representation ............................................................................. 9
Appendix D
Derivation of Stream Equations ........................................................................... 9
3
Preface
Chapter 1
Introduction
Chapter 2
Lexical Structure
Chapter 3
Operators and Expressions
Chapter 4
Classes, Predefined Types, and Declarations
Chapter 5
Scoping, Name Lookup, and Flattening
4 MCP <number> <short description>
Chapter 6
Interface or Type Relationships
Chapter 7
Inheritance, Modification, and Redeclaration
Chapter 8
Equations
Chapter 9
Connectors and Connections
Chapter 10
Arrays
MCP <number> <short description> 5
Chapter 11
Statements and Algorithm Sections
Chapter 12
Functions
Chapter 13
Packages
Chapter 14
Overloaded Operators
Chapter 15
Stream Connectors
6 MCP <number> <short description>
Chapter 16
Synchronous Language Elements
16.8
Continuous-Time Equations in Clocked Partitions
Continuous-Time Equations in Clocked Partitions
16.8.1
After sub-clock inferencing, see Section Error! Reference source not found., every partition that is
associated to a clock has to be categorized as “clocked discrete-time” or “clocked discretized continuous-time”
partition.
If a clocked partition contains no operator der, delay, spatialDistribution, no event related operators from
section Error! Reference source not found. (with exception of noEvent(..)), and no when-clause with a Boolean
condition, it is a “clocked discrete-time” partition [that is, it is a standard sampled data system that is described
by difference equations.]
If a clocked partition is not a “clocked discrete-time” partition, it is a “clocked discretized continuous-time”
partition. Such a partition has to be solved with a “solver method” of section Error! Reference source not
found.. When previous(x) is used on a continuous-time state variable x, then previous(x) uses the start
value of x as value for the first clock tick.
In a clocked discrete-time partition all event generating mechanisms do no longer apply. Especially neither
relations, nor one of the built-in operators of section Error! Reference source not found. (event triggering
mathematical functions) will trigger an event.
16.9
Other Operators
The following additional utility operators are provided:
firstTick(u)
interval(u)
This operator returns true at the first tick of the clock of the expression, in which this operator
is called. The operator returns false at all subsequent ticks of the clock. The optional argument
u is only used for clock inference.
This operator returns the interval between the previous and present tick of the clock of the
expression, in which this operator is called and the clock of the optional argument u. At the
first tick of the clock the following is returned: a) if the specified clock interval is parametric,
this value is returned; b) otherwise the start value of the variable specifying the interval is
returned; c) for an event clock the additional startInterval argument to the event clock
constructor is returned. The interval is returned as a Real number.
[Example:
A discrete PI controller is parameterized with the parameters of a continuous PI controller, in order that the
discrete block is robust against changes in the sample period. This is achieved by discretizing a continuous PI
controller (here with an implicit Euler method):
block ClockedPI
parameter Real T "Time constant of continuous PI controller";
parameter Real k "Gain of continuous PI controller";
input Real u;
output Real y;
MCP <number> <short description> 7
Real x(start=0);
protected
Real Ts = interval(u);
equation
/* Continuous PI equations: der(x) = u/T; y = k*(x + u);
Discretization equation: der(x) = (x - previous(x))/Ts;
*/
when Clock() then
x = previous(x) + Ts/T*u;
y = k*(x + u);
end when;
end ClockedPI;
A continuous-time model is inverted, discretized and used as feedforward controller for a PI controller
(der(..), previous, interval are used in the same partition):
block MixedController
parameter Real T "Time constant of continuous PI controller";
parameter Real k "Gain of continuous PI controller";
input Real y_ref, y_meas;
Real y;
output Real yc;
Real z(start=0);
Real xc(start=1, fixed=true);
Clock c = Clock(Clock(0.1), solverMethod="ImplicitEuler");
protected
Real uc;
Real Ts = interval(uc);
equation
/* Continuous-time, inverse model */
uc = sample(y_ref, c);
der(xc) = uc;
/* PI controller */
z = if firstTick() then 0 else previous(z) + Ts/T*(uc - y_meas);
y = xc + k*(xc + uc);
yc = hold(y);
end MixedController;
]
8 MCP <number> <short description>
Chapter 17
State Machines
Chapter 18
Annotations
Chapter 19
Unit Expressions
Chapter 20
The Modelica Standard Library
Appendix A
Glossary
Appendix B
Modelica Concrete Syntax
MCP <number> <short description> 9
Appendix C
Modelica DAE Representation
Appendix D
Derivation of Stream Equations