You are on page 1of 6

ODE boundary value problems (BVPs)

 Be able to distinguish bewteen ODE IVPs and BVPs


 Be able to formulate three common types of boundary conditions:
Dirichlet, Neumann, Robin

Finite difference method (FDM)

 Be able to derive forward, backward, and centered finite difference


approximations for the first derivatives
 Be able to derive centered finite difference approximations for the second
derivatives
 Be able to state the truncation errors for different finite difference
approximations

Solving ODE BVPs

 Demonstrate the ability to discretize ODE BVPs into a set of algebraic


equations
 Be able to deal with Dirichlet boundary conditions
 Be able to deal with Neumann and Robin boundary conditions by making
fictious nodes
 Solve algebraic equations using appropriate numerical methods (Gauss-
Siedel for linear systems or Newton-Raphson for nonlinear systems)

Solving coupled BVPs*

 Be able to solve coupled BVPs by interlacing the unknown dependent


variables
 Be able to identify the bandwidth of the Jacobin matrix of the reformulated
equations

* Not covered in tutorial

In the last tutorial, we introduced the general ODE form,

,
which when combined with initial conditions, formed the ODE-IVP problem, that
we then proceeded to solve.

In this unit, we consider ODE problems in which auxiliary conditions are


specified at different values of the independent variable rather than just the
specification of the initial condition. Such conditions are termed boundary
conditions and the resulting problems are called boundary value problems
(BVPs). In most of the problems of interest in chemical engineering the ODE will
be of the form,

where belongs to an interval . The positions and define the


boundaries of the spatial domain of interest. The three common types of
boundary conditions are as follows:

1. Dirichlet (boundary condition of the first kind): For this type, we


specify the value of on the boundary, e.g. .
2. Neumann (boundary condition of the second kind): For this type, we
specify the derivative of on the boundary, e.g. .
3. Robin (boundary condition of the third kind): This type involves a
combination of y and the derivative of on the boundary, e.g.
.

The finite difference method is a common approach for solving ODE-BVPs. The
first step to apply the finite difference method, is to discretize the spatial
domain. This begins by defining (often equidistant) nodes . The
discretization step is then given by

First-order derivatives and second-order derivatives appearing in will be


replaced with finite difference approximations. Common finite difference
approximations for the first-order derivatives are list below.

 Forward difference approximation:


 Backward difference approximation:
 Centered finite difference approximation:

The centered finite difference approximation is the most common finite


difference approximation used for second-order derivatives and is defined as
After the spatial discretization and the derivation of the finite difference
approximations, we can proceed with the transformation of the ODE-BVP into a
set of algebraic equations. At each interior node, we use the centered finite
difference approximations to convert the ODE into the discretized
form

The result is a set of algebraic equations in unknowns. The remaining two


equations will come from the boundary conditions. The resulting set of (in
general, nonlinear) algebraic equations will have to be solved simultaneously to
obtain the values of the unknowns. An outline for general approach to solving
BVPs is:

1. Discretize the domain into n nodes.


2. For the interior nodes, discretize the ODE using finite difference
approximations of the derivatives.
3. For the boundary nodes, if there is a Dirichlet boundary, set the
boundary node to the specified value. Otherwise, make a fictitious node
and discretize both the boundary condition and the ODE.
4. If the problem is linear, solve using any method the resulting system
. If the problem is nonlinear, form the Jacobian and solve by
Newton–Raphson.
5. Check for mesh refinement.

When solving ODE-BVPs, it is very important to apply the appropriate procedure


for dealing with each different of type of boundary condition.

When a Dirichlet boundary condition is present, the value of the boundary node is
a specified, e.g. if we have , then we set .

When a Neumann and Robin boundary conditions with a derivative term is


present, extra consideration is merited. When using the centered finite
difference method for approximations, a fictious node should be introduced in
order to to keep the same level of accuracy at the boundary.

Consider a Neumann boundary condition at the left boundary , we need to


introduce a fictious node on the left of , with a corresponding value of
. Subsequently, we implement the centered finite difference
approximation of the boundary condition:

which we can solve for the value of the fictitious node,


We now substitute this result into the differential equation at .

Suppose we have laminar flow of water, at 20 °C, through a horizontal cylindrical


tube.

Assume that we only consider the kinematics in the z-direction, and the flow is
fully developed and at steady state. Then we can have the equation:

We can rearrange and simplify the above equation as

The viscosity of water at is , and the pressure drop through


the pipe is . We plug in this information and the equation simplifed
to

At the inner surface of the pipe, a no-slip boundary condition holds, which is a
Dirichlet condition:

At the center of the pipe, a no-flux boundary condition holds due to symmetry,
which is a Neumann condition:

We may now solve for the -direction velocity profile.

We first discretize the spatial domain into nodes, , with step size
.
Then, we use centered finite difference approximations for the derivative terms
at each interior node:

Thus, the equations for interior nodes become

For the boundary nodes, at where the Dirchlet boundary condition is


applied, we have

At where the Neumann boundary condition is applied, a fictious node is


introduced, thus we have

Solving for the fictious node, we get . The equation for the first node has
to be modified because the radius is equal to zero at that node. We apply
L’Hôpital’s rule:

So the equation at becomes .

We apply centered finite differencing and plug the fictious node into the first
equation to obtain

Now, we have a system of linear equations and we can solve for the
velocity profile.

% process specifications and constants


mu = 8.9e-4; % Pa*s
dPdz = -1000; % Pa/m
delta_r = 0.001; % m
r = 0:delta_r:0.05; % m

Interactive! Now, we enter the discretized system of linear algebraic equations


in matrix-vector form. You should write the equation for the first node (center of
the pipe) by yourself.

% creating a matrix and vector for the equations


n = length(r);
A = zeros(n);
b = zeros(n,1);

% first node
A(1,1) = -4/delta_r^2;
A(1,2) = 4/delta_r^2;
b(1) = -1000/8.9e-4;

% interior nodes
for i = 2:n-1
A(i,i-1) = -1/(r(i)*2*delta_r) + 1/delta_r^2;
A(i,i) = -2/delta_r^2;
A(i,i+1) = 1/(r(i)*2*delta_r) + 1/delta_r^2;
b(i) = dPdz/mu;
end

% last node
A(n,n) = 1;
b(n) = 0;

% solving the matrix for the velocity profile


u = A\b;

% plot of velocity profile


plot(u,r,'b',u,-r,'b')
set(gca,'yticklabel',abs(get(gca,'ytick')))
xlabel('Velocity (m/s)')
ylabel('Radius (m)')

You might also like