10.07.2015 Views

Numerical Methods Library for OCTAVE

Numerical Methods Library for OCTAVE

Numerical Methods Library for OCTAVE

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

X equispaced grid of NX intervals.U solution array.Notice that we use beuler to integrate each ODE of this system. In fact if we are computingthe solution of the heat equation <strong>for</strong> example. After the finite difference approximationwe obtain the system y ′ = Ay with A = tridiag(1,-2,1). The Jacobian matrix A of this systemhas eigenvalues between 4c/(∆x)2 and 0, which makes the ODE very stiff as the spatial meshsize ∆x becomes small. This stiffness, which is typical of ODEs derived from PDEs in thismanner, must be taken into account in choosing an ODE method <strong>for</strong> solving the semidiscretesystem.3.10.2 2-D solver <strong>for</strong> Advection equationAdvection equation :u t + cu x = 0 (20)[T, X, U] = PDE_ADVEC_EXP(N, DX, K, DT, C, F) solves the advection equationD U/DT = -C D U/DX with the explicit method on [0,1]x[0,1]. Initial conditionis U(0,X) = F. C is a positive constant. N is the number of space integrationintervals and K is the number of time-integration intervals. DX is the sizeof a space integration interval and DT is the size of time-integration intervals.ParametersNX number of space integration intervals.DX size of a space integration interval.NT number of time-integration intervals.DT size of time-integration intervals.C positive constant.F initial condition U(0,X) = F(X).ReturnsT grid of NT intervals.X grid of NX intervals.U solution array.[T, X, U] = PDE_ADVEC_IMP(N, DX, K, DT, C, F) solves the advection equationD U/DT = -C D U/DX with the implicit method on [0,1]x[0,1]. Initial conditionis U(0,X) = F. C is a positive constant. N is the number of space integrationintervals and K is the number of time-integration intervals. DX is the sizeof a space integration interval and DT is the size of time-integration intervals.ParametersNX number of space integration intervals.DX size of a space integration interval.NT number of time-integration intervals.DT size of time-integration intervals.C positive constant.27

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!