The problem that we consider is the one-dimensional wave equation:

where we have adopted the common subscript notation for partial differentiation, and we have set the speed of wave propagation to unity. The general solution of this equation represents a superposition of left moving (l) and right moving (r) waves (radiation):

We will solve the equation on the domain {x = [0..1] : t = [0..T]}
with so-called "outgoing radiation" or "Sommerfeld" conditions specified at x = 0
and x = 1. That is, at x = 0 and x = 1, we demand that there be no radiation coming
*from* the left or right respectively. Thus we have

and

We recast the wave equation in first order form (first order in time, first order in space), by introducing auxiliary variables, pp and pi, which are the spatial and temporal derivatives, respectively, of phi:

The wave equation then becomes the following pair of first order equations

and the boundary conditions are

The **RNPL** code **w1dcn_rnpl**, solves
the above system of equations using a second-order Crank-Nicholson approximation:
second-order centred approximations to the spatial derivatives are used for the
interior equations, while second-order forward and backward formulas are used for
the spatial derivatives needed in the implementation of the left and right boundary
conditions respectively.
(See the finite difference **NOTES**, particularly section
1.4.2 for a discussion of Crank-Nicholson schemes).

Hopefully, by this time you will have had a look at the available **RNPL**
documentation, and will be thus be able to understand most of the details of
the source code. if you have any questions concerning the implementation,
ask one of the lab instructors for assistance.

A tar-ed and gzip-ed distribution for the **RNPL** solution of the above wave
equation is available for download **HERE**.
Download the distribution to some convenient location within your home
directory on the lab machines, then upack it via

Change to the% tar xzf w1dcn.tar.gz

Build the application by typing% cd w1dcn% lsMakefile id0 id1 id2 id3 id4 w1dcn_rnpl

Note that the% make/usr/local/bin/rnpl -l allf w1dcn_rnpl rnpl_fix_f77 updates.f initializers.f residuals.f f77 -O6 -c w1dcn.f f77 -O6 -c updates.f f77 -O6 -c residuals.f f77 -O6 -L/usr/local/lib w1dcn.o updates.o residuals.o -lrnpl -lvs -lsv -o w1dcn f77 -O6 -c w1dcn_init.f f77 -O6 -c initializers.f f77 -O6 -L/usr/local/lib w1dcn_init.o updates.o residuals.o initializers.o -lrnpl -lvs -lsv -o w1dcn_init

as well as two executables,% ls *.f *.incgfuni0.inc initializers.f residuals.f updates.f w1dcn_init.f globals.inc other_glbs.inc sys_param.inc w1dcn.f

If you are so inclined, you may wish to quickly inspect the contents of% ls w1dcn w1dcn_initw1dcn* w1dcn_init*

The various diagnostic messages written to the terminal require some explanation. First,% w1dcn id0Can't open in0.sdf Calling initial data generator. WARNING: using default for parameter epsiterid. WARNING: using default for parameter maxstep. WARNING: using default for parameter maxstepid. WARNING: using default for parameter s_step. WARNING: using default for parameter ser. WARNING: using default for parameter start_t. WARNING: using default for parameter trace. WARNING: using default for parameter epsiterid. WARNING: using default for parameter maxstep. WARNING: using default for parameter maxstepid. WARNING: using default for parameter s_step. WARNING: using default for parameter ser. WARNING: using default for parameter start_t. WARNING: using default for parameter trace. Starting evolution. step: 0 at t= 0. step: 1 t= 0.0125 steps= 7 step: 2 t= 0.025 steps= 7 step: 3 t= 0.0375 steps= 6 step: 6 t= 0.075 steps= 7 . . . step: 123 t= 1.5375 steps= 11 step: 124 t= 1.55 steps= 11 step: 125 t= 1.5625 steps= 11 step: 126 t= 1.575 steps= 11 step: 127 t= 1.5875 steps= 11 step: 128 t= 1.6 steps= 11

Can't open in0.sdf Calling initial data generator.indicates that the intial state file,

During the initialization phases of both **w1dcn_init** and **w1dcn**,
warning messages are issued if default parameter values are being used for any
of the generic **RNPL** parameters (generic in the sense that they are defined
for *all* **RNPL** applications). Thus, in the diagnostics, we see
the sequence

