Help us understand the problem. What is going on with this article?

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

More than 1 year has passed since last update.

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).

https://docs.scipy.org/doc/scipy-0.18.1/reference/generated/scipy.integrate.ode.html

LSODARの説明

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

https://www.rdocumentation.org/packages/deSolve/versions/1.21/topics/lsodar

少し複雑な問題を回す 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)).

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

UedaShigenori
CAEの普及と活用に興味があります。 プロフィールは以下から https://connpass.com/user/uedashige/
https://github.com/UedaShigenori
Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Comments
No comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
ユーザーは見つかりませんでした