Clase 9 (SEMANA 10) Calculo Numerico II - PGRA - 2024 - I

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 29

Calculo Numérico II

IF-392

Semana 09
Dr. Pierre Giovanny Ramos Apestegui

Cálculo Numérico II-IF392


Boundary-Value Problems with
Mixed Boundary Conditions

Cálculo Numérico II-IF392


BVP with Mixed Boundary Conditions
In the case of mixed boundary conditions, information involving the
derivative of the dependent variable is prescribed at one or both of
the endpoints of the domain of solution. In these situations, the
finite-difference method can be used as before, but the resulting
system of equations cannot be solved because the values of the
dependent variable at both endpoints are not available. This means
there are more unknowns than there are equations. The additional
equations are derived by using finite differences to discretize the one
or two boundary conditions that involve the derivative. The
combination of the equations already obtained at the interior grid
points and those just generated at the endpoint(s) form a system of
algebraic equations that can be solved as usual.

Cálculo Numérico II-IF392


BVP with Mixed Boundary Conditions

Cálculo Numérico II-IF392


BVP with Mixed Boundary Conditions

Cálculo Numérico II-IF392


BVP with Mixed Boundary Conditions

Cálculo Numérico II-IF392


BVP with Mixed Boundary Conditions

Cálculo Numérico II-IF392


BVP with Mixed Boundary Conditions

Cálculo Numérico II-IF392


Example 01.
Consider the BVP:

Solve by the finite-difference method and Δt = 0.25. Use central-difference


approximations for all derivatives.

Cálculo Numérico II-IF392


Cálculo Numérico II-IF392
Replacing:

−1
2𝑡6 − ∆𝑡 𝑤5 − 4𝑡6 𝑤6 + 2𝑡6 + ∆𝑡 −2∆𝑡 + 4𝑤6 − 𝑤5 = −4𝑡6 ∆𝑡 2
3

1 4
2𝑡6 − ∆𝑡 𝑤5 − 2𝑡6 + ∆𝑡 𝑤5 − 4𝑡6 𝑤6 + 𝑤 2𝑡 + ∆𝑡 =
3 3 6 6
2
−4𝑡6 ∆𝑡 2 + ∆𝑡 2𝑡6 + ∆𝑡
3

4 4 −4 4 2
2
𝑡 − ∆𝑡 𝑤5 + 𝑡 + ∆𝑡 𝑤6 = −4𝑡6 ∆𝑡 + ∆𝑡 2𝑡6 + ∆𝑡
3 6 3 3 6 3 3

4 −4 2
𝑡6 − ∆𝑡 𝑤5 + 𝑡6 − ∆𝑡 𝑤6 = −4𝑡6 ∆𝑡 2 + ∆𝑡 2𝑡6 + ∆𝑡
3 3 3
Cálculo Numérico II-IF392
The coefficient matrix is once again tridiagonal. This system is solved for the
solution vector to obtain the approximate values at the interior grid points. The
process is completed by attaching w1, which is available, and w7, which is found, to
the vector of the interior grid values. The following Matlab script performs these
tasks:

Command Windows of Matlab:

>> Example01Clase09

Cálculo Numérico II-IF392


Results

Cálculo Numérico II-IF392


Cálculo Numérico II-IF392
Remembering: Summary of Finite Difference Formulas for First and Second
Derivatives

Cálculo Numérico II-IF392


The Finite Difference Method for
Nonlinear Problems

Cálculo Numérico II-IF392


The Finite Difference Method for
Nonlinear BVP Problems

Cálculo Numérico II-IF392


The Finite Difference Method for Nonlinear BVP Problems

𝑖=1

𝑖=2

𝑖 =𝑁−1

𝑖=𝑁
Cálculo Numérico II-IF392
Remembering:

Eq. 1

Cálculo Numérico II-IF392


Cálculo Numérico II-IF392
Because J is tridiagonal this is not as formidable a problem as it might at first
appear. The process is detailed in the following Algorithm.
Cálculo Numérico II-IF392
Algorithm for Nonlinear Finite-Difference

Cálculo Numérico II-IF392


Cálculo Numérico II-IF392
Cálculo Numérico II-IF392
Exercise 01

Solution:

𝑅𝑒𝑎𝑙 𝑠𝑜𝑙𝑢𝑡𝑖𝑜𝑛:
𝑥 2 + 16
𝑥
Cálculo Numérico II-IF392
Example 02
The temperature distribution along a in can be modeled as a BVP.

Cálculo Numérico II-IF392


Example 02

We will solve this system of nonlinear equations using Newton’s method for
systems. To that end, we first conveniently express the above system as

Cálculo Numérico II-IF392


Example 02

It is readily observed that the coefficient matrix in Equation 1 is tridiagonal, thus the
system in Equation 1 is most efficiently solved using the Thomas method.

The following script implements Newton’s method to find the solution estimates at
the four interior grid points. The initial values are arbitrarily selected as 400. The
maximum number of iterations was 20 and the tolerance was 10−4 .
Command Windows of Matlab:

>> Example_02_Clase_09
Cálculo Numérico II-IF392
La solución se encontró en la iteración 3:

Valor de T:

457.678576 422.704908 393.768618 369.817590

We compare these solution estimates with those obtained by the


shooting method (Metodo_Biseccion)

x Finit Difference Shooting Method


0 500 500
0.04 457.678576 457.637487
0.08 422.704908 422.649326
0.12 393.768618 393.717793
0.16 369.817590 369.786230
0.2 350 350.000088

Cálculo Numérico II-IF392

You might also like