Skip to content

Commit c61abfc

Browse files
committed
First commit of calculating the eigenvectors and values manually.
1 parent 6c5709a commit c61abfc

File tree

2 files changed

+17
-18
lines changed

2 files changed

+17
-18
lines changed

src/+otp/+qg/QuasiGeostrophicProblem.m

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ function onSettingsChanged(obj)
117117
n = [nx, ny];
118118

119119
hx = 1/(nx + 1);
120-
hy = 1/(ny + 1);
120+
hy = 2/(ny + 1);
121121

122122
xdomain = [0, 1];
123123
ydomain = [0, 2];
@@ -152,23 +152,22 @@ function onSettingsChanged(obj)
152152
% for a detailed method, the "Eigenvalue Method" which makes this
153153
% particularly efficient
154154

155-
nfLx = -full(Lx);
156-
nfLy = -full(Ly);
157-
[P1, Lambda] = eig(nfLx);
158-
[P2, D] = eig(nfLy);
155+
%nfLx = -full(Lx);
156+
%nfLy = -full(Ly);
157+
%[P1, Lambda] = eig(nfLx);
158+
%[P2, D] = eig(nfLy);
159159

160160
% We can represent the eigenvalues as
161-
%dLambda = (4/(hx^2) * (sin(pi*(1:nx)/(2*(nx + 1))).^2)).';
162-
%dD = (4/(hy^2) * (sin(pi*(1:ny)/(2*(ny + 1))).^2)).';
163-
%L12 = 1./(dLambda + dD.');
164-
%P1 = sqrt(2/(nx + 1))*sin((1:nx).'*(1:nx)*pi/(nx + 1));
165-
%P2 = sqrt(2/(ny + 1))*sin((1:ny).'*(1:ny)*pi/(ny + 1));
161+
dLambda = (4/(hx^2) * (sin(pi*(1:nx)/(2*(nx + 1))).^2)).';
162+
dD = (4/(hy^2) * (sin(pi*(1:ny)/(2*(ny + 1))).^2)).';
163+
L12 = 1./(dLambda + dD.');
164+
P1 = sqrt(2/(nx + 1))*sin((1:nx).'*(1:nx)*pi/(nx + 1));
165+
P2 = sqrt(2/(ny + 1))*sin((1:ny).'*(1:ny)*pi/(ny + 1));
166166

167-
168-
169-
L12 = 1./(diag(Lambda) + diag(D).');
170-
P1T = P1.';
171-
P2T = P2.';
167+
168+
%L12 = 1./(diag(Lambda) + diag(D).');
169+
%P1T = P1.';
170+
%P2T = P2.';
172171

173172
ys = linspace(ydomain(1), ydomain(end), ny + 2);
174173
ys = ys(2:end-1);
@@ -179,7 +178,7 @@ function onSettingsChanged(obj)
179178
F = sin(pi*(ymat.' - 1));
180179

181180
obj.Rhs = otp.Rhs(@(t, psi) ...
182-
otp.qg.f(psi, Lx, Ly, P1, P1T, P2, P2T, L12, Dx, DyT, F, Re, Ro), ...
181+
otp.qg.f(psi, Lx, Ly, P1, P2, L12, Dx, DyT, F, Re, Ro), ...
183182
...
184183
otp.Rhs.FieldNames.JacobianVectorProduct, @(t, psi, u) ...
185184
otp.qg.jvp(psi, u, L, RdnL, PdnL, Ddx, Ddy, Re, Ro), ...

src/+otp/+qg/f.m

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
function dpsit = f(psi, Lx, Ly, P1, P1T, P2, P2T, L12, Dx, DyT, F, Re, Ro)
1+
function dpsit = f(psi, Lx, Ly, P1, P2, L12, Dx, DyT, F, Re, Ro)
22

33
[nx, ny] = size(L12);
44

@@ -24,7 +24,7 @@
2424
dqtmq = mJ + (1/Ro)*(dpsix) + (1/Ro)*F;
2525

2626
% solve the sylvester equation
27-
nLidqtmq = P1*(L12.*(P1T*dqtmq*P2))*P2T;
27+
nLidqtmq = P1*(L12.*(P1*dqtmq*P2))*P2;
2828

2929
% solve into stream form of the rhs
3030
dpsit = reshape(nLidqtmq - (1/Re)*(q), nx*ny, 1);

0 commit comments

Comments
 (0)