ansys.dyna.core.solver.launcher#
Module for launching the pydyna solver service locally.
Attributes#
Classes#
Provides server thread properties. |
Functions#
|
Check the state of ports in a port range. |
|
Determine if a port is in use at a given host. |
|
Launch the solver service locally in gRPC mode. |
|
Start DYNA remotely using the product instance management API. |
|
Start DYNA locally. |
Module Contents#
- ansys.dyna.core.solver.launcher.check_ports(port_range, ip='localhost')[source]#
Check the state of ports in a port range.
- ansys.dyna.core.solver.launcher.port_in_use(port, host=LOCALHOST)[source]#
Determine if a port is in use at a given host.
- Parameters:
- port
int Port.
- host
- Host. The default is
LOCALHOST, in which case"127.0.0.1" is used.
- Host. The default is
- port
- Returns:
Truewhenaportisinuseatthegivenhost,Falseotherwise.
Notes
The port must “bind” the address. Just checking if a socket can be created is insufficient because it is possible to run into permission errors like this one:
“An attempt was made to access a socket in a way forbidden by its access permissions.”
- ansys.dyna.core.solver.launcher.launch_grpc(port=DYNA_DEFAULT_PORT, ip=LOCALHOST, server_path='', product_version=None) tuple[source]#
Launch the solver service locally in gRPC mode.
- Parameters:
- port
int,optional Port to launch the solver service on. The default is
DYNAPRE_DEFAULT_PORT. The final port is the first port available after (or including) this port.- ip
str,optional IP address. The default is
LOCALHOST, in which case"127.0.0.1"is used.- server_path
str,optional Path to the solver service. The default is
None.
- port
- Returns:
intPort number that the gRPC instance started on.
- ansys.dyna.core.solver.launcher.launch_remote_dyna(version=None, cleanup_on_exit=True) ansys.dyna.core.solver.DynaSolver[source]#
Start DYNA remotely using the product instance management API.
When calling this method, you need to ensure that you are in an environment where PyPIM is configured. This can be verified with
pypim.is_configured.- Parameters:
- Returns:
ansys.dyna.core.solver.DynaSolverAn instance of DynaSolver.
- ansys.dyna.core.solver.launcher.launch_dyna(product_version: int = None, port=None, ip=None) ansys.dyna.core.solver.DynaSolver[source]#
Start DYNA locally.
- Parameters:
- product_version: int, optional
The product version to be started. Goes from v20.1 to the latest. Default is
None. If a specific product version is requested but not installed locally, a SystemError will be raised.Ansys products versions and their corresponding int values:
241: Ansys 24R1242: Ansys 24R2
- port
int Port to launch DYNA gRPC on. Final port will be the first port available after (or including) this port. Defaults to 5000.
- ipbool,
optional You can provide a hostname as an alternative to an IP address. Defaults to
'127.0.0.1'.
Examples
Launch DYNA using the best protocol.
>>> from ansys.dyna.core.solver import launch_dyna >>> solution = launch_dyna()
Connect to an existing instance of DYNA at IP 192.168.1.30 and port 5000.
>>> solution = launch_dyna(ip='192.168.1.30',port=5000)