LocalMechanicalPool#

class ansys.mechanical.core.pool.LocalMechanicalPool(n_instances, wait=True, port=10000, progress_bar=True, restart_failed=True, **kwargs)#

Create a pool of Mechanical instances.

Parameters:
n_instanceint

Number of Mechanical instances to create in the pool.

waitbool, optional

Whether to wait for the pool to be initialized. The default is True. When False, the pool starts in the background, in which case all resources might not be immediately available.

starting_portint, optional

Starting port for the instances. The default is 10000.

progress_barbool, optional

Whether to show a progress bar when starting the pool. The default is True, but the progress bar is not shown when wait=False.

restart_failedbool, optional

Whether to restart any failed instances in the pool. The default is True.

**kwargsdict, optional

Additional keyword arguments. For a list of all keyword arguments, use the ansys.mechanical.core.launch_mechanical() function. If the exec_file keyword argument is found, it is used to start instances. PyPIM is used to create instances if the following conditions are met:

  • PyPIM is configured.

  • version is specified.

  • exec_file is not specified.

Examples

Create a pool of 10 Mechanical instances.

>>> from ansys.mechanical.core import LocalMechanicalPool
>>> pool = LocalMechanicalPool(10)
Creating Pool: 100%|########| 10/10 [00:01<00:00,  1.43it/s]

On Windows, create a pool while specifying the Mechanical executable file.

>>> exec_file = 'C:/Program Files/ANSYS Inc/v231/aisol/bin/winx64/AnsysWBU.exe'
>>> pool = LocalMechanicalPool(10, exec_file=exec_file)
Creating Pool: 100%|########| 10/10 [00:01<00:00,  1.43it/s]

On Linux, create a pool while specifying the Mechanical executable file.

>>> exec_file = '/ansys_inc/v231/aisol/.workbench'
>>> pool = LocalMechanicalPool(10, exec_file=exec_file)
Creating Pool: 100%|########| 10/10 [00:01<00:00,  1.43it/s]

In the PyPIM environment, create a pool.

>>> pool = LocalMechanicalPool(10, version="231")
Creating Pool: 100%|########| 10/10 [00:01<00:00,  1.43it/s]

Methods

LocalMechanicalPool.exit([block])

Exit all Mechanical instances in the pool.

LocalMechanicalPool.map(func[, iterable, ...])

Run a user-defined function on each Mechanical instance in the pool.

LocalMechanicalPool.next_available([...])

Wait until a Mechanical instance is available and return this instance.

LocalMechanicalPool.run_batch(files[, ...])

Run a batch of input files on the Mechanical instances in the pool.

Attributes

LocalMechanicalPool.ports

Get a list of the ports that are used.