0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

[Modelica]functionの非因果性

Posted at

すごく小さいTipsだが、functionで定義するとalgorithmセクションで書かれていても非因果となる。

例えば、

y=x+1

という式があったとしてalgorithmで書きたいとする。

以下のような、y=f(x)の式をy=function(x)で書けば非因果となる。つまり、yに値を代入するとxが求まる。便利。
計算順序が決まるので計算も安定するという噂もある。

model a

  Real x;
  Real y;
  
    function func
      input Real x;
      output Real y;
    algorithm
      y:=x+1;
      
    end func;
  
  equation
  y=1;
  y=func(x);

end a;

計算結果はちゃんと x= 0 となる。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?