EE One step of Explicit Euler scheme for 1D parabolic problems. [u1]=ee(tt,deltat,f,u0,dx,A,w,visc,uex,uex1,bc); Input : tt =time deltat = time step f = function for the r.h.s of the parabolic equation u0 = initial data dx = LGL first derivative matrix A = matrix related to differential operator w = LGL weights array visc = viscosity coefficient (constant > 0) uex = exact solution (uex=@(x)[uex(x)], with .*, .^, ./) uex1 = exact solution (uex=@(x)[uex(x)], with .*, .^, ./) bc = choice of boundary conditions: 1 == Dirichlet 2 == Neumann Output: u1 = array solution, computed with one step of EE Written by Paola Gervasio $Date: 2007/04/01$
0001 function [u1]=ee(tt,deltat,f,u0,dx,A,w,visc,uex,uex1,bc); 0002 % EE One step of Explicit Euler scheme for 1D parabolic problems. 0003 % 0004 % [u1]=ee(tt,deltat,f,u0,dx,A,w,visc,uex,uex1,bc); 0005 % 0006 % Input : tt =time 0007 % deltat = time step 0008 % f = function for the r.h.s of the parabolic equation 0009 % u0 = initial data 0010 % dx = LGL first derivative matrix 0011 % A = matrix related to differential operator 0012 % w = LGL weights array 0013 % visc = viscosity coefficient (constant > 0) 0014 % uex = exact solution (uex=@(x)[uex(x)], with .*, .^, ./) 0015 % uex1 = exact solution (uex=@(x)[uex(x)], with .*, .^, ./) 0016 % bc = choice of boundary conditions: 1 == Dirichlet 0017 % 2 == Neumann 0018 % 0019 % Output: u1 = array solution, computed with one step of EE 0020 % 0021 % Written by Paola Gervasio 0022 % $Date: 2007/04/01$ 0023 % 0024 0025 K1=feval(f,tt,deltat,u0,A,dx,w,visc,uex,uex1,bc); 0026 u1=u0+deltat*K1; 0027 if bc==1 0028 np=length(u1); 0029 u1(1)=uex(-1,tt); 0030 u1(np)=uex(1,tt); 0031 end 0032 0033 return 0034