Skip to content

Commit b113ced

Browse files
committed
time integration
1 parent 7c3b59e commit b113ced

File tree

2 files changed

+100
-5
lines changed

2 files changed

+100
-5
lines changed

source/3_numerical.rst

Lines changed: 95 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ Lagrangian Advection
1111

1212

1313
.. _intp:
14+
1415
Velocity Interpolation
1516
~~~~~~~~~~~~~~~~~~~~~~~
1617

@@ -21,20 +22,110 @@ Wall Treatment
2122

2223
.. _marching:
2324

24-
Particle Marching
25+
Time Integration
2526
~~~~~~~~~~~~~~~~~~
2627

28+
Consider the initial-value problem for particle advection in a velocity field
2729

30+
.. math::
2831
29-
.. _ftlefinal:
32+
\frac{d\mathbf{x}}{dt} = \sigma\,\mathbf{u}(\mathbf{x},t),
33+
\quad \mathbf{x}(t_n) = \mathbf{x}_n,
3034
31-
FTLE Computation
32-
-------------------
35+
where :math:`\sigma = \pm 1` indicates forward/backward advection.
36+
37+
**Explicit Euler Method**
38+
39+
Given :math:`\mathbf{x}_n` at time :math:`t_n`, the first-order (Euler) update is
40+
41+
.. math::
42+
43+
\mathbf{x}_{n+1} = \mathbf{x}_n + \Delta t\,f(\mathbf{x}_n,t_n)
44+
= \mathbf{x}_n + \sigma\,\Delta t\,\mathbf{u}(\mathbf{x}_n,t_n)
45+
46+
Implementation steps:
47+
48+
1. Evaluate velocity:
49+
.. math::
50+
\mathbf{u}_n = \mathbf{u}(\mathbf{x}_n, t_n)
51+
2. Advance position:
52+
.. math::
53+
\mathbf{x}_{n+1} = \mathbf{x}_n + \sigma\,\Delta t\,\mathbf{u}_n
54+
55+
This method is simple but incurs :math:`O(\Delta t)` local truncation error.
56+
57+
**Second-Order Runge–Kutta (Heun’s Method)**
58+
59+
A two-stage explicit scheme with :math:`O(\Delta t^2)` accuracy:
60+
61+
.. math::
62+
63+
k_1 &= f(\mathbf{x}_n, t_n),\\
64+
\mathbf{x}^* &= \mathbf{x}_n + \Delta t\,k_1,\\
65+
k_2 &= f(\mathbf{x}^*, t_n + \Delta t),\\
66+
\mathbf{x}_{n+1} &= \mathbf{x}_n + \tfrac{\Delta t}{2}\,(k_1 + k_2).
67+
68+
Implementation steps:
3369

70+
1. Compute :math:`k_1 = \sigma\,\mathbf{u}(\mathbf{x}_n, t_n)`.
71+
2. Predict step:
72+
.. math::
73+
\mathbf{x}^* = \mathbf{x}_n + \sigma\,\Delta t\,k_1
74+
3. Compute :math:`k_2 = \sigma\,\mathbf{u}(\mathbf{x}^*, t_n + \Delta t)`.
75+
4. Update:
76+
.. math::
77+
\mathbf{x}_{n+1} = \mathbf{x}_n + \tfrac{\sigma\,\Delta t}{2}\,(k_1 + k_2)
3478
79+
**Classical Fourth-Order Runge–Kutta (RK4)**
3580

81+
A four-stage scheme with :math:`O(\Delta t^4)` accuracy:
3682

