
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:
Application of the dispersion relationship to tsunami waves (coding exercises and 4 numeric and multiple-choice questions)
Cross-shore variation of wave length and wave celerity (2 multiple-selection questions)
Wave groups (coding exercises, 9 numeric and multiple-selection questions, a few open follow-up questions)
Import libraries that we use for our analysis¶
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()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("2b").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):
## 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 and the wavenumber , through the water depth . It holds for small-amplitude waves and read as follows:
You may also find it in this form [try to rewrite (2) to obtain (3)]:
For known and wave length (or, equivalently, ), it is straightforward to find the wave period (or, equivalently, ). However, generally and would be known instead and we would end up with an implicit equation in or . There are a few methods to solve this implicit equation:
Use Table A.3 of the Coastal Dynamics Open Textbook
Use the explicit approximation of Fenton (Equation 5.4.20 in Ocean Waves by Leo Holthuijsen)
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 , 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 to 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 = 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 and , respectively.
Question B: What is the range in wave lengths for tsunami waves at this water depth? Let’s assign the variable name and to the lower and upper bound of the tsunami wave period range, so = 300 s and = 3600 s. We will refer to the corresponding wave lengths as and , respectively.
Question A: What is the wave period range for which this depth is classified as intermediate water?¶
Or, in other words, compute and . Also compute and (you will need these later).
Let’s do these computations in two ways:
First we use the shallow and deep water approximations
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 and .
Deep and shallow water approximations¶
In the code cell below, compute and 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 and , you used the deep and shallow water approximations. In the code cell below, recompute and 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 and 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 and . 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 and , corresponding to the tsunami wave periods = 300 s and = 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 and , corresponding to the tsunami wave periods = 300 s and = 3600 s, respectively. So far, the formulas we used were explicit. Now we need to solve an implicit equation to obtain . 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 and .
## 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 and (and the previously computed and ). 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 , , and 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 . 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)Phase velocities and group velocities¶
Can you now compute the corresponding phase velocities , , and and group velocities , , and for the four tsunami waves under consideration? Note that in Notebook 2a, the equation for the group velocity was repeated. Where appropriate, you can use shallow or deep water approximations.
Use the code cell below to assign values to these variables. You can check them in the visualization in the next cell.
## Use this code cell to compute c1, c2, c3, c4, cg1, cg2, cg3, cg4 and print your answers
c1 = None
c2 = None
c3 = None
c4 = None
cg1 = None
cg2 = None
cg3 = None
cg4 = None
print("""Shortest tsunami wave: """,'\n',"""T1 = """, T1, 's','\n',"""c1 = """, c1, 'm/s','\n',"""cg1 = """, cg1, 'm/s')
print("""Deep water limit: """, '\n',"""T2 = """, T2, 's','\n',"""c2 = """, c2, 'm/s','\n',"""cg2 = """, cg2, 'm/s')
print("""Shallow water limit: """,'\n',"""T3 = """, T3, '\n',"""c3 = """, c3, 'm/s','\n',"""cg3 = """, cg3, 'm/s')
print("""Longest tsunami wave: """, '\n',"""T4 = """, T4, 's','\n',"""c4 = """, c4, 'm/s','\n',"""cg4 = """, cg4, 'm/s')
Shortest tsunami wave:
T1 = 300 s
c1 = None m/s
cg1 = None m/s
Deep water limit:
T2 = None s
c2 = None m/s
cg2 = None m/s
Shallow water limit:
T3 = None
c3 = None m/s
cg3 = None m/s
Longest tsunami wave:
T4 = 3600 s
c4 = None m/s
cg4 = None m/s
Figure of phase and group velocities¶
You can now verify your answers for phase velocities , , and and group velocities , , and . Again, we will use a figure for this, in which your answers will be plotted together with the correct answer. Note that:
You can either fill in the correct values 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 . Hence, the blue line corresponds to the shallow water limit and the yellow line to the deep water limit.
Study the figures for and and answer the folllowing questions:
For this constant depth, which waves travel faster, shorter-period or longer-period waves?
What is the ratio between and in deep and shallow, respectively?
# Give the speeds in meters per second!
# 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 c1, c2, c3, c4, cg1, cg2, cg3 and cg4 will be automatically used.
# c1 = None
# c2 = None
# c3 = None
# c4 = None
# cg1 = None
# cg2 = None
# cg3 = None
# cg4 = None
mod_2b.W2_tsunami_c_cg(c1, c2, c3, c4,cg1, cg2, cg3, cg4)Part 2: Cross-shore variation of wave length and wave celerity¶
In Part 1, we have considered waves with different wave periods at a constant water depth . Now we will consider waves with a certain wave period propagating towards the shore (so from larger water depths to a zero water depth). The wave period remains constant, but since the depth of the water decreases gradually, the wave celerity and the wavelength change also. Given the wave period , we can compute the wave length and wave celerity as they vary with .
We have already performed this task for you (we have used the Fenton approximation to the dispersion relationship). The result is shown in the below interactive figure. In the figure three waves with different wave periods are compared. You can change the wave periods for these three waves. You can also change the parameter , which indicates the bed slope (1:) as well as the water depth at the most seaward point (variable “max. depth”).
Play around with the graph to study the cross-shore variation of and and assess the influence of the various parameters. When you have done so, you can run the question cell below the figure and try answering the presented questions.
# Run this cell to get the cross-shore distribution of wave length and wave celerity for different wave periods and cross-shore profile characteristics
mod_2b.hv_W2_Q7()# Run this question cell to get two questions about the above figure: "Cross-shore distribution of wave length and wave celerity"
q = [
"Q2b-cross-shore-1",
"Q2b-cross-shore-2"
]
question_industry.serve(q)Part 3: Wave grouping¶
Bichromatic wave train on horizontal bed¶
Multiple wave components can coexist, influencing the shape of the sea surface elevation. For multiple components with frequencies that are close together, the sea-surface elevation will exhibit groupiness. We will investigate this for the simplified situation of a bi-chromatic wave train (bi-chromatic refers to two frequencies or periods). Let’s express the sea surface elevation in terms of two harmonic components:
When , this can be rewritten to (using the addition formula for two sinusoids):
We can also write this as:
using:
In this formula you can recognize a so-called carrier wave with a slowly-varying amplitude .
Plot the wave group for two waves with the same amplitude¶
We will investigate the formula for the wave group, Eq. (6), in the remainder of this notebook, using the same conditions as in the slides and textbook (see Figure 3.11) as a default: = 20 m, = 7 s, = 6.2 s and = 1.5 m.
Eq. (6) depends on t and on x, and, if we want to plot it, we can do this for a constant t and a range of x-values, or, for a constant x and a range of t-values. If you run the two code cells below, without any adjustments, you will get both a spatial plot and a time plot of:
the surface elevation;
the slowly-varying amplitude;
the so-called upper envelope.
The spatial signals are shown for t = 0, and the time signals for x = 0 m, respectively. The lower envelope is not plotted, but will simply be the negative of the upper envelope. Can you see from the figure why the name envelope is used?
Once you have seen the plot, try to code your own functions for the surface elevation, slowly-varying amplitude and upper envelope in the below cell and re-run the below two cells. The second cell will not only plot your coded functions but also check them and provide feedback as to whether your code is correct.
In the left panel of the figure, your own coded functions are shown, in the right panel the correct functions are shown. Also: compare the figure with Figure 3.11 in the textbook and then try to change the input values to see the effect.
## Below you can code your own spatial and time functions for the surface elevation, varying amplitude and upper envelope
# It is handy to first view the correct answers before you code your own functions, so that you can see what we are after
# You can do this by making no adjustments (simply leaving the code as it is, including the "None"
# If you then run the next code cell that makes the plot, only the correct answers are shown
# To code your own functions: replace None by your own code in terms of a, T1, T2, L1, L2, x, tp and xp
# The variables a, T1, T2, L1 and L2 are defined in the above given equations.
# tp is the time at which the spatial function is plotted
# xp is the location at which the time function is plotted
# We assume that a, T1 and T2 are given an that L1 and L2 are also known via Fenton as follows:
# k1 = waveNumber_Fenton(T1, h)
# k2 = waveNumber_Fenton(T2, h)
# L1 = 2 * np.pi/k1
# L2 = 2 * np.pi/k2
# Spatial function 1: the surface elevation eta for t = tp: eta(x, t = tp)
def eta_x(a, T1, T2, L1, L2, x, tp):
eta_X = None # write in terms of a, T1, T2, L1, L2, x, tp
return eta_X
# Spatial function 2: the slowly-varying amplitude for t = tp: A(x, t = tp)
def varying_amplitude_x(a, T1, T2, L1, L2, x, tp):
var_amp = None # write in terms of a, T1, T2, L1, L2, x, tp
return var_amp
# Spatial function 3: the upper envelope for t = tp
def envelope_x(a, T1, T2, L1, L2, x, tp):
envelope = None # write in terms of a, T1, T2, L1, L2, x, tp
return envelope
# Time function 1: the surface elevation eta for x = xp: eta(x = xp, t)
def eta_t(a, T1, T2, L1, L2, t, xp):
eta_T = None # write in terms of a, T1, T2, L1, L2, t, xp
return eta_T
# Time function 2: the slowly-varying amplitude for x = xp: A(x = xp, t)
def varying_amplitude_t(a, T1, T2, L1, L2, t, xp):
var_amp = None # write in terms of a, T1, T2, L1, L2, t, xp
return var_amp
# Time function 3: the upper envelope for x = xp
def envelope_t(a, T1, T2, L1, L2, t, xp):
envelope = None # write in terms of a, T1, T2, L1, L2, t, xp
return envelope
#### Run this cell to make the spatial and time plot of the surface elevation, slowly-varying amplitude and upper envelope
#### The plot function in this cell plots the functions as defined in the above code cell.
#### It uses below defined input values for the depth h = h_val, the amplitude a = a_val, the period T1 = T_1 and T2 = T_2.
#### You can use the given values and compare the results to the slides and book. Or you can change these values if you wish and run!
### First define the input values. The unknown wave lengths are computed for you using Fenton (you do not have to do anything for this!).
h_val = 20 # depth [m]
a_val = 1.5 # amplitude of wave 1 and 2 [m]
T_1 = 7 # period of wave 1 [s]
T_2 = 6.2 # period of wave 2 [s]
# Now define the x-range for spatial plot and t-range for time plot
# These are default ranges that work well for T_1 = 7, T_2 = 6.2 and h = 20
x = np.linspace(0, 1000, 5000) # x-range for spatial plot
t = np.linspace(0, 175, 1000) # t-range for time plot
## Instead of using the above defined x and t you can define x and t through the number of groups n_groups that will be shown in space and in time.
## If n_groups is set to a positive value: the above defined x and t are overruled, such that ...
# x ranges automatically from x=0 to n_groups*L_group and t ranges from t = 0 to n_groups*T_group
## If n_groups = None the above defined default x and t are used
n_groups = 4 # The number of groups in time and space
#n_groups = None # If n_groups is set to None then the above x and t are used
## Choose the fixed t- and x- values for the spatial and time plots
tp = 0 # constant t-value for spatial plot (0 is default)
xp = 0 # constant x-value for time plot (0 is default)
### End of input
### Do not change below this line
# If a value for n_groups is given:
# x and t are automatically defined, x ranges from x=0 to n_groups*L_group and t ranges from t = 0 to n_groups*T_group
if n_groups is not None:
x,t = mod_2b.ranges(h_val, T_1, T_2, n_groups) # x-range for spatial plot and t-range for time plot if n_groups has a value
# Input for spatial plot
input_values_x = {
'h': h_val,
'a': a_val,
'T1': T_1,
'T2': T_2,
'L1': [],
'L2': [],
'x': x,
'tp': tp
}
input_values_t = {
'h': h_val,
'a': a_val,
'T1': T_1,
'T2': T_2,
'L1': [],
'L2': [],
't': t,
'xp': xp
}
output_x, figure_x = mod_2b.W2_Q9_x(input_values_x, [eta_x, varying_amplitude_x, envelope_x])
output_t, figure_t = mod_2b.W2_Q9_t(input_values_t, [eta_t, varying_amplitude_t, envelope_t])
print(output_x,output_t)
display(figure_x,figure_t)Your spatial functions:
Function 1 is incorrect.
Function 2 is incorrect.
Function 3 is incorrect.
Your time functions:
Function 1 is incorrect.
Function 2 is incorrect.
Function 3 is incorrect.
Compute the group characteristics¶
Eq. (6) shows that the frequency and wave number of the slowly-varying amplitude are given by and , respectively. From the figure, we can see that the group period and length are half the period and length of the slowly-varying amplitude. Thus, the group length can be computed from and the group period from . See also Eqs. (3.24a-b) in the textbook.
Can you now compute the following wave and group characteristics:
celerity of wave 1 [m/s]
celerity of wave 2 [m/s]
celerity of the carrier wave [m/s]
group velocity [m/s]
group length [m]
group period [s]
Use the code cell below for your computations and then check your answers using the questions generated by the subsequent question cell. Note that:
The questions assume the default conditions: = 20 m, = 7 s, = 6.2 s and = 1.5 m. NB. Do you think the amplitude is relevant?
Our correct answers are computed using Fenton, which is going to be the default method for solving the full dispersion relationship in this and the upcoming notebooks. If you use Table A.3 you will find (only slightly) different values. In that case, check your answers with the answers provided on the slides of Chapter 3 or in the below interactive graph (in the part: what if the amplitudes are not equal).
## Code cell to compute correct answers for group characteristics
T_1 = 7 # Wave period 1 [s]
T_2 = 6.2 # Wave period 2 [s]
h_val = 20 # water depth [m]
Delta_w = None # Eq. 6a
Delta_k = None # Eq. 6b
w_av = None # Eq. 6c
k_av = None # Eq. 6d
c_1 = None # celerity of wave 1 [m/s]
c_2 = None # celerity of wave 2 [m/s]
c_av = None # celerity of carrier wave [m/s]
c_group = None # group velocity [m/s]
L_group = None # group length [m]
T_group = None # group period [s]
print("""c_1: """, c_1)
print("""c_2: """, c_2)
print("""c_av: """, c_av)
print("""c_group: """, c_group)
print("""L_group: """, L_group)
print("""T_group: """, T_group)
# Example print statement with four significant figures
#print("c_1",'{:g}'.format(float('{:.{p}g}'.format(c_1, p=4))))
c_1: None
c_2: None
c_av: None
c_group: None
L_group: None
T_group: None
### Run this cell to get questions to verify your computations
q = [
"Q2b-wave_group_c1",
"Q2b-wave_group_c2",
"Q2b-wave_group_cav",
"Q2b-wave_group_cgroup",
"Q2b-wave_group_Lgroup",
"Q2b-wave_group_Tgroup"
]
question_industry.serve(q)What if the amplitudes of the two waves are not equal?¶
The above used mathematical approach was possible because of the simplification that . But what if the amplitudes are not equal? Now the envelope does not go to zero, since the two components don’t cancel each other out at the nodes.
The code cell below produces a graph of the temporal and spatial signal of a wave group consisting of two different wave components with . We use a Hilbert transform to calculate the envelope for this situation. The mathematical treatment of this method is not part of this course.
Run the code cell to get the graph and use it to analyse the wave signals for various conditions. The questions below the graph can help with that.
filterwarnings("ignore", category=FutureWarning)
cd.launch_app(mod_2b.W2_wave_groups())'See the app at: http://localhost:35753'## Run this cell to get some questions about the above graph
q = [
"Q2b-wave_amplitudes_diffa1",
"Q2b-wave_amplitudes_max_envelope",
"Q2b-wave_amplitudes_min_envelope"
]
question_industry.serve(q)Follow-up questions¶
Use the graph to answer the following questions:
For the default conditions, how many waves are there (approximately) in the wave group in space and in time? NB. To reset to default values, re-run the code cell that produces the graph.
Can you now set the graph such that the number of waves in the group in space and time are equal?
When is the difference between the number of waves in a group for space and time about a factor of 2? Set the graph such that this is the case.
Can you use the graph to reproduce a spring-neap tidal cycle in a semi-diurnal tidal environment?
The end¶
You have reached the end of this Notebook 2b. You can continue with this week’s third notebook, Notebook 2c on the generation of the tide.