Modelica when 语句中离散状态机变量的方程太多
Too many equations for discrete state machine variables in when statements in Modelica
我有一个人为设计的 Modelica 模型,其中有一个由多个 when
语句操纵的状态机变量:
model WhenExample
type State = enumeration(first, second, third);
State state;
initial equation
state = State.first;
equation
when sample(0, 1) then
state = State.second;
end when;
when sample(0, 3) then
state = State.third;
end when;
end WhenExample;
在 OpenModelica OMC 下编译时,出现以下错误:
[1] 16:46:39 Symbolic Error
Too many equations, over-determined system. The model has 2 equation(s) and 1 variable(s).
这有点有意义,因为我 做 我的单个 state
变量有两个方程。然而,这些方程只适用于离散的时间点,对吧?
我是否需要确保特定变量的所有 "manipulations" 只发生在单个 when
语句中?
参见 Modelica 规范,第 8.5 节事件和同步:
https://www.modelica.org/documents/ModelicaSpec33Revision1.pdf
在第 8.6 节之前有一个示例应该对您有所帮助。
下面给出了一些基于此的代码:
model WhenExample
parameter Integer multiplySample = 3;
Boolean fastSample, slowSample;
Integer ticks(start=0);
type State = enumeration(first, second, third);
State state(start = State.first);
equation
fastSample = sample(0,1);
algorithm
when fastSample then
ticks := if pre(ticks) < multiplySample then pre(ticks)+1 else 0;
slowSample := pre(ticks) == 0;
state := State.second;
end when;
when slowSample then
state := State.third;
end when;
end WhenExample;
我有一个人为设计的 Modelica 模型,其中有一个由多个 when
语句操纵的状态机变量:
model WhenExample
type State = enumeration(first, second, third);
State state;
initial equation
state = State.first;
equation
when sample(0, 1) then
state = State.second;
end when;
when sample(0, 3) then
state = State.third;
end when;
end WhenExample;
在 OpenModelica OMC 下编译时,出现以下错误:
[1] 16:46:39 Symbolic Error
Too many equations, over-determined system. The model has 2 equation(s) and 1 variable(s).
这有点有意义,因为我 做 我的单个 state
变量有两个方程。然而,这些方程只适用于离散的时间点,对吧?
我是否需要确保特定变量的所有 "manipulations" 只发生在单个 when
语句中?
参见 Modelica 规范,第 8.5 节事件和同步: https://www.modelica.org/documents/ModelicaSpec33Revision1.pdf
在第 8.6 节之前有一个示例应该对您有所帮助。 下面给出了一些基于此的代码:
model WhenExample
parameter Integer multiplySample = 3;
Boolean fastSample, slowSample;
Integer ticks(start=0);
type State = enumeration(first, second, third);
State state(start = State.first);
equation
fastSample = sample(0,1);
algorithm
when fastSample then
ticks := if pre(ticks) < multiplySample then pre(ticks)+1 else 0;
slowSample := pre(ticks) == 0;
state := State.second;
end when;
when slowSample then
state := State.third;
end when;
end WhenExample;