Modelicaの基本文法

一般文法(部分) 

  • 変数宣言
    • タイプ Real、、、 IntegerBoolean
    • プレフィックス:  inputoutputparameter
    • 可視性:  publicprotected
  • 算術演算:  +-*/
  • ノート:
    • 一行コメント:// this is a line comment
    • 複数行のコメント:/* this is a block comment */
    • 引用されたコメント:Real foo "A special comment";
  • 配列:
    • x[3]:1次元配列(3要素ベクトル)
    • x[3, 3]: 2次元配列(3x3行列)
  • 論理演算子: andornot<><><=>=
  • 条件文:
    if <condition> then
    ...
    elseif <condition> then
    ...
    else
    ...
    end if;
  • ループステートメント:
    for i in 1:10 loop
        ...
    end for;

    関数の構文

  • パラメータ宣言:input
  • 出力ステートメント:output
  • 代入演算子::=
  • 特徴(一部):
    • 上から下へ順番に実行
    • パラメータ参照モードは読み取り専用です。つまり、入力パラメータの値は関数内で変更できません。

関数の構文と呼び出し

  • パーティション識別子
    • 機能内容:algorithm
    • ローカル変数:protected
  • パラメータのデフォルト値:input Real tol = 1e-5 "Input with default value"
  • 複数の出力変数
  • 移行

関数テンプレート

function <函数名>
  input  TypeI1 in1;
  input  TypeI2 in2;
  input  TypeI3 in3 = <默认值> "注释" annotation(...);
  ...
  output TypeO1 out1;
  output TypeO2 out2 = <默认值>;
protected
  <局部变量>
  ...
algorithm
  <语句>
  ...
end <函数名>;

おすすめ

転載: blog.csdn.net/qq_25368751/article/details/131354530