003 Primer On Mathematics

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

ERE 722

Dr. Qasem Abdelal

1
Abdelal
This discussion will involve some mathematical
tools and methods and their applications in
engineering.

For Modeling purposes, environmental


mechanical, and electrical systems can be
categorized as deterministic with continuous
variables. Deterministic systems can be
described either by static, or dynamic
formulations

2
Abdelal
Models here are built using algebraic equations
that are not a function of time. They could be
linear or non-linear.

Y = aX +b (linear)

Y=ex+b (Non Linear)

3
Abdelal
These are typically described by differential
equations, which are equations that contain
one or more derivatives.
1. Ordinary differential equations when there
is only one independent variable
𝒅𝒚
= 𝟓𝒙𝟐 + 𝟑 for example
𝒅𝒙
2. Partial differential equation, when there are
more than one independent variable
𝝏𝟐 𝒖
𝑼𝒕 = + 𝒆−𝒕 for example
𝝏𝒙𝟐

4
Abdelal
Mathematical analysis can be either analytical or
computational (Numerical)

Analytical solution: the solution of the formulation


is found as an expression consisting of the
parameters and the independent variables in terms
of symbols

Computational (Numerical solution): The solution


is found numerically, often with the aid of a
computer. Solutions are approximate and numeric.
This has the advantage of being applicable to a
wide class of mathematical formulations,
particularly complex systems

5
Abdelal
Simple algebraic •Steady state concentration of a
equations contaminant in a completely mixed lake

System of a simultaneous •Steady state concentration in lakes in


linear equations series that are completely mixed

Ordinary differential •Transient concentration in a well mixed


equations lake

Partial differential •Contaminant transport in a stratified


equations lake under transient load

6
Abdelal
7
Abdelal
Simple algebraic •Steady state concentration of a
equations contaminant in a completely mixed lake

System of a simultaneous •Steady state concentration in lakes in


linear equations series that are completely mixed

Ordinary differential •Transient concentration in a well mixed


equations lake

Partial differential •Contaminant transport in a stratified


equations lake under transient load

8
Abdelal
The solution (root) is the independent variable
X, that when substituted into f(x) will make it
equal to zero.
a) Single linear equation, one variable, straight
forward.
b) A set of linear equations: typical examples
of these include chemical speciation
calculations
𝑎11 𝑥1 + 𝑎12 𝑥2 + 𝑎13 𝑥3 = 𝑏1
𝑎21 𝑥1 + 𝑎22 𝑥2 + 𝑎23 𝑥3 = 𝑏2
𝑎31 𝑥1 + 𝑎32 𝑥2 + 𝑎33 𝑥3 = 𝑏3

9
Abdelal
𝑎11 𝑥1 + 𝑎12 𝑥2 + 𝑎13 𝑥3 = 𝑏1
𝑎21 𝑥1 + 𝑎22 𝑥2 + 𝑎23 𝑥3 = 𝑏2
𝑎31 𝑥1 + 𝑎32 𝑥2 + 𝑎33 𝑥3 = 𝑏3
Here, m = number of equations = 3
n = number of varaiables = 3
If n = m then there is a unique solution.
The equations above can be represented in a
matrix format
Ax= b
Where x is the solution matrix  x=A-1b

10
Abdelal
One method to solve these sets of equations is
using the Gauss-Seidel method.

11
Abdelal
Example: Solve the following set of equations

12
Abdelal
Another method for solving the system of
linear equations is Gauss elimination, this is
the method used by software such as Excel
solver.

Here, the equations are written in the format


F(x,y,z,…) = 0, therefore, the iterative
procedure will search through the tentative
values of x,y,z that would yield the value to be
zero.

13
Abdelal
14
Abdelal
c) Single, nonlinear equation
Here , the solution is either direct or indirect.

Direct solution involves known formulas


applied to standard forms of the equations in a
non-repetitive manner. A known example is
the solution to the quadratic equation
ax2+bx+c=0, which is

15
Abdelal
Indirect methods, repeated application of some
algorithm is implemented to yield an
approximate solution.

Examples of those are the binary method and


the Newton Raphson Method.

16
Abdelal
1- The Binary method
◦ Guess the values of XL and Xu those will bracket the
real root X such that XL < X and Xu>X. Also,
f(XL).f(Xu)<0.
◦ A new X, called Xr, is obtained, the process above is
repeated with either XL, Xr or with Xr, Xu depending
on wither the product of f(XL)f(Xr)<0 or f(Xu)f(Xr)<0
Xr=(XL+Xu)/2
◦ The process is repeated until the new guess is very
close to the old one.

