バックナンバーはこちら。
https://www.simulationroom999.com/blog/model-based-of-minimum-2-backnumber/
はじめに
前回はFMILibraryのサンプルプロジェクトのfmi2_import_cs_testのシミュレーション。
どうやら、シミュレーションステップとサンプリングを簡単に変えられそうです。
実際にはFMUにシミュレーション時間を指示して、細かくシミュレーション時間を進めながらサンプリングしているようである。
今回はステップとシミュレーション時間を変えてみて、
それの結果を確認してみることとする。
登場人物
博識フクロウのフクさん

イラストACにて公開の「kino_k」さんのイラストを使用しています。
https://www.ac-illust.com/main/profile.php?id=iKciwKA9&area=1
エンジニア歴8年の太郎くん

イラストACにて公開の「しのみ」さんのイラストを使用しています。
https://www.ac-illust.com/main/profile.php?id=uCKphAW2&area=1
fmi2_import_cs_testのシミュレーションステップとシミュレーション時間

前回のシミュレーションステップを20ms、シミュレ―ジョン時間を3秒に変えた。
fmi2_real_t hstep = 0.1;
fmi2_real_t tend = 2.0;
↓
fmi2_real_t hstep = 0.02;
fmi2_real_t tend = 3.0;
※ サンプルのBouncingBall2_cs.fmu内部の演算周期が0.01秒のため、それ以下の時間を指定するとうまくシミュレーションしてくれなくなる点に注意が必要。

というわけで、早速実行!!
シミュレーションステップとシミュレーション時間を変えたfmi2_import_cs_test実行結果

とりあえず、サンプリングしたデータのとこだけ抽出。
Ball height Ball speed
1.07902 3.8038
1.15411 3.6076
1.22528 3.4114
1.29253 3.2152
1.35585 3.019
1.41525 2.8228
1.47073 2.6266
1.52228 2.4304
1.56991 2.2342
1.61361 2.038
1.65339 1.8418
1.68924 1.6456
1.72117 1.4494
1.74918 1.2532
1.77326 1.057
1.79342 0.8608
1.80966 0.6646
1.82197 0.4684
1.83036 0.2722
1.83482 0.076
1.83536 -0.1202
1.83197 -0.3164
1.82466 -0.5126
1.81343 -0.7088
1.79827 -0.905
1.77919 -1.1012
1.75619 -1.2974
1.72926 -1.4936
1.69841 -1.6898
1.66363 -1.886
1.62493 -2.0822
1.5823 -2.2784
1.53575 -2.4746
1.48528 -2.6708
1.43088 -2.867
1.37256 -3.0632
1.31032 -3.2594
1.24415 -3.4556
1.17406 -3.6518
1.10004 -3.848
1.0221 -4.0442
0.940234 -4.2404
0.854445 -4.4366
0.764732 -4.6328
0.671095 -4.829
0.573534 -5.0252
0.472049 -5.2214
0.36664 -5.4176
0.257307 -5.6138
0.14405 -5.81
0.026869 -6.0062
0.0305215 2.95405
0.0886215 2.75785
0.142797 2.56165
0.193049 2.36545
0.239377 2.16925
0.281781 1.97305
0.320261 1.77685
0.354817 1.58065
0.385449 1.38445
0.412157 1.18825
0.434941 0.99205
0.453801 0.79585
0.468737 0.59965
0.479749 0.40345
0.486837 0.20725
0.490001 0.01105
0.489241 -0.18515
0.484557 -0.38135
0.475949 -0.57755
0.463417 -0.77375
0.446961 -0.96995
0.426581 -1.16615
0.402277 -1.36235
0.374049 -1.55855
0.341897 -1.75475
0.305821 -1.95095
0.265821 -2.14715
0.221897 -2.34335
0.174049 -2.53955
0.122277 -2.73575
0.0665815 -2.93195
0.0069615 -3.12815
0.0161313 1.51503
0.0454508 1.31883
0.0708463 1.12263
0.0923178 0.926425
0.109865 0.730225
0.123489 0.534025
0.133188 0.337825
0.138964 0.141625
0.140815 -0.054575
0.138743 -0.250775
0.132746 -0.446975
0.122826 -0.643175
0.108981 -0.839375
0.0912128 -1.03557
0.0695203 -1.23177
0.0439038 -1.42797
0.0143633 -1.62417
0.00861138 0.763037
0.0228911 0.566837
0.0332469 0.370637
0.0396786 0.174437
0.0421864 -0.0217625
0.0407701 -0.217963
0.0354299 -0.414163
0.0261656 -0.610363
0.0129774 -0.806563
2.22658e-16 0.501381
0.00904663 0.305181
0.0141693 0.108981
0.0153679 -0.0872187
0.0126425 -0.283419
0.00599313 -0.479619
1.50062e-16 0.337909
0.00577719 0.141709
0.00763038 -0.0544906
0.00555956 -0.250691
9.92297e-17 0.223445
0.00348791 0.0272453
0.00305181 -0.168955
8.10806e-17 0.182577
0.00267055 -0.0136227
0.00141709 -0.209823
0.00153961 0.0558613
0.00167584 -0.140339
7.47266e-17 0.168269
0.00238439 -0.0279307
0.000844773 -0.224131
0.00161115 0.0630153
0.00189046 -0.133185
7.31381e-17 0.164692
0.00231285 -0.0315077
0.000701693 -0.227708
0.00162904 0.0648038
0.00194411 -0.131396
7.2741e-17 0.163798
0.00229496 -0.0324019
0.000665923 -0.228602
0.00163351 0.065251
0.00195753 -0.130949
7.26417e-17 0.163575
0.00229049 -0.0326255
0.000656981 -0.228825
0.00163463 0.0653627
0.00196088 -0.130837
7.26169e-17 0.163519
0.00228937 -0.0326814
0.000654745 -0.228881
グラフ表示

明かなに細かくなったぞ!

じゃ、それをグラフにしてみよう。

グラフにしてみた。


一応、100ms周期版も


うん。
サンプリング制度が上がって、シミュレーション時間も3秒に伸びてる。

と、こんな感じでシミュレーションの精度や時間の調整は割と簡単ってことだねー。
まとめ

まとめだよ。
- fmi2_import_cs_testのシミュレーションステップとシミュレーション時間を変えてみた。
- 上記のシミュレーションを実行。
- 精度を細かくしたのと、シミュレーション時間を延ばしたことでデータ量は増えた。
- グラフで確認。
- 前回の100msサンプリングと同じ特性で精度、時間が変わっていた。
バックナンバーはこちら。
コメント