Installation#

The ansys-fluent-core package supports Python 3.7 through Python 3.10 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/pyansys/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 Fluent installation, PyFluent automatically uses the AWP_ROOT<ver> environment variable, where <ver> is the three-digit format for the release. For example, AWP_ROOT222 is the environment variable for the 2022 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 2022 R2 release, you would set the AWP_ROOT222 environment variable to point to an absolute location such as C:\Program Files\ANSYS Inc\v222.

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 show_gui=True to the launch_fluent() method:

session = pyfluent.launch_fluent(precision="double", processor_count=2, show_gui=True, mode="solver")

If you want to print the debug information for development, set the following environment variable:

pyfluent.set_log_level('DEBUG') # for development, by default only errors are shown

Additional PyFluent packages#

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