CoCalc Public Filestmp / Shelf_1d.ipynb

# Tsunami-like wave approaching a continental shelf

This one dimensional test problem consists of a flat ocean floor, linear continental slope, flat continental shelf, and a solid wall reflecting boundary.

It is designed to illustrate how a tsunami wave is modified as it moves from the deep ocean onto the continental shelf, and the manner in which some of the energy can be trapped on the shelf and bounce back and forth.

In [1]:
%pylab inline

Populating the interactive namespace from numpy and matplotlib

Check that the CLAW environment variable is set. (It must be set in the Unix shell before starting the notebook server).

In [2]:
try:
import clawpack
location = clawpack.__file__.replace('clawpack/__init__.pyc','')
print "Using Clawpack from ",location
except:
print "*** Problem importing Clawpack -- check if environment variable set"

Using Clawpack from /usr/local/sage/sage-6.4/local/lib/python2.7/site-packages/clawpack/__init__.py

Import some modules needed below...

In [4]:
import clawpack.visclaw.JSAnimation.JSAnimation_frametools as J
from clawpack.clawutil import nbtools

--------------------------------------------------------------------------- ImportError Traceback (most recent call last) <ipython-input-4-522aa6413ca9> in <module>() 1 import clawpack.visclaw.JSAnimation.JSAnimation_frametools as J ----> 2 from clawpack.clawutil import nbtools 3 from IPython.display import FileLink ImportError: cannot import name nbtools 
In [25]:
reload(nbtools)

<module 'clawpack.clawutil.nbtools' from '/projects/db8e7c40-91ef-4ef7-a15a-7e12bcb3c959/clawpack/clawpack/clawutil/nbtools.pyc'>

### Compile the Fortran code:

In [26]:
nbtools.make_exe(new=True)

Executing shell command: make new Done... Check this file to see output:
{"html":["<a href='compile_output.txt' target='_blank'>compile_output.txt</a><br>"],"metadata":{},"output_type":"display_data","text":["/projects/db8e7c40-91ef-4ef7-a15a-7e12bcb3c959/notebooks/shelf1d/compile_output.txt"]}

### Make documentation files:

In [27]:
nbtools.make_htmls()

{"html":["<a href='README.html' target='_blank'>README.html</a><br>"],"metadata":{},"output_type":"display_data","text":["/projects/db8e7c40-91ef-4ef7-a15a-7e12bcb3c959/notebooks/shelf1d/README.html"]}

## Set parameters, run code, and plot results...

The module setrun.py contains all the default parameters. See the README.html file for a link to setrun.py if you want to inspect this.

A few of the parameters will be redefined below for each example.

In [28]:
import setrun
rundata = setrun.setrun()  # initialize most run-time variables for clawpack


The cells below set the following parameters:

• Bocean = depth of ocean (meters below sea level)
• Bshelf = depth of continental shelf
• width = width of continental slope (linear section connecting floor to shelf)
• start = location of start of continental slope

The initial data is a hump of water with zero velocity everywhere. Note that the intial hump splits into left-going and right-going waves. The left-going wave leaves the domain (since "non-reflecting" boundary conditions are used at the left boundary).

The right-going wave hits the continental slope, where some of the wave energy is reflected and some is transmitted onto the shelf. The transmitted wave reflects off the coastline (a vertical wall in this model). The reflected wave hits the slope again and is partly transmitted out to the ocean, and partly reflected back towards shore. Depending on the relative depths and steepness of the slope, quite a bit of energy may be trapped on the shelf and bounce back and forth for some time.

Note that the wave propagates more slowly on the shelf than in the deep ocean. In the shallow water equations the wave propagation speed is $\sqrt{gh}$ where $g = 9.81 m/s^2$ is the gravitational acceleration and $h$ is the water depth. The wave form also gets compressed as it moves onto the shelf because of the slower wave speed.

### Example 1.

The width of the slope is 1 m, so essentially a step discontinuity:

In [ ]:
rundata.probdata.Bocean = -4000.
rundata.probdata.Bshelf = -400.
rundata.probdata.width = 1.
rundata.probdata.start = -30.e3  # 30 kilometers offshore
rundata.write()

outdir,plotdir = nbtools.make_output_and_plots(verbose=True)
anim = J.make_anim(plotdir, fname_base='frame*fig2', figsize=(8,6))
anim