83+
.. math::
3784
85+
k_1 &= f(\mathbf{x}_n, t_n),\\
86+
k_2 &= f\!\bigl(\mathbf{x}_n + \tfrac{\Delta t}{2}k_1,\;t_n + \tfrac{\Delta t}{2}\bigr),\\
87+
k_3 &= f\!\bigl(\mathbf{x}_n + \tfrac{\Delta t}{2}k_2,\;t_n + \tfrac{\Delta t}{2}\bigr),\\
88+
k_4 &= f(\mathbf{x}_n + \Delta t\,k_3,\;t_n + \Delta t),\\
89+
\mathbf{x}_{n+1} &= \mathbf{x}_n + \tfrac{\Delta t}{6}\,(k_1 + 2k_2 + 2k_3 + k_4).
90+
91+
Implementation steps:
92+
93+
1. Compute :math:`k_1` at :math:`\mathbf{x}_n`.
94+
2. Compute :math:`k_2` at :math:`\mathbf{x}_n + \tfrac{\Delta t}{2}k_1`.
95+
3. Compute :math:`k_3` at :math:`\mathbf{x}_n + \tfrac{\Delta t}{2}k_2`.
96+
4. Compute :math:`k_4` at :math:`\mathbf{x}_n + \Delta t\,k_3`.
97+
5. Combine:
98+
.. math::
99+
\mathbf{x}_{n+1} = \mathbf{x}_n + \tfrac{\Delta t}{6}\,(k_1 + 2k_2 + 2k_3 + k_4)
100+
101+
**Sixth-Order Runge–Kutta (RK6)**
102+
103+
A six-stage explicit method with :math:`O(\Delta t^6)` accuracy. Define:
104+
105+
.. math::
106+
107+
k_1 &= f(\mathbf{x}_n, t_n),\\
108+
k_2 &= f\!\bigl(\mathbf{x}_n + \tfrac{\Delta t}{3}k_1,\;t_n + \tfrac{\Delta t}{3}\bigr),\\
109+
k_3 &= f\!\Bigl(\mathbf{x}_n + \Delta t\bigl(\tfrac{1}{6}k_1 + \tfrac{1}{6}k_2\bigr),\;t_n + \tfrac{\Delta t}{3}\Bigr),\\
110+
k_4 &= f\!\Bigl(\mathbf{x}_n + \Delta t\bigl(\tfrac{1}{8}k_1 + \tfrac{3}{8}k_3\bigr),\;t_n + \tfrac{\Delta t}{2}\Bigr),\\
111+
k_5 &= f\!\Bigl(\mathbf{x}_n + \Delta t\bigl(\tfrac{1}{2}k_1 - \tfrac{3}{2}k_3 + 2k_4\bigr),\;t_n + \tfrac{2\Delta t}{3}\Bigr),\\
112+
k_6 &= f\!\Bigl(\mathbf{x}_n + \Delta t\bigl(-\tfrac{3}{2}k_1 + 2k_2 - \tfrac{1}{2}k_3 + k_4\bigr),\;t_n + \Delta t\Bigr),\\
113+
\mathbf{x}_{n+1} &= \mathbf{x}_n + \Delta t\Bigl(\tfrac{1}{20}k_1 + \tfrac{1}{4}k_4 + \tfrac{1}{5}k_5 + \tfrac{1}{2}k_6\Bigr).
114+
115+
Implementation steps:
116+
117+
1. Compute each :math:`k_i = \sigma\,\mathbf{u}(\cdot)` at its intermediate point.
118+
2. Form the weighted sum:
119+
.. math::
120+
\mathbf{x}_{n+1} = \mathbf{x}_n + \Delta t\Bigl(\tfrac{1}{20}k_1 + \tfrac{1}{4}k_4 + \tfrac{1}{5}k_5 + \tfrac{1}{2}k_6\Bigr)
121+
122+
All methods assume a continuous, differentiable velocity field via tricubic interpolation; replacing :math:`f` by the chosen sampler affects only boundary‐condition treatment.
123+
124+
125+
.. _ftlefinal:
126+
127+
FTLE Computation
128+
-------------------
38129

39130

40131

source/5_gui.rst

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,8 @@
33
Graphical User Interface (GUI)
44
===============
55

6-
This page describes
6+
This page describes how to use GUI mode of ``PyFTLE3D``, which is friendly for who would like to use the software without command-line operations.
7+
The author holds the opinion that coding should not be a barrier for using scientific analysis tools such as ``FTLE``.
8+
For some peers or even experts and professors, coding is absolutely boring.
9+
10+
The GUI shares exactly the same functionalities as the command-line mode, but is more difficult to customize, as ``PyQt`` is used for building it.

0 commit comments

Comments
 (0)