aboutsummaryrefslogtreecommitdiffstats
path: root/modelica-parser-lalrpop/examples/modelica_models/breaking_pendulum.mo
blob: 87b58d3e60c2ccfa288eff871a37a78a557ef567 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
model BreakingPendulum3
 parameter Real m=1, g=9.81;
 input Boolean Broken;
 input Real u;
 Real pos[2], vel[2];
 constant Real PI=3.141592653589793;
 Real phi(start=PI/4), phid;
 Real L=0.5, Ldot;
equation
 pos = [L*sin(phi); -L*cos(phi)];
 vel = der(pos);
 phid = der(phi);
 Ldot = der(L);
 0 = if not Broken then [
 // Equations of pendulum
 m*der(phid) + m*g*L*sin(phi) - u;
 der(Ldot)]
 else
 // Equations of free flying mass
 m*der(vel) = m*[0; -g];
end BreakingPendulum3;