Application Center - Maplesoft

App Preview:

Visualizing free and forced harmonic oscillations

You can switch back to the summary page by clicking here.

Learn about Maple
Download Application


 

forced_oscillations.mws

Visualizing Free and Forced Harmonic Oscillations using Maple V R5

Harald Pleym

Telemark College, Department of Technology

Kjolnes Ring 56, 3914 Porsgrunn, Norway

harald.pleym@hit.no

Abstract

This paper focuses on how the symbolic, numerical and graphical power of the computer algebra system Maple V Release 5 can be used to explore and visualize with animation free harmonic motion with and without damping and vibration of a mass-spring system forced by an external sharp blow. Dirac's delta function is used to model the external force that acts for a very short period of time. It is also demonstrated how displacement resonance in a forced oscillations readily can be obtained from the transfer function of the system represented by a second order differential equation. And the information contained in the system frequency response may also be conveniently displayed in animated graphical form.

Introduction

At Telemark College, Department of Technology in Porsgrunn, Norway we have incorporated the use of the computer algebra system Maple V in the engineering mathematics curriculum from August 1995. With the powerful software program including graphical, symbolic and numerical techniques, Maple V Release 5 is the ideal program to make mathematics more relevant and motivating for engineering students and an excellent demonstration tool for the classroom. The use of Maple has changed the way I teach and hopefully the way the students learn. I now have the opportunity to emphasize the learning of concepts, the visualizatione of concepts and the solution of more realistic engineering applications.

Many of the phenomena we observe in everyday life have a periodic motion. And in many cases the periodic motion is maintained by a periodic driving force. For these forced oscillations the amplitude depends on the frequency of the driving force. There is usually some frequency of the driving force at which the oscillations have their maximum amplitude. This occur when the natural frequency of the vibrating system and the frequency of the driving force are approximately equal. This phenomenon of resonance plays an important role in almost every branch of physics. And the avoidance of destructive resonance vibrations is an important factor in the design of mechanical systems of all types.

Application of differential equations plays an important role in science and engineering. And the most important step in determining the natural frequency of vibration of a system is the formulation of its differential equation. The purpose of this article is to demonstrate how Maple can be used to investigate and visualize with animations:

- simple harmonic motion of a mass-spring system
- the response of a mechanical system (mass-spring system) to an impulse function
- the displacement resonance in forced oscillations

Animation

Coding in Maple does not require expert programmimg skills, so writing a Maple program deals with putting a proc ( ) and an end around a sequence of commands. And it is pretty easy to put prewitten routines together from Maples powerful bulding blocks and plotting facilities. The plottools package provides many useful commands for producing plotting objects, which can be scaled, translated and rotated. The following Maple codes will be used in the coming sections. The first prosedure animate a spring-mass system with and without a dashpot, and the second animate the response to a rectangular pulse by a linear differential second order equation.


Because it is impossible to show animation on paper, the animation figures shows 4 consecutive frames. The animations in this paper can be seen live on the Journal's Web site.

Maple code for a mass-spring system

m: mass, r: damping constant, k: spring constant, x1,x2: positions of the spring
x0 = x(0), xp0=D(x)(0): initial conditions, f: driving force, n: number of frames

> mass_spring:=proc(m,r,k,x1,x2,x0,xp0,tk,f,n )
local mass,deq,init,sol,xk,xu,plt1,plt2,plt,pltxk,rect,base,spring,
spring1,rod,cylinder, piston,fluid,dashpot;
with(plots):with(plottools):
spring:=proc(x1,x2,n) #procedure for the spring
local p1,p2,p3,p4,pn_1,pn,p;
p1:=[x1,0];
p2:=[x1+0.25,0];
p3:=[x2-0.25,0];
p4:=[x2,0];
p:=i->[x1+0.25+(x2-x1-0.5)/n*i,(-1)^(i+1)*0.5];
plot([p1,p2,seq(p(i),i=1..n-1),p3,p4],thickness=2,color=aquamarine);
end:
spring1:=x2->spring(x1,x2,12);
rect:=t->translate(rectangle([-0.2,-0.2],[0.2,0.2],color=red),t,xk(t)+x2+1);
#rect: display the position of the mass on the displacement curve x(t)
mass:=x2->rectangle([x2,-1],[x2+2,1],color=red):
if x0=0 and xk(0.1)=0 then
xu:=1.5
elif x0=0 and xk(0.1)<>0 then
xu:=5.0;
else
xu:=x0;
fi;
rod:=x2->plot([[x2+2,0],[x2+2.5+2*xu,0]],color=grey,thickness=2);
cylinder:=plot([[x2+2.5+xu,-1],[x2+2.5+xu,1],[x2+3.5+3*xu,1],[x2+3.5+3*xu,-1],
[x2+2.5+xu,-1]],color=tan,thickness=2);
piston:=x2->rectangle([x2+2.5+2*xu,-1],[x2+3+2*xu,1],color=grey);
fluid:=rectangle([x2+2.5+xu,-1],[x2+3.5+3*xu,1],color=blue);
dashpot:=x2->display(rod(x2),cylinder,piston(x2),fluid);
deq:=m*diff(x(t),t$2)+r*diff(x(t),t)+k*x(t)=f(t);
print(deq);
init:=x(0)=x0, D(x)(0)=xp0:
sol:=dsolve({deq,init},x(t));
print(combine(simplify(sol)));
xk:=unapply(rhs(sol),t);
#xk=x(t) : the displacement of mass
pltxk:=plot([xk(t)+x2+1,x2+1],t=0..max(tk,x2+4+3*xu)+0.5,
color=[blue,grey],numpoints=400);
base:=plot(-1.1,t=0..max(tk,x2+4+3*xu)+0.5,color=brown,thickness=4);
if r=0 then #undamped case
plt1:=x->translate(display(spring1(x2+x),mass(x2+x),base),0,-3);
else #with damping
plt1:=x->translate(display(spring1(x2+x),mass(x2+x),dashpot(x2+x),base),0,-3);
fi;
plt2:=i->display(pltxk,rect(tk/n*i));
plt:=i->display(plt1(xk(tk/n*i)),plt2(i));
display(seq(plt(i),i=0..n),insequence=true,args[11..nargs]);
end:

Maple code for a rectangular pulse

m: mass, r: damping constant, k: spring constant,
a: constant in the impulse function
delta(t-a) ,
eps: width
epsilon of a rectangular pulse , n: number of frames

> impulse_func:=proc(m,r,k,a,eps,n)
local h,dlign1,dlign2,sol1,sol2,plt1,plt2,pltd,plt,txt,txtd,kloss,e;
with(plots):
alias(u=Heaviside):
h:=eps->(u(t-a)-u(t-a-eps))/eps;
dlign1:=eps->m*diff(y(t),t,t)+r*diff(y(t),t)+k*y(t)=5*h(eps);
dlign2:=m*diff(y(t),t,t)+r*diff(y(t),t)+k*y(t)=5*Dirac(t-a);
print(dlign1(eps), epsilon=eps);
print(dlign2);
sol1:=eps->simplify(dsolve({dlign1(eps),y(0)=0,D(y)(0)=0},y(t)));
sol2:=dsolve({dlign2,y(0)=0,D(y)(0)=0},y(t));
e:= textplot([6,1.3,convert([101],bytes)], font=[SYMBOL,12]):
txt:=eps->textplot([6.9,1.3,cat(` = `,convert(evalf(eps,2),string))]);
txtd:=textplot([4,1.4,`Response to Dirac's delta function`],align={RIGHT,ABOVE});
pltd:=eps->plot(h(eps),t=0..5*Pi,color=green,thickness=2):
plt1:=eps->plot(rhs(sol1(eps)),t=0..5*Pi,color=red,thickness=2):
plt2:=plot(rhs(sol2),t=0..5*Pi,color=blue,thickness=2):
plt:=eps->display(pltd(eps),txt(eps),e,txtd,plt1(eps),plt2);
display(seq(plt(eps-(eps-0.1)/n*i),i=0..n),insequence=true,args[7..nargs]);
end:

