Module containing the Simulation class.

Simulation#

class ansys.dpf.post.simulation.ResultCategory(value)#

Enum for available result categories.

class ansys.dpf.post.simulation.Simulation(data_sources: DataSources, model: Model)#

Base class of all PyDPF-Post simulation types.

release_streams()#

Release the streams to data files if any is active.

property results: List[AvailableResult]#

Available results.

Returns a list of available results.

Examples

>>> from ansys.dpf import post
>>> from ansys.dpf.post import examples
>>> simulation = post.load_simulation(examples.static_rst)
>>> print(simulation.results) 
[...]
property result_info#

Return information concerning the available results.

property geometries#

List of constructed geometries in the simulation.

Returns a list of geometry objects.

Examples

>>> from ansys.dpf import post
>>> from ansys.dpf.post import examples
>>> simulation = post.load_simulation(examples.static_rst)
>>> print(simulation.geometries) 
[]
property mesh: Mesh#

Mesh representation of the model.

Returns a ansys.dpf.post.mesh.Mesh object.

Examples

>>> from ansys.dpf import post
>>> from ansys.dpf.post import examples
>>> simulation = post.load_simulation(examples.static_rst)
>>> print(simulation.mesh) 
    DPF  Mesh:
      81 nodes
      8 elements
      Unit: m
      With solid (3D) elements
property named_selections: List[str]#

List of named selections in the simulation.

Returns a list of named selections names.

Examples

>>> from ansys.dpf import post
>>> from ansys.dpf.post import examples
>>> simulation = post.load_simulation(examples.static_rst)
>>> print(simulation.named_selections) 
['_FIXEDSU']
plot(mesh: bool = True, constructed_geometries: bool = True, loads: bool = True, boundary_conditions: bool = True, **kwargs)#

General plot of the simulation object.

Plots by default the complete mesh contained in the simulation, as well as a representation of the constructed geometry, the loads, and the boundary conditions currently defined. Each representation can be deactivated with its respective boolean argument.

Parameters:
  • mesh (bool, default: True) – Whether to plot the mesh representation.

  • constructed_geometries (bool, default: True) – Whether to plot the constructed geometries.

  • loads (bool, default: True) – Whether to plot the loads.

  • boundary_conditions (bool, default: True) – Whether to plot the boundary conditions.

  • **kwargs – Additional keyword arguments for the plotter. More information are available at pyvista.plot().

Returns:

Returns a plotter instance of the active visualization backend.

Examples

>>> from ansys.dpf import post
>>> from ansys.dpf.post import examples
>>> simulation = post.load_simulation(examples.static_rst)
>>> simulation.plot() 
property active_selection: Selection | None#

Active selection used by default for result queries.

Returns a :object:`ansys.dpf.post.selection.Selection` object.

Examples

>>> from ansys.dpf import post
>>> from ansys.dpf.post import examples
>>> simulation = post.load_simulation(examples.static_rst)
>>> selection = post.selection.Selection()
>>> simulation.active_selection = selection
>>> print(simulation.active_selection) 
<ansys.dpf.post.selection.Selection object at ...>
deactivate_selection()#

Deactivate the currently active selection.

Examples

>>> from ansys.dpf import post
>>> from ansys.dpf.post import examples
>>> simulation = post.load_simulation(examples.static_rst)
>>> selection = post.selection.Selection()
>>> simulation.active_selection = selection
>>> print(simulation.active_selection) 
<ansys.dpf.post.selection.Selection object at ...>
>>> simulation.deactivate_selection()
>>> print(simulation.active_selection) 
None
property time_freq_support: TimeFreqSupport#

Description of the temporal/frequency analysis of the model.

property set_ids: List#

Returns the list of set IDs available in the simulation.

property units#

Returns the current units used.

split_mesh_by_properties(properties: List[elemental_properties] | Dict[elemental_properties, int | List[int]])#

Splits the simulation Mesh according to properties and returns it as Meshes.

Parameters:

properties (Union[List[elemental_properties], Dict[elemental_properties, Union[int, List[int]]]]) – Elemental properties to split the global mesh by. Returns all meshes if a list, or returns only meshes for certain elemental property values if a dict with elemental properties labels with associated value or list of values.

Return type:

A Meshes entity with resulting meshes.

Examples

>>> from ansys.dpf import post
>>> from ansys.dpf.post.common import elemental_properties
>>> from ansys.dpf.post import examples
>>> example_path = examples.download_all_kinds_of_complexity()
>>> simulation = post.StaticMechanicalSimulation(example_path)
>>> # Split by elemental properties and get all resulting meshes
>>> meshes_split = simulation.split_mesh_by_properties(
...     properties=[elemental_properties.material,
...                 elemental_properties.element_shape]
... )
>>> # Split by elemental properties and only get meshes for certain property values
>>> # Here: split by material and shape, return only for material 1 and shapes 0 and 1
>>> meshes_filtered = simulation.split_mesh_by_properties(
...     properties={elemental_properties.material: 1,
...                 elemental_properties.element_shape: [0, 1]}
... )
class ansys.dpf.post.simulation.MechanicalSimulation(result_file: PathLike | str | DataSources, server: BaseServer | None = None)#

