
2a: Pre-knowledge waves¶
This is the first of four notebooks for this week, and the one that we hope you will skip! Why? It contains basic instruction and exercise material for the dispersion relationship, which should be very familiar to you after having followed the Waves Unit. We have plenty of material to cover in Coastal Systems, so our advice would be to first move to Notebook 2b and only return to Notebook 2a if you cannot solve the questions in notebook 2b. In Notebook 2b you will also use the dispersion relationship, which should give you plenty of opportunity to refresh your knowledge and practice.
This notebook 2a consists of two parts:
Part 1: Approximations for shallow, intermediate, and deep water (coding exercises and 5 multiple-choice and mulitple-selection questions)
Part 2: Three methods to solve the dispersion relationship for known and (coding exercises and 7 numeric and multiple-selection questions)
Theory¶
A brief summary of linear wave theory, including the linear dispersion relationship, is given in Sections 3.2-3.6 and Appendix A of the Coastal Dynamics Open Textbook. Here we repeat some of the equations.
The linear dispersion relation relates the wave frequency and the wavenumber , through the water depth (with the wave period and the wave length ). It holds for small-amplitude (not too high and not too steep) waves and reads as follows:
You may also find it in this form [try to rewrite (1a) to obtain (1b)]:
The wave celerity (a.k.a. phase velocity or wave speed or propagation speed) is the speed at which a certain phase of the wave, e.g. the wave crest, travels. It is equal to or, equivalenlty, . The group velocity is the speed at which the wave energy (wave front, wave group) travels. It relates to as with:
Simplifications can be made to the hyperbolic functions and , for the specific cases of deep and shallow water. These cases are found in Table A.1 in the textbook and repeated in the table below (the subscript “0” denotes deep water):
| Shallow water | Deep water |
|---|---|
Since and for , Eqs. (1) reduce for shallow water to:
or:
and:
Since and for , Eqs. (1) reduce for deep water to:
or:
and:
With the shallow and deep water approximations (Eqs. 2 and 3, respectively), you can directly determine from known and as well as from known and . For intermediate water however, the full relationships must be used (Eqs. 1). For known and wave length (or, equivalently, ), it is then still straightforward to find (and the wave period ). However, generally and would be known instead, and we would end up with an implicit equation in or . You can choose between three methods to solve this implicit equation:
Use look-up Table A.3 from the textbook (handy to use for a quick hand computation)
Use the explicit approximation of Fenton (see your Ocean Waves book and below)
Use an iterative procedure
This notebook addresses all three methods. You can use the Python function for method 2 that you have coded in the Waves Unit. You may also have coded method 3 during Waves.
Import libraries that we use for our analysis¶
from pathlib import Path
import numpy as np
import panel as pn
import coastal_dynamics as cd
pn.extension()import sys
sys.path.append('../')
from modules import mod_2aquestions = cd.read_questions(Path("../hashed_questions/2a_pre_knowledge_waves_hashed.json"))
question_industry = cd.QuestionIndustry(questions)
cd.UseAnswersApp("2a").serve()Fenton approximation¶
In the next notebooks, we are going to use the Fenton approximation as the standard method, 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: Shallow, intermediate, and deep water¶
Can you distinguish between shallow, deep water and intermediate water? Consider the following conditions:
| Wave | Characteristics |
|---|---|
| 1 | = 9 s, = 5 m |
| 2 | = 6 s, = 40 m |
| 3 | = 35 m, = 3 m |
| 4 | = 100 km, = 20 m |
Run the below question cell to get some questions. You can use the code cell below the questions, to make the computations supporting your answer.
q = [
"Q2a-depth1",
"Q2a-depth2",
"Q2a-depth3",
"Q2a-depth4",
"Q2a-depth5"
]
question_industry.serve(q)# You can use this cell to answer the above questions about Part 1
T1 = 9
h1 = 5
T2 = 6
h2 = 40
L3 = 35
h3 = 3
L4 = 100000
h4 = 20
test=12.3456
# Example print statement with 4 significant numbers
print("test",'{:g}'.format(float('{:.{p}g}'.format(test, p=4))))
test 12.35
Part 2: Three methods to solve the dispersion relationship for known and ¶
For known values of and , these values can be entered into Eqs. 1 to directly obtain . For known and , the equation is implicit in and can be solved using one of the three methods described above. Here we will try all three of them for the same conditions: = 7.1 seconds and = 4.3 meter.
Method 1: Look-up Table¶
Can you determine , and through table A.3 of the book, for a wave period () is 7.1 seconds and the water depth () is 4.3 meter? You can manually extract the values you need from Table A.3. Note that in doing so, you will have to interpolate for intermediate values. Alternatively, you can make use of the code in the below cell to do the extraction and interpolation.
Steps to take:
Study the code in the below code cell to see how to get the unknown values from Table A.3. Try it a few times with different input. For this input: verify the answers you get from the code with the values you read from the Table!
Move to the next code cell and write your code to determine , and for the given and . Make use of the given code to extract values from Table A.3. Verify with the values from the Table!
Verify your answers for , and by answering the questions in the question cell.
## METHOD TO EXTRACT VALUES
## Run this code cell to extract the unknown values from the first three columns of Table A.3 and the 8th column.
## You can apply this method in the next code cell to find answers for L, c and cg.
## Linear interpolation is used to obtain intermediate values
## Check the values with the values from the Table
# How to apply? Give a known value for h/L0 OR tanhkh OR h/L (not for n, that won't work)
# Give None for the three unknown parameters that must be looked up
# For instance: h/L0 = None, tanhkh=0.82, h/L = None, n = None
# The unknowns will be returned by the function (together with the known value).
# IMPORTANT do not change the order of the input and output!! Always use this order: h_L0,tanhkh,h_L,n
# Use a similar syntax in your computations in the next code cell
h_L0 = None # If this has a value, the other 3 should be None
tanhkh = None # If this has a value, the other 3 should be None
h_L = 0.05 # If this has a value, the other 3 should be None
n = None # This should never have a value, always n = None
h_L0,tanhkh,h_L,n=mod_2a.find_interpolate_table(h_L0,tanhkh,h_L,n)
# print with four significant figures
print("h_L0",'{:g}'.format(float('{:.{p}g}'.format(h_L0, p=4))))
print("tanhkh", '{:g}'.format(float('{:.{p}g}'.format(tanhkh, p=4))))
print("h_L", '{:g}'.format(float('{:.{p}g}'.format(h_L, p=4))))
print("n", '{:g}'.format(float('{:.{p}g}'.format(n, p=4))))h_L0 0.01525
tanhkh 0.3043
h_L 0.05
n 0.9685
## You can use this cell to code Method 1
T = 7.1 # seconds
h = 4.3 # meters
L_Table = None # replace by your code to determine L
c_Table = None # replace by your code to determine c
cg_Table = None # replace by your code to determine cg
# You can make use of these print statements to print the values with four significant figures:
#print("L_Table", '{:g}'.format(float('{:.{p}g}'.format(L_Table, p=4))))
#print("c_Table", '{:g}'.format(float('{:.{p}g}'.format(c_Table, p=4))))
#print("cg_Table", '{:g}'.format(float('{:.{p}g}'.format(cg_Table, p=4))))
# Questions about Method 1
q = [
"Q2a-table_wavelength",
"Q2a-table_wavecelerity",
"Q2a-table_groupvelocity"]
question_industry.serve(q)Method 2: Explicit approximation of Fenton¶
Can you now determine , and using the explicit approximation of Fenton (Eq.4)? Use the function that you coded at the start of this notebook. Use again a wave period () of 7.1 seconds and a water depth () of 4.3 meter. Verify your answers for , and by answering the questions in the question cell. You will notice that the answers are very close to the answers as found by using the Table.
## You can use this cell to code Method 2
T = 7.1 # seconds
h = 4.3 # meters
## Call the function that you coded at the top of this notebook
L_Fenton = None # replace by your code to determine L
c_Fenton = None # replace by your code to determine c
cg_Fenton = None # replace by your code to determine cg
## You can make use of these print statements to print the values with four significant figures:
#print("L_Table", '{:g}'.format(float('{:.{p}g}'.format(L_Table, p=4))))
#print("c_Table", '{:g}'.format(float('{:.{p}g}'.format(c_Table, p=4))))
#print("cg_Table", '{:g}'.format(float('{:.{p}g}'.format(cg_Table, p=4))))
# Questions about Method 2
q = [
"Q2a-explicit_wavelength",
"Q2a-explicit_wavecelerity",
"Q2a-explicit_groupvelocity"
]
question_industry.serve(q)Method 3: Iterative approach (optional)¶
In the Waves Unit you may or may not have coded an iterative method to solve the dispersion relationship. If you have, you could copy your function below and compute , and for the same wave characteristics as above ( = 7.1 seconds and is 4.3 meter). You should again find nearly the same values.
If you do not have the code handy, you can still proceed to the reflective question below the code cell.
## You can use this cell to code Method 3
T = 7.1 # seconds
h = 4.3 # meters
def waveNumber_Fenton_iterative(T, h):
"""
Calculate wave number using the an iterative method for dispersion relation.
Args:
T (float): Wave period.
h (float): Water depth.
tolerance (float): Tolerance for convergence, for instance tolerance=1e-12.
Returns:
float: Calculated wave number.
"""
k = None # Replace by your own code
return k # Return the final calculated wave number
k_iter = None
L_iter = None
c_iter = None
cg_iter = None
# Add your own print statements
# Question about the three methods
q = [
"Q2a-3methods"
]
question_industry.serve(q)The end¶
You have reached the end of this Notebook 2a. You can continue with this week’s second notebook, Notebook 2b on wave dispersion and wave grouping.