WARNING: using default for parameter epsiterid. WARNING: using default for parameter maxstep. WARNING: using default for parameter maxstepid. WARNING: using default for parameter s_step. WARNING: using default for parameter ser. WARNING: using default for parameter start_t. WARNING: using default for parameter trace.appearing twice, first from the execution of

The final sequence of messages:

Starting evolution. step: 0 at t= 0. step: 1 t= 0.0125 steps= 7 step: 2 t= 0.025 steps= 7 step: 3 t= 0.0375 steps= 6 step: 6 t= 0.075 steps= 7 . . . step: 123 t= 1.5375 steps= 11 step: 124 t= 1.55 steps= 11 step: 125 t= 1.5625 steps= 11 step: 126 t= 1.575 steps= 11 step: 127 t= 1.5875 steps= 11 step: 128 t= 1.6 steps= 11represents a trace of the time-stepping alogorithm of the application. The time steps at which diagnostic output, such as

step: 1 t= 0.0125 steps= 7is produced, coincide with the those at which grid function output to

output := 0-*indicating that output (at level 0) is to occur at

epsiter := 1.0e-5

% ls *_0.sdf pi_0.sdf pp_0.sdfone for each of the grid functions for which output has been enabled in the

float pp on g1 at 0,1 {out_gf = 1} float pi on g1 at 0,1 {out_gf = 1}The

Start **xvs** from the command line as follows:

(your invocation of the command will use a different port number)% xvs &xvs: Starting service on port 5001 xvs: For help/documentation see http://laplace.physics.ubc.ca/Doc/xvs/

Once **xvs** is running, you can transmit data to it from 1-D **.sdf**
files using the **sdftoxvs** command. For example, if you invoke

or, equivalently% sdftoxvs pp_0.sdf

the% sdftoxvs pp_0

In particular, all 5% diff id0 id18c8 < level := 0 --- > level := 1 13,14c13,14 < in_file := "in0.sdf" < out_file := "out0.sdf" --- > in_file := "in1.sdf" > out_file := "out1.sdf"

Note that output (both diagnostic and% w1dcn id1Can't open in1.sdf Calling initial data generator. WARNING: using default for parameter epsiterid. WARNING: using default for parameter maxstep. WARNING: using default for parameter maxstepid. WARNING: using default for parameter s_step. WARNING: using default for parameter ser. WARNING: using default for parameter start_t. WARNING: using default for parameter trace. WARNING: using default for parameter epsiterid. WARNING: using default for parameter maxstep. WARNING: using default for parameter maxstepid. WARNING: using default for parameter s_step. WARNING: using default for parameter ser. WARNING: using default for parameter start_t. WARNING: using default for parameter trace. Starting evolution. step: 0 at t= 0. step: 2 t= 0.0125 steps= 5 step: 4 t= 0.025 steps= 5 step: 6 t= 0.0375 steps= 5 step: 8 t= 0.05 steps= 5 step: 10 t= 0.0625 steps= 5 step: 12 t= 0.075 steps= 5 . . . step: 246 t= 1.5375 steps= 10 step: 248 t= 1.55 steps= 11 step: 250 t= 1.5625 steps= 11 step: 252 t= 1.575 steps= 11 step: 254 t= 1.5875 steps= 11 step: 256 t= 1.6 steps= 10

We can quickly perform a series of runs at levels 0 through 4 (output supressed)

then send all of the data for% w1dcn id0 % w1dcn id1 % w1dcn id2 % w1dcn id3 % w1dcn id4

The% xvs kaCloses pre-existingxvswindows% sdftoxvs pp_*.sdf

Bring the window labelled **pp_4_** to the foreground by positioning the
cursor in it and hitting the **space bar**. Type **S**, then use the
right and left mouse buttons to step forward and backward, respectively,
through the results of the convergence test. For example, stepping to the
28th frame, you should see

pp_1 - pp_0 4 * (pp_2 - pp_1) 16 * (pp_3 - pp_2) 64 * (pp_4 - pp_3)If the results from

**IMPORTANT FINAL NOTE!**

Due to the fact that **RNPL** evolutions
always start from an initial state file (such as **in0.sdf**), one must
be very careful that the state file that is read by the application actually
corresponds to the desired run parameters. It is a common error to run
an **RNPL** program with the wrong initial state file, and, unfortunately,
if can sometimes be difficult to detect that this has happened.

You should get in the habit of *always* removing the initial state
file before running an **RNPL** code, and you may wish to consider defining
a shell alias or script to combine the operations of removing the state
file and running the **RNPL** program.