You are on page 1of 12

APIE COURSE EXERCISES

RUUD MEULENBROEK
S0110388

CONTENT
APiE Exercises 09.11.2009 ............................................................................................................................................................. 2
Exercise 1 .................................................................................................................................................................................... 2
Exercise 1.1 .............................................................................................................................................................................. 3
Exercise 1.2 .............................................................................................................................................................................. 5
Exercise 1.3 .............................................................................................................................................................................. 6
Exercise 2. ................................................................................................................................................................................... 6
Exercise 3. ................................................................................................................................................................................... 8
Exercise 4 .................................................................................................................................................................................. 10
Exercise 5 .................................................................................................................................................................................. 12
APiE Exercises 16.11.2009 ........................................................................................................................................................... 13
Exercise 1 .................................................................................................................................................................................. 13
Exercise 2 .................................................................................................................................................................................. 14
Exercise 3 .................................................................................................................................................................................. 20
Exercise 4 .................................................................................................................................................................................. 21
Exercise 5 .................................................................................................................................................................................. 22
Exercise 6 .................................................................................................................................................................................. 22
Exercise 7 .................................................................................................................................................................................. 26
Exercise 8 .................................................................................................................................................................................. 26
Exercise 9 .................................................................................................................................................................................. 26
Exercise 10 ................................................................................................................................................................................ 27
Exercise 11 ................................................................................................................................................................................ 27
Exercise 12 ................................................................................................................................................................................ 27

Exercise 13 ................................................................................................................................................................................ 27
APiE Exercises 23.11.2009 ........................................................................................................................................................... 28
Exercise 1 .................................................................................................................................................................................. 28
Exercise 2 .................................................................................................................................................................................. 30
Exercise 3 .................................................................................................................................................................................. 30
Exercise 4 .................................................................................................................................................................................. 30
Exercise 5 .................................................................................................................................................................................. 31
Exercise 6 .................................................................................................................................................................................. 31
APiE Exercises 07.12.2009 ........................................................................................................................................................... 31
Exercise 1 .................................................................................................................................................................................. 31
APiE Exercises 14.12.2009 ........................................................................................................................................................... 32
Exercise 1 .................................................................................................................................................................................. 32
Exercise 2 .................................................................................................................................................................................. 33
APiE exercises 04.01.2010 ............................................................................................................................................................ 34
Exercise 1 .................................................................................................................................................................................. 34
Exercise 2 .................................................................................................................................................................................. 35
Exercise 3 .................................................................................................................................................................................. 36

APIE EXERCISES 09.11.2009


EXERCISE 1

The motion of the harmonic oscillator is described by the differential equation:

(1.1)

where m is the mass, k is the spring-constant, x(t) is the position and d2x/dt2 is the
second time-derivative of x(t).

EXERCISE 1.1

Get analytically the solution of Eq. (1.1) for initial conditions x0 = x(0) and v0 = x = v(0)
and plot it as function of time.
Analytical solution:
= sin +

0 = sin
0 = cos

0.5

0
1

t
0.5

Plot:
A=1, =1, =0, x(t)=sine(t)

What is the period T and the frequency ?


Angular velocity is 2 =2

. Period

is 2
= 2

Normally, the equation (1.1) and all coefficients have dimensions. Make the equation
dimensionless, by introducing reference-units of length, , mass m0, and time .

Denote dimensionless quantities with a prime: x = x/, m = m/m0, etc. The equation is
dimensionless with k = 0.1, m = 1, x0 = 0 and v0 = 0.1. What is the period T and the frequency ?
T=2

= 2 10 , = 2

k
m

= 2 0.1

As an example, the unit of length is 0 = 0.1mm, the unit of density is = 2000 kg/m3
and the unit of energy is e0 = 108 kgm2 s2. What is the period T and the frequency ?
T=2

= 2 10 , = 2

k
m

= 2 0.1

Same answer as above, only the nondimensional quantities become those in the second column of
the table below.

