Note
Go to the end to download the full example code.
2.3.3 Using simulation trackers
This example illustrates how trackers can be used to analyze simulations.
0%| | 0/3.0 [00:00<?, ?it/s]
Initializing: 0%| | 0/3.0 [00:00<?, ?it/s]
0%| | 0/3.0 [00:05<?, ?it/s]
3%|▎ | 0.1/3.0 [00:05<02:31, 52.27s/it]
7%|▋ | 0.2/3.0 [00:05<01:13, 26.14s/it]
37%|███▋ | 1.1/3.0 [00:05<00:09, 4.81s/it]
37%|███▋ | 1.1/3.0 [00:05<00:09, 4.93s/it]
100%|██████████| 3.0/3.0 [00:05<00:00, 1.81s/it]
100%|██████████| 3.0/3.0 [00:05<00:00, 1.81s/it]
508.899972790844
508.89997279084395
508.899972790844
508.89997279084406
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(interrupts=1), # store data every simulation time unit
pde.PlotTracker(show=True), # show images during simulation
# print some output every 5 real seconds:
pde.PrintTracker(interrupts=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.484 seconds)