17
Abdelal
k = 0.25 (1/day)

18
Abdelal
2- The Newton Raphson Method
Based on Taylor’s expansion which is based on
the statement that each smooth function can
be approximated as a polynomial

h here is Xn+1-Xn

19
Abdelal
Abdelal Wikipedia 20
The first derivative of the function at X is
equivalent to the slope


𝑓 𝑥𝑖 − 0
𝑓 𝑥𝑖 =
𝑥𝑖− 𝑥𝑖+1
Rearranging:
𝑓(𝑥𝑖 )
𝑥𝑖+1 = 𝑥𝑖 − ′
𝑓 (𝑥𝑖 )

The derivative can be approximated as


𝑓 𝑥𝑛 −𝑓(𝑥𝑛−1 )
𝑓′ 𝑥𝑛 = 𝑠𝑙𝑜𝑝𝑒 𝑎𝑡 𝑥𝑛 =
𝑥𝑛 −𝑥𝑛−1
This approximation is referred to as the secant
method
21
Abdelal
D) Set of non-linear equations
There are no direct methods for solving
simultaneous non-linear equations. The most
popular method is the newton’s iteration
method, which is based on Taylor’s expansion.

22
Abdelal
Simple algebraic •Steady state concentration of a
equations contaminant in a completely mixed lake

System of a simultaneous •Steady state concentration in lakes in


linear equations series that are completely mixed

Ordinary differential •Transient concentration in a well mixed


equations lake

Partial differential •Contaminant transport in a stratified


equations lake under transient load

23
Abdelal
Most environmental systems can be modeled as
ODE

Only a few ODEs can be solved analytically, the rest


numerically.

All solution methods for the ODEs require that the


dependent variable and/or its derivatives be known
at prescribed values of the independent variables.
Cases where the independent values are at zero
values are referred to as initial value problems.

24
Abdelal
If the values are other than zero, they are
referred to as boundary value problems.

The constraints are called initial conditions for


the initial value problem and boundary
conditions at the boundary value problem.

25
Abdelal
A) Analytical solution of the ODE
The general form of an ODE may be stated as
follows:

with an IC of

The solution to this will be a function y(x) that


satisfies both the differential equation and the
IC
26
Abdelal
Some of the most common analytical solutions
for ordinary differential equations are given
below:
1- First-order equations: when an ODE can be
expressed in the form:

then the equation is separable, and the


solution can be found by integrating each term
in:

27
Abdelal
2- First-order nonhomogeneous linear
equations: when an ODE can be expressed in
the form

it can be solved by using an integrating factor


of the form: to give the solution as

b is the constant of integration


28
Abdelal
3- Second-order equation with
equidimensional coefficients: when the ODE
can be expressed in the form:

The solution can be given as

29
Abdelal
Where s is given by:

30
Abdelal
4- Second-order equation with constant
coefficients: when the ODE can be expressed in
the form:

The solution can be given as:

31
Abdelal
Where s is given by:

32
Abdelal
Example:
The buildup of the concentration, C, in a lake
due to a new step waste load input can be
described by the following equation

The initial concentration of the waste material


in the lake = 0. Develop a solution to the above
ODE to describe the concentration in the lake
as a function of time.

33
Abdelal
34
Abdelal
35
Abdelal
B-Computational Solutions of ODEs
Two of the more common computational
methods used for solving such equations,
Euler’s Method and the Runge-Kutta Method,

1- Euler’s method: this method is based on the


application of Taylor’s series to estimate the
function

36
Abdelal
By ignoring terms of h2 and higher order, the
equation can be approximated by the
following:

So a function value (y) at a step (xo+h) can be


approximated using its derivative value y’ from
the previous step (xo).

The assumption is that slope at the beginning


of the step is the same over the entire step.

37
Abdelal
Example:
Solve the previous
example numerically

38
Abdelal
39
Abdelal
1- Runge-Kutta method: the error in Euler’s
method stems from the assumption that the
slope at the beginning of the calculation step is
the same over the entire step.

This approach overcomes this limitation by


introducing a higher order approximation of
the derivatives, which is an average slope of
four parameters, hence called a fourth order.

40
Abdelal
Here, f is the derivative function, xn is the
independent variable, yn is the dependent variable

41
Abdelal
Example:
Employ the Runge Kutta method to integrate Y’
where:
Y’ =4e0.8t-0.5y
From t=0 to 1 using a step size of 1 with Y(0)
=2

42
Abdelal
43
Abdelal
44
Abdelal
Systems of coupled ODEs are rather common in
many environmental systems.

The Runge-Kutta method can be extended to


systems of ODEs as well as to higher-order
differential equations

Higher-order equations have to be reduced to


first-order equations by introducing new
variables before applying the Runge Kutta
method

45
Abdelal
Higher order ODE need to be reduced to first
order equations, for example:

The order of the above can be reduced from 2


to 1 by introducing

46
Abdelal
Hence, the original problem is now equivalent
to one with two coupled ODEs:

Details are in the book

47
Abdelal
Simple algebraic •Steady state concentration of a
equations contaminant in a completely mixed lake

System of a simultaneous •Steady state concentration in lakes in


linear equations series that are completely mixed

Ordinary differential •Transient concentration in a well mixed


equations lake

Partial differential •Contaminant transport in a stratified


equations lake under transient load

48
Abdelal
These are used when dependent variables are
expressed in more than one independent
variable.

For example, the concentration of a pollutant


in a river may be a function of time and river
miles, whereas that in an aquifer may be a
function of the three spatial dimensions as well
as of time. Such systems are modeled using
partial differential equations

49
Abdelal
To solve these, initial and boundary conditions
are required

Most PDEs can’t be solved analytically, rather


numerically.

Finite difference and finite element methods


are most known.

50
Abdelal
Finite difference:
The continuous
model depicted by
the conceptual
model is replaced
with a set of
discrete points
arranged in a grid
pattern. Finite
difference grid.

51
Abdelal
Here the partial derivative is approximated by
difference according to Taylor’s expansion.
The procedure is as follows:
1- The problem domain is first divided into a
grid of n node points
2- The PDE is approximated
by difference equations
relating the functional
value at neighboring
points in the grid.

52
Abdelal
Finite difference:
3- Then, the resulting set of n equations in n
unknowns is solved to obtain the approximate
solution values at the node points

Using the notation of


subscript “j ” for the
y-variable and subscript
“i” for the x-variable,
the difference equations
take the following forms

53
Abdelal
 Consider the forward Taylor series expansion of a
function h(x) near a point x

h(x)
 Solve for 1st derivative
h(x)
x x
x
x  x x x  x

From: Daene C. McKinney


Abdelal
 Consider the backward Taylor series expansion of a
function f(x) near a point x

 Solve for 1st derivative h(x)

h(x)
x x
x
x  x x x  x

From: Daene C. McKinney


Abdelal
h(x)

hi-1 hi+1
hi

x x
x
ii-1 i i +1

𝑙 𝑙 𝑙 𝑙 𝑙
𝜕ℎ ℎ𝑖+1 − ℎ𝑖𝑙 𝜕ℎ ℎ𝑖+1 − ℎ𝑖−1
≈ ≈
𝜕𝑥 𝑖 ∆𝑥 𝜕𝑥 2∆𝑥
𝑖
1st x Derivative 1stx Derivative 1stx Derivative
(Backward) (Forward) (Central difference)

From: Daene C. McKinney


Abdelal
Abdelal
From: Wikipedia 57
t, l

1st t Derivative i, l  1
(Backward) t
i  1, l i  1, l
i, l
x, i
x

i, l  1

1st t Derivative
(Forward)

From: Daene C. McKinney


Abdelal
h(x)

hi-1 hi+1
hi

x x
i -1 i -1/ 2 i i +1/ 2 i +1

From: Daene C. McKinney


Abdelal
60
Abdelal
Example:
The advective-diffusive transport of a pollutant in
a river, undergoing a first-order decay reaction,
can be modeled by the following equation

C is the concentration of the pollutant,


E is the dispersion coefficient,
U is the velocity,
k is the reaction rate constant,
t is the time, and
x is the distance along the river
Develop the finite difference formulation to
solve the above PDE numerically
61
Abdelal
For the following ODE, use the finite difference
method find u as a function of r, use 4
equidistant nodes to do the problem
𝑑2 𝑢 1 𝑑𝑢 𝑢
2
+ − 2=0
𝑑𝑟 𝑟 𝑑𝑟 𝑟
Given the following boundary conditions:
U(2) = 0.008, U(6.5)=0.003

62
Abdelal
63
Abdelal
Consider a two dimensional steady state
governing equation for homogeneous isotropic
aquifers (Laplace equation)
𝜕2ℎ 𝜕2ℎ
2
+ 2=0
𝜕𝑥 𝜕𝑧
Develop the finite difference formulation for a
regular grid where a ∆x and ∆z are constant.

64
Abdelal
65
Abdelal
66
Abdelal

You might also like