Local Mechanical Pool#
This section describes how to work with a local pool of Mechanical instances.
LocalMechanicalPool Class#
LocalMechanicalPool
provides functionality for working with a local pool of Mechanical instances.
- 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_instance
int
Number of Mechanical instances to create in the pool.
- waitbool,
optional
Whether to wait for the pool to be initialized. The default is
True
. WhenFalse
, the pool starts in the background, in which case all resources might not be immediately available.- starting_port
int
,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 whenwait=False
.- restart_failedbool,
optional
Whether to restart any failed instances in the pool. The default is
True
.- **kwargs
dict
,optional
Additional keyword arguments. For a list of all keyword arguments, use the
ansys.mechanical.core.launch_mechanical()
function. If theexec_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.
- n_instance
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]
|
Create a pool of Mechanical instances. |