1
私はmodelicaを学ぼうとしており、チュートリアル:Peter Fritzson氏の「OpenModelica OpenModelicaによるオブジェクト指向モデリングとシミュレーション入門」の簡単な例をコーディングして始めました。Link私はダイモラと一緒に働いています。 Moon Landingと呼ばれる1つの例があります。これは実行できません。 シミュレーションを開始した後、私は変数をプロットできません。 私のコードは次のとおりです。Modelica Example MoonLanding
model Example
class Rocket "rocket class"
parameter String name;
Real mass(start = 1038.3);
Real altitude(start = 59404);
Real velocity(start = -2003);
Real thrust;
Real acceleration;
Real gravity;
parameter Real massLossRate=0.000277;
equation
acceleration = (thrust-mass*gravity)/mass;
der(mass) = -massLossRate * abs(thrust);
der(altitude)=velocity;
der(velocity)=acceleration;
end Rocket;
class CelesticalBody
constant Real g = 6.672e-11;
parameter Real radius;
parameter String name;
parameter Real mass;
end CelesticalBody;
class MoonLanding
parameter Real force1 = 36350;
parameter Real force2 = 1308;
protected
parameter Real thrustEndTime = 210;
parameter Real thrustDecreaseTime = 43.2;
public
Rocket apollo(name="apollo13");
CelesticalBody moon(name="moon",mass = 7.382e22, radius=1.738e6);
equation
apollo.thrust = if (time < thrustDecreaseTime) then force1
else if
(time < thrustEndTime) then force2
else 0;
apollo.gravity = moon.g*moon.mass/(apollo.altitude+moon.radius)^2;
end MoonLanding;
end Example;
誰かが間違いの可能性があることを知っていますか?
package Example
model Rocket "rocket class"
...
end Rocket;
model CelestialBody
...
end CelestialBody
model MoonLanding
...
end MoonLanding;
end Example;
:@ルネ・ジャスト・ニールセンは、あなたがExample.MoonLandingをシミュレートするために持っていて、例パッケージ(ないモデル)を作成し、MoonLanding(ロケット、CelestialBody)モデル(ないクラス)べきで示されているように
私のために働きます(コードをコピーし、MoonLandingクラスを230秒間シミュレートしました)。私はすべての変数にアクセスできます。シミュレーションタブでクラス(apollo、moon)が見えますか? –
お返事ありがとうございます。 私は常に、すべてのクラスを含むモデル全体をシミュレートしようとしました。 しかし、MoonLandingクラスだけをシミュレートする必要があります。 モデル全体をシミュレートするときになぜ機能しないのでしょうか? –
"モデル"全体は実際には3つの "モデル"を含む "パッケージ"です。モデル、パッケージ、ブロックなどは特別なModelicaクラスです。 –