Systems Dynamics Simulation Modeling of Transit Oriented ...
Modeling and simulation of systems
description
Transcript of Modeling and simulation of systems
Modeling and simulation of systems
Numerical methods for solving of differential equations
Slovak University of TechnologyFaculty of Material Science and Technology in Trnava
Euler´s method
we solve simple differential equation of first order y’ = f(x,y), y(x0) = y0
when we know the value yn= y(xn) solutions at the point xn
and f(xn,yn) = y’(xn) is the directive of tangent to graph of solution at the point (xn,yn)
we can substitute the graph of solution by the line segment with directive f(xn,yn) it means yn+1= y(xn+1) = yn + h f(xn,yn) for small? h on the interval xn,xn +h
Euler´s method
y = ex
0 1 2 3 4
Lack of Euler´s method – little precision.
Method of Runge-Kutta
The enlargement of the precision of Euler´s method in the method of Runge-Kutta lies in searching of increasing of at several points on the interval xn,xn+1
A = (xn,yn) slope at A k1 = h f(xn,yn)
B = (xn+ h/2, yn+ k1/2) slope at B k2 = h f (xn+ h/2, yn+ k1/2)
C = (xn+ h/2, yn+ k2/2) slope at C k3 = h f (xn+ h/2, yn+ k2/2)
D = (xn+ h, yn+ k3) slope at D k4 = h f (xn+ h, yn+ k3)
k1
k2
k3
k4
xn xn+ h/2 xn+1 xn+1+ h/2 xn+2
A
B
CD
Method of Runge-Kutta
Method of Runge-Kutta
Method of Runge-Kutta makes the increase – the value yn+1 as a linear combination k1,k2, k3,k4
Slope of function n = yn+1 - yn
n = 1/6 (k1+2k2+2 k3+k4) Accumulated error is not bigger than
constant multiple h5
Predictor-corrector method
For the precise/exact value is in force:
1
),(11
n
in
x
x
ii dxyxfyy
It is also necessary to know values of solution in several previous point, this follows from the formula.
Let´s substitute integral for closed trapezoid formula:
)(2
),(),(2
'1
'
111
1
nnn
nnnnnn
nn
yyh
y
yxfyxfxx
yy
1
Predictor-corrector method
Let´s subsitute integral for opened trapezoid formula:
)(23
),(),(2
''12
1121
21
nnn
nnnnnn
nn
yyhy
yxfyxfxx
yy
2
The first formula is more precise but is in implicit state. First of all we calculate the predictive value yn+1,0 by help of the second formula. Then we set y’
n+1,0 and finally we calculate reconstructive value yn+1,1 according to relation 1. This method repeats until the difference of two calculated values is smaller than determined accuracy.
Prediction of valueyn+1,0
Calculationy‘
n+1,0= f(xn+1, yn+1,0)
0j
Calculation y‘
n+1,j+1= f(xn+1, yn+1,j)
Calculation of corrected valueyn+1,j+1
y‘n+1,j+1- y‘
n+1,j
yn+1= yn+1,j+1
y‘n+1 = y‘
n+1,j+1
j+1 j
A
N
Predictor-corrector method
Comparison of methods of numerical integration
The method R-K does not call for additional primary values. There is the possibility to change the step of integration randomly.
The methods P-C call for others primary values. It is generally needed to calculate the primary conditions for the new step at the change of the step of integration.
The accuracy of both methods is approximately the same, often R-K are more precise than P-C of the same rule
R-K needs at each step so much calculation of value f(x,y) as the rule of method. The methods P-C of the fourth rule usually demand two calculation – prediction and correction. That is why we can say that they are about faster twice as R-K of the same order.
The usage of methods of numerical integration
How big is the local defect (error of method, rounding error...)
How influence has the local error upon the results in the next step. Then it is necessary to notify the stability of the method.
The necessity to know the primary conditions The speed of method
Example
Calculate the value(1.5) of solution of differential equationy’=yx, if y(1)=2 and select step 0,1.
y0=y(1) a y1=y(1.1)
k1= h f(x0,y0)= 0.1*21=0.2
2179.0)22.0
2(*1.0
)2
,2
(
2
1.01
1002
ky
hxfhk
Example
2189.0)2
2179.02(*1.0
)2
,2
(
2
1.01
2003
ky
hxfhk
k4=h*f(x0+h,y0+k3)=0.1*(2+0.2189)1+0.1=0.2403
y1=y0+1/6*(k1+2k2+2k3+k4)=...=2.219