LoginSignup
0
0

More than 5 years have passed since last update.

JModelicaでFluidパッケージを計算する

Last updated at Posted at 2018-11-20

JModelicaでFluidパッケージを計算する

JModelicaで最適化が出来ることを確認した
https://qiita.com/UedaShigenori/items/4452d95cfa440658163a

私はいまModelica Standar LibraryのFluidパッケージを使って計算しているため
Fluidパッケージが使えないと意味がない

簡単なモデルを回す EmptyTanks

FluidパッケージのExamplesに以下の簡単なモデルがある
image.png

JModelicaで実行する
実行の仕方は以下を参考にすれば出来る
https://qiita.com/UedaShigenori/items/4452d95cfa440658163a

以下のエラーメッセージが得られた

pyfmi.fmi.FMUException: Failed to update the events at time: 1.488260E-03.            : CVode

ソルバを変更する

JModelicaで選択可能なソルバ
https://jmodelica.org/downloads/UsersGuide-2.4.pdf
5.3.2.2. Options for Model Exchange FMUs

デフォルトはさっき計算が回らなかったCVode
image.png

変更・実行方法は以下

# 変更
opts['solver'] = "LSODAR"
# 実行
res = loadModel.simulate(options=opts)

ソルバ変更結果

以下のようにDopri5, LSODARだけが計算できた

# RungeKutta34の結果

pyfmi.fmi.FMUException: Failed to update the events at time: 4.868013E-03.


# Dopri5の結果

Final Run Statistics: ---

 Number of steps                       : 28
 Number of function evaluations        : 270
 Number of error test failures         : 5
 Number of state function evaluations  : 54
 Number of state events                : 2

Solver options:
  Iteration variable "der(pipe.mediums[1].p)" is missing sta
 Solver                  : Dopri5
 Tolerances (absolute)   : [  1.00000000e-06   3.00000000e-04   1.00000000e-06   3.00000000e-04]ms[2].p)" is missing sta
 Tolerances (relative)   : 0.0001
Warning in flattened model:
Simulation interval    : 0.0 - 50.0 seconds.ng start value!
Elapsed simulation time: 0.0130757042289 seconds.


# RodasOEDの結果
pyfmi.fmi.FMUException: Failed to update the events at time: 4.868013E-03.



# LSODARの結果

Final Run Statistics: ---

 Number of steps                       : 74
 Number of function evaluations        : 203
 Number of Jacobian evaluations        : 10
 Number of state function evaluations  : 139
 Number of state events                : 3

Solver options:

 Solver                  : LSODAR
 Absolute tolerances     : [  1.00000000e-06   3.00000000e-04   1.00000000e-06   3.00000000e-04]
 Relative tolerances     : 0.0001
 Starter                 : classical

Simulation interval    : 0.0 - 50.0 seconds.
Elapsed simulation time: 0.042390283661 seconds.


# ExplicitEulerの結果
pyfmi.fmi.FMUException: Failed to update the events at time: 4.542121E-05.

Dopri5の説明

陽解法の可変ソルバとのこと
This is an explicit runge-kutta method of order (4)5 due to Dormand & Prince (with stepsize control and dense output).

LSODARの説明

stiff, non-stiffを自動で切り替えるらしい。便利
Solver For Ordinary Differential Equations (ODE), Switching Automatically Between Stiff And Non-Stiff Methods And With Root Finding

少し複雑な問題を回す Coffeeモデル

もう少し複雑な問題に対してJModelicaがどこまで頑張ってくれるか確認する
以下に私が作成中のコーヒーの温度を計算するモデルがある
https://github.com/UedaShigenori/CoffeeTemperature

CoffeeTemperature.Test.CoffeeTest8クラスをソルバを変更して回す
結論から言うとInitializeの段階で躓いていた
OpenModelicaでは回るのだが・・・

# LSODARの結果
pyfmi.fmi.FMUException: Enter Initialize returned with an error. Enable logging for more information, (FMUModel(..., enable_logging=True)).

# Dopri5の結果
pyfmi.fmi.FMUException: Enter Initialize returned with an error. Enable logging for more information, (FMUModel(..., enable_logging=True)).

その後各変数などに初期値を入れて駄目だったがそれはまた別のお話

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