| 1 | // Google-translated Bouncing Ball model word by word
|
|---|
| 2 | // This probably does not make much sense to a native speaker of Japanese, but at least it tests what it should...
|
|---|
| 3 |
|
|---|
| 4 | model '跳ねるボール'
|
|---|
| 5 | parameter Real e=0.7 "反発係数";
|
|---|
| 6 | parameter Real g=9.81 "重力加速度";
|
|---|
| 7 | Real '高さ'(start=1) "ボールの高さ";
|
|---|
| 8 | Real '速度' "ボールの速度";
|
|---|
| 9 | Boolean '飛行'(start=true) "trueの場合、ボールが飛んでいる場合、";
|
|---|
| 10 | Boolean '影響';
|
|---|
| 11 | Real '新しい速度';
|
|---|
| 12 | discrete Integer 'バウンスの数'(start=0);
|
|---|
| 13 | equation
|
|---|
| 14 | '影響' = '高さ' <= 0.0;
|
|---|
| 15 | der('速度') = if '飛行' then -g else 0;
|
|---|
| 16 | der('高さ') = '速度';
|
|---|
| 17 |
|
|---|
| 18 | when {'高さ' <= 0.0 and '速度' <= 0.0,'影響'} then
|
|---|
| 19 | '新しい速度' = if edge('影響') then -e*pre('速度') else 0;
|
|---|
| 20 | '飛行' = '新しい速度' > 0;
|
|---|
| 21 | reinit('速度', '新しい速度');
|
|---|
| 22 | 'バウンスの数'=pre('バウンスの数')+1;
|
|---|
| 23 | end when;
|
|---|
| 24 |
|
|---|
| 25 | end '跳ねるボール';
|
|---|