Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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 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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started