Question: This is using matlab 6. Coding problem: write Matlab code to solve the following advection problem using forward Euler and 1st-order upwinding spatial discretization scheme.

This is using matlab  This is using matlab 6. Coding problem: write Matlab code to
solve the following advection problem using forward Euler and 1st-order upwinding spatial

6. Coding problem: write Matlab code to solve the following advection problem using forward Euler and 1st-order upwinding spatial discretization scheme. + - + = 0 which is solved on a 2D domain, [0, 1] x [0, 1] with periodicity along both x and y directions. The initial condition is u0(x,y) = exp (- [(x=0.5)*+(9 -0.5)?). The time integration is carried out for one period, and then we perform convergence study. (Hint: the initial condition is the exact solution at final time; a code template is provided in the next page and you might develop your own code based on it or from scratch.) Error Rate Ngrid x Ngrid 41 x 41 81 x 81 161 x 161 321 x 321 clc close clear Ngrid = 81; $ no. of grid pts along x & x = linspace(0, 1, Ngrid); y = linspace(0, 1, Ngrid); h = 1/(Ngrid-1); % grid spacing [X, Y] = meshgrid(x, y); % 2d arrays of x,y values X = X'; % transpose so that x(i, j), (i, j) are Y = Y'; $ coordinates of (i, j) point F = expl - ((X-0.5).^2 + (Y-0.5).^2) / 0.05 ); $ initial condition % contourf(X, Y, F); dt = 0.001; & time-step size (adjustable) u = F; & initialization tour = 0; Ntime - 1/dt; for itime = 1:Ntime tour = tour + dt; end % error evaluation err = sqrt(sum( sum (u - F).^2)) / Ngrid/Ngrid); fprintf('discretization error is %d ', err); contourf(X, Y, u); 6. Coding problem: write Matlab code to solve the following advection problem using forward Euler and 1st-order upwinding spatial discretization scheme. + - + = 0 which is solved on a 2D domain, [0, 1] x [0, 1] with periodicity along both x and y directions. The initial condition is u0(x,y) = exp (- [(x=0.5)*+(9 -0.5)?). The time integration is carried out for one period, and then we perform convergence study. (Hint: the initial condition is the exact solution at final time; a code template is provided in the next page and you might develop your own code based on it or from scratch.) Error Rate Ngrid x Ngrid 41 x 41 81 x 81 161 x 161 321 x 321 clc close clear Ngrid = 81; $ no. of grid pts along x & x = linspace(0, 1, Ngrid); y = linspace(0, 1, Ngrid); h = 1/(Ngrid-1); % grid spacing [X, Y] = meshgrid(x, y); % 2d arrays of x,y values X = X'; % transpose so that x(i, j), (i, j) are Y = Y'; $ coordinates of (i, j) point F = expl - ((X-0.5).^2 + (Y-0.5).^2) / 0.05 ); $ initial condition % contourf(X, Y, F); dt = 0.001; & time-step size (adjustable) u = F; & initialization tour = 0; Ntime - 1/dt; for itime = 1:Ntime tour = tour + dt; end % error evaluation err = sqrt(sum( sum (u - F).^2)) / Ngrid/Ngrid); fprintf('discretization error is %d ', err); contourf(X, Y, u)

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!