That was the simple question. Now make a table with 5 columns:
First column: name of quantity ... all of them ...
Second column: quantity as used in the simulation (dimensionless)
Third column: quantity with dimensions
Fourth column: quantity with dimensions (use SI-units!)
Fifth column: new units - see next question.
This table will get many rows for x, m, t, k, T, , E, etc.

Name of Quantity as

Quantity

Quantity with

New units.

quantity. used in
simulation.

with
dimensions [SI].
dimensions.

x*10-4

Mass

0 3

Time

0 02

Angular
velocity

Energy

Length

Springconstant
Period

EXERCISE 1.2

Now plot the kinetic and potential and total energy of the harmonic oscillator as function
of time (together).

Now choose: A=1, m=2, k=1.


Potential energy then becomes:

Kinetic energy:
Plot: Green = kinetic energy
Black = potential energy
Red

= kinetic + potential energy

Range: 0<t<10 sec.

0.5

0.4

0.3

0.2

0.1

0
0

So the sum of the potential and kinetic energy remains constant (independent of your choice for A,
k, and m).

EXERCISE 1.3

Modify mass and spring and describe how T changes with k and m.
T=2

EXERCISE 2.

a) Solve the Eq. (1.1) numerically using the Euler algorithm as introduced in the course.
Plot solution and energies together with the analytical solution of the previous exercise
Compare them for different time-steps. Which time-step do you find satisfactory?
Program:
Minimum stepsize:

APIE_w1_ex2.m
+/- 0.01 sec

b) Solve the Eq. (1.1) numerically using the Euler-Cromer algorithm as introduced in the
course. Plot solution and energies together with the analytical solution of the previous
exercises 1 and 2 (use different colors). Compare them for different time-steps. Which
time-step do you find satisfactory for Euler-Cromer?
Program:
Minimum stepsize:

APIE_w1_ex2b.m
+/- 0.2 sec (so factor 20 larger).

The wobbling of the total energy tells me that perhaps a smaller time step is required.
EXERCISE 3.

Program: APIE_w1_ex3.m
In order to solve this differential equation numerically, you can use the so-called Verlet
integration algorithm. It was derived in class, but we also show the steps here - repeat
them for yourself!
1. Write down the Taylor-series for x(t+t) and x(tt) up to second order in time
(terms higher than t2 are ignored).
2. Add x(tt) from x(t+t) and rewrite the equation such that you have x(t+t)
on the left-hand side of the equation.
3. This scheme can now be used to compute the trajectory of the mass (with given
x(t), x(t t), and acceleration d2x/dt2 = f(t)/m, with force f(t) = kx(t).
For the old position use the estimate: x(t t) _ x(t) v(t) t.

4. Plot the old time-x-series and the new results, using the same amplitude, phase angle
= 0, m = 1, k = 0.1, _t = 0.1, and tmax = 200, x(0) = 0 and v(0) = 0.1.

5. How big is the error of the calculation and how would you quantify it? Or, with
other words, which time-step would you use to have a reasonably small error here?

Plot also the total energy of the numeric harmonic oscillator as function of time. Plot
separately kinetic and potential energy. Describe the differences to the analytical solution.
Here for example I have plotted as error (yellow) just the absolute difference between the
analytical and the numerical solution, and used a large timestep of one second:

Since this makes the error quite large I suggest staying below 0.5 seconds. Perhaps it would
be better to plot the relative error.
EXERCISE 4

Add a damping force fd = v(t) to the spring-force and plot the new results for a
such that the motion is damped completely at t = 200. Which -value did you use?

Program: APIE_w1_ex4.m
Plot below is for equals 0,05 [Ns/m].

Solve the new corresponding differential equation analytically first - and then compare
it to one of your previous solutions. How did the period change when you added the
damping force?

The period changes as described in the last equation in the derivation above.

Implement the damping force in your Verlet numerical solution from exercise 4.
Modify and describe how T changes with .

EXERCISE 5

Solve the differential equation (1.1) with a built-in Matlab function of your choice.
Program: APIE_w1_ex5_v2.m and osc.m

You might also like