plot module

This module declares the functions used by this project to create plots.

velocity_stream_lines() function

plot.velocity_stream_lines(flow, x_lim=None, y_lim=None, x_num_points=50, y_num_points=50, fig_num=1, fig_size=(6, 6), file_name='', plot_title='Velocity stream lines', show=True, iterative=False)

This function creates a matplotlib.pyplot.streamplot of the velocity of the flow. The velocity corresponds to the real and imaginary parts of the derivative of the complex potential of the flow.

Parameters
  • flow (flow_element.Flow) – Instance of flow_element.Flow containing the flow elements

  • x_lim (list, optional) – plotting limit of x axis [x min, x max]

  • y_lim (list, optional) – plotting limit of y axis [y min, y max]

  • x_num_points (int, optional) – Number of points in the meshgrid

  • y_num_points (int, optional) – Number of points in the meshgrid

  • fig_num (int, optional) – Figure number

  • fig_size (tuple, optional) – Figure size

  • file_name (str, optional) – If the string is not empty the figure is saved in that file

  • plot_title (str, optional) – Custom plot title

  • show (bool, optional) – If set to False doesn’t show the plot

  • iterative (bool, optional) – If set to true, clears the plot to update

velocity_colorplot() function

plot.velocity_colorplot(flow, x_lim=None, y_lim=None, x_num_points=100, y_num_points=100, fig_num=2, fig_size=(6, 6), file_name='', plot_title='Velocity color plot', show=True, iterative=False)

This function creates a matplotlib.pyplot.imshow plot of the magnitude of the velocity of the flow. The magnitude of the velocity is obtained by taking the modulus of the derivative of the complex potential.

Parameters
  • flow (flow_element.Flow) – Instance of flow_element.Flow containing the flow elements

  • x_lim (list, optional) – plotting limit of x axis [x min, x max]

  • y_lim (list, optional) – plotting limit of y axis [y min, y max]

  • x_num_points (int, optional) – Number of points in the meshgrid

  • y_num_points (int, optional) – Number of points in the meshgrid

  • fig_num (int, optional) – Figure number

  • fig_size (tuple, optional) – Figure size

  • file_name (str, optional) – If the string is not empty the figure is saved in that file

  • plot_title (str, optional) – Custom plot title

  • show (bool, optional) – If set to False doesn’t show the plot

  • iterative (bool, optional) – If set to true, clears the plot to update

velocity_potential() function

plot.velocity_potential(flow, x_lim=None, y_lim=None, x_num_points=50, y_num_points=50, file_name='', plot_title='Velocity potential', show=True, fig_size=(6, 6), fig_num=3, iterative=False)

This function creates a matplotlib.pyplot.contour plot of the velocity potential. The velocity potential is obtained by taking the real part of the complex potential of the flow.

Parameters
  • flow (flow_element.Flow) – Instance of flow_element.Flow containing the flow elements

  • x_lim (list, optional) – plotting limit of x axis [x min, x max]

  • y_lim (list, optional) – plotting limit of y axis [y min, y max]

  • x_num_points (int, optional) – Number of points in the meshgrid

  • y_num_points (int, optional) – Number of points in the meshgrid

  • fig_num (int, optional) – Figure number

  • fig_size (tuple, optional) – Figure size

  • file_name (str, optional) – If the string is not empty the figure is saved in that file

  • plot_title (str, optional) – Custom plot title

  • show (bool, optional) – If set to False doesn’t show the plot

  • iterative (bool, optional) – If set to true, clears the plot to update

stream_function() function

plot.stream_function(flow, x_lim=None, y_lim=None, x_num_points=50, y_num_points=50, file_name='', plot_title='Stream function', show=True, fig_size=(6, 6), fig_num=3, iterative=False)

This function creates a matplotlib.pyplot.contour plot of the stream function of the flow. The stream function is obtained by taking the imaginary part of the complex potential of the flow.

Parameters
  • flow (flow_element.Flow) – Instance of flow_element.Flow containing the flow elements

  • x_lim (list, optional) – plotting limit of x axis [x min, x max]

  • y_lim (list, optional) – plotting limit of y axis [y min, y max]

  • x_num_points (int, optional) – Number of points in the meshgrid

  • y_num_points (int, optional) – Number of points in the meshgrid

  • fig_num (int, optional) – Figure number

  • fig_size (tuple, optional) – Figure size

  • file_name (str, optional) – If the string is not empty the figure is saved in that file

  • plot_title (str, optional) – Custom plot title

  • show (bool, optional) – If set to False doesn’t show the plot

  • iterative (bool, optional) – If set to true, clears the plot to update

trajectory() function

plot.trajectory(flow, out, x_lim=None, y_lim=None, file_name='', plot_title='Trajectory', show=True, fig_size=(6, 6))

This function creates a matplotlib.pyplot.plot plot of the trajectory of the flow elements. The positions of the flow elements are obtained from the solution of the ODEs returned by utils.solve_velocity_ode().

Parameters
  • flow (flow_element.Flow) – Instance of flow_element.Flow containing the flow element

  • out (numpy.array) – Result of the the numerical analysis

  • x_lim (list, optional) – plotting limit of x axis [x min, x max]

  • y_lim (list, optional) – plotting limit of y axis [y min, y max]

  • file_name (str, optional) – If the string is not empty the figure is saved in that file

  • plot_title (str, optional) – Custom plot title

  • show (bool, optional) – If set to False doesn’t show the plot

  • fig_size (tuple, optional) – Figure size

animated_trajectory() function

plot.animated_trajectory(flow, out, x_lim=None, y_lim=None, file_name='', plot_title='Animated trajectory', show=True, fig_size=(6, 6))

This function creates a matplotlib.animation plot of the trajectory of the flow elements. The positions of the flow elements are obtained from the solution of the ODEs returned by utils.solve_velocity_ode().

Parameters
  • flow (flow_element.Flow) – Instance of flow_element.Flow containing the flow element

  • out (np.array) – Result of the the numerical analysis

  • x_lim (list, optional) – plotting limit of x axis [x min, x max]

  • y_lim (list, optional) – plotting limit of y axis [y min, y max]

  • file_name (str, optional) – If the string is not empty the figure is saved in that file

  • plot_title (str, optional) – Custom plot title

  • show (bool, optional) – If set to False doesn’t show the plot

  • fig_size (tuple, optional) – Figure size

from_dir_to_video() function

plot.from_dir_to_video(dir_with_imgs, output_video)

This function takes a directory containing images and creates a video from the images.

Parameters
  • dir_with_imgs (str) – Path to directory containing images

  • output_video (str) – Path the video should be saved at

plotting_limit() function

plot.plotting_limit(flow, isY, margin=2.0)

Work out the plot limits

Parameters
  • flow (class:flow_element.Flow) – Instance of flow_element.Flow containing the flow element

  • isY (bool) – Works out y plot limits if set to true, x plot limits if false

  • margin (float, optional) – Value to add/substract to max/min values, defaults to 2.0

Returns

[max, min] plot limits

Return type

list