2.6 Creating a Hybrid Model in the WSM Package …
81
modeling of heterogeneous systems, the elements, and subsystems of which have a
different physical nature.
In the classical representation, the continuous behavior of the HS is described by
a system of differential or differential–algebraic equations. Discrete behavior is represented by logical predicates (finite automata) determining the states and conditions
of transitions between continuous states.
In the Modelica language, states with continuous behavior (if there are several) can
be described using the if statement, whereas for tracking events, the when statement
is usually used. It should be noted that the event is described by a logical expression
and is formed at that moment as soon as this expression changes the value from false
to true. If, in this case, the trigger condition for the event continues to be fulfilled, it
will not occur a second time until it returns from the trigger condition again.
2.6.1 Modelica Language Features to Describe Continuous
and Discrete Events
To describe hybrid models with multiple states, use the if statement. The if operator
allows you to switch between states that are described by different differential–
algebraic equations, if the condition.
The if statement generally has the following syntax:
if cond1 then
// This branch is used if cond1 == true
elseif cond2 then
// This branch is used if cond1 == false
and cond2 == true
// ...
elseif condn then
// This branch is used if all previous
conditions are false
// and condn == true
else
// If all conditions are false,
// then this branch is used
end if;
It is important to note that when the if operator is used, the number of equations
must be the same regardless of which branch is being executed (this is also the case
for elseif). One of the exceptions is the use of if within the original equation or
the initial section of the algorithm, where the else condition is not required, since
the number of equations should not be the same for both branches. Another notable
81
modeling of heterogeneous systems, the elements, and subsystems of which have a
different physical nature.
In the classical representation, the continuous behavior of the HS is described by
a system of differential or differential–algebraic equations. Discrete behavior is represented by logical predicates (finite automata) determining the states and conditions
of transitions between continuous states.
In the Modelica language, states with continuous behavior (if there are several) can
be described using the if statement, whereas for tracking events, the when statement
is usually used. It should be noted that the event is described by a logical expression
and is formed at that moment as soon as this expression changes the value from false
to true. If, in this case, the trigger condition for the event continues to be fulfilled, it
will not occur a second time until it returns from the trigger condition again.
2.6.1 Modelica Language Features to Describe Continuous
and Discrete Events
To describe hybrid models with multiple states, use the if statement. The if operator
allows you to switch between states that are described by different differential–
algebraic equations, if the condition.
The if statement generally has the following syntax:
if cond1 then
// This branch is used if cond1 == true
elseif cond2 then
// This branch is used if cond1 == false
and cond2 == true
// ...
elseif condn then
// This branch is used if all previous
conditions are false
// and condn == true
else
// If all conditions are false,
// then this branch is used
end if;
It is important to note that when the if operator is used, the number of equations
must be the same regardless of which branch is being executed (this is also the case
for elseif). One of the exceptions is the use of if within the original equation or
the initial section of the algorithm, where the else condition is not required, since
the number of equations should not be the same for both branches. Another notable
