Note
Click here to download the full example code
2.16. Using simulation trackers¶
This example illustrates how trackers can be used to analyze simulations.
Out:
0%| | 0/3.0 [00:00<?, ?it/s]
Initializing: 0%| | 0/3.0 [00:00<?, ?it/s]
0%| | 0/3.0 [00:07<?, ?it/s]
3%|3 | 0.1/3.0 [00:08<03:58, 82.25s/it]
7%|6 | 0.2/3.0 [00:09<02:07, 45.57s/it]
10%|9 | 0.3/3.0 [00:09<01:22, 30.38s/it]
13%|#3 | 0.4/3.0 [00:09<00:59, 22.79s/it]
13%|#3 | 0.4/3.0 [00:09<01:00, 23.26s/it]
100%|##########| 3.0/3.0 [00:09<00:00, 3.10s/it]
100%|##########| 3.0/3.0 [00:09<00:00, 3.10s/it]
497.76892478259754
497.76892478259754
497.7689247825976
497.76892478259754
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.RealtimeIntervals(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 9.368 seconds)