aboutsummaryrefslogtreecommitdiffstats
path: root/modelica-parser-lalrpop/examples/modelica_other/breaking_pendulum.mo
blob: f719a04259a3f765bdbb08231940b3e785e6d369 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
record PendulumData
    parameter Real m, g, L;
end PendulumData;

partial model BasePendulum
    PendulumData p;
    input
    Real u;
    output Real pos[2], vel[2];
end BasePendulum;

block Pendulum
    extends BasePendulum;
    constant Real PI=3.141592653589793;
    output
    Real phi(start=PI/4), phid;
equation
    phid = der(phi);
    p.m*p.L*p.L*der(phid) + p.m*p.g*p.L*sin(phi) = u;
    pos = [p.L*sin(phi); -p.L*cos(phi)];
    vel = der(pos);
end Pendulum;

block BrokenPendulum
    extends BasePendulum;
equation
    vel = der(pos);
    p.m*der(vel) = p.m*[0; -p.g];
end BrokenPendulum;