Edit on Gitlab Launch with Binder

Visualization

[1]:
import numpy as np
import matplotlib.pyplot as plt
from dynamiks.utils.test_utils import DefaultDWMFlowSimulation

fs = DefaultDWMFlowSimulation(x=[0,500],y=[0,0], ti=0.05, d_particle=1, n_particles=20)
fs.run(100)

The flow simulation object has three visualization methods:

  • show: Plot the current state

  • visualize: Animate and show the simulation

  • animate: Animate and save the animation to a file

All three methods takes a view (see documentation) as optional input.

The View defaults to the default XYView (all turbulence (x,y)-grid points at average hub height) with a Flow2DVisualizer (see documentation) visualizing the u component of the flow

Visualization methods

Show

The show(view=None, block=True) method plots the current state. block is passed to `pyplot.show <https://matplotlib.org/stable/api/_as_gen/matplotlib.pyplot.show.html>`__

[2]:
fs.show()
../_images/notebooks_Visualization_4_0.png

Visualize

visualize(time_stop, view=None, dt=None) runs the simulation until time time_stop and visualizes the state for every dt seconds. If dt=None every time step is visualized.

[3]:
fs.visualize(fs.time+10)
../_images/notebooks_Visualization_6_0.png

Animate

animate(time_stop, filename, view=None, dt=None, interval=None) runs the simulation until time time_stop and saves the animation to filename. A frame is saved for every dt seconds (If dt=None every time step is visualized) and interval specifies the time between each frame (in ms) in the playback. If interval=None the animation move plays in real time, while interval<dt results in faster playback

[4]:
# save animation
ani = fs.animate(fs.time+10, filename='visualization.gif');
../_images/notebooks_Visualization_8_1.png
[5]:
# show saved gif animation
from IPython.display import HTML
HTML('<img src="visualization.gif">')
[5]: