Solving PDES in MATLAB - George Mason Universitymath.gmu.edu/.../PEER_GMU_NMAIST_PDES_MATLAB.pdf ·...
Transcript of Solving PDES in MATLAB - George Mason Universitymath.gmu.edu/.../PEER_GMU_NMAIST_PDES_MATLAB.pdf ·...
Solving PDES in MATLAB
PEER 2013 Sept 6, 2013
One-Dimensional Heat Equation
Discretizing the Domain
Discretizing the Equations
Discretizing the Equations
Programming Heat Equation in MATLAB
% This is the finite difference implementation % for the heat equation on the domain (0,1) % u_t = u_xx, u(0,t)=0, u(1,t)=0, u(x,0)= x(1-x) clear all a = 0; % Left point b = 1; % Right point N = 10; % Number of intervals in x M = 10000; % Number of intervals in t T = 50; % Final Time del_x = (b - a)/N; % Step size in x del_t = T/M; % Step size in t x=a:del_x:b; % x grid t=0:del_t:T; % t grid lambda = del_t/del_x^2; % Defining Lambda
if lambda > 0.5 disp('Your lambda value is too big') else A = diag((1-2*lambda)*ones(N-1,1),0); A = A + diag(lambda*ones(N-2,1),1); A = A + diag(lambda*ones(N-2,1),-1); u_initial = x.*(1-x); Sol_mat(:,1) = u_initial(2:N)'; for i=1:10 Sol_mat(:,i+1) = A*Sol_mat(:,i); end u(1,:)=zeros(1,11); u(2:N,:)=Sol_mat; u(N+1,:)=zeros(1,11); for i=1:10 plot(x,u) hold on end end
PDE Toolbox MATLAB
Rectangular Plate with a circular Hole
( ) 0=∇− Tdiv
PDETOOL BOX
>> pdetool
Change generic scalar in the drop down menu to heat transfer.
Change generic scalar in the drop down menu to heat transfer.
Click the PDE button and select PDE Specification.
By default Type of PDE is Elliptic. Change values of h and Q to 0. Click OK.
Rectangle with a hole
• Click on one of the rectangle button on the main menu and use your mouse to define a rectangle.
Creating a Rectangle
Changing Rectangle Parameters
Click on the Rectangle and change the dimensions
Click the circle (ellipse) button and position a circle outside the rectangle
Create a Circle by changing radius
Drag the circle into the square R1 + E1
Set Formula Box R1 – E1
Click the Ω∂
Select Specify Boundary Conditions from the Boundary menu
Select Specify Boundary Conditions from the Boundary menu
Select the big
Select the big =
Refine by clicking
Push = again