Home > Src > Burgers > rk2.m

rk2

PURPOSE ^

RK2 One step of Explicit Runge-Kutta second order scheme.

SYNOPSIS ^

function [u1]=rk2(t,deltat,f,u0,dx,A,w,visc,uex,uex1,bc);

DESCRIPTION ^

 RK2 One step of  Explicit Runge-Kutta second order scheme.
 
 [u1]=rk2(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 RK2

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function [u1]=rk2(t,deltat,f,u0,dx,A,w,visc,uex,uex1,bc);
0002 % RK2 One step of  Explicit Runge-Kutta second order scheme.
0003 %
0004 % [u1]=rk2(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 RK2
0020 %
0021 
0022 %   Written by Paola Gervasio
0023 %   $Date: 2007/04/01$
0024 %
0025 
0026 K1=feval(f,t,deltat,u0,A,dx,w,visc,uex,uex1);
0027 t1=t+deltat; u1=u0+deltat*K1;
0028 if bc ==1
0029 u1(1)=uex(-1,t1); u1(np)=uex(1,t1);
0030 end
0031 
0032 K2=feval(f,t1,deltat,u0,A,dx,w,visc,uex,uex1);
0033 u1=u0+deltat/2*(K1+K2);
0034 if bc ==1
0035 u1(1)=uex(-1,t1); u1(np)=uex(1,t1);
0036 end
0037 
0038 return
0039

Generated on Fri 21-Sep-2007 10:07:00 by m2html © 2003