Commit 1fbf8747 authored by Gidon Lucian Bauer's avatar Gidon Lucian Bauer 🏳
Browse files

Der verzweifelte Versuch den Bumms zum laufen zu bekommen

parent bfe23ea8
%% multidimensional Finite Volume method
function [U] = FVM_3D(u0, flux, f, xspan, tspan, N)
temp = 4;
U = zeros(N, temp*N, 3); % Nx(2N)x3
U = zeros(N, N, 3); % NxNx3
dx = (xspan(2) - xspan(1)) / N;
dt = dx/temp; % this is currently arbitrarily choosen
dt = (tspan(2) - tspan(1)) / N;
U(:, 1, :) = u0;
for time = 1:temp*N-1
for space = 2:N-1
fluxl = flux(f, U(space-1, time, :), U(space, time, :));
fluxr = flux(f, U(space, time, :), U(space+1, time, :));
for time = 1:N-1
for space = 1:N
% assuming periodic boundary conditions
if space == 1
fluxl = flux(f, U(end, time, :), U(space, time, :));
fluxr = flux(f, U(space, time, :), U(space+1, time, :));
elseif space == N
fluxl = flux(f, U(space-1, time, :), U(space, time, :));
fluxr = flux(f, U(space, time, :), U(1, time, :));
else
fluxl = flux(f, U(space-1, time, :), U(space, time, :));
fluxr = flux(f, U(space, time, :), U(space+1, time, :));
end
U(space, time+1, 1) = U(space, time, 1) + (dt/dx) * (fluxl(1) - fluxr(1));
U(space, time+1, 2) = U(space, time, 2) + (dt/dx) * (fluxl(2) - fluxr(2));
U(space, time+1, 3) = U(space, time, 3) + (dt/dx) * (fluxl(3) - fluxr(3));
......
......@@ -14,10 +14,11 @@ f = @f_euler;
flux = @HLL_flux;
%% Setup
N = 5;
N = 10;
xspan = [0;1];
tspan = [0;0.25];
tspan = [0;0.15];
% tspan = [0;0.25];
%% Set initial conditions
% Note: this ul and ur contains [rho, v, p], while all other u further in
......@@ -45,4 +46,33 @@ end
u0 = init_cond(ul, ur, N);
U = FVM_3D(u0, flux, f, xspan, tspan, N);
\ No newline at end of file
U = FVM_3D(u0, flux, f, xspan, tspan, N);
%% Plotting
x = linspace(xspan(1), xspan(2), N);
t = linspace(tspan(1), tspan(2), N);
figure(1);
tiledlayout(2,2);
nexttile;
pcolor(t, x, U(:,:,1));
% surf(t, x, U(:,:,1));
title('Density');
xlabel('t');
ylabel('x');
nexttile;
pcolor(t, x, U(:,:,2));
% surf(t, x, U(:,:,2));
title('Velocity');
xlabel('t');
ylabel('x');
nexttile;
pcolor(t, x, U(:,:,3));
% surf(t, x, U(:,:,3));
title('Total energy');
xlabel('t');
ylabel('x');
......@@ -16,5 +16,4 @@ function [ar] = max_eig(func, ul, ur)
if ar > 1e5
ar = 1e5;
end
% disp(ar);
end
\ No newline at end of file
......@@ -12,9 +12,9 @@ function [al] = min_eig(func, ul, ur)
eigs(1:si) = eig(Jacl);
eigs(si+1:end) = eig(Jacr);
al = min(eigs);
% al = min(eigs);
al = min(real(eigs)); % only using the real part of the eigenvalue
if (al < -1e5)
al = -1e5;
end
% disp(al);
end
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment