1. Help Center
  2. Twin Builder
  3. Functional Mockup Unit (FMU)

How to generate a Functional Mockup Unit (FMU) via Python for Ansys Twin Builder and/or Ansys Fluent

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

  1. Download pip from https://bootstrap.pypa.io/




  2. 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.




  3. 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.



  4. While still in the Command Prompt window, issue the command    
               python get-pip.py



  5. Add the directory where pip is installed to the environment variables Path for user and system.



         

Stage 2: Install the pythonfmu package

  1. While in Command Prompt window, change directory to the Scripts directory



  2. While in Command Prompt window issue the installation command:
                    pip install pythonfmu




Stage 3: Build the FMU with pythonfmu



  1. 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

                              For this example, a python script is named pyscript4fmu.py.