Skip to content

Commit 254933e

Browse files
committed
time integration
1 parent b113ced commit 254933e

File tree

2 files changed

+35
-67
lines changed

2 files changed

+35
-67
lines changed

source/3_numerical.rst

Lines changed: 34 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -25,102 +25,70 @@ Wall Treatment
2525
Time Integration
2626
~~~~~~~~~~~~~~~~~~
2727

28-
Consider the initial-value problem for particle advection in a velocity field
28+
Consider the initialvalue problem for passive tracer advection in a continuous velocity field
2929

3030
.. math::
3131
32-
\frac{d\mathbf{x}}{dt} = \sigma\,\mathbf{u}(\mathbf{x},t),
33-
\quad \mathbf{x}(t_n) = \mathbf{x}_n,
32+
\frac{d\mathbf{x}}{dt} = \sigma\,\mathbf{u}(\mathbf{x},t)\,,
33+
\mathbf{x}(t_n)=\mathbf{x}_n\,,
3434
35-
where :math:`\sigma = \pm 1` indicates forward/backward advection.
35+
where :math:`\sigma = \pm1` selects forward or backward integration.
3636

3737
**Explicit Euler Method**
3838

39-
Given :math:`\mathbf{x}_n` at time :math:`t_n`, the first-order (Euler) update is
39+
The first‐order explicit Euler scheme advances the position by sampling the velocity at the beginning of the time step:
4040

4141
.. math::
4242
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)
43+
\mathbf{u}_n = \mathbf{u}(\mathbf{x}_n,t_n),\\
44+
\mathbf{x}_{n+1} = \mathbf{x}_n + \sigma\,\Delta t\,\mathbf{u}_n.
4545
46-
Implementation steps:
46+
This method incurs a global error of order :math:`O(\Delta t)` and requires only one velocity evaluation per step.
4747

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
48+
**Second‐Order Runge–Kutta (Heun’s Method)**
5449

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:
50+
Heun’s method attains second‐order accuracy by combining predictor and corrector slopes:
6051

6152
.. math::
6253
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:
54+
k_1 = \sigma\,\mathbf{u}(\mathbf{x}_n,t_n),\\
55+
\mathbf{x}^* = \mathbf{x}_n + \Delta t\,k_1,\\
56+
k_2 = \sigma\,\mathbf{u}(\mathbf{x}^*,t_n + \Delta t),\\
57+
\mathbf{x}_{n+1} = \mathbf{x}_n + \tfrac{\Delta t}{2}\,(k_1 + k_2).
6958
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)
59+
This scheme yields a global error of order :math:`O(\Delta t^2)` with two velocity evaluations per step.
7860

79-
**Classical Fourth-Order Runge–Kutta (RK4)**
61+
**Classical FourthOrder Runge–Kutta (RK4)**
8062

81-
A four-stage scheme with :math:`O(\Delta t^4)` accuracy:
63+
The classical RK4 method achieves fourth‐order accuracy via four slope evaluations at intermediate points:
8264

8365
.. math::
8466
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).
67+
k_1 = \mathbf{u}(\mathbf{x}_n,t_n),\\
68+
k_2 = \mathbf{u}\!\bigl(\mathbf{x}_n + \tfrac{\Delta t}{2}k_1,\;t_n + \tfrac{\Delta t}{2}\bigr),\\
69+
k_3 = \mathbf{u}\!\bigl(\mathbf{x}_n + \tfrac{\Delta t}{2}k_2,\;t_n + \tfrac{\Delta t}{2}\bigr),\\
70+
k_4 = \mathbf{u}(\mathbf{x}_n + \Delta t\,k_3,\;t_n + \Delta t),\\
71+
\mathbf{x}_{n+1} = \mathbf{x}_n + \tfrac{\Delta t}{6}\,(k_1 + 2k_2 + 2k_3 + k_4).
9072
91-
Implementation steps:
73+
This yields a global error of order :math:`O(\Delta t^4)` with four velocity evaluations per step.
9274

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)
75+
**Sixth‐Order Runge–Kutta (RK6)**
10076

101-
**Sixth-Order Runge–Kutta (RK6)**
102-
103-
A six-stage explicit method with :math:`O(\Delta t^6)` accuracy. Define:
77+
The six‐stage scheme uses non‐uniform weights to attain sixth‐order accuracy:
10478

10579
.. math::
10680
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)
81+
k_1 = \mathbf{u}(\mathbf{x}_n,t_n),\\
82+
k_2 = \mathbf{u}\!\bigl(\mathbf{x}_n + \tfrac{\Delta t}{3}k_1,\;t_n + \tfrac{\Delta t}{3}\bigr),\\
83+
k_3 = \mathbf{u}\!\bigl(\mathbf{x}_n + \Delta t(\tfrac{1}{6}k_1 + \tfrac{1}{6}k_2),\;t_n + \tfrac{\Delta t}{3}\bigr),\\
84+
k_4 = \mathbf{u}\!\bigl(\mathbf{x}_n + \Delta t(\tfrac{1}{8}k_1 + \tfrac{3}{8}k_3),\;t_n + \tfrac{\Delta t}{2}\bigr),\\
85+
k_5 = \mathbf{u}\!\bigl(\mathbf{x}_n + \Delta t(\tfrac{1}{2}k_1 - \tfrac{3}{2}k_3 + 2k_4),\;t_n + \tfrac{2\Delta t}{3}\bigr),\\
86+
k_6 = \mathbf{u}\!\bigl(\mathbf{x}_n + \Delta t(-\tfrac{3}{2}k_1 + 2k_2 - \tfrac{1}{2}k_3 + k_4),\;t_n + \Delta t\bigr),\\
87+
\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).
12188
122-
All methods assume a continuous, differentiable velocity field via tricubic interpolation; replacing :math:`f` by the chosen sampler affects only boundary‐condition treatment.
89+
This scheme incurs a global error of order :math:`O(\Delta t^6)` with six velocity evaluations.
12390

91+
All methods assume a continuous velocity interpolation (e.g., tricubic) to supply :math:`\mathbf{u}` at arbitrary particle positions and times.
12492

12593
.. _ftlefinal:
12694

source/5_gui.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,6 @@ Graphical User Interface (GUI)
55

66
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.
77
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.
8+
For some peers or even experts and professors, coding is absolutely boring, especially for GPU tasks on such large dataset scale.
99

1010
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)