2.17. Using simulation trackers

This example illustrates how trackers can be used to analyze simulations.

Time: 3
  0%|          | 0/3.0 [00:00<?, ?it/s]
Initializing:   0%|          | 0/3.0 [00:00<?, ?it/s]/home/docs/checkouts/readthedocs.org/user_builds/py-pde/checkouts/0.29.0/pde/grids/boundaries/local.py:1822: NumbaDeprecationWarning: The 'nopython' keyword argument was not supplied to the 'numba.jit' decorator. The implicit default value for this argument is currently False, but it will be changed to True in Numba 0.59.0. See https://numba.readthedocs.io/en/stable/reference/deprecation.html#deprecation-of-object-mode-fall-back-behaviour-when-using-jit for details.
  def virtual_point(

  0%|          | 0/3.0 [00:05<?, ?it/s]
  3%|3         | 0.1/3.0 [00:05<02:38, 54.50s/it]
  7%|6         | 0.2/3.0 [00:05<01:16, 27.26s/it]
 20%|#9        | 0.6/3.0 [00:05<00:21,  9.09s/it]
 20%|#9        | 0.6/3.0 [00:05<00:22,  9.45s/it]
100%|##########| 3.0/3.0 [00:05<00:00,  1.89s/it]
100%|##########| 3.0/3.0 [00:05<00:00,  1.89s/it]
507.56472676995577
507.56472676995577
507.56472676995577
507.5647267699559

import pde

grid = pde.UnitGrid([32, 32])  # generate grid
state = pde.ScalarField.random_uniform(grid)  # generate initial condition

storage = pde.MemoryStorage()

trackers = [
    "progress",  # show progress bar during simulation
    "steady_state",  # abort when steady state is reached
    storage.tracker(interval=1),  # store data every simulation time unit
    pde.PlotTracker(show=True),  # show images during simulation
    # print some output every 5 real seconds:
    pde.PrintTracker(interval=pde.RealtimeInterrupts(duration=5)),
]

eq = pde.DiffusionPDE(0.1)  # define the PDE
eq.solve(state, 3, dt=0.1, tracker=trackers)

for field in storage:
    print(field.integral)

Total running time of the script: ( 0 minutes 5.743 seconds)