MATLAB Mathematics - SERC - Index of

MATLAB Mathematics - SERC - Index of MATLAB Mathematics - SERC - Index of

serc.iisc.ernet.in
from serc.iisc.ernet.in More from this publisher
15.11.2014 Views

5 Differential Equations 2.5 Solution of van der Pol Equation, µ = 1000 2 1.5 1 0.5 solution y 1 0 −0.5 −1 −1.5 −2 −2.5 0 500 1000 1500 2000 2500 3000 time t Example: Finite Element Discretization fem1ode illustrates the solution of ODEs that result from a finite element discretization of a partial differential equation. The value of N in the call fem1ode(N) controls the discretization, and the resulting system consists of N equations. By default, N is 19. This example involves a mass matrix. The system of ODEs comes from a method of lines solution of the partial differential equation e – t ∂ ----- u = ∂t ∂ 2 --------- u ∂x 2 with initial condition u( 0, x) = sin( x) and boundary conditions ut0 ( , ) = utπ ( , ) = 0 . An integer N is chosen, h is defined as π ⁄ ( N + 1) , and 5-22

Initial Value Problems for ODEs and DAEs the solution of the partial differential equation is approximated at x k k = 0, 1, ..., N+1 by = kh for N ∑ utx (, k ) ≈ c k ()φ t k ( x) k = 1 Here φ k () x is a piecewise linear function that is 1 at x k and 0 at all the other . A Galerkin discretization leads to the system of ODEs x j Mt ()c′ = Jc where ct () = c 1 () t c N () t and the tridiagonal matrices Mt () and J are given by and ⎧2h ⁄ 3exp( – t) if i = j ⎪ M ij = ⎨h ⁄ 6exp( – t) if i = j ± 1 ⎪ ⎩ 0 otherwise ⎧ – 2 ⁄ h if i = j ⎪ J ij = ⎨ 1 ⁄ h if i = j ± 1 ⎪ ⎩ 0 otherwise The initial values c( 0) are taken from the initial condition for the partial differential equation. The problem is solved on the time interval [ 0, π] . In the fem1ode example, the properties options = odeset('Mass',@mass,'MStateDep','none','Jacobian',J) indicate that the problem is of the form Mt ()y′ = Jy . The nested function mass(t) evaluates the time-dependent mass matrix Mt () and J is the constant Jacobian. 5-23

Initial Value Problems for ODEs and DAEs<br />

the solution <strong>of</strong> the partial differential equation is approximated at x k<br />

k = 0, 1, ..., N+1 by<br />

=<br />

kh<br />

for<br />

N<br />

∑<br />

utx (, k ) ≈ c k ()φ t k ( x)<br />

k = 1<br />

Here φ k () x is a piecewise linear function that is 1 at x k and 0 at all the other<br />

. A Galerkin discretization leads to the system <strong>of</strong> ODEs<br />

x j<br />

Mt ()c′<br />

= Jc where ct () =<br />

c 1 () t<br />

c N () t<br />

and the tridiagonal matrices Mt () and J are given by<br />

and<br />

⎧2h ⁄ 3exp( – t)<br />

if i = j<br />

⎪<br />

M ij = ⎨h ⁄ 6exp( – t)<br />

if i = j ± 1<br />

⎪<br />

⎩ 0 otherwise<br />

⎧ – 2 ⁄ h if i = j<br />

⎪<br />

J ij = ⎨ 1 ⁄ h if i = j ± 1<br />

⎪<br />

⎩ 0 otherwise<br />

The initial values c( 0)<br />

are taken from the initial condition for the partial<br />

differential equation. The problem is solved on the time interval [ 0,<br />

π]<br />

.<br />

In the fem1ode example, the properties<br />

options = odeset('Mass',@mass,'MStateDep','none','Jacobian',J)<br />

indicate that the problem is <strong>of</strong> the form Mt ()y′ = Jy . The nested function<br />

mass(t) evaluates the time-dependent mass matrix Mt () and J is the constant<br />

Jacobian.<br />

5-23

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

Saved successfully!

Ooh no, something went wrong!