PyFluent provides Pythonic access to Ansys Fluent.
To run PyFluent, you must have a licensed copy of Ansys Fluent installed locally. PyFluent supports Fluent 2022 R2 and later.
For more information on Fluent, see the Ansys Fluent page on the Ansys website.
Install the package#
ansys-fluent-core package supports Python 3.7 through
Python 3.10 on Windows and Linux.
Install the latest release from PyPi with:
pip install ansys-fluent-core
If you plan on doing local development of PyFluent with Git, install the latest release with:
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.
To launch Fluent from PyFluent, use the
import ansys.fluent.core as pyfluent solver = pyfluent.launch_fluent(precision="double", processor_count=2, mode="solver") solver.check_health()
Once Fluent is active, you can use the
session.solver.tui interface to send
Fluent TUI commands to Fluent. For example, you can read a
case file, update a setting, and iterate the solver with:
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 graphical user interface, pass
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 libraries#
You can also install and use these additional PyFluent libraries: