from pathlib import Path
from warnings import filterwarnings
import numpy as np
import holoviews as hv
import hvplot.pandas
import pooch
import panel as pn
from IPython.display import display
import coastal_dynamics as cd
pn.extension()
2b: Wave dispersion and grouping
Welcome to the second of the four notebooks that you can practice with this week. It deals with wave dispersion and grouping. If you have succesfully taken the Waves Unit, these topics should not have many secrets to you anymore. If this is indeed the case, you could either choose to skip this notebook or use it as a refresher. If you have not taken Waves, you can use this notebook (and the more basic Notebook 2a, if necessary) to get you up-to-speed with the prerequisite knowledge for Coastal Systems. In Coastal Systems, we will not examine this knowledge separately. We will however build on it, and as such, (small) parts of it may come back in the examination.
Wind-generated and tidal waves can travel great distances until they finally reach the coast. In this notebook, we consider the propagation of both individual waves and wave groups. It is recommended to read chapter 3 of the book Coastal Dynamics when studying this notebook.
The notebook consists of three parts: 1. Application of the dispersion relationship to tsunami waves (coding exercises and 4 numeric and multiple-choice questions) 2. Cross-shore variation of wave length and wave celerity (2 multiple-selection questions) 3. Wave groups (coding exercises, 9 numeric and multiple-selection questions, a few open follow-up questions)
Import libraries that we use for our analysis
import sys
sys.path.append('../')
from modules import mod_2bquestions = cd.read_questions(Path("../hashed_questions/2b_wave_dispersion_hashed.json"))
question_industry = cd.QuestionIndustry(questions)
cd.UseAnswersApp("Q2b").serve()Fenton approximation
In this and next notebooks, we are going to use the Fenton approximation as the standard method for solving the dispersion relationship, so it is handy to find the function as you programmed it in Waves and define it in the below code field. Remember that the explicit approximation reads (see also Equation 5.4.20 in Ocean Waves by Leo Holthuijsen):
\[\begin{equation} \tag{1} k h \approx ( \frac{\alpha + \beta^2 (\cosh \beta)^{-2})}{ \tanh \beta + \beta (\cosh \beta)^{-2}} \; \mathrm{with} \; \beta = \alpha (\tanh \alpha)^{-0.5} \; \mathrm{and} \; \alpha = k_0 h \end{equation}\]
## Fenton approximation to the linear dispersion relationship
def waveNumber_Fenton(T, h):
"""
Calculate wave number using the Fenton explicit approximation
Args:
T (float): Wave period.
h (float): Water depth.
Returns:
float: Calculated wave number.
"""
k = None # Replace by your own code
return k
Part 1: Dispersion relation for tsunami waves
Theory
The linear dispersion relation relates the wave frequency \(\omega=2\pi/T\) and the wavenumber \(k=2\pi/L\), through the water depth \(h\). It holds for small-amplitude waves and read as follows:
\[\begin{equation} \tag{2} \omega = \sqrt{gk tanh(kh)} \end{equation}\]
You may also find it in this form [try to rewrite (2) to obtain (3)]:
\[\begin{equation} \tag{3} L = \frac{g}{2\pi}T^2 tanh(2\pi\frac{h}{L}) \end{equation}\]
For known \(h\) and wave length \(L\) (or, equivalently, \(k\)), it is straightforward to find the wave period \(T\) (or, equivalently, \(\omega\)). However, generally \(h\) and \(T\) would be known instead and we would end up with an implicit equation in \(k\) or \(L\). There are a few methods to solve this implicit equation: 1. Use Table A.3 of the Coastal Dynamics Open Textbook 2. Use the explicit approximation of Fenton (Equation 5.4.20 in Ocean Waves by Leo Holthuijsen) 3. Use an iterative procedure
If you have no idea at all how to apply these methods, you could first step back to Notebook 2a on Preknowledge Waves, where you can try all three methods. If you are sufficiently familiar with the methods (we assume you are, since you have followed Waves!), you can continue with this notebook 2b. From here on, we will only use explicit approximation of Fenton (Equation 5.4.20 in Ocean Waves by Leo Holthuijsen) and the deep and shallow water approximations. In Waves you should have programmed a Python function for the Fenton solution. We will use that here!
Both for large and small \(kh\), the dispersion relationship can be simplified to explicit expressions that can be solved without iterations. You should be able to find and use these simplified equations in an exam situation (see for instance Table A.3 and Section 3.5.2. in the textbook). Note that the simplified equations are also summarized in Notebook 2a.
Exercise
Here, we will apply the dispersion relationship to tsunami waves, following the exercise as described in footnote 2 on page 114 of the textbook. Tsunami periods range from 5 to 60 minutes. We assume a water depth of 4000 m.
We are going to address the following to questions: - Question A: What is the wave period range for which this depth of \(h\) = 4000 m is classified as intermediate water? In the following, we will refer to the periods that correspond to the deep and shallow water limits of this wave period range as \(T_2\) and \(T_3\), respectively. - Question B: What is the range in wave lengths for tsunami waves at this water depth? Let’s assign the variable name \(T_1\) and \(T_4\) to the lower and upper bound of the tsunami wave period range, so \(T_1\) = 300 s and \(T_4\) = 3600 s. We will refer to the corresponding wave lengths as \(L_1\) and \(L_4\), respectively.
Question A: What is the wave period range for which this depth is classified as intermediate water?
Or, in other words, compute \(T_2\) and \(T_3\). Also compute \(L_2\) and \(L_3\) (you will need these later).
Let’s do these computations in two ways: 1. First we use the shallow and deep water approximations 1. Next we use the full dispersion relationship (in the Fenton approximation)
You can use the below code cells to make your computations. Once you have done this, run the subsequent question cell to verify your answers for \(T_2\) and \(T_3\).
Deep and shallow water approximations
In the code cell below, compute \(T_2\) and \(T_3\) using the appropriate deep and shallow water approximations. This will help us get an idea of how close these approximations are to the full dispersion relationship at the shallow and deep water limits.
## Use this code cell to compute and print your answer using the shallow and deep water approximations.
h = 4000
g = 9.81
############ WRITE CODE HERE ###########
T2 = None # Replace by your code
T3 = None # Replace by your code
# You can use these print statements if you wish
# print("""Deep water limit: """,'\n',"""T2 = """, T2, 's')
# print("""Shallow water limit: """,'\n',"""T3 = """, T3, 's')
####################################Full dispersion relationship
In order to compute \(T_2\) and \(T_3\), you used the deep and shallow water approximations. In the code cell below, recompute \(T_2\) and \(T_3\) using the full dispersion relationship to get an idea of how close - at the shallow and deep water limits - these approximations are to the full dispersion relationship. For completeness, also compute \(L_2\) and \(L_3\) in this code cell (we will need these values later).
## Use this code cell to compute and print your answer using the full dispersion relationship.
h = 4000
L2 = None
L3 = None
T2 = None
T3 = None
print("""Deep water limit: """, '\n',"""L2 = """, L2, 'm','\n',"""T2 = """, T2, 's')
print("""Shallow water limit: """, '\n',"""L3 = """, L3, 'm','\n',"""T3 = """, T3, 's')
Deep water limit:
L2 = None m
T2 = None s
Shallow water limit:
L3 = None m
T3 = None s
Solution to Question A
Using the below question cell, you can verify your answers for \(T_2\) and \(T_3\). You should have found that the two approaches give slightly different values. Verify the most accurate values.
# Run this question cell to get two questions to check the answer you coded above
q = [
"Q2b-charact_tsunami_period_deep",
"Q2b-charact_tsunami_period_shallow"
]
question_industry.serve(q)Question B: What is the range in wave lengths for tsunami waves at this water depth?
We can rephrase this question as: determine the wave lengths \(L_1\) and \(L_4\), corresponding to the tsunami wave periods \(T_1\) = 300 s and \(T_4\) = 3600 s, respectively.
Let us first determine whether these waves are in deep, shallow or intermediate water. This will tell us whether we can use a deep or shallow water approximation to the dispersion relationship or not. Run the below question cell for questions about this.
# Run this question cell to get two questions about wave conditons 1 and 4
q = [
"Q2b-t1-reflection",
"Q2b-t4-reflection"
]
question_industry.serve(q)Make the computations for Question B
Now determine the wave lengths \(L_1\) and \(L_4\), corresponding to the tsunami wave periods \(T_1\) = 300 s and \(T_4\) = 3600 s, respectively. So far, the formulas we used were explicit. Now we need to solve an implicit equation to obtain \(L\). You can use your previously created Fenton function (or Table A.3 in the textbook, see also Notebook 2a), or, instead, use a deep or shallow water approximation, where appropriate (see the above questions).
Use the code cell below to compute \(L_1\) and \(L_4\).
## Use this code cell to compute L1 and L4 and print your answer
## Compute the wave lengths in meters!
h = 4000
T1 = 300
T4 = 3600
L1 = None
L4 = None
print("""Shortest tsunami wave: """,'\n',"""T1 = """, T1, 's','\n',"""L1 = """, L1, 'm','\n')
print("""Longest tsunami wave: """,'\n',"""T4 = """, T4, 's','\n',"""L4 = """, L4, 'm','\n')
Shortest tsunami wave:
T1 = 300 s
L1 = None m
Longest tsunami wave:
T4 = 3600 s
L4 = None m
Solution to Question B
You can now verify your answers for \(L_1\) and \(L_4\) (and the previously computed \(L_2\) and \(L_3\)). For this we will use a figure, in which your answers will be plotted together with the correct answer.
Note that: - You can either fill in the values for \(L_1\), \(L_2\), \(L_3\) and \(L_4\) in the code cell below, or leave the lines commented, in which case your above computed values are taken as input automatically. - If your answers are on the solid line they are correct - On the horizontal axis of the figure, we have \(\omega=2\pi/T\). Hence, the blue line corresponds to the shallow water limit and the yellow line to the deep water limit.
# Give the wave lengths in meters!
# Your input will be plotted together with the correct line. If your answers are on the solid line, they are correct.
# If you leave the below code lines commented, your above computed values for L1, L2, L3 and L4 will be automatically used.
# L1 = None
# L2 = None
# L3 = None
# L4 = None
mod_2b.W2_tsunami_L(L1, L2, L3, L4)