Executing shell command: make output OUTDIR=_output Done... Check this file to see output:
{"html":["<a href='run_output.txt' target='_blank'>run_output.txt</a><br>"],"metadata":{},"output_type":"display_data","text":["/projects/db8e7c40-91ef-4ef7-a15a-7e12bcb3c959/notebooks/shelf1d/run_output.txt"]}
Executing shell command: make plots OUTDIR=_output PLOTDIR=_plots

### Example 2.

The width of the slope is 1 m, so essentially a step discontinuity.

In this example the shelf is shallower than before. Note that the wave on the shelf travels slower than in Example 1, and is more compressed and higher amplitude.

In [ ]:
rundata.probdata.Bocean = -4000.
rundata.probdata.Bshelf = -50.
rundata.probdata.width = 1.
rundata.probdata.start = -30.e3
rundata.write()

outdir,plotdir = nbtools.make_output_and_plots(verbose=True)
anim = J.make_anim(plotdir, fname_base='frame*fig2', figsize=(8,6))
anim


### Example 3.

In this example, there is a wide continental slope instead of a step discontinuity. Note that there is much less reflection of energy at the slope in this case, and less energy trapped on the shelf.

In [ ]:
rundata.probdata.Bocean = -4000.
rundata.probdata.Bshelf = -100.
rundata.probdata.width = 100.e3
rundata.probdata.start = -130.e3
rundata.write()

outdir,plotdir = nbtools.make_output_and_plots(verbose=True)
anim = J.make_anim(plotdir, fname_base='frame*fig2', figsize=(8,6))
anim

Executing shell command: make output OUTDIR=_output Done... Check this file to see output:
{"html":["<a href='run_output.txt' target='_blank'>run_output.txt</a><br>"],"metadata":{},"output_type":"display_data","text":["/projects/db8e7c40-91ef-4ef7-a15a-7e12bcb3c959/notebooks/shelf1d/run_output.txt"]}
Executing shell command: make plots OUTDIR=_output PLOTDIR=_plots Done... Check this file to see output:
{"html":["<a href='plot_output.txt' target='_blank'>plot_output.txt</a><br>"],"metadata":{},"output_type":"display_data","text":["/projects/db8e7c40-91ef-4ef7-a15a-7e12bcb3c959/notebooks/shelf1d/plot_output.txt"]}
View plots created at this link:
{"html":["<a href='_plots/_PlotIndex.html' target='_blank'>_plots/_PlotIndex.html</a><br>"],"metadata":{},"output_type":"display_data","text":["/projects/db8e7c40-91ef-4ef7-a15a-7e12bcb3c959/notebooks/shelf1d/_plots/_PlotIndex.html"]}

Experiment with adjusting the parameters below and execute the cell to produce a new animation.

Note:

• You must be running the notebook for this to work (not just viewing it via nbviewer)
• The plotting routines expect parameters similar to those used above or the plots might not be scaled properly.
• It may take a few minutes to run.
In [ ]:
rundata.probdata.Bocean = -2000.
rundata.probdata.Bshelf = -1000.
rundata.probdata.width = 10.e3
rundata.probdata.start = -40.e3
rundata.write()

outdir,plotdir = nbtools.make_output_and_plots(label='new', verbose=True)
anim = J.make_anim(plotdir, fname_base='frame*fig2', figsize=(8,6))
anim

Done... Check this file to see output:
{"html":["<a href='run_output_new.txt' target='_blank'>run_output_new.txt</a><br>"],"metadata":{},"output_type":"display_data","text":["/projects/db8e7c40-91ef-4ef7-a15a-7e12bcb3c959/notebooks/shelf1d/run_output_new.txt"]}
Executing shell command: make plots OUTDIR=_output_new PLOTDIR=_plots_new Done... Check this file to see output:
{"html":["<a href='plot_output_new.txt' target='_blank'>plot_output_new.txt</a><br>"],"metadata":{},"output_type":"display_data","text":["/projects/db8e7c40-91ef-4ef7-a15a-7e12bcb3c959/notebooks/shelf1d/plot_output_new.txt"]}
View plots created at this link:
{"html":["<a href='_plots_new/_PlotIndex.html' target='_blank'>_plots_new/_PlotIndex.html</a><br>"],"metadata":{},"output_type":"display_data","text":["/projects/db8e7c40-91ef-4ef7-a15a-7e12bcb3c959/notebooks/shelf1d/_plots_new/_PlotIndex.html"]}

Once Loop Reflect