2021 09 24 - Solvers
2021 09 24 - Solvers
2021 09 24 - Solvers
Simulink
Solution:
� 𝑑𝑑𝑑𝑑 = � sin 𝑡𝑡 𝑑𝑑𝑑𝑑
⇔ 𝑥𝑥 𝑡𝑡 = − cos 𝑡𝑡 + 𝑐𝑐
𝑥𝑥 0 = 0
⇒ 0 = cos 0 + 𝑐𝑐
⇔ 𝑐𝑐 = 1
⇒ 𝑥𝑥(𝑡𝑡) = −cos 𝑡𝑡 + 1
2
Numeric method for solving ODE’s: Euler Explicit
ODE:
𝑥𝑥̇ = 𝑓𝑓(𝑡𝑡), 𝑥𝑥 𝑡𝑡0 = 𝑥𝑥0
Time step:
𝑡𝑡1 = 𝑡𝑡0 + ∆𝑡𝑡
First step:
𝑥𝑥1 = 𝑥𝑥0 + ∆𝑡𝑡 � 𝑥𝑥(𝑡𝑡
̇ 0)
Second step:
𝑥𝑥2 = 𝑥𝑥1 + ∆𝑡𝑡 � 𝑥𝑥(𝑡𝑡
̇ 1)
Third step:
𝑥𝑥3 = 𝑥𝑥2 + ∆𝑡𝑡 � 𝑥𝑥(𝑡𝑡
̇ 2)
𝑥𝑥𝑖𝑖 → 𝑥𝑥(𝑡𝑡𝑖𝑖 )
3
Given ODE:
𝑥𝑥̇ = 𝑠𝑠𝑠𝑠𝑠𝑠(𝑡𝑡), 𝑥𝑥 0 = 0
Time step:
∆𝑡𝑡=0,2 s.
Euler Explicit:
𝑥𝑥0 = 0
4
More steps following Euler Explicit and comparing with the analytical solution
to the ODE:
t x x (anal.) Error
(Euler Expl.) 𝑥𝑥(𝑡𝑡) = −cos 𝑡𝑡 + 1 Anal. – Euler expl.
0 0 0 0
5
Change the time step and see how it influences on the result:
𝑥𝑥̇ = 𝑠𝑠𝑠𝑠𝑠𝑠(𝑡𝑡), 𝑥𝑥 0 = 0
Duration of simulation:
𝑡𝑡 = 1 𝑠𝑠.
⇒ 𝐶𝐶𝐶𝐶𝐶𝐶𝐶𝐶𝐶𝐶𝐶𝐶𝐶𝐶𝐶𝐶𝐶𝐶𝐶𝐶𝐶𝐶!
6
Error check on Euler expl.:
∆𝒕𝒕 Error
0,2 s. 0,0857
0,1 s. 0,0425
0,01 s. 0,0042
0,001 s. 0,00042
7
Numeric method for solving ODE’s: Runge-Kutta 4th order
ODE:
𝑥𝑥̇ = 𝑓𝑓(𝑡𝑡), 𝑥𝑥 𝑡𝑡0 = 𝑥𝑥0
Where:
𝑘𝑘1 = ∆𝑡𝑡𝑥𝑥(𝑡𝑡
̇ 𝑛𝑛 )
1
𝑘𝑘2 = ∆𝑡𝑡𝑥𝑥(𝑡𝑡
̇ 𝑛𝑛 + ∆𝑡𝑡)
2
1
𝑘𝑘3 = ∆𝑡𝑡𝑥𝑥(𝑡𝑡
̇ 𝑛𝑛 + ∆𝑡𝑡)
2
𝑘𝑘4 = ∆𝑡𝑡𝑥𝑥(𝑡𝑡
̇ 𝑛𝑛 + ∆𝑡𝑡)
Note: 𝑘𝑘2 and 𝑘𝑘3 are the same since x depends only on t.
8
Change the time step and see how it influences on the result:
𝑥𝑥̇ = 𝑠𝑠𝑠𝑠𝑠𝑠(𝑡𝑡), 𝑥𝑥 0 = 0
Duration of simulation:
𝑡𝑡 = 1 𝑠𝑠.
9
Error check on R-K 4th order
∆𝒕𝒕 Error
0,2 s. 2,5 � 10−7
0,005 s. 1 � 10−13
10