pycfast.Visualization#

class pycfast.Visualization(viz_type, comp_id=None, plane=None, position=None, value=None)[source]#

Represents a Smokeview visualization output in CFAST.

Calculated results from a CFAST simulation can be visualized using Smokeview. In addition to a simplified view of the layer temperatures and vent flows, more detailed estimates of gas temperature and gas velocity can be visualized.

There are three types of visualizations:

  • 2-D slice (&SLCF DOMAIN = '2-D'): a single plane slice of temperature at the position and axis specified. The slice is placed perpendicular to the selected axis (the Y-Z plane for the X axis, the X-Z plane for the Y axis, and the X-Y plane for the Z axis).

  • 3-D slice (&SLCF DOMAIN = '3-D'): a set of three animated slices whose position can be moved along their respective axes.

  • Isosurface (&ISOF): a fixed 3-D surface where the gas temperature is equal to the value specified.

Visualizations can be placed in a single compartment or, when no compartment is specified, in all compartments.

Parameters:
  • viz_type (str) – Type of visualization. Options: “2-D” for a single plane slice, “3-D” for a set of three animated slices, “ISOSURFACE” for a fixed 3-D surface of constant gas temperature.

  • comp_id (str | None) – Compartment ID where the visualization is placed. If None (default), the visualization applies to all compartments.

  • plane (str | None) – Axis perpendicular to the slice (“X”, “Y” or “Z”). Required for 2-D slices, must be None otherwise.

  • position (float | None) – Position (m) along the specified axis where the slice is placed: measured from the compartment origin when comp_id is given, in absolute domain coordinates when comp_id is None (compartments the plane does not intersect are silently skipped). Required for 2-D slices, must be None otherwise.

  • value (float | None) – Gas temperature (°C) of the isosurface. Required for isosurfaces, must be None otherwise.

Raises:
  • TypeError – If viz_type, comp_id or plane are not strings, or if position or value are not numeric when provided.

  • ValueError – If viz_type is not “2-D”, “3-D” or “ISOSURFACE”, if comp_id is an empty string, if plane or position are missing for a 2-D slice, if plane is not “X”, “Y” or “Z”, if position is negative, or if value is missing for an isosurface.

Notes

By default, slice files are generated with a grid of 50 data points in each direction for each compartment specified. The grid spacing can be adjusted individually by compartment with the grid parameter of Compartment.

Examples

Create a 2-D temperature slice in all compartments:

>>> slice_2d = Visualization.slice_2d(plane="X", position=2.5)

Create a 3-D slice in a single compartment:

>>> slice_3d = Visualization.slice_3d(comp_id="ROOM1")

Create an isosurface of gas temperature at 305 °C:

>>> isosurface = Visualization.isosurface(value=305.0)
VALID_PLANES: frozenset[str] = frozenset({'X', 'Y', 'Z'})#
VALID_TYPES: frozenset[str] = frozenset({'2-D', '3-D', 'ISOSURFACE'})#
classmethod isosurface(value, comp_id=None)[source]#

Create an isosurface visualization of gas temperature.

Parameters:
  • value (float) – Gas temperature (°C) of the isosurface

  • comp_id (str | None) – Compartment ID, or None (default) for all compartments

Returns:

Configured visualization instance for an isosurface.

Return type:

Visualization

Examples

>>> isosurface = Visualization.isosurface(value=305.0, comp_id="ROOM1")
classmethod slice_2d(plane, position=0.0, comp_id=None)[source]#

Create a 2-D slice visualization of gas temperature.

Parameters:
  • plane (str) – Axis perpendicular to the slice (“X”, “Y” or “Z”)

  • position (float) – Position (m) along the axis: relative to the compartment origin if comp_id is given, absolute if None. Default: 0.0

  • comp_id (str | None) – Compartment ID, or None (default) for all compartments

Returns:

Configured visualization instance for a 2-D slice.

Return type:

Visualization

Examples

>>> slice_2d = Visualization.slice_2d(plane="Y", position=1.2, comp_id="ROOM1")
classmethod slice_3d(comp_id=None)[source]#

Create a 3-D slice visualization of gas temperature.

Parameters:

comp_id (str | None) – Compartment ID, or None (default) for all compartments

Returns:

Configured visualization instance for a 3-D slice.

Return type:

Visualization

Examples

>>> slice_3d = Visualization.slice_3d(comp_id="ROOM1")
to_input_string()[source]#

Convert the visualization to a formatted string for CFAST input file.

Returns:

Formatted string ready for inclusion in CFAST input file.

Return type:

str

Examples

>>> slice_2d = Visualization.slice_2d(plane="X", position=2.5)
>>> print(slice_2d.to_input_string())
&SLCF DOMAIN = '2-D' PLANE = 'X' POSITION = 2.5 /
>>> slice_3d = Visualization.slice_3d(comp_id="ROOM1")
>>> print(slice_3d.to_input_string())
&SLCF COMP_ID = 'ROOM1' DOMAIN = '3-D' /
>>> isosurface = Visualization.isosurface(value=305.0)
>>> print(isosurface.to_input_string())
&ISOF VALUE = 305.0 /