# Apparatus

class Apparatus(name: Union[str, NoneType] = None, description: Union[str, NoneType] = None)

A unique network of components.

Note

The same components may be organized into multiple distinct apparatuses, depending on the connections between them.

# Arguments

  • name: The name of the apparatus. Defaults to "Apparatus_X" where X is apparatus count. This should be short and sweet.
  • description: A description of the apparatus. Can be as long and wordy as you want.

# Attributes

  • components: A set containing the components that make up the apparatus.
  • description: A description of the apparatus. Can be as long and wordy as you want.
  • name: The name of the apparatus. Defaults to "Apparatus_X" where X is apparatus count. This should be short and sweet.
  • network: A list of tuples in the form (from_component, to_component, tube) describing the configuration of the apparatus.

# add

def add(self, from_component: Union[mechwolf.components.stdlib.component.Component, Iterable[mechwolf.components.stdlib.component.Component]], to_component: Union[mechwolf.components.stdlib.component.Component, Iterable[mechwolf.components.stdlib.component.Component]], tube: mechwolf.components.stdlib.tube.Tube) -> None

Adds connections to the apparatus. If both from_component and to_component are iterables, then their Cartesian product will be added to the apparatus.

# Arguments

  • from_component: The Component from which the flow is originating. If an iterable, all items in the iterable will be connected to the same component.
  • to_component: The Component where the flow is going. If an iterable, all items in the iterable will be connected to the same component.
  • tube: Tube that connects the components.

# Raises

  • ValueError: When the connection being added is invalid.

# describe

def describe(self) -> Union[str, IPython.core.display.Markdown]

Generates a human-readable description of the apparatus.

# Returns

  • A description of apparatus. When in Jupyter, this string is wrapped in a IPython.display.Markdown object for nicer display.

# Raises

  • RuntimeError: When a component cannot be described.

# summarize

def summarize(self, style: str = 'gfm') -> Union[IPython.core.display.Markdown, NoneType]

Prints a summary table of the apparatus.

# Arguments

  • style: Either gfm for GitHub-flavored Markdown or ascii. If equal to gfm and in a Jupyter notebook, returns a rendered HTML version of the GFM table.

# Returns

  • In Jupyter, a nice HTML table. Otherwise, the output is printed to the terminal.

# visualize

def visualize(self, title: Union[bool, str] = True, label_tubes: bool = False, describe_vessels: bool = False, rankdir: str = 'LR', node_attr: Union[Mapping[str, str], NoneType] = None, edge_attr: Union[Mapping[str, str], NoneType] = None, graph_attr: Union[Mapping[str, str], NoneType] = None, file_format: str = 'pdf', filename: Union[str, NoneType] = None, **kwargs) -> Union[graphviz.graphs.Digraph, NoneType]

Generates a visualization of an apparatus's network graph.

For full list of acceptable Graphviz attributes, see the graphviz.org docs and its Python API's docs.

# Arguments

  • describe_vessels: Whether to display the names or content descriptions of Vessel components.
  • edge_attr: Controls the appearance of the edges (tubes) of the Apparatus. Must be of the form {"attribute": "value"}.
  • file_format: The output format of the graph, either "pdf" or "png".
  • filename: The name of the output file. Defaults to the name of the apparatus.
  • graph_attr: Controls the appearance of the Apparatus. Must be of the form {"attribute": "value"}. To get orthogonal splines (i.e. edges with sharp corners), pass splines="ortho". To increase the separation between components, set nodesep = "0.5" or similar.
  • label_tubes: Whether to label the tubes between components with the length, inner diameter, and outer diameter.
  • node_attr: Controls the appearance of the nodes (components) of the Apparatus. Must be of the form {"attribute": "value"}.
  • rankdir: The direction of the graph. Use LR for left to right and TD for top down.
  • title: Whether to show the title in the output. Defaults to True. If a string, the title to use for the output.