Base class for mechanical type simulations.

This class provides common methods and properties for all mechanical type simulations.

property active_selection: Selection | None#

Active selection used by default for result queries.

Returns a :object:`ansys.dpf.post.selection.Selection` object.

Examples

>>> from ansys.dpf import post
>>> from ansys.dpf.post import examples
>>> simulation = post.load_simulation(examples.static_rst)
>>> selection = post.selection.Selection()
>>> simulation.active_selection = selection
>>> print(simulation.active_selection) 
<ansys.dpf.post.selection.Selection object at ...>
deactivate_selection()#

Deactivate the currently active selection.

Examples

>>> from ansys.dpf import post
>>> from ansys.dpf.post import examples
>>> simulation = post.load_simulation(examples.static_rst)
>>> selection = post.selection.Selection()
>>> simulation.active_selection = selection
>>> print(simulation.active_selection) 
<ansys.dpf.post.selection.Selection object at ...>
>>> simulation.deactivate_selection()
>>> print(simulation.active_selection) 
None
property geometries#

List of constructed geometries in the simulation.

Returns a list of geometry objects.

Examples

>>> from ansys.dpf import post
>>> from ansys.dpf.post import examples
>>> simulation = post.load_simulation(examples.static_rst)
>>> print(simulation.geometries) 
[]
property mesh: Mesh#

Mesh representation of the model.

Returns a ansys.dpf.post.mesh.Mesh object.

Examples

>>> from ansys.dpf import post
>>> from ansys.dpf.post import examples
>>> simulation = post.load_simulation(examples.static_rst)
>>> print(simulation.mesh) 
    DPF  Mesh:
      81 nodes
      8 elements
      Unit: m
      With solid (3D) elements
property named_selections: List[str]#

List of named selections in the simulation.

Returns a list of named selections names.

Examples

>>> from ansys.dpf import post
>>> from ansys.dpf.post import examples
>>> simulation = post.load_simulation(examples.static_rst)
>>> print(simulation.named_selections) 
['_FIXEDSU']
plot(mesh: bool = True, constructed_geometries: bool = True, loads: bool = True, boundary_conditions: bool = True, **kwargs)#

General plot of the simulation object.

Plots by default the complete mesh contained in the simulation, as well as a representation of the constructed geometry, the loads, and the boundary conditions currently defined. Each representation can be deactivated with its respective boolean argument.

Parameters:
  • mesh (bool, default: True) – Whether to plot the mesh representation.

  • constructed_geometries (bool, default: True) – Whether to plot the constructed geometries.

  • loads (bool, default: True) – Whether to plot the loads.

  • boundary_conditions (bool, default: True) – Whether to plot the boundary conditions.

  • **kwargs – Additional keyword arguments for the plotter. More information are available at pyvista.plot().

Returns:

Returns a plotter instance of the active visualization backend.

Examples

>>> from ansys.dpf import post
>>> from ansys.dpf.post import examples
>>> simulation = post.load_simulation(examples.static_rst)
>>> simulation.plot() 
release_streams()#

Release the streams to data files if any is active.

property result_info#

Return information concerning the available results.

property results: List[AvailableResult]#

Available results.

Returns a list of available results.

Examples

>>> from ansys.dpf import post
>>> from ansys.dpf.post import examples
>>> simulation = post.load_simulation(examples.static_rst)
>>> print(simulation.results) 
[...]
property set_ids: List#

Returns the list of set IDs available in the simulation.

split_mesh_by_properties(properties: List[elemental_properties] | Dict[elemental_properties, int | List[int]])#

Splits the simulation Mesh according to properties and returns it as Meshes.

Parameters:

properties (Union[List[elemental_properties], Dict[elemental_properties, Union[int, List[int]]]]) – Elemental properties to split the global mesh by. Returns all meshes if a list, or returns only meshes for certain elemental property values if a dict with elemental properties labels with associated value or list of values.

Return type:

A Meshes entity with resulting meshes.

Examples

>>> from ansys.dpf import post
>>> from ansys.dpf.post.common import elemental_properties
>>> from ansys.dpf.post import examples
>>> example_path = examples.download_all_kinds_of_complexity()
>>> simulation = post.StaticMechanicalSimulation(example_path)
>>> # Split by elemental properties and get all resulting meshes
>>> meshes_split = simulation.split_mesh_by_properties(
...     properties=[elemental_properties.material,
...                 elemental_properties.element_shape]
... )
>>> # Split by elemental properties and only get meshes for certain property values
>>> # Here: split by material and shape, return only for material 1 and shapes 0 and 1
>>> meshes_filtered = simulation.split_mesh_by_properties(
...     properties={elemental_properties.material: 1,
...                 elemental_properties.element_shape: [0, 1]}
... )
property time_freq_support: TimeFreqSupport#

Description of the temporal/frequency analysis of the model.

property units#

Returns the current units used.