render module#
Links together methods from calc, coloring, and visuals to process simulation data for visualization. Also contains color base classes and utilities for defining color schemes based on reaction coordinates. Mostly concerned with plotting single matplotlib figures to render using moviepy.
Contains methods for rendering particle configurations on matplotlib figures. Contains methods to animate rendered matplotlib figures into moviepy movies.
- render.render.render_npole(snap: Frame, style: ColorBase, PEL='contour', show_text=True, dpi=600, figsize=3.5, dark=True, **kwargs)#
Create a visualization of a single GSD frame with superellipse particles and optional field overlays.
- Parameters:
snap (gsd.hoomd.Frame) – GSD frame object containing particle data and simulation state
style (ColorBase) –
ColorBaseobject for coloring schemePEL (str, optional) – Type of potential energy landscape (PEL) overlay to render; options are ‘contour’ or ‘spectral’ (default: ‘contour’)
show_text (bool, optional) – Whether to display text annotations (default: True)
dpi (int, optional) – Resolution for output image (default: 600)
figsize (float, optional) – Base figure size in inches (default: 3.5)
dark (bool, optional) – Whether to use dark background theme (default: True)
kwargs (dict) – Additional options for customizating action strings and other overlays
- Returns:
Matplotlib figure and axis objects
- Return type:
Tuple[plt.Figure, plt.Axes]
- render.render.render_3d(snap: Frame, style: ColorBase, view_dir=array([0, 0, 1]), view_dist=50, show_text=True, dpi=600, figsize=3.5, dark=True, **kwargs)#
Create a visualization of a single GSD frame with particles in a 3d space.
- Parameters:
snap (gsd.hoomd.Frame) – GSD frame object containing particle data and simulation state
style (ColorBase) –
ColorBaseobject for coloring schemeview_dir (ndarray, optional) – Direction vector for viewing the sphere (default: [0,0,1])
view_dist (float, optional) – Distance from the sphere center to the viewpoint (default: 100)
show_text (bool, optional) – Whether to display text annotations (default: True)
dpi (int, optional) – Resolution for output image (default: 600)
figsize (float, optional) – Base figure size in inches (default: 3.5)
dark (bool, optional) – Whether to use dark background theme (default: True)
kwargs (dict) – Additional options for customizating action strings and other overlays. Can include ‘Lx’, ‘Ly’ or ‘L’ to specify static box dimensions. Defaults to box dimensions from GSD frame, but since these may change over the course of a trajectory, specifying fixed values can help maintain consistent aspect ratios across frames.
- Returns:
Matplotlib figure and axis objects
- Return type:
Tuple[plt.Figure, plt.Axes]
- render.render.render_sphere(snap: Frame, style: ColorBase, view_dir=array([0, 0, 1]), view_dist=100, show_text=True, dpi=600, figsize=3.5, dark=True, **kwargs)#
Create a visualization of a single GSD frame with particles on a spherical surface.
- Parameters:
snap (gsd.hoomd.Frame) – GSD frame object containing particle data and simulation state
style (ColorBase) –
ColorBaseobject for coloring schemeview_dir (ndarray, optional) – Direction vector for viewing the sphere (default: [0,0,1])
view_dist (float, optional) – Distance from the sphere center to the viewpoint (default: 100)
show_text (bool, optional) – Whether to display text annotations (default: True)
dpi (int, optional) – Resolution for output image (default: 600)
figsize (float, optional) – Base figure size in inches (default: 3.5)
dark (bool, optional) – Whether to use dark background theme (default: True)
kwargs (dict) – Additional options for customizating action strings and other overlays. Can include ‘Lx’, ‘Ly’ or ‘L’ to specify static box dimensions. Defaults to box dimensions from GSD frame, but since these may change over the course of a trajectory, specifying fixed values can help maintain consistent aspect ratios across frames.
- Returns:
Matplotlib figure and axis objects
- Return type:
Tuple[plt.Figure, plt.Axes]
- render.render.render_surf(snap: Frame, style: ColorBase, gradient: callable, view_dir=array([0, 0, 1]), view_dist=100, show_text=True, dpi=600, figsize=3.5, dark=True, **kwargs)#
Create a visualization of a single GSD frame with particles on an arbitrary surface defined by a gradient function which computes the surface normal at each point.
- Parameters:
snap (gsd.hoomd.Frame) – GSD frame object containing particle data and simulation state
style (ColorBase) –
ColorBaseobject for coloring schemegradient (callable) – Function that computes surface normal vectors at given positions
view_dir (ndarray, optional) – Direction vector for viewing the sphere (default: [0,0,1])
view_dist (float, optional) – Distance from the sphere center to the viewpoint (default: 100)
show_text (bool, optional) – Whether to display text annotations (default: True)
dpi (int, optional) – Resolution for output image (default: 600)
figsize (float, optional) – Base figure size in inches (default: 3.5)
dark (bool, optional) – Whether to use dark background theme (default: True)
kwargs (dict) – Additional options for customizating action strings and other overlays. Can include ‘Lx’, ‘Ly’ or ‘L’ to specify static box dimensions. Defaults to box dimensions from GSD frame, but since these may change over the course of a trajectory, specifying fixed values can help maintain consistent aspect ratios across frames.
- Returns:
Matplotlib figure and axis objects
- Return type:
Tuple[plt.Figure, plt.Axes]
- render.render.animate(render_frames: HOOMDTrajectory, outpath: str, figure_maker: callable, fps: int = 20, codec='mpeg4')#
Render a movie from the given frames using the specified figure maker function.
The
figure makerfunction should take a GSD frame and return a matplotlib figure.- Parameters:
render_frames (gsd.hoomd.HOOMDTrajectory) – GSD trajectory containing frames to render
outpath (str) – Output file path for the rendered movie
figure_maker (callable) – Function that generates a matplotlib figure from a GSD frame
fps (int, optional) – Frames per second for the output movie, defaults to 20
codec (str, optional) – Codec to use for movie encoding, defaults to ‘mpeg4’