Spring Mass System
Spring Mass System
1 Problem statement
Given is a spring-mass system attached to a movable ceiling. The masspoint has to reach the
target. This can be achieved by controlling the acceleration of the movable ceiling such that
vibrations are induced and the amplitude of the vibration is built up.
The mass-spring system consists of three subsystems: the ceiling, the spring and a masspoint.
Each subsystem contains at least one connector of type flange.
connector flange
Real y; // y-position
flow Real F; // force
end flange;
1
model ceiling
flange down;
Real y( start=1);
Real v( start=0);
parameter Real u; // acceleration == control variable
equation
down.y = y;
der(y)=v;
der(v)=u;
end ceiling;
model masspoint
flange top;
parameter Real m = 1;
Real y (start=0);
Real v (start=0);
Real F;
parameter Real g=9.81;
equation
y=top.y;
F=-top.F-m*g;
der(y)=v;
m*der(v)=F;
end masspoint;
model spring
flange top;
flange down;
parameter Real l0=1;
parameter Real k=100;
Real l;
equation
l = top.y - down.y;
top.F = k*(l-l0);
down.F = top.F;
end spring;
model spring_mass_system
ceiling ceil;
masspoint mass;
spring sp;
2
Real timevar(start=0);
equation
connect(ceil.down,sp.top);
connect(sp.down, mass.top);
der(timevar)=1;
end spring_mass_system;
For the optimization an additional variable for the elapsed time is introduced. The flat model
with no model structure is given by
model spring_mass_system
Real ceil.down.y;
Real ceil.down.F;
Real ceil.y(start = 1);
Real ceil.v(start = 0);
Real mass.top.y;
Real mass.top.F;
Real mass.y;
Real mass.v;
Real mass.F;
Real sp.top.y;
Real sp.top.F;
Real sp.down.y;
Real sp.down.F;
Real sp.l;
Real timevar(start = 0);
equation
ceil.down.y = ceil.y;
der(ceil.y) = ceil.v;
der(ceil.v) = ceil.u;
mass.y = mass.top.y;
mass.F = -(mass.top.F+mass.m*mass.g);
der(mass.y) = mass.v;
mass.m*der(mass.v) = mass.F;
sp.l = sp.top.y-sp.down.y;
sp.top.F = sp.k*(sp.l-sp.l0);
sp.down.F = sp.top.F;
der(timevar) = 1;
ceil.down.F+sp.top.F = 0;
sp.top.y = ceil.down.y;
3
mass.top.F+sp.down.F = 0;
sp.down.y = mass.top.y;
end spring_mass_system;
resulting into a DAE with 17 scalar unknowns and 17 scalar equations. The optimization problem
is given by
min timevar(T )
ceil.u(t),T
s.t. model equations,
− 2 ≤ ceil.u(t) ≤ 2,
0.9 ≤ ceil.y(t) ≤ 1.1,
mass.y(T ) = −0.5.
The Figures 2 and 3 show trajectories of a feasible solution of the optimization problem.
2 1.1
PEND.CEIL.U PEND.CEIL.Y
1.5
1.05
1
0.5
1
0.95
−0.5
−1
0.9
−1.5
−2 0.85
0 0.5 1 1.5 2 2.5 0 0.5 1 1.5 2 2.5
0.2 0.4
PEND.MASS.Y PEND.CEIL.V
0.3
0.1
0.2
0
0.1
−0.1
0
−0.2 −0.1
−0.2
−0.3
−0.3
−0.4
−0.4
−0.5
−0.5
−0.6 −0.6
0 0.5 1 1.5 2 2.5 0 0.5 1 1.5 2 2.5