Question: this is using matlab. please answer the question in picture one 6. Coding problem: write Matlab code to solve the following advection problem using forward

 this is using matlab. please answer the question in picture one
6. Coding problem: write Matlab code to solve the following advection problem
this is using matlab. please answer the question in picture one

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)*+(59 -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),Y(i.) are Y = Y'; $ coordinates of (1,1) point F = expl - ((X-0.5).^2 + (Y-0.5). 2) / 0.05 ); $ initial condition & contourt(X, Y, F); dt = 0.001; 8 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 id ', 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!