Skip to content

Commit

Permalink
Merge pull request #368 from FourierFlows/ncc/aliasing-docs
Browse files Browse the repository at this point in the history
Fix figures in Docs/Aliasing & Docs/Timestepping + add \citet ref style
  • Loading branch information
navidcy authored Jul 31, 2024
2 parents f831e98 + bf3a781 commit 1c412b9
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 16 deletions.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ Reexport = "189a3867-3050-52da-a836-e630ba90ab69"
Statistics = "10745b16-79ce-11e8-11f9-7d13ad32a3b2"

[compat]
CUDA = "1, 2.4.2, 3.0.0 - 3.6.4, 3.7.1, 4, 5"
CUDA = "1, 2.4.2, 3.0.0 - 3.6.4, 3.7.1, 4, 5.4"
DocStringExtensions = "0.8, 0.9"
FFTW = "1"
Interpolations = "0.12, 0.13, 0.14, 0.15"
Expand Down
2 changes: 1 addition & 1 deletion docs/make.jl
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ using
#####

bib_filepath = joinpath(@__DIR__, "src/references.bib")
bib = CitationBibliography(bib_filepath)
bib = CitationBibliography(bib_filepath, style=:authoryear)

const EXAMPLES_DIR = joinpath(@__DIR__, "..", "examples")
const OUTPUT_DIR = joinpath(@__DIR__, "src/literated")
Expand Down
16 changes: 11 additions & 5 deletions docs/src/aliasing.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,9 @@ lines!(ax, range(-Lx/2, Lx/2, length=200), f2;
color = (:salmon, 0.3), label = "cos(6x)")
scatter!(ax, x, f1.(x);
markersize = 12, color = (:steelblue, 0.9), label = "cos(4x)")
markersize = 24, marker = :star5, color = (:steelblue, 0.9), label = "cos(4x)")
scatter!(ax, x, f2.(x);
markersize = 24, marker = :star5, color = (:salmon, 0.9), label = "cos(6x)")
markersize = 12, color = (:salmon, 0.9), label = "cos(6x)")
axislegend(merge = true)
Expand Down Expand Up @@ -82,15 +82,21 @@ harmonics with wavenumbers beyond those that our grid is able to resolve and, th
aliasing errors.

The above-mentioned 1/2-rule for dealiasing for quadratic nonlinearities is, however, not the
most efficient. [Orszag-1971](@cite) pointed out that for quadratic nonlirearities, simply only
most efficient. [Orszag-1971](@citet) pointed out that for quadratic nonlirearities, simply only
discarding the highest-1/3 of wavenumber components is enough to save us from aliasing errors.
To be fair, with Orszag's so-called 2/3-rule for dealiasing, still some aliasing errors occur, but
those errors only occur to the higher-1/3 wavenumber components that will be zero-ed out at the
next time step, when we next dealias our solution anyway.

When constructing a `grid` we can specify the `aliased_fraction` parameter. By default, this is
set to ``1/3``, appropriate for quadratic nonlinearities. Then `dealias!(fh, grid)` will zero-out
the highest-`aliased_fraction` wavenumber components of `fh`.
set to ``1/3``, appropriate for quadratic nonlinearities.

```@example 1
grid = OneDGrid(; nx, Lx)
```

Then we can use `dealias!(fh, grid)` to zero-out the highest-`aliased_fraction` wavenumber
components of `fh`.

```@docs
FourierFlows.dealias!
Expand Down
12 changes: 6 additions & 6 deletions docs/src/timestepping.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ FourierFlows.jl includes several time-stepping algorithms.
Most of the time-stepping algorithms are fully explicit schemes: [`ForwardEulerTimeStepper`](@ref),
[`AB3TimeStepper`](@ref), [`RK4TimeStepper`](@ref), and [`LSRK54TimeStepper`](@ref).
Also we have implemented an [`ETDRK4TimeStepper`](@ref) scheme with the improvements described
by [Kassam-Trefethen-2005](@cite).
by [Kassam-Trefethen-2005](@citet).

The [`Problem`](@ref FourierFlows.Problem) constructor expects the chosen time stepper as
as string that includes the corresponding name of the time stepper _without_ the ending `TimeStepper`.
Expand Down Expand Up @@ -41,9 +41,9 @@ close to machine precision. That is:
\alpha = \frac{- \log\delta}{(k_{\textrm{max}} - k_{\textrm{cutoff}})^p} \ .
```

The above-mentioned filter form originates from the book by [Canuto-etal-1987](@cite).
In geophysical turbulence applications it was used by [LaCasce-1996](@cite) and later
by [Arbic-Flierl-2004](@cite).
The above-mentioned filter form originates from the book by [Canuto-etal-1987](@citet).
In geophysical turbulence applications it was used by [LaCasce-1996](@citet) and later
by [Arbic-Flierl-2004](@citet).

!!! warning "Not too steep, not too shallow"
Care should be taken if one decides to fiddle with the filter parameters. Changing
Expand All @@ -70,15 +70,15 @@ using FourierFlows: makefilter
K = 0:0.001:1 # non-dimensional wavenumber k * dx / π
fig = Figure()
ax = Axis(fig[1, 1], xlabel = "|𝐤| dx / π", ylabel = "filter", aspect=2.5, xticks=0:0.2:1)
ax = Axis(fig[1, 1], xlabel = "|𝐤| dx / π", ylabel = "filter", xticks=0:0.2:1)
vlines!(ax, 2/3, color = (:gray, 0.4), linewidth = 6, label = "cutoff wavenumber |𝐤| dx / π = 2/3 (default)")
lines!(ax, K, makefilter(K), linewidth = 4, label = "order 4 (default)")
lines!(ax, K, makefilter(K, order = 1), linestyle = :dash, label = "order 1")
lines!(ax, K, makefilter(K, order = 10), linestyle = :dot, label = "order 10")
axislegend(position = :lb)
fig[0, 1] = Legend(fig, ax)
current_figure() # hide
```
6 changes: 3 additions & 3 deletions src/timesteppers.jl
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,7 @@ uⁿ⁺¹ = uⁿ
```
where `Aᵢ`, `Bᵢ`, and `Cᵢ` are the ``A``, ``B``, and ``C`` coefficients from
the LSRK table at the ``i``-th stage. For details, refer to [Carpenter-Kennedy-1994](@cite).
the LSRK table at the ``i``-th stage. For details, refer to [Carpenter-Kennedy-1994](@citet).
!!! info "Usage"
The `LSRK54TimeStepper` is *slower* than the [`RK4TimeStepper`](@ref) but
Expand Down Expand Up @@ -429,7 +429,7 @@ That is,
uⁿ⁺¹ = exp(L * dt) * uⁿ + RK4(N(uⁿ))
```
For more info refer to [Kassam-Trefethen-2005](@cite).
For more info refer to [Kassam-Trefethen-2005](@citet).
"""
struct ETDRK4TimeStepper{T,TL} <: AbstractTimeStepper{T}
# ETDRK4 coefficents
Expand Down Expand Up @@ -684,7 +684,7 @@ Calculate the coefficients associated with the (diagonal) linear coefficient
`L` for an ETDRK4 timestepper with timestep `dt`.
The calculation is done by integrating over a unit circle in the complex space.
For more info refer to [Kassam-Trefethen-2005](@cite).
For more info refer to [Kassam-Trefethen-2005](@citet).
"""
function getetdcoeffs(dt, L; ncirc=32, rcirc=1)
shape = Tuple(cat(ncirc, ones(Int, ndims(L)), dims=1))
Expand Down

0 comments on commit 1c412b9

Please sign in to comment.