【问题标题】:Dymola - Continuous Input for State MachineDymola - 状态机的连续输入
【发布时间】:2014-06-17 17:13:11
【问题描述】:

尝试在 Dymola 中使用状态机时(顺便说一句:我绝对是新手),我无法将正弦曲线声明为输入变量。我收到以下第一条错误消息(我只粘贴开头):

Continuous time parts and discrete parts don't decompose for:
_StateMachines.state1.activeReset
_StateMachines.state1.act... 

还有第二个:

Decomposition in base clocks failed.
See the file dsmodelBaseClockDecomposition.mof.

我知道问题是由于尝试使用连续时间变量(即正弦函数)作为离散块(即状态机)的输入而引起的。

如何将正弦函数与状态机连接起来?

编辑:

我的代码是这样的(我已经删除了注释):

model ZLG3_v2 "2nd Version of ZLG3"

  inner Real T_2(start=283);
  Real T_ZuL(start=295);

  model State1
    outer output Real T_2;

  equation
    T_2=previous(T_2)+2;

  end State1;
  State1 state1;

  model State3
    outer output Real T_2;
  equation
    T_2=previous(T_2)-1;

  end State3;
  State3 state3;

  Modelica.Blocks.Sources.Sine sine(freqHz=0.25, offset=305);
equation
//T_ZuL = 295;
T_ZuL=sine.y;

  initialState(state1);
  transition(
    state3,
    state1,T_2 <= T_ZuL,
    immediate=false,
    reset=true,
    synchronize=false,
    priority=1);
  transition(
    state1,
    state3,T_2 > T_ZuL,
    immediate=false,
    priority=1,
    reset=true,
    synchronize=false);
end ZLG3_v2;

两行

//T_ZuL = 295;
T_ZuL=sine.y;

感兴趣。使用 sine.y 的(当前未注释的)方程会出现错误消息。反之,一切正常。

非常感谢您并致以最诚挚的问候。

【问题讨论】:

    标签: state continuous modelica dymola


    【解决方案1】:

    问题在于您必须明确推断出的时钟,否则您在具有自己的离散时钟的离散状态机中使用连续信号 (sine.y)。用状态机的时钟对 sin 信号进行采样,一个采样块就足够了:

    model ZLG3_v3 "3rd Version of ZLG3"
      inner Real T_2(start=283);
      State1 state1;
      State2 state2;
      Modelica.Blocks.Logical.Greater greater;
      Modelica.Blocks.Sources.RealExpression realExpression(y=T_2);
      Modelica.Blocks.Sources.Sine sin(y(start=295),freqHz=0.25, offset=305);
      Modelica_Synchronous.RealSignals.Sampler.Sample sample;
      model State1
        outer output Real T_2;
      equation 
        T_2=previous(T_2)+2;
      end State1;
      model State2
        outer output Real T_2;
      equation 
        T_2=previous(T_2)-1;
      end State2;
    equation 
      transition(
        state2,
        state1,greater.y,immediate=true,reset=true,synchronize=false,priority=1);
      transition(
        state1,
        state2,not greater.y,immediate=true,reset=true,synchronize=false,priority=1);
      connect(realExpression.y, greater.u2);
      connect(sin.y, sample.u);
      connect(sample.y, greater.u1);
    end ZLG3_v3;
    

    编辑:

    我注意到状态机本身存在问题,在具有与转换触发器相同的真实输入信号的状态机快照下方,没有错误检查并且模拟:

    【讨论】:

    • 感谢您的回答!该解决方案工作正常。我只需要补充一句,'initialState(state1);'在方程部分丢失,我不得不将立即设置为假,否则会发生另一个错误。非常感谢。
    猜你喜欢
    • 2013-09-18
    • 1970-01-01
    • 1970-01-01
    • 2020-11-24
    • 2023-04-02
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-02-11
    相关资源
    最近更新 更多