Skip to content

Commit 0c4ba09

Browse files
authored
Merge pull request #73 from FourierFlows/UpdateDocs
Adds details in twodturb module in docs
2 parents ffda3f2 + 5382098 commit 0c4ba09

File tree

2 files changed

+84
-8
lines changed

2 files changed

+84
-8
lines changed

docs/src/modules/barotropicqg.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,4 +45,4 @@ $$\mathcal{N}(\widehat{\zeta}) = - \mathrm{i}k_x \mathrm{FFT}(u q)-
4545

4646
- `examples/barotropicqg/ACConelayer.jl`: A script that simulates barotropic quasi-geostrophic flow above topography reproducing the results of the paper by
4747

48-
> Constantinou, N. C. (2018). A barotropic model of eddy saturation. *J. Phys. Oceanogr.*, **48 (2)**, 397-411
48+
> Constantinou, N. C. (2018). A barotropic model of eddy saturation. *J. Phys. Oceanogr.*, **48 (2)**, 397-411.

docs/src/modules/twodturb.md

Lines changed: 83 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,23 +24,99 @@ viscosity corresponds to $n_{\nu}=1$.
2424

2525
The equation is time-stepped forward in Fourier space:
2626

27-
$$\partial_t \widehat{q} = - \widehat{J(\psi, q)} -\left[\mu k^{2n_\mu}
28-
+\nu k^{2n_\nu}\right] \widehat{q} + \widehat{f}\ .$$
27+
$$\partial_t \widehat{q} = - \widehat{J(\psi, q)} -\left(\mu k^{2n_\mu}
28+
+\nu k^{2n_\nu}\right) \widehat{q} + \widehat{f}\ .$$
2929

30-
In doing so the Jacobian is computed in the conservative form: $\J(f,g) =
31-
\partial_y [ (\partial_x f) g] -\partial_x[ (\partial_y f) g]$.
30+
In doing so the Jacobian is computed in the conservative form: $\J(a,b) =
31+
\partial_y [ (\partial_x a) b] -\partial_x[ (\partial_y a) b]$.
3232

3333
Thus:
3434

