API
SpectralWaves.Problem
SpectralWaves.absolute_error
SpectralWaves.bottom_bump!
SpectralWaves.bottom_slope!
SpectralWaves.bottom_step!
SpectralWaves.bottom_surface
SpectralWaves.bottom_vector!
SpectralWaves.convolution_power
SpectralWaves.convolution_range
SpectralWaves.convolve
SpectralWaves.convolve_dsp
SpectralWaves.factorial_lookup
SpectralWaves.fourier_transform
SpectralWaves.general_error
SpectralWaves.init_nonlinear_bottom_boundary_condition
SpectralWaves.init_nonlinear_surface_boundary_condition
SpectralWaves.inverse_fourier_transform
SpectralWaves.linear_regular_wave!
SpectralWaves.linear_wavemaker!
SpectralWaves.moving_bottom_bump!
SpectralWaves.moving_pressure_bump!
SpectralWaves.nonlinear_dfsbc_correction
SpectralWaves.nonlinear_kfsbc_correction
SpectralWaves.relative_error
SpectralWaves.solve_problem!
SpectralWaves.surface_bump!
SpectralWaves.surface_pressure
SpectralWaves.time_integration_coeffs
SpectralWaves.toeplitz
SpectralWaves.update_bbc_sle!
SpectralWaves.water_surface
SpectralWaves.water_velocity
SpectralWaves.Problem
— TypeProblem(ℓ::Real, d::Real, ℐ::Integer, t::AbstractRange{Real}; O = 4, M_s = 0, M_b = 0, static_bottom = true)
Construct an IBV Problem object corresponding to a fluid domain of length ℓ
and depth d
with ℐ
harmonics and N
time steps.
Output is a Problem object with fields:
ℓ
is the fluid domain length (m),d
is the water depth (m),ℐ
is the number of harmonics,t
is the time range,Δt
is the time step (s),N
is the number of time steps,O
is the order of the time-stepping scheme,κ
are wave numbers (rad/m),η̂
are free-surface elevation amplitudes (m),η̇
are free-surface vertical velocity amplitudes (m/s),β̂
are bottom-surface elevation amplitudes (m),β̇
are bottom-surface vertical velocity amplitudes (m/s),ϕ̂
are flat-bottom velocity potential amplitudes (m²/s),ϕ̇
are flat-bottom acceleration potential amplitudes (m²/s²),ψ̂
are uneven-bottom velocity potential amplitudes (m²/s),ψ̇
are uneven-bottom acceleration potential amplitudes (m²/s²),p̂
are surface pressure head amplitudes (m),χ
is wavemaker paddle displacement (m),ξ
is wavemaker paddle velocity (m/s),ζ
is wavemaker paddle acceleration (m/s²),𝒯
are hyperbolic tangent lookup values,𝒮
are hyperbolic secant lookup values,static_bottom
is a boolean flag to indicate if the bottom is static.
SpectralWaves.absolute_error
— Methodabsolute_error(a::Vector{<:Number}, b::Vector{<:Number})
Compute absolute error between vectors a
and b
.
Examples
julia> a = [1, 2]; b = [1, 1]; absolute_error(a, b)
1.0
SpectralWaves.bottom_bump!
— Functionbottom_bump!(p::Problem, h, λ, x₀ = 0)
Calculate β̂
coefficients of a problem p
for a bottom bump of height h
and characteristic length λ
at a position x₀
.
SpectralWaves.bottom_slope!
— Methodbottom_slope!(p::Problem, h)
Calculate β̂
coefficients a wave problem p
for a bottom slope of height h
.
SpectralWaves.bottom_step!
— Methodbottom_step!(p::Problem, h)
Calculate β̂
coefficients of a wave problem p
for a bottom step of height h
.
SpectralWaves.bottom_surface
— Functionbottom_surface(p::Problem, x::Real, n=1)
Compute the bottom surface elevation β
at position x
and for time instant n
.
SpectralWaves.bottom_vector!
— Methodbottom_vector!(p::Problem, x::AbstractRange{<:Real}, β::Vector{<:Real})
Calculate β̂
coefficients of a wave problem p
for a bottom profile β(x)
.
SpectralWaves.convolution_power
— Methodconvolution_power(a::Vector{<:Number}, n::Integer)
Compute convolution n
-th power of vector a
.
Examples
julia> a = [1, 2, 3]; convolution_power(a, 3)
7-element Vector{Int64}:
1
6
21
44
63
54
27
SpectralWaves.convolution_range
— Methodconvolution_range(m::Integral, M::Integral, n::Integer)
Compute range r
of indices of a central part of convolution vector corresponding to the m
-th order of convolution, where M
is the maximum order of convolution, N
is the length of convolution vector corresponding to the M
-th order of convolution, and ℐ
is the number of harmonics.
Examples
julia> m = 1; M = 3; ℐ = 5; c_range = convolution_range(m, M, ℐ)
11:31
SpectralWaves.convolve
— Methodconvolve(a::Vector{Ta}, b::Vector{Tb}) where {Ta<:Number, Tb<:Number}
Compute direct convolution of vectors a
and b
.
Examples
julia> a = [1, 2]; b = [1, 1]; convolve(a, b)
3-element Vector{Int64}:
1
3
2
SpectralWaves.convolve_dsp
— Methodconvolve_dsp(a::Vector{Ta}, b::Vector{Tb}) where {Ta<:Number, Tb<:Number}
Compute direct convolution of vectors a
and b
using DSP package.
Examples
julia> a = [1, 2]; b = [1, 1]; convolve(a, b)
3-element Vector{Int64}:
1
3
2
SpectralWaves.factorial_lookup
— Methodfactorial_lookup(n::Integer)
Compute lookup table for factorials of numbers from 0 to n
.
Examples
julia> factorial_lookup(3)
4-element Vector{Float64}:
1.0
1.0
2.0
6.0
SpectralWaves.fourier_transform
— Methodfourier_transform(f::Vector{<:Number}, ω::Real, x::AbstractRange{<:Real})
Compute f̂(ω)
using function values f
at points x
.
Examples
julia> f = [-1, 0, 1, 0, -1]; ω = 1; x = range(-π, π, length = 5);
julia> fourier_transform(f, ω, x)
0.5 + 0.0im
SpectralWaves.general_error
— Methodgeneral_error(a::Vector{<:Number}, b::Vector{<:Number})
Compute a general error between vectors a
and b
as a relative_error(a, b)
or an absolute_error(a, b)
for norm(a)
not equal or equal to 0, respectively.
SpectralWaves.init_nonlinear_bottom_boundary_condition
— Methodinit_nonlinear_bottom_boundary_condition(κ, 𝒯, 𝒮, ℐ, M)
Initialize expansion coefficients for nonlinear bottom boundary conditions for eigenvalues κ
, hyperbolic tangent 𝒯
and secant 𝒮
values, number of harmonics ℐ
and order of nonlinear expansion M
.
Output is a tuple (Ψ̂′, Ψ̂″, Ψ̃′, Ψ̃″)
, where:
Ψ̂′
are surface-potential-amplitude dependent expansion coefficients andΨ̂″
are bottom-potential-amplitude dependent expansion coefficients for computing bottom velocity potential amplitudes and its vertical gradients,Ψ̃′
are surface-potential-amplitude dependent expansion coefficients andΨ̃″
are bottom-potential-amplitude dependent expansion coefficients for computing bottom horizontal velocity potential amplitudes and its vertical gradients.
SpectralWaves.init_nonlinear_surface_boundary_condition
— Methodinit_nonlinear_surface_boundary_condition(κ, 𝒯, 𝒮, ℐ, M)
Initialize expansion coefficients for nonlinear free-surface boundary conditions for eigenvalues κ
, hyperbolic tangent 𝒯
and secant 𝒮
values, number of harmonics ℐ
and order of nonlinear expansion M
.
Output is a tuple (Φ̇′, Φ̇″, Φ̂′, Φ̂″, Φ̃′, Φ̃″)
, where:
Φ̇′
are surface-potential-amplitude dependent expansion coefficients andΦ̇″
are bottom-potential-amplitude dependent expansion coefficients for computing
surface acceleration potential amplitudes and its vertical gradients,
Φ̂′
are surface-potential-amplitude dependent expansion coefficients andΦ̂″
are bottom-potential-amplitude dependent expansion coefficients for computing
surface velocity potential amplitudes and its vertical gradients,
Φ̃′
are surface-potential-amplitude dependent expansion coefficients andΦ̃″
are bottom-potential-amplitude dependent expansion coefficients for computing
surface horizontal velocity potential amplitudes and its vertical gradients.
SpectralWaves.inverse_fourier_transform
— Methodinverse_fourier_transform(f̂::Vector{<:Number}, ω::AbstractRange{<:Real}, x::Real)
Compute f(x)
using expansion amplitudes f̂
and eigenvalues ω
.
Examples
julia> f̂ = [0.5, 0, 0.5]; ω = -1:1; x = π; inverse_fourier_transform(f̂, ω, x)
-1.0
SpectralWaves.linear_regular_wave!
— Methodlinear_regular_wave!(p::Problem, H, L, nΔt)
Calculate initial values of η̂
, η̇
, ϕ̂
, ϕ̇
for a regular linear wave of height H
and length L
.
SpectralWaves.linear_wavemaker!
— Methodlinear_wavemaker!(p::Problem, H, L, t₀)
Calculate wavemaker paddle displacement χ
, velocity ξ
, and acceleration ζ
for a train of linear waves of height H
and period T
and a number of ramped periods nT₀
.
SpectralWaves.moving_bottom_bump!
— Functionmoving_bottom_bump!(p::Problem, h, λ, u, x₀ = 0)
Calculate β̂
coefficients of a wave problem p
for a moving bottom bump of height h
, characteristic length λ
, and velocity u
at initial position x₀
.
SpectralWaves.moving_pressure_bump!
— Functionmoving_pressure_bump!(p::Problem, h, λ, u, x₀ = 0)
Calculate p̂
coefficients of a problem p
for a moving pressure bump of height h
, characteristic length λ
, and velocity u
at initial position x₀
.
SpectralWaves.nonlinear_dfsbc_correction
— Methodnonlinear_dfsbc_correction(η̂, ϕ̂, ϕ̇, ψ̂, ψ̇, Φ̇′, Φ̇″, Φ̂′, Φ̂″, Φ̃′, Φ̃″, κ′, ℐ, F, M, ξ, ζ, ℓ, d)
Calculate nonlinear correction δϕ̇
to dynamic free-surface boundary condition.
SpectralWaves.nonlinear_kfsbc_correction
— Methodnonlinear_kfsbc_correction(η̂, ϕ̂, ψ̂, Φ̂′, Φ̂″, Φ̃′, Φ̃″, κ, κ′, ℐ, F, M)
Calculate nonlinear correction δη̇
to kinematic free-surface boundary condition.
SpectralWaves.relative_error
— Methodrelative_error(a::Vector{<:Number}, b::Vector{<:Number})
Compute relative error between vectors a
and b
.
Examples
julia> a = [2, 2]; b = [1, 1]; relative_error(a, b)
0.5
SpectralWaves.solve_problem!
— Methodsolve_problem!(p::Problem; msg_flag = true)
Calculate solution coefficients η̂
, η̇
, ϕ̂
, ϕ̇
, ψ̂
, ψ̇
of the wave problem.
Modified in-place variables:
η̂
are free-surface elevation potential amplitudes (m),η̇
are free-surface vertical velocity amplitudes (m/s),ϕ̂
are flat-bottom velocity potential amplitudes (m²/s),ϕ̇
are flat-bottom acceleration potential amplitudes (m²/s²),ψ̂
are uneven-bottom velocity potential amplitudes (m²/s),ψ̇
are uneven-bottom acceleration potential amplitudes (m²/s²),
Input variables:
β̂
are bottom-surface elevation amplitudes (m),β̇
are bottom-surface vertical velocity amplitudes (m/s),p̂
are surface pressure head amplitudes (m),κ
are wave numbers (rad/m),𝒯
are hyperbolic tangent lookup values,𝒮
are hyperbolic secant lookup values,ℐ
is the number of harmonics,M_s
is the order of nonlinear free-surface boundary condition,M_b
is the order of nonlinear bottom boundary condition,Δt
is the time step (s),O
is the order of the time-stepping scheme,N
is the number of time steps,χ
is wavemaker paddle displacement (m),ξ
is wavemaker paddle velocity (m/s),ζ
is wavemaker paddle acceleration (m/s²),ℓ
is the fluid domain length (m),d
is the water depth (m).
Keyword arguments:
static_bottom
is a boolean flag to indicate whether the bottom is static,msg_flag
is a boolean flag to indicate whether to print progress messages.
SpectralWaves.surface_bump!
— Functionsurface_bump!(p::Problem, h, λ, x₀ = 0)
Calculate η̂
coefficients of a problem p
for a surface bump of height h
and characteristic length λ
at position x₀
.
SpectralWaves.surface_pressure
— Functionsurface_pressure(p::Problem, x::Real, n=1)
Compute the surface pressure P
at position x
and for time instant n
.
SpectralWaves.time_integration_coeffs
— Methodtime_integration_coeffs(O::Integer)
Calculate Adams-Bashforth-Moulton time-stepping scheme coefficients for a given order O
.
Output is a tuple of two vectors with Adams-Bashforth and Adams-Moulton coefficients, respectively.
SpectralWaves.toeplitz
— Methodtoeplitz(a::Vector{T}) where T
Transform vector a
to a Toeplitz matrix.
Examples
julia> a = [1, 2, 3]; toeplitz(a)
2×2 Matrix{Int64}:
2 1
3 2
SpectralWaves.update_bbc_sle!
— Methodupdate_bbc_sle!(A′, A″, Ψ̂′, Ψ̂″, Ψ̃′, Ψ̃″, w′, β̂, κ, κ′, ℐ, F, M)
Compute coefficients A′
, A″
, and w′
for the bottom boundary condition system of linear equations (SLE).
Modified in-place variables:
A′
are constant coefficients of the system of linear equations andA″
are coefficients of the system of linear equations,w′
are coefficients corresponding to the linear wavemaker term.
SpectralWaves.water_surface
— Methodwater_surface(p::Problem, x::Real, n::Integer)
Compute the water surface elevation η
at position x
and for time instant n
.
SpectralWaves.water_velocity
— Methodwater_velocity(p::Problem, x::Real, z::Real, n::Integer, c::Symbol)
Compute the water velocity component u
or w
using the symbol :x
or :z
at position (x, z)
, and for time instant n
.