In229: Simulation and Visualisation Description of the Student Project 1 General Information

advertisement
In229: Simulation and Visualisation
Description of the Student Project
Knut–Andreas Lie
February 19, 2003
1
General Information
The project consists of three parts; a simulation part, a visualization part, and
a final part that will be handed out near the end of the semester. The result of
each part is to be handed in as separate web-reports. A template to use for the
simulation part is available on the URL:
www.ifi.uio.no/~in229/project/mal.html
This template is intended for novice HTML-writers, and contains a minimum of
what is required from the report.
The current note describes the objective of the project and what you are going
to do. The latest available information will always be given on the URL:
www.ifi.uio.no/~in229/project/index.html
We will try to assist you if you have questions.
2
Part I: Simulation
2.1
Getting to Know the Wave Equation
Try to reimplement the finite difference simulator for the one-dimensional wave
equation utt = uxx given in the lectures using object orientation ideas. Try to
structure the code in logical units. Some points to consider:
• Should there be a grid class and a field class (i.e., a set of scalars imposed on
top of a grid) for the unknown fields un ? If so, how should these be coupled?
• Should the initial data be separated out in functors, i.e., classes wrapping
the evaluation of a function? (A functor would typically have two methods,
one to evaluate the function and one to initialize necessary parameters and
variables). This corresponds to the ideas introduced in ODEProblem.
• How should user-defined parameters be read (prompt the user, use command
line switches, use parameter file,...) ?
Once you have developed a code, play around with it a bit to make sure the implementation is reasonable.
We do not require that you do this point, but it is recommended as a soft introduction to the rest of the assignment.
1
2.2
A Simulator for Slide-generated Surface Waves
Underwater slides can generate water surface waves acting destructively with massive force. Thus, simulation of this phenomenon can be of importance in parts of
the world where such situations tend to occur.
Mathematically, we can model an underwater slide as a movement of the seabed.
Incorporation of a time-dependent (scaled) depth H(x, t) in the governing wave
equation leads to an extra source term:
∂2u
∂
∂u
∂2H
=
H(x,
t)
+
.
(1)
∂t2
∂x
∂x
∂t2
Here H > 0 is the depth from the still water surface at elevation zero.
In the finite difference scheme, we assume that H is available only in the grid
points (where we can evaluate it by a function call) and that the second-order
derivative can be approximated directly by
∂2H
∂t2
l
i
≈
1
(H(xi , tl+1 ) − 2H(xi , tl ) + H(xi , tl−1 )).
∆t2
(2)
The other two terms in (1) are discretized as given in the lectures. Notice in
particular, that we have not given a stability criterion. Can you imagine what it
is?
Implement a simulation program for the equation (1) restricted to one space
dimension. The simulator should be written in an object-oriented manner and you
should aim at producing a modular code, taking into account the considerations
from §2.1. The minimum requirement is that the bottom topography and the initial
waver elevation should be easy to replace (e.g., with other explicit functions or with
values read from a data file).
Dump the elevation u(x, t) and the seabed H(x, t) at each time level. Generate
a movie of the time-varying surface elevation and the seabed. Let the 1D simulator
use
H1D (x, t) = ∆ − β(x + )(x − (L + ))
2 !
1
1
L++2
αt
exp −
−K√
x−
+ ce
(3)
γ
4
2πγ
as a model of the seabed. Here, ∆, β, , L, K, γ, c and α are constants that
can be tuned to produce a particular slide. The function H can be interpreted as
the sum of a parabola and a bell-shaped curve, the latter moving with a velocity
αc exp(αt). Clearly, choosing α < 0 gives a retarding slide. Implement H as a
function (or preferably as a functor). The initial data u(x, 0) is given by still water,
e.g., u(x, 0) = ut (x, 0) = 0. As boundary condition, we can use u(0, t) = u(L, t) = 0.
Deliverable Run the simulator using ∆ = −0.1, β = 0.04, = 0.5, L = 10,
K = 0.7, γ = 0.7, c = 1.2 and α = −0.3. Pick the the time interval and the
discretization parameters such that the “interesting part” of the wave is simulated
accurately and with as little influence from boundary conditions as possible. (Hint:
Notice that since the function H1D indicated the depth, it should always be strictly
positive in your domain, and in your plots you should plot −H1D .)
(By varying ∆, L, K and α (one value at a time), you can investigate how
these parameters influence the shape of the seabed and how this affects the surface
elevation, including relevant figures or animations.)
At the end, you should produce and hand in the following:
2
• a PostScript/PDF report describing what you have done and why (restricted
to three A4 pages)
• a well-documented simulator code
• a description of how to compile the code (e.g., in the form of a makefile)
• a description of how to run the code with suitable parameters
• an animation of the wave either in the form of a description of how to invoke
gnuplot/Matlab/... and run a suitable “script” or as an mpeg-file (information
of how to produce mpeg-files will be given later)
We emphasize that the code will be compiled and run on a standard Unix/Linux
platform. It is your reponsibility that the course instructors are able to compile/run
your program and read/visualize the results.
Deadline:
March 12 (Wednesday), 12:00.
3
Download