The path.py module#

Summary#

get_available_ansys_installations

Return a dictionary of available Ansys unified installation versions with their base paths.

find_mechanical

Search for the Mechanical path in the standard installation location.

find_mapdl

Searches for Ansys MAPDL path within the standard install location

find_dyna

Searches for Ansys LS-Dyna path within the standard install location

find_ansys

Obsolete method, use find_mapdl.

is_valid_executable_path

change_default_mapdl_path

Change your default Ansys MAPDL path.

change_default_dyna_path

Change your default Ansys LS-Dyna path.

change_default_mechanical_path

Change your default Mechanical path.

change_default_ansys_path

Deprecated, use change_default_mapdl_path instead

save_mechanical_path

Find the Mechanical path or query user.

save_dyna_path

Find Ansys LD-Dyna’s path or query user.

save_mapdl_path

Find Ansys MAPDL’s path or query user.

save_ansys_path

Deprecated, use save_mapdl_path instead

clear_configuration

Clear the entry of the specified product in the configuration file

get_saved_application_path

get_mapdl_path

Acquires Ansys MAPDL Path:

get_dyna_path

Acquires Ansys LS-Dyna Path from a cached file or user input

get_ansys_path

Deprecated, use get_mapdl_path instead

get_mechanical_path

Acquires Ansys Mechanical Path

version_from_path

Extract the product version from a path.

get_latest_ansys_installation

Return a tuple with the latest ansys installation version and its path

Module detail#

path.get_available_ansys_installations(supported_versions: SUPPORTED_VERSIONS_TYPE = SUPPORTED_ANSYS_VERSIONS) Dict[int, str]#

Return a dictionary of available Ansys unified installation versions with their base paths.

Returns:
dict[int: str]

Return all Ansys unified installations paths in Windows.

Notes

On Windows, It uses the environment variable AWP_ROOTXXX.

The student versions are returned at the end of the dict and with negative value for the version.

Examples

>>> from ansys.tools.path import get_available_ansys_installations
>>> get_available_ansys_installations()
{222: 'C:\Program Files\ANSYS Inc\v222',
 212: 'C:\Program Files\ANSYS Inc\v212',
 -222: 'C:\Program Files\ANSYS Inc\ANSYS Student\v222'}

Return all installed Ansys paths in Linux.

>>> get_available_ansys_installations()
{194: '/usr/ansys_inc/v194',
 202: '/usr/ansys_inc/v202',
 211: '/usr/ansys_inc/v211'}
path.find_mechanical(version: float | None = None, supported_versions: SUPPORTED_VERSIONS_TYPE = SUPPORTED_ANSYS_VERSIONS) Tuple[str, float] | Tuple[Literal[''], Literal['']]#

Search for the Mechanical path in the standard installation location.

Returns:
mechanical_pathstr

Full path to the executable file for the latest Mechanical version.

versionfloat | str

Version in the float format. For example, 23.1 for 2023 R1. If no version has be found, version is set to “”

Examples

On Windows:

>>> from ansys.tools.path import find_mechanical
>>> find_mechanical()
('C:/Program Files/ANSYS Inc/v231/aisol/bin/winx64/AnsysWBU.exe', 23.1)

On Linux:

>>> find_mechanical()
('/usr/ansys_inc/v231/aisol/.workbench', 23.1)
path.find_mapdl(version: int | float | None = None, supported_versions: SUPPORTED_VERSIONS_TYPE = SUPPORTED_ANSYS_VERSIONS) Tuple[str, float] | Tuple[Literal[''], Literal['']]#

Searches for Ansys MAPDL path within the standard install location and returns the path of the latest version.

Parameters:
versionint, float, optional

Version of Ansys MAPDL to search for. If using int, it should follow the convention XXY, where XX is the major version, and Y is the minor. If using float, it should follow the convention XX.Y, where XX is the major version, and Y is the minor. If None, use latest available version on the machine.

Returns:
ansys_pathstr

Full path to ANSYS executable.

versionfloat

Version float. For example, 21.1 corresponds to 2021R1.

Examples

Within Windows

>>> from ansys.tools.path import find_mapdl
>>> find_mapdl()
'C:/Program Files/ANSYS Inc/v211/ANSYS/bin/winx64/ansys211.exe', 21.1

Within Linux

>>> find_mapdl()
(/usr/ansys_inc/v211/ansys/bin/ansys211, 21.1)
path.find_dyna(version: int | float | None = None, supported_versions: SUPPORTED_VERSIONS_TYPE = SUPPORTED_ANSYS_VERSIONS) Tuple[str, float] | Tuple[Literal[''], Literal['']]#

Searches for Ansys LS-Dyna path within the standard install location and returns the path of the latest version.

Parameters:
versionint, float, optional

Version of Ansys LS-Dyna to search for. If using int, it should follow the convention XXY, where XX is the major version, and Y is the minor. If using float, it should follow the convention XX.Y, where XX is the major version, and Y is the minor. If None, use latest available version on the machine.

Returns:
ansys_pathstr

Full path to Ansys LS-Dyna executable.

versionfloat

Version float. For example, 21.1 corresponds to 2021R1.

