MATLAB Code for explicit forward Eular method:
clc; clear;
delta_t = 0.001; %%% grid size in time
delta_x=0.1; %%% grid size in space
m = 10; %%% number of grid points
N = 100; %%% levels in time
lemda =delta_t/delta_x^2;
x(1:m+1)= delta_x * ((1:m+1)-1);
%%%%%%%%%%% initial condition
for i = 1:m+1
u(1,i) = sin(pi * x(i));
end
%%%%% boundary conditions
u(1,1)= 0;
u(1,m+1)= 0;
%%%%% solution of the equation
for n = 1:N+1
u(n+1,1)= 0;
u(n+1,m+1)= 0;
for i = 2 : m
u(n+1,i) =lemda*(u(n,i+1)+u(n,i-1))+(1-2*lemda)* u(n,i)
end
end
MATLAB Code for Crank Nicholson method:
clc; clear;
delta_t = 0.001; %%% grid size in time
delta_x=0.1; %%% grid size in space
m = 10; %%% number of grid points
N = 100; %%% levels in time
lemda =delta_t/delta_x^2;
x(1:m+1)= delta_x * ((1:m+1)-1);
a1(1:m-1)=1+lemda;
a2(1:m-2)= -lemda/2;
a3(1:m-2)= -lemda/2;
A=diag(a1)+ diag(a2,1)+ diag(a3,-1);
b1(1:m-1)=1-lemda;
b2(1:m-2)= lemda/2;
b3(1:m-2)= lemda/2;
B=diag(b1)+ diag(b2,1)+ diag(b3,-1);
for i = 1:m+1
u(1,i) = sin(pi * x(i));
end
%%%%% boundary conditions
u(1,1)= 0;
u(1,m+1)= 0;
%%%%% solution of the equation
for n = 1:N+1
C = B* u(n,2:m)';
u(n+1,2:m) = inv(A)* C
end
Comments:
the 2D and 3D plots can be drawn by using plot (x,y) and plot3 (x,y,z) command in MATLAB. I will upload them soon.
Example 9.2. One-Dimensional Parabolic PDE: Heat Flow Equation Consider the parabolic PDE 5 1.0515 for 0s1,0S10.1(E92.1) with the initial condition and the boundary conditions E9 2.2 Solve the par...
For : U(x,0) = Sin(ax) a= 2.6 using the Explicit Forward Euler and Crank-Nicholson methods. Example 92. One-Dimensional Parabolic PDE: Heat Flow Equation. Consider the parabolic PDE d-u(x, t) du(x, t) 0t with the initial condition and the boundary conditions (E9.2.2) We were unable to transcribe this image Example 92. One-Dimensional Parabolic PDE: Heat Flow Equation. Consider the parabolic PDE d-u(x, t) du(x, t) 0t with the initial condition and the boundary conditions (E9.2.2)
Consider the one-dimensional heat equation for nonconstant thermal properties debelo - (Kolon with the initial condition u(x, 0) = f(x). [Hint: Suppose it is known that if u(x, t) = ??(x ) h(t), then 1 dh 1 d do Ko(c) = -1 h dt c(x)p(x)o dx dx You may assume the eigenfuctions are known. Briefly discuss limt- u(x, t). Solve the initial value problem: (a) with boundary conditions u(0, t) = 0 and u(L, t) = 0 au *(b) with...
Solve the heat equation Ut = Uxx + Uyy on a square 0 <= x <= 2, 0<= y<= 2 with the following boundary and initial conditions 2. Solve the heat equation boundary conditions uvw on a square O S r s 2, 0 S vS 2 with the (note the mix of u and tu) and with initial condition 0 otherwise Present your answer as a double trigonometric sum. 2. Solve the heat equation boundary conditions uvw on a...
Solve the heat equation ut = for all time (zero Neumann boundary conditions), if the initial temperature is given by (ax)xsin TX. First, formulate the mathematical problem and complete the three steps as described 10uforarod of length 1 with both ends insulated Mathematical Formulation Step 1 Derive an expression for all nontrivial product (separated) solutions including an eigenvalue problem satisfying the boundary conditions Step 2: Solve the eigenvalue problem Step 3: Use the superposition principle and Fourier series to find...
(a) Consider the one-dimensional heat equation for the temperature u(x, t), Ou,02u where c is the diffusivity (i) Show that a solution of the form u(x,t)-F )G(t) satisfies the heat equation, provided that 护F and where p is a real constant (ii) Show that u(x,t) has a solution of the form (,t)A cos(pr)+ Bsin(p)le -P2e2 where A and B are constants (b) Consider heat flow in a metal rod of length L = π. The ends of the rod, at...
3. Consider the non homogeneous heat equation ut- urr+ 1 with non homogeneous boundary conditions u(0. t) 1, u(1t) (a) Find the equilibrium solution ueqx) to the non homogeneous equation. (b) The solution w(r, t) to the homogenized PDE wt-Wra, with w(0,t,t)0 1S -1 Verify that ugen(x, t)Ue(x) +w(x, t) solves the full PDE and BCs (c) Let u(x,0)- f(x) - 2 - ^2 be the initial condition. Find the particular solution by specifying all Fourier coefficients 3. Consider the...
Problem 1. Consider the nonhomogeneous heat equation for u(x,t) subject to the nonhomogeneous boundary conditions and the initial condition e solution u(z, t) by completing each of the following steps Find the equilibrium temperature distribution ue(a) (b) Denote v(, t)t) -)Derive the IBVP for the function vz,t). (c) Find v(x, t) (d) Find u(x,t) Problem 1. Consider the nonhomogeneous heat equation for u(x,t) subject to the nonhomogeneous boundary conditions and the initial condition e solution u(z, t) by completing each...
Let u be the solution to the initial boundary value problem for the Heat Equation au(t,) -48Fu(t,), te (0,oo), z (0,5); with boundary conditions u(t,0) 0, u(t,5) 0, and with initial condition 5 15 15 The solution u of the problem above, with the conventions given in class, has the form with the normalization conditions vn(0)-1, u Find the functions vnwn and the constants cn n(t) wnr) Let u be the solution to the initial boundary value problem for the...
formulate complete PDE problems (specify the equation, space domain, time interval, boundary, and initial conditions) for the following model situations: a) Conduction heat transfer occurs in a thin rod of length L with insulated side walls. Temperature is initially constant T(0) = T0. We are asked to find the temperature distribution in the time period 0 < t < t1, during which the left end of the rod is kept at the temperature T0, and the right end is subject...
Problem 1. Consider the nonhomogeneous heat equation for u(,) subject to the nonhomogeneous boundary conditions 14(0,t) 1, u(r,t)-0,t> and the initial condition the solution u(x, t) by completing each of the following steps (a) Find the equilibrium temperature distribution u ( (b) Denote v, t)t) - u(). Derive the IBVP for the function vz,t). (c) Find v(x, t) (d) Find u(x, t) Problem 1. Consider the nonhomogeneous heat equation for u(,) subject to the nonhomogeneous boundary conditions 14(0,t) 1, u(r,t)-0,t>...