In this problem, we will look at the convergence of the solution to a boundary value problem

Question:

In this problem, we will look at the convergence of the solution to a boundary value problem as a function of the grid spacing. Consider the reaction–diffusion equationdc dx = k(x)c

where the spatially dependent reaction term isk(x) = 10[1 + sin(x)]

The boundary conditions for the problem are c(−1) = 1 and c(1) = 0.5.

You should write a MATLAB code that solves this problem using centered finite differences for grid spacings Δx = 1/2, 1/4, . . . , 1/1024. For the smallest value of Δx = Δxmin, make a plot of the concentration versus position. We will estimate the error in the solution by comparing the value of the solution at x = 0 for the different values of Δx. Define the error of the solution as(.x) = = c(0, .x) c(0, .Xmin)  1 -

In other words, lets assume that the finest grid spacing corresponds to a “perfect” solution and assess the fractional error at the other values of x. Make a semilog-x plot of ϵ versus Δx.

Step by Step Answer:

Related Book For  book-img-for-question
Question Posted: