バックナンバーはこちら。
https://www.simulationroom999.com/blog/model-based-of-minimum-2-backnumber/
はじめに
前回、「Modelicaのソースコードに変数を設置」の効能として
「シミュレーションの試行回数の引き上げ」を説明した。
というわけで今回は
- OpenModelica Connecter Editor上の見え方
- シミュレーション
- パラメータ変更後の再シミュレーション
をやってみる。
登場人物
博識フクロウのフクさん
![指差しフクロウ](https://www.simulationroom999.com/blog/wp-content/uploads/2020/05/指差しフクロウ.png)
イラストACにて公開の「kino_k」さんのイラストを使用しています。
https://www.ac-illust.com/main/profile.php?id=iKciwKA9&area=1
エンジニア歴8年の太郎くん
![技術者太郎](https://www.simulationroom999.com/blog/wp-content/uploads/2020/05/技術者01アップ.png)
イラストACにて公開の「しのみ」さんのイラストを使用しています。
https://www.ac-illust.com/main/profile.php?id=uCKphAW2&area=1
まずはOpenModelica Connecter Editor上の見え方
![フクさん](https://www.simulationroom999.com/blog/wp-content/uploads/2020/05/指差しフクロウ.png)
Modelicaコードを修正したわけだけど、
それがOpenModelica Connecter Editor上でどのように見えているか確認してみよう。
![太郎くん](https://www.simulationroom999.com/blog/wp-content/uploads/2020/05/「技術者a」13アップ.png)
え?見え方が変わるの?
![フクさん](https://www.simulationroom999.com/blog/wp-content/uploads/2020/05/お休みフクロウ.png)
まぁパラメータに関わるところだけね。
元々の見え方
![constantForce1、constantForce2、mass、-1N、2N、m=1kg](https://www.simulationroom999.com/blog/wp-content/uploads/2021/06/05_masstestモデル.png)
コード修正後
![constantForce1、constantForce2、mass、Force1 N、Force2 N、m=1kg](https://www.simulationroom999.com/blog/wp-content/uploads/2021/06/02_masstestモデルコード修正後.png)
![太郎くん](https://www.simulationroom999.com/blog/wp-content/uploads/2020/05/技術者03アップ.png)
あ、なるほど。
元々の方は即値が入ってたけど、
コード修正後は変数を指定してるから、
その変数名がOpenModelica Connecter Editor上からも見えるってことか。
こういうのが見えるってのは便利だね。
次にシミュレーションしてみる
![フクさん](https://www.simulationroom999.com/blog/wp-content/uploads/2020/05/指差しフクロウ.png)
じゃ、シミュレーションしてみようか。
変数を間に置いたとは言え、初期値は一緒なんで
同じ結果になるはずだけど。
![太郎くん](https://www.simulationroom999.com/blog/wp-content/uploads/2020/05/技術者02アップ.png)
うん。
同じ結果になったね。
![Auto Scale、Fit in View、Save、Print、Grid、Detailed Grid、No Grid、Log X、Log Y、Setup、変数ブラウザ、masstest、constantForce1、constantForce2、mass、L、Length of component, from left flange to right flange (= flange_b.s - flange_a.s)、Absolute acceleration of component、der(Absolute position of center of component (s = flange_a.s + L/2 = flange_b.s - L/2))、der(Absolute velocity of component)、Mass of the sliding mass、Absolute position of center of component (s = flange_a.s + L/2 = flange_b.s - L/2)、Priority to use s and v as states、Absolute velocity of component](https://www.simulationroom999.com/blog/wp-content/uploads/2021/06/03_シミュレーション結果-1024x422.png)
![太郎くん](https://www.simulationroom999.com/blog/wp-content/uploads/2020/05/「技術者a」13アップ.png)
で、ちょっと気になったのが、
変数ブラウザのところに
今回ソースコード上に追加した
Force1とForce2が見えてるね?
![太郎くん](https://www.simulationroom999.com/blog/wp-content/uploads/2020/05/技術者03アップ.png)
もしかして、これって書き換えられるのか?!
![フクさん](https://www.simulationroom999.com/blog/wp-content/uploads/2020/05/まるフクロウ.png)
その通り。
正解だ。
変数を書き換えてからシミュレーションしてみる。
![フクさん](https://www.simulationroom999.com/blog/wp-content/uploads/2020/05/指差しフクロウ.png)
じゃ、変数ブラウザのForce1を\(-1[N]\)から\(-3[N]\)にして
再シミュレーションのボタンを押してみよう。
![OpenModelica、再シミュレーション、再シミュレーションのセットアップ、新規プロットウィンドウ](https://www.simulationroom999.com/blog/wp-content/uploads/2021/06/04_再シミュレーション.png)
![太郎くん](https://www.simulationroom999.com/blog/wp-content/uploads/2020/05/技術者02アップ.png)
こんな結果になった。
![Auto Scale、Fit in View、Save、Print、Grid、Detailed Grid、No Grid、Log X、Log Y、Setup、変数ブラウザ、masstest、constantForce1、constantForce2、mass、L、Length of component, from left flange to right flange (= flange_b.s - flange_a.s)、Absolute acceleration of component、der(Absolute position of center of component (s = flange_a.s + L/2 = flange_b.s - L/2))、der(Absolute velocity of component)、Mass of the sliding mass、Absolute position of center of component (s = flange_a.s + L/2 = flange_b.s - L/2)、Priority to use s and v as states、Absolute velocity of component](https://www.simulationroom999.com/blog/wp-content/uploads/2021/06/05_再シミュレーション結果-1024x522.png)
![太郎くん](https://www.simulationroom999.com/blog/wp-content/uploads/2020/05/技術者03アップ.png)
モデルチェック、コンパイルが不要だから
すぐにシミュレーションが出来て結果が見れたね。
これが変数を使った場合の効能か!
![フクさん](https://www.simulationroom999.com/blog/wp-content/uploads/2020/05/お休みフクロウ.png)
こういうちょっとしたテクニックを知ってるだけでいろいろ効率化ができるってことだねー。
![太郎くん](https://www.simulationroom999.com/blog/wp-content/uploads/2020/05/技術者01アップ.png)
なるほどー。
しかも大した手間もかからないし、勉強になったよー。
まとめ
![フクさん](https://www.simulationroom999.com/blog/wp-content/uploads/2020/05/指差しフクロウ.png)
まとめだよ。
- Modelicaコードで変数追加後のOpenModelica Connecter Editor上の見え方確認。
- まずは普通にシミュレーション。
- 変数ブラウザで変数を書き換えたあとに再シミュレーション。
- モデルチェック、コンパイル無しで即シミュレーション結果が得られた。
- ちょっとしたテクニックをしってるだけで効率化可能。
バックナンバーはこちら。
コメント