|
1 | 1 | classdef QuasiGeostrophicProblem < otp.Problem |
2 | | - |
| 2 | + % A chaotic PDE modeling the flow of a fluid on the earth. |
| 3 | + % |
| 4 | + % The governing partial differential equation that is discretized is, |
| 5 | + % |
| 6 | + % $$ |
| 7 | + % Δψ_t = -J(ψ,ω) - {Ro}^{-1} \partial_x ψ -{Re}^{-1} Δω - {Ro}^{-1} F, |
| 8 | + % $$ |
| 9 | + % where the Jacobian term is a quadratic function, |
| 10 | + % $$ |
| 11 | + % J(ψ,ω) \equiv \partial_x ψ \partial_x ω - \partial_x ψ \partial_x ω, |
| 12 | + % $$ |
| 13 | + % the relationship between the vorticity $ω$ and the stream function $ψ$ is |
| 14 | + % $$ |
| 15 | + % ω = -Δψ, |
| 16 | + % $$ |
| 17 | + % the term $Δ$ is the two dimensional Laplacian over the |
| 18 | + % discretization, the terms $\partial_x$ and $\partial_y$ are the first derivatives |
| 19 | + % in the $x$ and $y$ directions respectively, $Ro$ is the Rossby number, $Re$ is the Reynolds |
| 20 | + % number, and $F$ is a forcing term. |
| 21 | + % The spatial domain is fixed to $x ∈ [0, 1]$ and $y ∈ [0, 2]$, and |
| 22 | + % the boundary conditions of the PDE are assumed to be zero dirichlet |
| 23 | + % everywhere. |
| 24 | + % |
| 25 | + % A second order finite difference approximation is performed on the |
| 26 | + % grid to create the first derivative operators and the Laplacian |
| 27 | + % operator. |
| 28 | + % |
| 29 | + % The Laplacian is defined using the 5-point stencil |
| 30 | + % $$ |
| 31 | + % Δ = \begin{bmatrix} & 1 & \\ 1 & -4 & 1\\ & 1 & \end{bmatrix}, |
| 32 | + % $$ |
| 33 | + % which is scaled with respect to the square of the step size in each |
| 34 | + % respective direction. |
| 35 | + % The first derivatives, |
| 36 | + % $$ |
| 37 | + % \partial_x &= \begin{bmatrix} & 0 & \\ 1/2 & 0 & 1/2\\ & 0 & \end{bmatrix},\\ |
| 38 | + % \partial_y &= \begin{bmatrix} & 1/2 & \\ 0 & 0 & 0\\ & 1/2 & \end{bmatrix}, |
| 39 | + % $$ |
| 40 | + % are the standard second order central finite difference operators in |
| 41 | + % the $x$ and $y$ directions. |
| 42 | + % |
| 43 | + % The Jacobian is discretized using the Arakawa approximation, |
| 44 | + % |
| 45 | + % $$ |
| 46 | + % J(ψ,ω) = \frac{1}{3}[ψ_x ω_y - ψ_y ω_x + (ψ ω_y)_x - (ψ ω_x)_y + (ψ_x ω)_y - (ψ_y ω)_x], |
| 47 | + % $$ |
| 48 | + % |
| 49 | + % in order for the system to not become unstable. |
| 50 | + % |
| 51 | + % The Poisson equation is solved by the eigenvalue sylvester method for |
| 52 | + % computational efficiency. |
| 53 | + % |
| 54 | + % An Approximate deconvolution large eddy simulation closure model from |
| 55 | + % :cite:p:`SSWZI11` is also implemented to have the same level of |
| 56 | + % accuracy with a coarser grid size. |
| 57 | + % |
| 58 | + % Notes |
| 59 | + % ----- |
| 60 | + % +---------------------+-----------------------------------------------------------+ |
| 61 | + % | Type | ODE | |
| 62 | + % +---------------------+-----------------------------------------------------------+ |
| 63 | + % | Number of Variables | $Nx \times Ny$ | |
| 64 | + % +---------------------+-----------------------------------------------------------+ |
| 65 | + % | Stiff | not typically, depending on $Re$, $Ro$, $Nx$, and $Ny$ | |
| 66 | + % +---------------------+-----------------------------------------------------------+ |
| 67 | + % |
| 68 | + % Example |
| 69 | + % ------- |
| 70 | + % >>> problem = otp.quasigeostrophic.presets.PopovMouSanduIliescu; |
| 71 | + % >>> sol = problem.solve(); |
| 72 | + % >>> problem.movie(sol); |
| 73 | + % |
| 74 | + |
3 | 75 | methods |
4 | 76 | function obj = QuasiGeostrophicProblem(timeSpan, y0, parameters) |
5 | 77 |
|
|
28 | 100 |
|
29 | 101 | methods (Static) |
30 | 102 |
|
31 | | - function u = resize(u, newsize) |
32 | | - % resize uses interpolation to resize states |
33 | | - |
34 | | - s = size(u); |
| 103 | + function psi = resize(psi, newsize) |
| 104 | + % Resizes the state onto a new grid by performing interpolation |
| 105 | + % |
| 106 | + % Parameters |
| 107 | + % ---------- |
| 108 | + % psi : numeric(nx, ny) |
| 109 | + % the old state on the $x \times y$ grid. |
| 110 | + % newsize : numeric(1, 2) |
| 111 | + % the new size as a two-tuple $[nx, ny]$ indicating the new state of the system. |
| 112 | + % |
| 113 | + |
| 114 | + s = size(psi); |
35 | 115 |
|
36 | 116 | X = linspace(0, 1, s(1) + 2); |
37 | 117 | Y = linspace(0, 2, s(2) + 2).'; |
|
43 | 123 | Xnew = Xnew(2:end-1); |
44 | 124 | Ynew = Ynew(2:end-1); |
45 | 125 |
|
46 | | - u = interp2(Y, X, u, Ynew, Xnew); |
| 126 | + psi = interp2(Y, X, psi, Ynew, Xnew); |
47 | 127 |
|
48 | 128 | end |
49 | 129 |
|
|
0 commit comments