Skip to content

Commit bcf8ee4

Browse files
committed
initial commit of QG docs
1 parent af1f458 commit bcf8ee4

File tree

3 files changed

+117
-11
lines changed

3 files changed

+117
-11
lines changed

toolbox/+otp/+quasigeostrophic/+presets/Canonical.m

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,28 @@
11
classdef Canonical < otp.quasigeostrophic.QuasiGeostrophicProblem
2+
% A preset of the Quasi-geostrophic equations starting at the unstable
3+
% state $ψ_0 = 0$.
4+
%
5+
% The value of the Reynolds number is $Re= 450$, the Rossby number is
6+
% $Ro=0.0036$, and the spatial discretization is $255$ interior units in
7+
% the $x$ direction and $511$ interior units in the $y$ direction.
8+
%
9+
% The timespan starts at $t=0$ and ends at $t=100$, which is
10+
% roughly equivalent to $25.13$ years.
11+
%
12+
213
methods
314
function obj = Canonical(varargin)
15+
% Create the Canonical Quasi-geostrophic problem object.
16+
%
17+
% Parameters
18+
% ----------
19+
% varargin
20+
% A variable number of name-value pairs. The accepted names are
21+
%
22+
% - ``ReynoldsNumber`` – Value of $Re$.
23+
% - ``RossbyNumber`` – Value of $Ro$.
24+
% - ``Size`` – Two-tuple of the spatial discretization, $[nx, ny]$.
25+
%
426

527
Re = 450;
628
Ro = 0.0036;

toolbox/+otp/+quasigeostrophic/+presets/PopovMouIliescuSandu.m renamed to toolbox/+otp/+quasigeostrophic/+presets/PopovMouSanduIliescu.m

Lines changed: 29 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,32 @@
1-
classdef PopovMouIliescuSandu < otp.quasigeostrophic.QuasiGeostrophicProblem
1+
classdef PopovMouSanduIliescu < otp.quasigeostrophic.QuasiGeostrophicProblem
2+
% A preset for the Quasi-geostrophic equations created for
3+
% CITE ME HERE.
4+
%
5+
% The initial condition is given by an internal file and was created by
6+
% integrating the canonical preset until time $t=100$.
7+
%
8+
% The value of the Reynolds number is $Re= 450$, the Rossby number is
9+
% $Ro=0.0036$, and the spatial discretization is $63$ interior units in
10+
% the $x$ direction and $127$ interior units in the $y$ direction.
11+
%
12+
% The timespan starts at $t=100$ and ends at $t=100.0109$, which is
13+
% roughly equivalent to one day in model time.
14+
215
methods
3-
function obj = PopovMouIliescuSandu(varargin)
16+
function obj = PopovMouSanduIliescu(varargin)
17+
% Create the PopovMouSanduIliescu Quasi-geostrophic problem object.
18+
%
19+
% Parameters
20+
% ----------
21+
% varargin
22+
% A variable number of name-value pairs. The accepted names are
23+
%
24+
% - ``ReynoldsNumber`` – Value of $Re$.
25+
% - ``RossbyNumber`` – Value of $Ro$.
26+
% - ``Size`` – Two-tuple of the spatial discretization, $[nx, ny]$.
27+
%
428

5-
defaultsize = [255, 511];
29+
defaultsize = [63, 127];
630

731
Re = 450;
832
Ro = 0.0036;
@@ -40,9 +64,9 @@
4064

4165
%% Do the rest
4266

43-
sixHours = 6*80/176251.2;
67+
oneday = 24*80/176251.2;
4468

45-
tspan = [100, 100 + sixHours];
69+
tspan = [100, 100 + oneday];
4670

4771
obj = obj@otp.quasigeostrophic.QuasiGeostrophicProblem(tspan, ...
4872
psi0, params);

toolbox/+otp/+quasigeostrophic/QuasiGeostrophicProblem.m

Lines changed: 66 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,57 @@
11
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} ψ_x -{Re}^{-1} Δω - {Ro}^{-1} F, \\
8+
% $$
9+
% where the Jacobian term is a quadratic function,
10+
% $$
11+
% J(ψ,ω) \equiv ψ_x ω_y - ψ_y ω_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, $Ro$ is the Rossby number, $Re$ is the Reynolds
19+
% number, and $F$ is a forcing term.
20+
% The spatial domain is fixed to $x ∈ [0, 1]$ and $y ∈ [0, 2]$, and
21+
% the boundary conditions of the PDE are assumed to be zero dirichlet
22+
% everywhere.
23+
%
24+
% A second order finite difference approximation is performed on the
25+
% grid to create the first derivative operators and the Laplacian
26+
% operator. The Jacobian is discretized using the Arakawa approximation
27+
% CITEME
28+
% $$
29+
% J(ψ,ω) = \frac{1}{3}[ψ_x ω_y - ψ_y ω_x + (ψ ω_y)_x - (ψ ω_x)_y + (ψ_x ω)_y - (ψ_y ω)_x],
30+
% $$
31+
% in order for the system to not become unstable.
32+
%
33+
% The Poisson equation is solved by the eigenvalue sylvester method for
34+
% computational efficiency.
35+
%
36+
% A ADLES MORE HERE.
37+
%
38+
% Notes
39+
% -----
40+
% +---------------------+-----------------------------------------------------------+
41+
% | Type | ODE |
42+
% +---------------------+-----------------------------------------------------------+
43+
% | Number of Variables | $nx \times ny$ |
44+
% +---------------------+-----------------------------------------------------------+
45+
% | Stiff | not typically, depending on $Re$, $Ro$, $Nx$, and $Ny$ |
46+
% +---------------------+-----------------------------------------------------------+
47+
%
48+
% Example
49+
% -------
50+
% >>> problem = otp.quasigeostrophic.presets.PopovMouSanduIliescu;
51+
% >>> sol = problem.solve();
52+
% >>> problem.movie(sol);
53+
%
54+
355
methods
456
function obj = QuasiGeostrophicProblem(timeSpan, y0, parameters)
557

@@ -19,10 +71,18 @@
1971

2072
methods (Static)
2173

22-
function u = resize(u, newsize)
23-
% resize uses interpolation to resize states
24-
25-
s = size(u);
74+
function psi = resize(psi, newsize)
75+
% Resizes the state onto a new grid by performing interpolation
76+
%
77+
% Parameters
78+
% ----------
79+
% psi : numeric(nx, ny)
80+
% the old state on the $x \times y$ grid.
81+
% newsize : numeric(1, 2)
82+
% the new size as a two-tuple $[nx, ny]$ indicating the new state of the system.
83+
%
84+
85+
s = size(psi);
2686

2787
X = linspace(0, 1, s(1) + 2);
2888
Y = linspace(0, 2, s(2) + 2).';
@@ -34,7 +94,7 @@
3494
Xnew = Xnew(2:end-1);
3595
Ynew = Ynew(2:end-1);
3696

37-
u = interp2(Y, X, u, Ynew, Xnew);
97+
psi = interp2(Y, X, psi, Ynew, Xnew);
3898

3999
end
40100

0 commit comments

Comments
 (0)