### MATLAB代写 | SF2520 Applied Numerical Methods Exercise

MATLAB边值问题的数值解

Computer Exercise 2

Numerical Solution of a Boundary Value Problem

Consider a pipe of length L with with small cylindrical cross section. In the pipe there is a fluid heated by an electric coil. The heat is spreading along the pipe and the tempera- ture T(z) at steady state is determined by the convection–diffusion ODE

d dT dT

−dz κdz +vρCdz=Q(z),

where all parameters are constant: κ is the heat conduction coefficient, v is the fluid velocity in the z-direction through the pipe, ρ is the fluid density and C is the heat capacity of the fluid. The driving function Q(z), modeling the electric coil, is defined as

0,

Q(z) = Q0 sin(z−a)π,

0,

0 ≤ z < a, a ≤ z ≤ b, b < z ≤ L.

At z = 0 the fluid has the inlet temperature T0,

T(0) = T0.

b−a

Beyond z = L the pipe is poorly insulated and heat is leaking out to the exterior, which has the temperature Tout. This assumption can be modeled by the following boundary condition (BC)

at z = L:

dT v2ρ2C2 2 vρC −κdz(L)=α(v)(T(L)−Tout), α(v)= 4 +α0 − 2 ,

where α0 is a heat convection coefficient for the non-convective (v = 0) case. Use the following valuesoftheparameters: L=10,a=1,b=3,Q0 =50,κ=0.5,α0 =10,ρ=1,C=1, Tout = 300 and T0 = 400.

Solve this boundary value problem with the finite difference method using Matlab. Dis- cretize the z-interval [0, L] with constant stepsize and use a node-numbering where z0 = 0 and zN = L. Use at least second order accurate approximations for the ODE and the BCs.

• Consider first the case v = 0, which corresponds to no convection, only diffusion. Plot the solution T(z) for v = 0 with N = 10, 20, 40, 80 in the same graph. Note the convergence of the curves in the graph. Is it second order?

• With N = 40 the solution is accurate enough for our purposes. Use this discretization to solve the problem for v = 0.1, 0.5, 1, 10, and plot the solutions in the same graph. Interpret the curves based on the physical problem they model. Are the results as expected?

SF2520 Applied Numerical Methods • HT19 Lennart Edsberg (and Olof Runborg)

1 (2)

2 (2)

• When v = 10 spurious oscillations occur. Make another plot when v = 10, showing the solution for N = 10, 20, 40 in the same graph. The oscillations become more pronounced when h increases.

• How can you get rid of these oscillations, without taking a very small h? (Hint: Check e.g. Section 4.2.4 in the text book.) Modify your implementation and show plots of the solution for N = 10, 20, 40 in the same graph.

SF2520 Applied Numerical Methods • HT19 Lennart Edsberg (and Olof Runborg)

## 发表评论