Examples

Within Windows

>>> from ansys.tools.path import find_dyna
>>> find_dyna()
'C:/Program Files/ANSYS Inc/v232/ANSYS/bin/winx64/LSDYNA232.exe', 23.2

Within Linux

>>> find_dyna()
(/usr/ansys_inc/v232/ansys/bin/lsdyna232, 23.2)
path.find_ansys(version: float | None = None, supported_versions: SUPPORTED_VERSIONS_TYPE = SUPPORTED_ANSYS_VERSIONS) Tuple[str, float] | Tuple[Literal[''], Literal['']]#

Obsolete method, use find_mapdl.

path.is_valid_executable_path(product: PRODUCT_TYPE, exe_loc: str) bool#
path.change_default_mapdl_path(exe_loc: str) None#

Change your default Ansys MAPDL path.

Parameters:
exe_locstr

Ansys MAPDL executable path. Must be a full path.

Examples

Change default Ansys MAPDL location on Linux

>>> from ansys.tools.path import change_default_mapdl_path, get_mapdl_path
>>> change_default_mapdl_path('/ansys_inc/v201/ansys/bin/ansys201')
>>> get_mapdl_path()
'/ansys_inc/v201/ansys/bin/ansys201'

Change default Ansys location on Windows

>>> mapdl_path = 'C:/Program Files/ANSYS Inc/v193/ansys/bin/winx64/ANSYS193.exe'
>>> change_default_mapdl_path(mapdl_path)
path.change_default_dyna_path(exe_loc: str) None#

Change your default Ansys LS-Dyna path.

Parameters:
exe_locstr

path to LS-Dyna executable. Must be a full path. This need not contain the name of the executable, because the name of the LS-Dyna executable depends on the precision.

Examples

Change default Ansys LS-Dyna location on Linux

>>> from ansys.tools.path import change_default_dyna_path, get_dyna_path
>>> change_default_dyna_path('/ansys_inc/v232/ansys/bin/lsdyna232')
>>> get_dyna_path()
'/ansys_inc/v232/ansys/bin/lsdyna232'

Change default Ansys LS-Dyna location on Windows

>>> dyna_path = 'C:/Program Files/ANSYS Inc/v232/ansys/bin/winx64/LSDYNA232.exe'
>>> change_default_dyna_path(dyna_path)
path.change_default_mechanical_path(exe_loc: str) None#

Change your default Mechanical path.

Parameters:
exe_locstr

Full path for the Mechanical executable file to use.

Examples

On Windows:

>>> from ansys.tools.path import change_default_mechanical_path, get_mechanical_path
>>> change_default_mechanical_path('C:/Program Files/ANSYS Inc/v231/aisol/bin/win64/AnsysWBU.exe')
>>> get_mechanical_path()
'C:/Program Files/ANSYS Inc/v231/aisol/bin/win64/AnsysWBU.exe'

On Linux:

>>> from ansys.tools.path import change_default_mechanical_path, get_mechanical_path
>>> change_default_mechanical_path('/ansys_inc/v231/aisol/.workbench')
>>> get_mechanical_path()
'/ansys_inc/v231/aisol/.workbench'
path.change_default_ansys_path(exe_loc: str) None#

Deprecated, use change_default_mapdl_path instead

path.save_mechanical_path(exe_loc: str | None = None, allow_prompt: bool = True) str#

Find the Mechanical path or query user.

Parameters:
exe_locstr, optional

Path for the Mechanical executable file (AnsysWBU.exe). The default is None, in which case an attempt is made to obtain the path from the following sources in this order:

  • The default Mechanical paths (for example, C:/Program Files/Ansys Inc/vXXX/aiso/bin/AnsysWBU.exe)

  • The configuration file

  • User input

If a path is supplied, this method performs some checks. If the checks are successful, it writes this path to the configuration file.

Returns:
str

Path for the Mechanical executable file.

Notes

The location of the configuration file config.txt can be found in ansys.tools.path.SETTINGS_DIR. For example:

>>> from ansys.tools.path import SETTINGS_DIR
>>> import os
>>> print(os.path.join(SETTINGS_DIR, "config.txt"))
C:/Users/[username]]/AppData/Local/Ansys/ansys_tools_path/config.txt

You can change the default for the exe_loc parameter either by modifying the config.txt file or by running this code:

>>> from ansys.tools.path import save_mechanical_path
>>> save_mechanical_path("/new/path/to/executable")
path.save_dyna_path(exe_loc: str | None = None, allow_prompt: bool = True) str#

Find Ansys LD-Dyna’s path or query user.

If no exe_loc argument is supplied, this function attempt to obtain the Ansys LS-Dyna executable from (and in order):

  • The default ansys paths (i.e. 'C:/Program Files/Ansys Inc/vXXX/ansys/bin/winx64/LSDYNAXXX')

  • The configuration file

  • User input

If exe_loc is supplied, this function does some checks. If successful, it will write that exe_loc into the config file.

Parameters:
exe_locstr, optional

Path of the LS-Dyna executable (‘lsdynaXXX’), by default None.

Returns:
str

Path of the LS-Dyna executable.

Notes