Free Harmonic Oscillations

Machines with rotating components commonly involve mass-spring systems or their equivalents in which the driving force is simple harmonic. The motion of a mass attached to a spring serves as a simple example of vibrations that occur in more complex mechanical systems.

From a teaching point of view it is suitable to consider a body of mass m attached to one end of a spring that resists compression as well as stretching. A rod attached to the mass carries a disk moving in an oil-filled cylinder (a dashpot). The other end of the spring could be attached to a fixed wall and vibrating horizontally. The resultant force on the body is the sum of the restoring force -
k*x(t) and the damping force - r*diff(x(t),t) , k is the force constant, x(t) is the distance of the body of mass from its equilibrium position, t is time and and r is the damping constant. We take x(t) > 0 when the spring is stretched. The differential equation of motion is therefore:

> deq1:=m*diff(x(t),t$2)+r*diff(x(t),t)+k*x(t)=0;

deq1 := m*diff(x(t),`$`(t,2))+r*diff(x(t),t)+k*x(t)...

If we set r = 0 in deq1 the motion is undamped. Otherwise the solution of deq1 presents three distinct cases of damping according to whether d = r^2-4*m*k is greater than, equal to, or less than zero.

> eq:=d=r^2-4*m*k;

eq := d = r^2-4*m*k

> solm:=solve(eq,m);

solm := 1/4*(-d+r^2)/k

Let us replace m with a new variable mv in deq1 .

> mv:=unapply(solm,d,r,k);

