Writing a simulation program for the vibration string

advertisement
The Vibrating String
Guide to the Practical Work
April 2004
Revised January 2008
1
Introduction
Dear reader,
The cover page of this assignment shows a picture of a guitar. The goal of the lab course is to
implement a model of a vibrating string that may serve as a model for a real guitar string. You
are encouraged to extend the simple model to a more realistic one.
Please read this syllabus carefully. It explains everything you need to know about this lab
course.
This assignment was formulated by Alfons Hoekstra.
SUCCES !!
Dick van Albada
dick@science.uva.nl
-2-
2
What you should know before you start
2.1
Lab report
You write one concise report of all the practical work for this assignment. The style of the
report is just as you learned previously (so, a clear introduction stating the problem at hand, a
theory section that introduces necessary theory, a methods section that describes the methods
used, e.g. pseudo code of the algorithms, etc, a results section that presents the main results
that you obtained, and finally a short discussion that critically goes through the results in view
of the original problem, like did you solve the problem satisfactory). Very important is that
any reader of your report must be able to reproduce your results. This more or less dictates the
amount of detail that will go into your report. Very important is that you also write a report
about the software that you create. That is, you also provide text that explains how you
implemented the simulations. The deadline for the report is May 16, 2008.
2.2
Choice of programming language
You may implement this assignment, like the previous ones, in Mathematica. So, take some
time to learn about the programming capabilities of Mathematica. All the standard constructs
(while loops, for loops, branching, etc.) are available. Just read in the Mathematica book
(available under the help menu) about all this. But you can also use one of the more traditional
languages: Java, C or C++.
3
The assignment
3.1
The Vibrating String
The problem at hand is the numerical solution of a one-dimensional wave equation, which
might describe the vibrations of a uniform string, the transport of voltage and current along a
lossless transmission line, the pressure and flow rate of a compressible liquid or gas in a pipe,
sound waves in gases or liquids, and optical waves. In our conceptual view, the domain of the
wave equation is the physical extent of a string, and the displacement Ψ(x,t) is a function of
the distance x and the time t representing the unknown solution.
The one-dimensional wave equation is
∂2Ψ
∂t 2
= c2
∂ 2Ψ
∂x 2
The solution Ψ(x,t) is the vibration amplitude expressed as a function of position and time.
The problem becomes fully posed with the addition of boundary conditions on the spatial
domain, and initial position and velocity distributions.
Numerical solution can be based on a uniform discretisation of the spatial and temporal
domains, approximating the partial differential equation by finite difference expressions. The
grid points of this problem consist of discrete nodal points at which Ψ is to be evaluated.
3.1.1
Assignments
Be sure to first follow the instructions in the previous chapters!
1.
Write a program that allows the simulation of the vibrating string. Do this in such a way
that you can handle any discretisation, and make sure that the correct boundary conditions
are enforced (so, the string should have a zero amplitude at the beginning and end).
-3-
Assume that the string has a length 1, that you discretise the string with say N points (so,
∆x = 1/(N-1) ), and assume that c = 1. Now choose an appropriate value for ∆t. Also
allow for the following initial conditions:
• A sinusoidal initial condition with y(x, t=0) = sin(m π x), with m and integer
• A “plucked” guitar string, that is a triangle shaped initial condition with a
maximum of 1 at position x0, i.e.
x
y ( x , t = 0) =
0 ≤ x ≤ x0
x0
y ( x , t = 0) =
•
1− x
1 − x0
x0 ≤ x ≤ 1
You’ll also need to define initial values for t = -∆t. Think carefully about these
and explain your choice and its implication for the calculation.
2.
Show the correct working of the wave programs using a number of runs. Use the
sinusoidal initial condition for this. Vary the parameters. Which behaviour do you
observe? Is it in agreement with your expectations?
3.
Now simulate the plucked guitar string, using the triangular initial condition. What do
you observe?
4.
It is known that the stability of the computation is limited for 0 ≤ τ ≤ 1, with τ as defined
in the syllabus. Show experimentally that this is true. For different values of ∆t, what is
the effect in time of the non-stable behaviour and what does this mean.
5.
EXTRA ASSINGMENT : Try to make your model a bit more realistic, by introducing a
∂y
damping term in the equation, i.e. − γ
. You can discretise this as
∂t
∂y y (t + ∆t ) − y (t )
=
∂t
∆t
4.1 : Implement this damping term in your simulation
4.2 : Run a few simulations, what do you observe?
4.3 : What is the influence of the damping parameter γ, explain.
-4-
Download