9.2.4. Step 4a: Create a System Coupling Python Run Script

When using Command-Line Interface (CLI) System Coupling, the next step is to create a System Coupling python run script in your working directory. The run script contains a series of commands to specify the System Coupling participants, coupling interfaces, and simulation options.

Steady-State Coupled Analysis

Below is an example run script for a steady-state coupled simulation, where Fluent and Forte are both Participants.

import os

# Forte is a Participant
# Forte's project file is named "Engine.ftsim" and is located under the "forte" subfolder in the working directory
forte = AddParticipant(InputFile = os.path.join('forte', 'Engine.ftsim'))

# Fluent is a Participant
# Fluent's System Coupling participant file is named "fluent.scp" and is placed in the working directory
fluent = AddParticipant(InputFile = 'fluent.scp')

# Add a coupling interface between Forte and Fluent, and specify 
coupling variables on each interface.

iName = AddInterface(SideOneParticipant = fluent,
                     SideOneRegions = ['wall_internal'],
                     SideTwoParticipant = forte,
                     SideTwoRegions = ['Wall'])

iheatrate = AddDataTransfer(Interface = iName,
                TargetSide = 'One',
                SideOneVariable = 'heatflow',
                SideTwoVariable = 'HEATR')

itemperature = AddDataTransfer(Interface = iName,
                TargetSide = 'Two',
                SideOneVariable = 'temperature',
                SideTwoVariable = 'TEMP')	


# Perform the System Coupling run
Solve()

At the beginning of the script, the AddParticipant command is used to set up both Forte and Fluent. Its arguments specify the name and location of the input files. For Forte, the input file named Engine.ftsim is placed into the subfolder "forte" in the working directory. For Fluent, the input file is fluent.scp in the working directory. In Step 3: Set Up a Working Folder for the System Coupling Run, we introduced how to prepare the files in the working directory and how to check their consistency with the settings here.

Next, we use the AddInterface command to define the coupling interface. In the Fluent project, the interface is at the boundary called "wall_internal". In the Forte project, the same interface is at the boundary called "Wall".

Then, we define data transfer on the coupling interface using the AddDataTransfer command. We added two transfers in the script since the data transfer is two-way:

  • The first data transfer is for heat transfer rate, which is named "HEATR" in Forte and "heatflow" in Fluent. This transfer is from Forte ("SideTwo") to Fluent ("SideOne").

  • The second data transfer is for temperature, which is named "TEMP" in Forte and "temperature" in Fluent. This transfer is from Fluent ("SideOne") to Forte ("SideTwo").


Note:  You may only transfer data for variables that are recognized by each participant. For a given variable, each participant has its own terminology to name it. For example, the heat transfer rate is named "HEATR" in Forte and "heatflow" in Fluent. For a list of variables available to transfer from/to Forte, refer to Variables Available for System Coupling.


Lastly but very importantly, the Solve() command is used to start the System Coupling simulation.

The commands used in the script are fully documented in the System Coupling documentation at System Coupling Settings and Commands Reference . In addition to the commands used in the above Python script, there are commands that control the convergence between the participants, such as ramping and relaxation; in some cases, these may be needed to ensure stable and rapid convergence to a coupled solution. See Best Practices for System Coupling in the System Coupling User's Guide and the System Coupling tutorial examples in the Forte Tutorials at the Help site for examples of using these options.

Transient Coupled Analysis

For a Transient coupled analysis, the python script must contain all the elements introduced in the above example. It must also contain two additional lines to set the end time of the simulation 'SolutionControl.EndTime' and the coupling step size 'SolutionControl.TimeStepSize' at which the participants will be exchanging their data. For example:

DatamodelRoot().SolutionControl.EndTime = 
'0.1 [s]' 
DatamodelRoot().SolutionControl.TimeStepSize = 
'0.01 [s]'

Here, the end time of the transient coupled analysis is set as 0.1 seconds, and the coupling step size is 0.01 seconds. So, it would take ten coupling steps to reach the end time. As we introduced in Steady-State and Transient Coupled Analysis, each coupling step could take several coupling iterations to converge.


Tip:  Note that the System Coupling syntax for certain commands may have changed, starting at release 2021 R2. So, if you want to run a previously set-up case, you may have to manually modify the python script using the most-updated commands. However, if you choose to follow Step 4b: Use the System Coupling Graphical User Interface, you can simply launch the System Coupling GUI and re-save the project.


Once you have set up the working directory and created the python script, you are ready to start the System Coupling run. Please proceed to How To Run System Coupling.

For more general information about using CLI System Coupling, see Using the System Coupling Command-Line Interface (CLI) in the System Coupling User's Guide.