TRACE User Guide  TRACE Version 9.8.1
Python file for user defined functions

The python file for user defined functions can be specified by the corresponding command line option and the documentation of the functionality can be found in the PyTraceSuite documentation.

TRACE checks the python file for functions with defined names.

Example
#!/usr/bin/env python3
from tracesuite.trace import TRACE
trace = None # define a global variable for the TRACE instance
def afterIteration(): # the name has to be "afterIteration", no parameters
global trace
# if the function is called for the first time, initialize the TRACE instance
if trace is None:
trace = TRACE.initialize()
# use the documented functionality to control the TRACE simulation

The example above shows the minimal content of a python file. Currently, only the "afterIteration" function is available, which is executed in the last step of every TRACE iteration, right before the time step increment.

Note
Since TRACE is already running, the commands
TRACE(command_line)
and
TRACE.run
are not necessary and may lead to unexpected behavior.