I would like to model an explictly time dependent differential equation in Modelica.
Say I would like to model
Real x(start=1);
der(x) = t;
in Modelica. What is the correct way to access the time variable t?
I would like to model an explictly time dependent differential equation in Modelica.
Say I would like to model
Real x(start=1);
der(x) = t;
in Modelica. What is the correct way to access the time variable t?
The time variable in Modelica is called time
and it is accessible in any model or block (but not packages, record, connectors or functions).
Also, instead of using the start
attribute I suggest using initial equations. So your complete model would look like this:
model FirstOrder
Real x;
initial equation
x = 1;
equation
der(x) = time;
end FirstOrder;
The equations in the initial equation
section are only applied to solve for initial values of states. The equation shown above is trivial, but you can do interesting stuff like:
model FirstOrder_IC2
Real x;
initial equation
x*x*x = 3.0*time+7.0;
equation
der(x) = time;
end FirstOrder_IC2;
The point here is that you can use other equations besides ones that directly specify the value of the state. The above initial equation is not "physically" interesting, but mathematically it is because it is both non-linear and time-varying (i.e. sensitive to the start time of the simulation).
© 2022 - 2024 — McMap. All rights reserved.