mv := proc (d, r, k) options operator, arrow; 1/4*(...

> deq2:=collect(4*k*subs(m=mv(d,r,k),deq1),diff(x(t),t$2));

deq2 := (-d+r^2)*diff(x(t),`$`(t,2))+4*k*(r*diff(x(...

With this differential equation, deq1 , the system is overdamped if 0 < d , critically damped if d = 0 and underdamped if d < 0 . If we request Maple to solve deq1 for the undamped case and deq2 for each of the damped cases,subject to initial condition x(0) = x[0] and = 0

> init:=x(0)=x[0],D(x)(0)=0: #initial conditions

we get:

UNDAMPED

With r = 0 Ns/m

With r = 0

> deq1a:=subs(r=0,deq1);

deq1a := m*diff(x(t),`$`(t,2))+k*x(t) = 0

> dsolve({deq1a,init},x(t));

x(t) = x[0]*cos(sqrt(m*k)*t/m)

A typical graph of x(t) with m = 1*kg and k = 1 N/m is shown i Figure 1. Figure 2 shows the animation of the undamped motion.

> xk:=unapply(rhs(%),m,k,x[0],t): # defines x = x(m,k,x[0],t)

OVERDAMPED

> interface(showassumed=0):

> assume(d>0):

> dsol:=dsolve({deq2,init},x(t));

dsol := x(t) = 1/2*x[0]*(r+sqrt(d))*exp(-2*(-r+sqrt...

> subs(eq,dsol);

x(t) = 1/2*x[0]*(r+sqrt(r^2-4*m*k))*exp(1/2*(-r+sqr...

> xo:=unapply(rhs(%),m,r,k,x[0],t): # defines x = x(m,r,k,x[0],t)

The solution consists of two exponential terms when r > sqrt(4*m*k) . In all subsequent figures we take m = 1*kg and k = 1 N/m . Figure 3 shows some typical graphs of the position function for the overdamped case. Figure 4 shows the animation of the motion with the damping constant r = 4 N*s/m .

CRITICALLY*DAMPED

> lhs(dsol)=limit(rhs(dsol),d=0);

x(t) = (2*k*t+r)*exp(-2*k*t/r)*x[0]/r

> subs(r=sqrt(4*m*k),%);

x(t) = 1/2*(2*k*t+2*sqrt(m*k))*exp(-k*t/(sqrt(m*k))...

> xc:=unapply(rhs(%),m,k,x[0],t): #defines x = x(m,k,x[0],t)

The solution consists of one exponential term when r = sqrt(4*m*k) . The graph in Figure 5 resemble those of the overdamped case in Figure 3. The animation of a critically damped motion with r = 2 N*s/m is shown in Figure 6.

UNDER*DAMPED

> assume(d<0):

> dsolve({deq2,init},x(t));

x(t) = -x[0]*r*exp(2*r*k*t/(d-r^2))*sin(2*sqrt(-d)*...

> subs(eq,%);

x(t) = -x[0]*r*exp(-1/2*r*t/m)*sin(-1/2*sqrt(-r^2+4...

> xu:=unapply(rhs(%),m,r,k,x[0],t): #defines x = x(m,r,k,x[0],t)

The solution represents exponentially damped oscillations of the mass-spring system about its equilibrium position as shown in both Figure 7 and Figure 8.

Undamped Motion

> with(plots): #load the plots package

Warning, the name changecoords has been redefined

> plot(xk(1,1,1,t),t=0..19,labels=[`t`,`x(t)`],labelfont=[TIMES,BOLD,12]);

[Maple Plot]

Figure 1 Undamped motion. m = 1*kg , k = 1 N/m , x(0) = 2*m

> mass_spring(1,0,1,0,5,2,0,14,0,60,scaling=constrained);

diff(x(t),`$`(t,2))+x(t) = 0

x(t) = 2*cos(t)

[Maple Plot]

Figure 2 Animation of an undamped motion. m = 1*kg , k = 1 N/m , x(0) = 2*m

The small rectangle shows the position of the mass on the displacement curve.

Overdamped Motion

If we select m = 1*kg , k = 1 N/m and three different d -values: 12, 45, 96 (N*s/m)^2 , r named rk becomes:

> rk:=(d,m,k)->simplify(sqrt(d+4*m*k)):

> r=[seq(rk(d,1,1),d=[12,45,96])];

r = [4, 7, 10]

> plt1:=d->plot(xo(1,rk(d,1,1),1,2,t),t=0..20):

> txt1:=d->textplot([4,xo(1,rk(d,1,1),1,2,4),convert(r = rk(d,1,1),string)]):

> pltod:=display(seq({plt1(d),txt1(d)},d=[12,45,96]),labels=[`t`,`x(t)`],labelfont=[TIMES,BOLD,12]):%;

[Maple Plot]

Figure 3 Overdamped motion, m = 1*kg , k = 1 N/m , x(0) = 2*m , r : damping constant

Figure 3 shows three typical graphs of the position function x(t) for the overdamped case. Figure 4 shows the animation of the motion with r = 4 N*s/m .

> mass_spring(1,4,1,0,5,2,0,14,0,60,scaling=constrained);

diff(x(t),`$`(t,2))+4*diff(x(t),t)+x(t) = 0

x(t) = exp((-2+sqrt(3))*t)+2/3*exp((-2+sqrt(3))*t)*...

[Maple Plot]

Figure 4 Animation of an overdamped motion of a mass-spring system with dashpot.
m = 1*kg , k = 1 N/m , x(0) = 2*m , r = 4 Ns/m

Critically Damped Motion

> plt2:=plot(xc(1,1,2,t),t=0..20):

> txt2:=textplot([3,xc(1,1,2,3),convert(r = rk(0,1,1),string)]):

> pltcd:=display(plt2,txt2):%;

[Maple Plot]

Figure 5 Critically damped motion, m = 1*kg , k = 1 N/m , x(0) = 2*m , r : damping constant

> mass_spring(1,2,1,0,5,2,0,14,0,60,scaling=constrained);

diff(x(t),`$`(t,2))+2*diff(x(t),t)+x(t) = 0

x(t) = 2*exp(-t)+2*exp(-t)*t

[Maple Plot]

Figure 6 Animation of an critically damped motion. m = 1*kg , k = 1 N/m , x(0) = 2*m , r = 2 Ns/m

In this critically damped case, then resistance of the dashpot is just large enough to damp out any oscillations.

Underdamped Motion

We select m = 1*kg , k = 1 N/m and two r values 1/2, 1/5, Ns/m .

> plt3:=plot([xu(1,1/2,1,2,t),xu(1,1/5,1,2,t)],t=0..20):

> txt3:=textplot([ [6.5,xu(1,1/2,1,2,6.5),`r=1/2`],[6.5,xu(1,1/5,1,2,6.5),`r=1/5`]]):

> pltod:=display(plt3,txt3,labels=[`t`,`x(t)`],labelfont=[TIMES,BOLD,12]):%;

[Maple Plot]

Figure 7 Underdamped motion,  m = 1*kg , k = 1 N/m , x(0) = 2*m , r : damping constant

> mass_spring(1,1/5,1,0,5,2,0,20,0,60,scaling=constrained);

diff(x(t),`$`(t,2))+1/5*diff(x(t),t)+x(t) = 0

x(t) = 2/33*sqrt(11)*exp(-1/10*t)*sin(3/10*sqrt(11)...

[Maple Plot]

Figure 8 Animation of an underdamped motion of a mass-spring system with dashpot. m = 1*kg , k = 1 N/m , r = 1/5 Ns/m

The action of the dashpot exponentially damps the oscillations in accord with with the time-varying amplitude. The dashpot also decreases the frequency of the motion from 1 in the undamped to case 3*sqrt(11)/10 in the underdamped motion with the same mass and force constant.


Comparison of the graphs in Figure 2, 5 and 7 (Figure 9) shows that when the motion is critically damped the mass reaches its equilibrium posistion in a shorter time than when the damping is larger. And for any damping constant less than
r = 2 Ns/m in our particular example the motion becomes oscillatory.

> display(plt1(45),plt2,plt3,txt1(45),txt2,txt3,labels=[`t`,`x(t)`],labelfont=[TIMES,BOLD,12]);

[Maple Plot]

Figure 9 Overdamped, critically damped and damped oscillatary motion of a mass-spring system.
m = 1*kg , k = 1 N/m , x(0) = 2*m , r : damping constant

Forced Harmonic Oscillations

Mechanical systems are often acted upon by an external force of large magnitude that acts for only a short period of time. For example a spring-mass system could be given a sharp blow at some specific time t . In engineering practice it is convenient to use the Dirac delta function as a mathematical model for such a blow. But it is my experience that it is often difficult for engineering students to get a real understanding of what this impulse function stands for. With the use of Maple it is easy and instructive to simulate Dirac's delta function delta(t-a)

The response of a mass-spring system to an impulse function

As said above the Dirac delta function delta(t-a) could serve as a mathematical model for an external force of large magntiude that acts for only a very short period of time.

> delta(t-a)=piecewise(t<a,0,t=a,infinity,t>a,0);

delta(t-a) = PIECEWISE([0, t < a],[infinity, t = a]...

where

> Int(delta(t-a),t=-infinity..infinity)=int(Dirac(t-a),t=-infinity..infinity);

Int(delta(t-a),t = -infinity .. infinity) = 1

Obviously no real function can satisfy beeing zero except at a single point and have an integral equal to one.

In Maple
delta(t-a) = Dirac (t - a) is expressed as the derivative of the Heaviside standard unit step function u(t-a)

> alias(u=Heaviside):

> Diff(u(t-a),t)=diff(u(t-a),t);

Diff(u(t-a),t) = Dirac(a-t)

It is instructive to use Maple to model such an instantaneous unit impulse by starting with the function

> delta[epsilon](t-a)=piecewise(t<a,0,t<a+epsilon,1/epsilon, 0);

delta[epsilon](t-a) = PIECEWISE([0, t < a],[1/epsil...

> h:=unapply(convert(rhs(%),Heaviside),t,a,epsilon);

h := proc (t, a, epsilon) options operator, arrow; ...

A plot of the rectangular pulse for a = Pi and epsilon = 3 gives:

> plot(h(t,Pi,3),t=0..10,thickness=3);

[Maple Plot]

Figure 10 Rectangular pulse delta[epsilon](t-a) with a = Pi and epsilon = 3 (width epsilon and height 1/epsilon )

The area of the rectangular pulse is equal to 1 .

> assume(epsilon>0):

> A:=Int(h(t,a,epsilon),t=a..a+epsilon):

> A=value(A);

Int(u(t-a)*u(a+epsilon-t)/epsilon,t = a .. a+epsilo...

where u(t) is Heavisides unit step function. We can compare the response of a damped mass-spring system to a rectangular pulse delta[epsilon](t-a) as with the response of the Dirac's delta function used by Maple.

The output of the Maple code impulse_func (written in section 3) in Figure 11 animate the response to the rectangular pulse
delta[epsilon](t-a) by a linear second order differential equation with constant coefficients and with damping.

> impulse_func(1,3,1,Pi,3,10);

diff(y(t),`$`(t,2))+3*diff(y(t),t)+y(t) = 5/3*u(t-P...

diff(y(t),`$`(t,2))+3*diff(y(t),t)+y(t) = 5*Dirac(t...

[Maple Plot]

Figure 11 The behavior of the response to a rectangular pulse by a linear second order

differential equation with damping as compared to the response to Dirac's delta function.

The last animated frame in Figure 11 shows little difference between the two responses when epsilon = .1

Figure 12 shows an animated response of the damped mass-spring system initially at rest. At time
t = Pi the system is suddenly given a sharp "hammerblow" modelled by f(t) = 5*Dirac(t-Pi)

> f:=t->5*Dirac(t-Pi):

> mass_spring(1,3,1,0,5,0,0,14,f,60,scaling=constrained);

diff(x(t),`$`(t,2))+3*diff(x(t),t)+x(t) = 5*Dirac(t...

x(t) = (exp(1/2*t*sqrt(5))-exp(-1/2*t*sqrt(5)+Pi*sq...

[Maple Plot]

Figure 12 The motion of a mass-spring system with dashpot

under the influence of a sharp blow at
t = Pi provided by 5*delta(t-Pi)

The displacement resonance in forced oscillations

In every oscillating system there is dissipation of mechanical energy, which results that the motion of the mass-spring system described in the previous sections dies out. If the oscillation are to be maintained, energy must be supplied to the system. In this section we shall assume that the system is acted on by a periodic driving force. Suppose that the mass-spring system is subjected to a periodic force F[0]*cos(omega*t) , where F[0] is the maximum value of the applied force and f = omega/(2*Pi) is its frequency. The equation of motion is then:

m*diff(x(t),t,t)+r*diff(x(t),t)+k*x(t) = F[0]*sin(o...

where m is the mass of the system, x(t) is the distance of the body of mass from its equilibrium position, r is the damping constant and k is the force constant. The frequency response of this system can be readily obtained from the system transfer function H(s) by replacing s by i*omega

> f:='f':

> with(inttrans): L:=x->laplace(x,t,s): invL:=X->invlaplace(X,s,t):

> alias(X(s)=L(x(t)),F(s)=L(f(t))):

> dlign:=m*diff(x(t),t$2)+r*diff(x(t),t)+k*x(t)=f(t);

dlign := m*diff(x(t),`$`(t,2))+r*diff(x(t),t)+k*x(t...

> simplify(L(dlign));

m*s^2*X(s)-m*s*x(0)-m*D(x)(0)+r*s*X(s)-r*x(0)+k*X(s...

> X(s)=solve(%,X(s));

X(s) = (m*s*x(0)+m*D(x)(0)+r*x(0)+F(s))/(m*s^2+r*s+...

> subs(x(0)=0,D(x)(0)=0,%);

X(s) = F(s)/(m*s^2+r*s+k)

The transfer function of the mass-spring system is given by:

H(s) = 1/(m*s^2+r*s+k)

> H:=s->1/(m*s^2+r*s+k):

It is easy to show that the steady-state frequency response to an input F(t) = F[0]*cos(omega*t) becomes:

> x(t)=F[0]*abs('H'(I*omega))*cos(omega*t+arg('H'(I*omega)));

x(t) = F[0]*abs(H(I*omega))*cos(omega*t+arg(H(I*ome...

> value(%);

x(t) = F[0]*cos(omega*t+arg(1/(-m*omega^2+I*r*omega...

The steady-state system response is also a cosine having the same frequency omega as the input. And the amplitude of this response is F[0]*abs(H(I*omega)) . The variation in both the magnitude abs(H(I*omega)) and argument arg(H(I*omega)) as the frequency omega of the input cosine is varied constitute the frequency response of the system, as the following example shows.

Lets us first solve the differential equation using Maples dsolve .

> f:=(omega,t)->2*cos(omega*t);

f := proc (omega, t) options operator, arrow; 2*cos...

> deq:=(m,r,k,omega)->m*diff(x(t),t$2)+r*diff(x(t),t)+k*x(t)=f(omega,t);

deq := proc (m, r, k, omega) options operator, arro...

> sol:=dsolve({deq(1,0.25,4,2),x(0)=0,D(x)(0)=0},x(t),method=laplace);

sol := x(t) = 4*sin(2*t)-64/255*sqrt(255)*exp(-1/8*...

> plot(rhs(sol),t=0..40);

[Maple Plot]

Figure 13 The displacement x(t) of a mass-spring system
undergoing forced oscillations plotted against the time.
m = 1*kg , r = .25 Ns/m , k = 4 N/m , omega = 2/s

The graph shows that the transient solution dies out as t increases.

The transfer function of the system is given by :

> H:=(m,r,k,s)->1/(m*s^2+r*s+k);

H := proc (m, r, k, s) options operator, arrow; 1/(...

With m = 1*kg , k = 4 N/m and s = I*omega , we get:

> 'H'(1,r,4,I*omega)=H(1,r,4,I*omega);

H(1,r,4,I*omega) = 1/(-omega^2+I*r*omega+4)

> Habs:=unapply(evalc(abs(H(1,r,4,I*omega))),r,omega);

Habs := proc (r, omega) options operator, arrow; 1/...

There is some frequency called the resonance frequency at which the amplitude A = 2*Habs becomes a maximum.

This resonance frequency can be recognized in many vibrating systems unless the damping force r is too large.

> solve(omega^4-8*omega^2+16+r^2*omega^2=0,{r});

{r = I*(omega+2)*(omega-2)/omega}, {r = -I*(omega+2...

With zero damping force, r = 0 and the resonance frequency omega = 2 in our example. See also Figure 15.

The phase angle
phi is given by:

> phi:=unapply(evalc(argument(H(1,r,4,I*omega))),r,omega);

phi := proc (r, omega) options operator, arrow; arc...

Substituting the values r = .25 Ns/m , omega = 2/s and F[0] = 2 N , gives the steady-state response, xs = x(t)

> xs:=unapply(2*Habs(0.25,2)*cos(2*t+phi(0.25,2)),t):
'xs'(t)=xs(t); #steady state respons

xs(t) = 4.000000000*cos(2*t-1.570796327)

> sol; # Maple's solution

x(t) = 4*sin(2*t)-64/255*sqrt(255)*exp(-1/8*t)*sin(...

As , %? .

> control:='4*sin(2*t)-4*cos(2*t-Pi/2)'=simplify(4*sin(2*t)-4*cos(2*t-Pi/2));

control := 4*sin(2*t)-4*cos(2*t-1/2*Pi) = 0

The system is lagging because the phase shift between input and output arg(H(i*omega)) is phi = -1.57 ... .

Figure 14 shows this phase shift.

> with(plots):
plt1:=plot([f(2,t),xs(t)],t=30..39,thickness=[1,2]):
plttext1:=textplot([[39,xs(39),`steady-state response`],[39,f(2,39),`input`]],align=RIGHT):
display({plt1,plttext1},labels=[`t`,`x(t)`],labelfont=[TIMES,BOLD,12]);

[Maple Plot]

Figure 14 Phase shift between steady-state response and input displacement x(t)

> A:='A':

> Habsi:=i->plot(Habs(i,omega),omega=1..3,A=0..2.5) :

> plt2:=i->display(Habsi(i),text2(i)):

> text2:=i->textplot([2,Habs(i,2),convert(r=i,string)],align=ABOVE,font=[TIMES,BOLD,12]):

> display(seq(plt2(i),i=[0.1,0.25,0.5,0.75,1,1.41]),labels=[`omega`,`A`],labelfont=[TIMES,BOLD,12]);

[Maple Plot]

Figure 15 Variation of the amplitude A = 2/sqrt(emoga^4-8*omega^2+16+r^2*omega^2)
against the angular velocity
omega of the forced oscillations-displacement resonance for different values of the damping constant r

Figure 15 shows that the smaller the value of r , the sharper the resonance of the vibrating system to the applied force.

And the resonance frequency varies with the value of the damping constant
r . The amplitude A becomes infinity when the applied frequency becomes equal to the resonance frequency and the system has zero damping.

Figure 16 animates the displacement resonance of the forced oscillations and Figure 17 shows the variation of the phase shift against the angular velocity, which is animated in Figure 18.

Figure 19 shows what happens with the mass-spring system when the damping constant
r = .25 N/s and Figure 20 when the damping constant is approximately equal to zero, r = `0.01` N/s .

> display(seq(plt2(0.05*i),i=1..28),insequence=true,labels=[`omega`,`A`],labelfont=[TIMES,BOLD,12]);

[Maple Plot]

Figure 16 Animation of Figure 15

> Harg:=i->plot(phi(i,omega),omega=1..3) :

> text3:=i->textplot([2.4,phi(i,2.4),convert(r=i,string)],align={RIGHT,ABOVE},font=[TIMES,BOLD,12]):

> plt3:=i->display(Harg(i),text3(i)):

> display(seq(plt3(i),i=[0.1,0.25,0.5,0.75,1,1.41]),labels=[`omega`,`phi`],labelfont=[TIMES,BOLD,12]);

[Maple Plot]

Figure 17 Variation of the phase shift phi = arctan(omega^2-r/(r*omega)) against the angular velocity omega of the forced oscillations-displacement resonance for different values of the damping constant r

As the applied angular velocity is increased from zero to the natural angular velocity of the system, the phase angle phi increases from zero to Pi/2 . When the r = 0 angle phi changes abruptly from 0 to Pi

> display(seq(plt3(0.05*i),i=1..28),labelfont=[TIMES,BOLD,12],insequence=true);

[Maple Plot]

Figure 18 Animation of Figure 17

> f:=t->2*sin(2*t):

> mass_spring(1,0.25,4,0,5,0,0,20,f,60,scaling=constrained);

diff(x(t),`$`(t,2))+.25*diff(x(t),t)+4*x(t) = 2*sin...

x(t) = -4*cos(2*t)+4/255*sqrt(255)*exp(-1/8*t)*sin(...

[Maple Plot]

Figure 19 The displacement x(t) of the mass-spring system
undergoing forced oscillations with damping constant
r = .25 .

> mass_spring(1,0.01,4,0,5,0,0,11.5,f,60,scaling=constrained);

diff(x(t),`$`(t,2))+.1e-1*diff(x(t),t)+4*x(t) = 2*s...

x(t) = 100/159999*sqrt(159999)*exp(-1/200*t)*sin(1/...

[Maple Plot]

Figure 20 The displacement x(t) of the mass-spring system
undergoing forced oscillations with damping constant
r = `0.01` Ns/m .

Summary

This paper discusses the use of the Computer Algebra System (CAS) Maple in calculating and animating the responses of free and force vibrations systems. CAS have changed the fundamental way in which many math and engineering course are taught. The user can enters a mathematical expression, which the CAS (in this paper Maple) subsequently execute and one are freed from tedious computations. This allow the student to explore how the solution of an engineering problem depends on various parameters of the problem under study. The graphics capabilities are extremely helpful for visualizing the behavior of the system under investigation. Maple's plots and plottools packages enable the user to utilize a lot of plotting objects for animating purposes. This is highlighted and demonstrated in this paper. It is hoped that this features can attract the attention of both lectures and students to visualize dynamic response, typical in engineering, more realistically.

>