This article documents a procedure for generating a FMU from a Python script. The procedure includes installing needed Python utilities. The FMU can be used with Ansys Fluent and/or Ansys Twin Builder.
A Python script can be used with Python utilities to generate a FMU for analysis in Ansys Fluent and/or Ansys Twin Builder. The procedure below can be used for downloading and installing Python scripts as well as generating the FMU. It is assumed that the operating system is Windows and that Python 3.12 is already installed.
There are 3 stages to complete if starting from scratch.
- Downloading and installing a utility called pip
- Using pip to install pythonfmu
- Using pythonfmu to build a FMU from a Python script
Stage 1: Download and install Python pip
- Download pip from https://bootstrap.pypa.io/
- Use Save link as and store get-pip.py in the same directory folder where Python is installed. For example, the file would be stored in the folder as shown below.
-
Use cmd to open a Command Prompt window.
In the Command Prompt window, change directory to the where the get-pip.py file is located. - While still in the Command Prompt window, issue the command
python get-pip.py - Add the directory where pip is installed to the environment variables Path for user and system.
Stage 2: Install the pythonfmu package
- While in Command Prompt window, change directory to the Scripts directory
- While in Command Prompt window issue the installation command:
Stage 3: Build the FMU with pythonfmu
- While in Command Prompt window change directory to the folder where the python script for FMU generation is located. Run pythonfmu build to create the fmu.
pythonfmu build -f scriptname.py