locate_lumerical_install#

ansys.lumerical.core.autodiscovery.locate_lumerical_install()#

Locate the installation directory and interop library directory for Lumerical software.

This function attempts to identify the most recent installation path of Lumerical software and its associated Python interop library directory based on the operating system and predefined directory structures.

Returns:
str or None

The path to the Lumerical installation directory, or None if not found.

Raises:
RuntimeError

If the operating system is not Windows or Linux.

Notes

  • Checks the LUMERICAL_HOME environment variable first. If set and valid, uses it.

  • On Windows, the function first searches the registry, then searches under “C:\Program Files\Lumerical\” and “C:\Program Files\Ansys Inc\Lumerical”.

  • On Linux, the function searches under “/opt/lumerical/” and “~/Ansys/ansys_inc/Lumerical”.

Examples

Example 1: Use autodiscovery to locate a Lumerical installation in a default location.

>>> import ansys.lumerical.core as lumapi
>>> # use lumapi ...

Example 2: Set the environment variable before importing the module.

>>> import os
>>> os.environ["LUMERICAL_HOME"] = r"C:\Program Files\Lumerical\v252\"
>>> import ansys.lumerical.core as lumapi
>>> # use lumapi ...

Example 3: Provide a custom installation path before importing the module.

>>> import ansys.api.lumerical.lumapi
>>> ansys.api.lumerical.lumapi.InteropPaths.setLumericalInstallPath(r"C:\Program Files\Lumerical\v252\")
>>> import ansys.lumerical.core as lumapi
>>> # use lumapi ...

Example 4: Provide a custom installation path after importing the module.

If autodiscovery fails to find an installation, a UserWarning is emitted (text: “Lumerical installation not found. Set the LUMERICAL_HOME environment variable or call InteropPaths.setLumericalInstallPath() to configure the path manually.”).

>>> import ansys.lumerical.core as lumapi
>>> lumapi.InteropPaths.setLumericalInstallPath(r"C:\Program Files\Lumerical\v252\")
>>> # use lumapi ...