Installation#

The ansys-fluent-core package supports Python 3.9 through Python 3.11 on Windows and Linux.

Note

This page provides information for quickly installing and launching the ansys-fluent-core package. Additional PyFluent packages, which are described later on this page, can also be installed. For information on installing all PyFluent packages in a virtual environment, see How do you install PyFluent? in Frequently asked questions.

Install the package#

Install the latest ansys-fluent-core package from PyPi with this code:

pip install ansys-fluent-core

If you plan on doing local development of PyFluent with Git, install the latest ansys-fluent-core package with this code:

git clone https://github.com/ansys/pyfluent.git
cd pyfluent
pip install pip -U
pip install -e .
python codegen/allapigen.py  # Generates the API files

Any changes that you make locally are reflected in your setup after you restart the Python kernel.

Launch Fluent#

To launch Fluent from PyFluent, use the launch_fluent() method:

import ansys.fluent.core as pyfluent
solver = pyfluent.launch_fluent(precision="double", processor_count=2, mode="solver")
solver.health_check_service.is_serving

To locate the latest Fluent installation, PyFluent automatically uses the AWP_ROOT<ver> environment variable, where <ver> is the three-digit format for the release. For example, AWP_ROOT232 is the environment variable for the 2023 R2 release.

On a Windows system, this environment variable is configured when a release is installed.

On a Linux system, you must configure this environment variable to point to the absolute path of the installed release. For example, for the 2023 R2 release, you would set the AWP_ROOT232 environment variable to point to an absolute location such as /apps/ansys_inc/v232.

For information on other ways of specifying the Fluent location for PyFluent, see How does PyFluent infer the location to launch Fluent? in Frequently asked questions.

Once Fluent is active, you can use the solver_session.tui interface to send Fluent TUI commands to PyFluent. For example, this code reads a case file, updates a setting, and iterates the solver:

solver.tui.file.read_case('elbow.cas.h5')
solver.tui.define.models.unsteady_2nd_order("yes")
solver.tui.solve.initialize.initialize_flow()
solver.tui.solve.dual_time_iterate(2, 3)

If you want to interact with the Fluent GUI (graphical user interface), pass ui_mode="gui" to the launch_fluent() method:

session = pyfluent.launch_fluent(precision="double", processor_count=2, ui_mode="gui", mode="solver")

If you want to look at PyFluent’s debug logging, use the following command:

pyfluent.logging.enable()

For more details, see Logging to file and debugging.

Additional PyFluent packages#

In addition to the ansys-fluent-core package, you can install and use the pyfluent-parameteric and pyfluent-visualization packages: