VTK Quick Plot#

class pybamm.VTKQuickPlot(solutions: Solution | Simulation | list[Solution | Simulation], output_variables: str | list[str] | None = None, options: dict[str, dict[str, Any] | list[dict[str, Any]]] | None = None, interpolate_time: bool = False)[source]#

Interactive VTK visualization for unstructured mesh solutions.

Supports spatial (unstructured 2D/3D) and 0D (time-series) variables.

Parameters:
  • solutions (pybamm.Solution or pybamm.Simulation) – The solution to plot; a single-element list is also accepted.

  • output_variables (str or list of str, optional) – Variables to plot. Defaults to the model’s default quick-plot variables that are 0D or live on an unstructured mesh.

  • options (dict, optional) –

    Per-variable options keyed by variable name. Each value is a dict that may contain:

    • "plot_type": "3d" (default) or "slice"

    • "x" / "y" / "z": float in [0, 1] giving the slice position as a fraction of the axis range (required when plot_type is "slice")

    • "scale": "auto" (default), None, or (sx, sy, sz)

    A variable’s value may also be a list of such dicts, in which case one panel is created per entry:

    options={"T": [
        {"plot_type": "3d"},
        {"plot_type": "slice", "x": 0.5},
    ]}
    

  • interpolate_time (bool, optional) – Evaluate the variables at the exact slider time instead of snapping to the nearest stored solution time. Default is False.

dynamic_plot(show_plot: bool = True) → None[source]#

Launch an interactive VTK window with a time slider.

save_gif(filename: str, fps: int = 10, n_frames: int = 100, width: int = 1800, height: int = 900) → None[source]#

Render an animation to a GIF file.

Parameters:
  • filename (str) – Output path (e.g. "anim.gif").

  • fps (int) – Frames per second.

  • n_frames (int) – Number of frames (evenly spaced in time).

  • width (int) – Pixel dimensions of each frame.

  • height (int) – Pixel dimensions of each frame.