Lecture 03 OdE
Lecture 03 OdE
http://www.mpia.de/homes/mordasini/UKNUM/UeB_ode.pdf
http://numericalmethods.eng.usf.edu
Transforming Numerical Methods Education for STEM
02/11/10 http://numericalmethods.eng.usf.edu 1
Simulation example: Formation of Stars
SPH simulation with
gravity and super-
sonic turbulence.
Initial conditions:
Uniform density
1000Msun
1pc diameter
Temperature 10K
Magneto Rotational Instability (MRI) drives
turbulence in accretion disks
12/13/2009
Simulation by Mario Flock using the
Hubert Klahr - Planet Formation - MPIA
Heidelberg Pluto code.
3
Gravoturbulent formation of
Formation Of
Planetesimals planetesimals - Concentration in
From pressure
trapped /
Zonal Flows:
gravitational
Bound heaps of
gravel - here
magnetic
turbulence:
512 ^2 simulation
64 Mio particles
Entire project used
15 Mio. CPU hours.
gas
dust
Poisson equation solved viaHubert
12/13/2009
FFT inHeidelberg
parallel mode: up to 2563 cells
Klahr - Planet Formation - MPIA
Euler Method
http://numericalmethods.eng.usf.edu
Euler’s Method
y
True value
y1, Predicted
Slope x0,y0 Φ value
Step size, h
http://
3 numericalmethods.eng.usf.edu
Euler’s Method
y
True Value
Φ
yi
h
Step size
x
xi xi+1
Example
is rewritten as
In this case
http://
5 numericalmethods.eng.usf.edu
Example
A ball at 1200K is allowed to cool down in air at an ambient temperature
of 300K. Assuming heat is lost only due to radiation, the differential
equation for the temperature of the ball is given by
Find the temperature at seconds using Euler’s method. Assume a step size of
seconds.
http://
6 numericalmethods.eng.usf.edu
Solution
Step 1:
http://
7 numericalmethods.eng.usf.edu
Solution Cont
Step 2: For
http://
8 numericalmethods.eng.usf.edu
Solution Cont
http://
9 numericalmethods.eng.usf.edu
Comparison of Exact and
Numerical Solutions
1200,0000
900,0000
θ(K)
Exact Solution
Temperature,
600,0000
h=240
300,0000
0,0000
0 125 250 375 500
Time, t(sec)
http://
11 numericalmethods.eng.usf.edu
Comparison with exact results
1200,0000
600,0000
h=120
Temperature,
300,0000 h=240
0,0000
-300,0000
h=480
-600,0000
-900,0000
-1200,0000
0 125 250 375 500
Time, t (sec)
Figure 4. Comparison of Euler’s method with exact solution for different step sizes
http://
12 numericalmethods.eng.usf.edu
Effects of step size on Euler’s
Method
750,0000
500,0000
250,0000
θ(K)
Temperature,
0,0000
-250,0000
-500,0000
-750,0000
-1000,0000
0 125 250 375 500
Step size, h (s)
As you can see the first two terms of the Taylor series
http://
14 numericalmethods.eng.usf.edu
Runge 2nd Order Method
http://numericalmethods.eng.usf.edu
Transforming Numerical Methods Education for STEM
Undergraduates
02/11/10 http://numericalmethods.eng.usf.edu 1
Runge-Kutta 2nd Order Method
http://numericalmethods.eng.usf.edu
Runge-Kutta 2nd Order Method
For
where
http://
3 numericalmethods.eng.usf.edu
Heun’s Method
Heun’s method
y
yi
resulting in
x
xi xi+1
where
Figure 1 Runge-Kutta 2nd order method (Heun’s method)
http://
4 numericalmethods.eng.usf.edu
Midpoint Method
Here is chosen, giving
resulting in
where
http://
5 numericalmethods.eng.usf.edu
Ralston’s Method
Here is chosen, giving
resulting in
where
http://
6 numericalmethods.eng.usf.edu
How to write Ordinary Differential
Equation
How does one write a first order differential equation in the form of
Example
is rewritten as
In this case
http://
7 numericalmethods.eng.usf.edu
Example
A ball at 1200K is allowed to cool down in air at an ambient temperature
of 300K. Assuming heat is lost only due to radiation, the differential
equation for the temperature of the ball is given by
Find the temperature at seconds using Heun’s method. Assume a step size of
seconds.
http://
8 numericalmethods.eng.usf.edu
Solution
Step 1:
http://
9 numericalmethods.eng.usf.edu
Solution Cont
Step 2:
http://
10 numericalmethods.eng.usf.edu
Solution Cont
http://
11 numericalmethods.eng.usf.edu
Comparison with exact results
http://
13 numericalmethods.eng.usf.edu
Effects of step size on Heun’s
Method
http://
14 numericalmethods.eng.usf.edu
Comparison of Euler and Runge-
Kutta 2nd Order Methods
Table 2. Comparison of Euler and the Runge-Kutta methods
Step θ(480)
size,
Euler Heun Midpoint Ralston
h
480 −987.84 −393.87 1208.4 449.78
240 110.32 584.27 976.87 690.01
120 546.77 651.35 690.20 667.71
60 614.97 649.91 654.85 652.25
(exact)
http://
15 numericalmethods.eng.usf.edu
Comparison of Euler and Runge-
Kutta 2nd Order Methods
Step size,
h Euler Heun Midpoint Ralston
480 252.54 160.82 86.612 30.544
240 82.964 9.7756 50.851 6.5537
120 15.566 0.58313 6.5823 3.1092
60 5.0352 0.36145 1.1239 0.72299
30 2.2864 0.097625
0.22353 0.15940
(exact)
http://
16 numericalmethods.eng.usf.edu
Comparison of Euler and Runge-
Kutta 2nd Order Methods
1200,0000
1025,0000 Midpoint
θ(K)
Temperature,
Ralston
850,0000 Heun
Analytical
675,0000
Euler
500,0000
0 125 250 375 500
Time, t (sec)
Figure 4. Comparison of Euler and Runge Kutta 2nd order methods with
exact results. http://
17 numericalmethods.eng.usf.edu
Additional Resources
For all resources on this topic such as digital audiovisual
lectures, primers, textbook chapters, multiple-choice
tests, worksheets in MATLAB, MATHEMATICA, MathCad
and MAPLE, blogs, related physical problems, please
visit
http://numericalmethods.eng.usf.edu/topics/
runge_kutta_2nd_method.html
Runge 4th Order Method
http://numericalmethods.eng.usf.edu
Transforming Numerical Methods Education for STEM
Undergraduates
02/11/10 http://numericalmethods.eng.usf.edu 1
Runge-Kutta 4th Order Method
http://numericalmethods.eng.usf.edu
Runge-Kutta 4th Order Method
For
where
http://
3 numericalmethods.eng.usf.edu
How to write Ordinary Differential
Equation
How does one write a first order differential equation in the form of
Example
is rewritten as
In this case
http://
4 numericalmethods.eng.usf.edu
Example
A ball at 1200K is allowed to cool down in air at an ambient temperature
of 300K. Assuming heat is lost only due to radiation, the differential
equation for the temperature of the ball is given by
http://
5 numericalmethods.eng.usf.edu
Solution
Step 1:
http://
6 numericalmethods.eng.usf.edu
Solution Cont
http://
7 numericalmethods.eng.usf.edu
Solution Cont
Step 2:
http://
8 numericalmethods.eng.usf.edu
Solution Cont
http://
9 numericalmethods.eng.usf.edu
Solution Cont
http://
10 numericalmethods.eng.usf.edu
Comparison with exact results
Step size,
θ (480) Et |єt|%
h
480 −90.278 737.85 113.94
240 594.91 52.660 8.1319
120 646.16 1.4122 0.21807
60 647.54 0.033626 0.0051926
30 647.57 0.00086900 0.00013419
(exact)
http://
12 numericalmethods.eng.usf.edu
Effects of step size on Runge-
Kutta 4th Order Method
gas
dust
Poisson equation solved viaHubert
12/13/2009
FFT inHeidelberg
parallel mode: up to 2563 cells
Klahr - Planet Formation - MPIA
THE END
54
55
56
57
58