The location of the configuration file config.txt can be found in ansys.tools.path.SETTINGS_DIR. For example:

>>> from ansys.tools.path import SETTINGS_DIR
>>> import os
>>> print(os.path.join(SETTINGS_DIR, "config.txt"))
C:/Users/[username]/AppData/Local/Ansys/ansys_tools_path/config.txt

Examples

You can change the default exe_loc either by modifying the mentioned config.txt file or by executing:

>>> from ansys.tools.path import save_dyna_path
>>> save_dyna_path('/new/path/to/executable')
path.save_mapdl_path(exe_loc: str | None = None, allow_prompt: bool = True) str#

Find Ansys MAPDL’s path or query user.

If no exe_loc argument is supplied, this function attempt to obtain the Ansys MAPDL executable from (and in order):

  • The default ansys paths (i.e. 'C:/Program Files/Ansys Inc/vXXX/ansys/bin/winx64/ansysXXX')

  • The configuration file

  • User input

If exe_loc is supplied, this function does some checks. If successful, it will write that exe_loc into the config file.

Parameters:
exe_locstr, optional

Path of the MAPDL executable (‘ansysXXX’), by default None.

Returns:
str

Path of the MAPDL executable.

Notes

The location of the configuration file config.txt can be found in ansys.tools.path.SETTINGS_DIR. For example:

>>> from ansys.tools.path import SETTINGS_DIR
>>> import os
>>> print(os.path.join(SETTINGS_DIR, "config.txt"))
C:/Users/[username]/AppData/Local/Ansys/ansys_tools_path/config.txt

Examples

You can change the default exe_loc either by modifying the mentioned config.txt file or by executing:

>>> from ansys.tools.path import save_mapdl_path
>>> save_mapdl_path('/new/path/to/executable')
path.save_ansys_path(exe_loc: str | None = None, allow_prompt: bool = True) str#

Deprecated, use save_mapdl_path instead

path.clear_configuration(product: PRODUCT_TYPE | Literal['all']) None#

Clear the entry of the specified product in the configuration file

path.get_saved_application_path(application: str) str | None#
path.get_mapdl_path(allow_input: bool = True, version: float | None = None, find: bool = True) str | None#

Acquires Ansys MAPDL Path:

First, it looks in the configuration file, used by save_mapdl_path Then, it tries to find it based on conventions for where it usually is. Lastly, it takes user input

Parameters:
allow_inputbool, optional

Allow user input to find Ansys MAPDL path. The default is True.

versionfloat, optional

Version of Ansys MAPDL to search for. For example version=22.2. If None, use latest.

find: bool, optional

Allow ansys-tools-path to search for Ansys Mechanical in typical installation locations

path.get_dyna_path(allow_input: bool = True, version: float | None = None, find: bool = True) str | None#

Acquires Ansys LS-Dyna Path from a cached file or user input

First, it looks in the configuration file, used by save_dyna_path Then, it tries to find it based on conventions for where it usually is. Lastly, it takes user input

Parameters:
allow_inputbool, optional

Allow user input to find Ansys LS-Dyna path. The default is True.

versionfloat, optional

Version of Ansys LS-Dyna to search for. For example version=22.2. If None, use latest.

find: bool, optional

Allow ansys-tools-path to search for Ansys Mechanical in typical installation locations

path.get_ansys_path(allow_input: bool = True, version: float | None = None) str | None#

Deprecated, use get_mapdl_path instead

path.get_mechanical_path(allow_input: bool = True, version: float | None = None, find: bool = True) str | None#

Acquires Ansys Mechanical Path

First, it looks in the configuration file, used by save_mechanical_path Then, it tries to find it based on conventions for where it usually is. Lastly, it takes user input

Parameters:
allow_inputbool, optional

Allow user input to find Ansys Mechanical path. The default is True.

versionfloat, optional

Version of Ansys Mechanical to search for. For example version=22.2. If None, use latest.

find: bool, optional

Allow ansys-tools-path to search for Ansys Mechanical in typical installation locations

path.version_from_path(product: PRODUCT_TYPE, path: str) int#

Extract the product version from a path.

Parameters:
pathstr

Path to the executable file.

Returns:
int

Integer version number (for example, 231).

path.get_latest_ansys_installation() Tuple[int, str]#

Return a tuple with the latest ansys installation version and its path

If there is a student version and a regular installation for the latest release, the regular one is returned

Returns:
Tuple[int, str]

Tuple with the latest version and path of the installation

path.PLUGINS: Dict[str, ansys.tools.path.applications.ApplicationPlugin]#
path.LOG#
path.PRODUCT_TYPE#
path.SUPPORTED_VERSIONS_TYPE#
path.LINUX_DEFAULT_DIRS#
path.CONFIG_FILE_NAME = 'config.txt'#
path.SUPPORTED_ANSYS_VERSIONS: SUPPORTED_VERSIONS_TYPE#
path.PRODUCT_EXE_INFO#
path.SETTINGS_DIR#
path.CONFIG_FILE#
path.linux_default_dirs = [['/', 'usr', 'ansys_inc'], ['/', 'ansys_inc'], ['/', 'install', 'ansys_inc']]#