In this section, we will recreate an interesting experiment [Berg] involving pendulums. If we create a series of pendulums with different natural frequencies and then start them all at the same position, what we will see is that they will oscillate at different frequencies. But if we remove any energy dissipation from the system, they will eventually all “reunite” at their initial position.
In general, the period between these “reunion” events is the least common multiple of the periods of all the pendulums in the system. We can choose the lengths of the pendulums to achieve a specific period between these “reunions”.
In this section, we will use arrays of components to build our subsystem model just like we did in our Spatially Distributed Heat Transfer example. But before we can create an array of pendulums, we need to first have a model of a single pendulum.
within ModelicaByExample.Subsystems.Pendula;
model Pendulum "A single individual pendulum"
import Modelica.Mechanics.MultiBody.Parts;
import Modelica.Mechanics.MultiBody.Joints;
parameter Modelica.SIunits.Position x;
parameter Modelica.SIunits.Mass m "Mass of mass point";
parameter Modelica.SIunits.Angle phi "Initial angle";
parameter Modelica.SIunits.Length L "String length";
parameter Modelica.SIunits.Diameter d=0.01;
Parts.Fixed ground(r={0,0,x}, animation=false)
annotation ...
Parts.PointMass ball(m=m, sphereDiameter=5*d)
annotation ...
Parts.BodyCylinder string(density=0, r={0,L,0}, diameter=d)
annotation ...
Joints.Revolute revolute(phi(fixed=true, start=phi),
cylinderDiameter=d/2, animation=false)
annotation ...
equation
connect(string.frame_a, ball.frame_a) annotation ...
connect(revolute.frame_b, ground.frame_b) annotation ...
connect(revolute.frame_a, string.frame_b) annotation ...
end Pendulum;
This particular model is using the Modelica.Mechanics.MultiBody
library.
This library not only includes many useful models of parts and joints commonly
found in mechanisms, but it also includes information about how to render those
parts. This allows Modelica tools to transform the simulated results of such a
model directly into a 3D animation of the system.
The components of the pendulum can be rendered as follows:
Now that we have an individual pendulum model, we can build a system of pendulums. If we want a system of pendulums where the period for a complete cycle of the system is seconds, we compute the length of the pendulum as:
where is Earth’s gravitational constant, is the number of pendulums, is the period of one complete cycle of the system and is the number of oscillations of the longest pendulum over seconds.
In Modelica, we could build such a system as follows:
within ModelicaByExample.Subsystems.Pendula;
model System "A system of pendula"
import Modelica.Constants.g_n;
import Modelica.Constants.pi;
parameter Integer n=15 "Number of pendula";
parameter Modelica.SIunits.Position x[n] = linspace(0,(n-1)*0.05,n);
parameter Modelica.SIunits.Time T = 54;
parameter Modelica.SIunits.Time X = 30;
parameter Modelica.SIunits.Length lengths[n] = { g_n*(T/(2*pi*(X+(n-i))))^2 for i in 1:n};
parameter Modelica.SIunits.Angle phi0 = 0.5;
Pendulum pendulum[n](x=x, each m=1, each phi=phi0, L=lengths)
annotation ...
inner Modelica.Mechanics.MultiBody.World world
annotation ...
end System;
There are two declarations of interest here. The first is the declaration of
the world
component. This is needed to provide a frame of reference for the
system as well as some key environmental parameters like the gravitational
constant to use in the system. In any given model there should only be one
world component in the system. Another very interesting declaration is the
pendulum
component:
Pendulum pendulum[n](x=x, each m=1, each phi=phi0, L=lengths)
Because pendulum
is an array of n
components, there will be
n
values for the x
, m
, phi
and L
parameters
associated with these pendulums. For example, if n=3
, then the
model will have 3 values for x
: pendulum[1].x
,
pendulum[2].x
and pendulum[3].x
. In the declaration of
pendulum
, we handle this in different ways for different
parameters. In the case of m
, we give each pendulum the same
value with the modification each m=1
. However, in the case of
L
(and x
), we supply an array of values, L=lengths
used to
initialize the parameters where the values in the lengths
array
are computed using the equation for pendulum lengths we introduced
earlier. We will give a more complete discussion on how to apply
modifications to arrays of components later in this chapter.
If we simulate this system, we get the following solution for the trajectory of each of the pendulums:
As we can see from this plot, although the pendulums oscillate at difference frequencies, their positions coincide at regular intervals. In fact, every 54 seconds they all simultaneously return to their initial positions.
This phenomenon can be more clearly visualized in three dimensions.
In this section, we have seen how arrays of components can be used, declared and modified. In this particular case, this allows us to specify the number of pendulums in our system and then simulate them to observe the peculiar behavior observed when we choose their lengths according to the equation specified earlier.
[Berg] | Richard E. Berg, “Pendulum waves: A demonstration of wave motion using pendula” http://dx.doi.org/10.1119/1.16608 |