3535
$$\mathcal{L} = -\mu k^{-2n_\mu} - \nu k^{2n_\nu}\ ,$$
3636
$$\mathcal{N}(\widehat{q}) = - \mathrm{i}k_x \mathrm{FFT}(u q)-
37-
\mathrm{i}k_y \mathrm{FFT}(\upsilon q)\ .$$
37+
\mathrm{i}k_y \mathrm{FFT}(\upsilon q) + \widehat{f}\ .$$
38+
39+
40+
### AbstractTypes and Functions
41+
42+
**Params**
43+
44+
For the unforced case ($f=0$) parameters AbstractType is build with `Params` and it includes:
45+
- `nu`: Float; viscosity or hyperviscosity coefficient.
46+
- `nnu`: Integer$>0$; the order of viscosity $n_\nu$. Case $n_\nu=1$ give normal viscosity.
47+
- `mu`: Float; bottom drag or hypoviscosity coefficient.
48+
- `nmu`: Integer$\ge 0$; the order of hypodrag $n_\mu$. Case $n_\mu=0$ give plain linear drag $\mu$.
49+
50+
For the forced case ($f\ne 0$) parameters AbstractType is build with `ForcedParams`. It includes all parameters in `Params` and additionally:
51+
- `calcF!`: Function that calculates the forcing $\widehat{f}$
52+
53+
54+
**Vars**
55+
56+
For the unforced case ($f=0$) variables AbstractType is build with `Vars` and it includes:
57+
- `q`: Array of Floats; relative vorticity.
58+
- `U`: Array of Floats; $x$-velocity, $u$.
59+
- `V`: Array of Floats; $y$-velocity, $v$.
60+
- `sol`: Array of Complex; the solution, $\widehat{q}$.
61+
- `qh`: Array of Complex; the Fourier transform $\widehat{q}$.
62+
- `Uh`: Array of Complex; the Fourier transform $\widehat{u}$.
63+
- `Vh`: Array of Complex; the Fourier transform $\widehat{v}$.
64+
65+
For the forced case ($f\ne 0$) variables AbstractType is build with `ForcedVars`. It includes all variables in `Vars` and additionally:
66+
- `Fh`: Array of Complex; the Fourier transform $\widehat{f}$.
67+
- `prevsol`: Array of Complex; the values of the solution `sol` at the previous time-step (useful for calculating the work done by the forcing).
68+
69+
70+
71+
**`calcN!` function**
72+
73+
The nonlinear term $\mathcal{N}(\widehat{q})$ is computed via functions:
74+
75+
- `calcN_advection!`: computes $- \widehat{J(\psi, q)}$ and stores it in array `N`.
76+
77+
```julia
78+
function calcN_advection!(N, sol, t, s, v, p, g)
79+
@. v.Uh = im * g.l * g.invKKrsq * sol
80+
@. v.Vh = -im * g.kr * g.invKKrsq * sol
81+
@. v.qh = sol
82+
83+
A_mul_B!(v.U, g.irfftplan, v.Uh)
84+
A_mul_B!s(v.V, g.irfftplan, v.Vh)
85+
A_mul_B!(v.q, g.irfftplan, v.qh)
86+
87+
@. v.U *= v.q # U*q
88+
@. v.V *= v.q # V*q
89+
90+
A_mul_B!(v.Uh, g.rfftplan, v.U) # \hat{U*q}
91+
A_mul_B!(v.Vh, g.rfftplan, v.V) # \hat{U*q}
92+
93+
@. N = -im*g.kr*v.Uh - im*g.l*v.Vh
94+
nothing
95+
end
96+
```
97+
98+
- `calcN_forced!`: computes $- \widehat{J(\psi, q)}$ via `calcN_advection!` and then adds to it the forcing $\widehat{f}$ computed via `calcF!` function. Also saves the solution $\widehat{q}$ of the previous time-step in array `prevsol`.
99+
100+
```julia
101+
function calcN_forced!(N, sol, t, s, v, p, g)
102+
calcN_advection!(N, sol, t, s, v, p, g)
103+
if t == s.t # not a substep
104+
v.prevsol .= s.sol # used to compute budgets when forcing is stochastic
105+
p.calcF!(v.Fh, sol, t, s, v, p, g)
106+
end
107+
@. N += v.Fh
108+
nothing
109+
end
110+
```
111+
- `updatevars!`: uses `sol` to compute $q$, $u$, $v$, $\widehat{u}$, and $\widehat{v}$ and stores them into corresponding arrays of `Vars`/`ForcedVars`.
112+
113+
- `updatevars!`: uses `sol` to compute $q$, $u$, $v$, $\widehat{u}$, and $\widehat{v}$ and stores them into corresponding arrays of `Vars`/`ForcedVars`.
38114

39115

40116
## Examples
41117

42118
- `examples/twodturb/McWilliams.jl`: A script that simulates decaying two-dimensional turbulence reproducing the results of the paper by
43119

44-
> McWilliams, J. C. (1984). The emergence of isolated coherent vortices in turbulent flow. *J. Fluid Mech.*, **146**, 21-43
120+
> McWilliams, J. C. (1984). The emergence of isolated coherent vortices in turbulent flow. *J. Fluid Mech.*, **146**, 21-43.
45121
46-
- `examples/twodturb/IsotropicRingForcing.jl`: A script that simulates stochastically forced two-dimensional turbulence. The forcing is temporally delta-corraleted and its spatial structure is isotropic with power in a narrow annulus of total radius `kf` in wavenumber space.
122+
- `examples/twodturb/IsotropicRingForcing.jl`: A script that simulates stochastically forced two-dimensional turbulence. The forcing is temporally delta-corraleted and its spatial structure is isotropic with power in a narrow annulus of total radius $k_f$ in wavenumber space.

0 commit comments

Comments
 (0)