tutorial 4: simulation of oblique waves on a 2D planar beach
In this tutorial we will consider the modelling of oblique incident waves on a 2D planar beach. These waves generate an undertow and a longshore current.
Our starting point here is the 1D model from the previous tutorial. We’ll add some components to this model and modify it as needed.
To clearly see the effect of the longshore current, we will adjust some parameters of the 1D model. First, we will increase the wave height from 0.5 m to 2 m. And second, we will make the seabed steeper, to 1:40. Furthermore, to make things a bit more realistic, we let the waves enter the model with some directional spreading. Finally, strong gradients in the current in the surf zone may lead to horizontal mixing. We will use the Smagorinsky model for this.
It is common to define the \(x\)-direction as perpendicular to the shore, which is the cross-shore direction, and the \(y\)-direction is the longshore direction.
step 1: prepare command file
Make a copy of the previous wave breaking model:
cp wavbrk.sws obqwav.sws
or, for Windows:
copy wavbrk.sws obqwav.sws
step 2: modify command file
Modify the file obqwav.sws according to the following instructions:
extend the model domain in \(y\)-direction with a length of 200 m
choose a rather coarse mesh size \(\Delta y = 20 \Delta x\)
apply periodic boundary conditions to both the northern and southern boundaries to avoid boundary effects
redefine the bottom as a 2D field with an offshore depth of 23 m
include the Smagorinsky model to allow horizontal mixing
impose irregular waves generated by a Jonswap spectrum on the west boundary with a height of 2 m, a period of 10 s, a direction of 15 degrees, and a directional spreading of 12 degrees
set
the cycle period for synthesizing the surface elevation to 20 min, and
the simulation time to 30 minutes
include the output parameter
MVELdefined as the depth- and phase-averaged wave-induced velocity vector (averaged over the last 20 minutes of simulation)add a transect in the middle, \(y = 100\) m, which extends along the entire model domain perpendicular to the shore, for output of, among other things,
MVELinclude the
BLOCKcommand to make a snapshot of the depth- and phase-averaged velocity vectors \((U,V)\) in the whole computational domain; make sure that the file extension is.mat
Attention
Since the deepest part is set to 23 m (making a beach slope of 25/1000 = 1:40) while the peak period is 10 s, \(kd \approx 1\) which implies 1 vertical layer.
Tip
Access the commands directly through this page.
Regarding the first three instructions, see the keyword
CGRID.Look at keywords
INPGRIDandREADINPfor point 4.For point 5 see
VISCOSITY.For point 9 see
CURVE.
If you can’t figure out how to deal with these instructions, copy the text below:
!************* HEADING ********************************************
!
! tutorial: oblique directional spread waves over 2D sloping beach
!
!*********** MODEL INPUT ******************************************
CGRID 0. 0. 0. 1000. 200. 1000 50 REPEAT Y
INPGRID BOTTOM 0. 0. 0. 1 1 1000. 200.
READINPUT BOTTOM 1. 'bathy.txt' 1 0 FREE
NONHYDROSTATIC
BREAK
FRIC MANNING 0.02
VISC SMAG
BOUND SHAPE JONSWAP SIG PEAK DSPR DEGRees
BOUND SIDE West CCW BTYPE WEAK ADDB CON SPECTrum h=2. per=10. dir=15. dd=12. cycle 20 min
DISCRET UPW MOM
DISCRET UPW WMOM H NONE
!************* OUTPUT REQUESTS ************************************
QUANT DIST HEXP 10.
QUANT HS MVEL DUR 20 MIN
CURVE 'transect' 0. 100. 1000 1000. 100.
TABLE 'transect' NOHEAD 'output.txt' DIST BOTLEV HS SETUP MVEL
BLOCK 'COMPGRID' NOHEAD 'output.mat' LAY 3 XP YP BOTLEV MVEL
COMPUTE 000000.000 0.05 SEC 003000.000
STOP
and also copy this bathy.txt:
23. -2.
23. -2.
step 3: run simulation
In general, two-dimensional phase-resolved wave models are computationally intensive, especially when more than one vertical layer is involved. However, we can speed up the computational workload by distributing it evenly across a number of CPUs and then run these CPUs simultaneously. This way of improving performance of demanding HPC workloads is known as the MPI paradigm.
Current laptops in most cases have at least 4 CPUs. Let’s run our simulation with 4 CPUs, as follows:
docker run -v .:/home/swash delftwaves/swash swashrun -input obqwav -mpi 4 > swashout &
Depending on your laptop, it will take a few minutes for the simulation to complete.
Tip
You may deploy your model simulation in the cloud, for instance, with Azure Container Instances.
Important
It is good to know that the scalability of parallel runs in Docker containers is not optimal. Instead of Docker it is better to use Apptainer or Singularity. Such container platforms are available by default on HPC clusters.
step 4: post processing
Adjust files mkplot.m or mkplot.ipynb as needed and apply them for output. For instance, include wave-induced currents (undertow and longshore current)
in your plots (Mvel_x and Mvel_y are \(x\)- and \(y\)-components of the velocity).
You can also make a quiver plot of the spatially-varying wave-induced current by entering the following commands in Matlab:
clear all
load output
figure
quiver(Xp(1:5:end,1:10:end),Yp(1:5:end,1:10:end),Mvel_x(1:5:end,1:10:end),Mvel_y(1:5:end,1:10:end),0.7)
axis([500 1000 0 200])
or in Jupyter Notebook:
import matplotlib.pyplot as plt
import numpy as np
import scipy.io
mat=scipy.io.loadmat("output.mat")
xp=mat.get('Xp')
yp=mat.get('Yp')
U=mat.get('Mvel_x')
V=mat.get('Mvel_y')
fig, ax = plt.subplots()
q = ax.quiver(xp[1::5,1::10], yp[1::5,1::10], U[1::5,1::10], V[1::5,1::10],scale=10)
ax.set_xlim(500,1000)
ax.set_ylim(0,200)
plt.show()
what next?
If you have completed all four of these tutorials then you should have essentially acquired the necessary skills to run your own SWASH simulations.
It is wise to install the SWASH executable on your own machine. More information about this can be found here. It is also a good idea to study this section of the manual thoroughly before you run your first wave model simulation.
Good luck!