OMSimulator

Version: v2.1.1.post35-g69d29f1

Introduction

The OMSimulator project is a FMI-based co-simulation tool that supports ordinary (i.e., non-delayed) and TLM connections. It supports large-scale simulation and virtual prototyping using models from multiple sources utilizing the FMI standard. It is integrated into OpenModelica but also available stand-alone, i.e., without dependencies to Modelica specific models or technology. OMSimulator provides an industrial-strength open-source FMI-based modelling and simulation tool. Input/output ports of FMUs can be connected, ports can be grouped to buses, FMUs can be parameterized and composed, and composite models can be exported according to the (preliminary) SSP (System Structure and Parameterization) standard. Efficient FMI based simulation is provided for both model-exchange and co-simulation. TLM-based tool connection is provided for a range of applications, e.g., Adams, Simulink, Beast, Dymola, and OpenModelica. Moreover, optional TLM (Transmission Line Modelling) domain-specific connectors are also supported, providing additional numerical stability to co-simulation. An external API is available for use from other tools and scripting languages such as Python and Lua.

OMSimulator

OMSimulator is a command line wrapper for the OMSimulatorLib library.

OMSimulator Flags

A brief description of all command line flags will be displayed using OMSimulator --help:

info:    Usage: OMSimulator [Options] [Lua script] [FMU] [SSP file]
         Options:
           --addParametersToCSV=<arg>      Export parameters to .csv file (true, [false])
           --algLoopSolver=<arg>           Specifies the alg. loop solver method ([fixedpoint], kinsol) used for algebraic loops spanning over multiple components.
           --clearAllOptions               Reset all flags to default values
           --deleteTempFiles=<bool>        Deletes temp files as soon as they are no longer needed ([true], false)
           --emitEvents=<bool>             Specifies whether events should be emitted or not ([true], false)
           --exportParametersInline=<arg>  Export ParameterBindings inline with .ssd file, 
           --fetchAllVars=<arg>            Workaround for certain FMUs that do not update all internal dependencies automatically
           --help [-h]                     Displays the help text
           --ignoreInitialUnknowns=<bool>  Ignore the initial unknowns from the modelDescription.xml (true, [false])
           --inputExtrapolation=<bool>     Enables input extrapolation using derivative information (true, [false])
           --intervals=<int> [-i]          Specifies the number of communication points (arg > 1)
           --logFile=<arg> [-l]            Specifies the logfile (stdout is used if no log file is specified)
           --logLevel=<int>                0 default, 1 debug, 2 debug+trace
           --maxEventIteration=<int>       Specifies the max. number of iterations for handling a single event
           --maxLoopIteration=<int>        Specifies the max. number of iterations for solving algebraic loops between system-level components. Internal algebraic loops of components are not affected.
           --mode=<arg> [-m]               Forces a certain FMI mode iff the FMU provides cs and me (cs, [me])
           --numProcs=<int> [-n]           Specifies the max. number of processors to use (0=auto, 1=default)
           --progressBar=<bool>            Shows a progress bar for the simulation progress in the terminal (true, [false])
           --realTime=<bool>               Experimental feature for (soft) real-time co-simulation (true, [false])
           --resultFile=<arg> [-r]         Specifies the name of the output result file
           --setInputDerivatives=<bool>    Deprecated; see '--inputExtrapolation'
           --skipCSVHeader=<arg>           Skip exporting the scv delimiter in the header (true, [false]), 
           --solver=<arg>                  Specifies the integration method (euler, [cvode])
           --solverStats=<bool>            Adds solver stats to the result file, e.g. step size; not supported for all solvers (true, [false])
           --startTime=<double> [-s]       Specifies the start time
           --stopTime=<double> [-t]        Specifies the stop time
           --stripRoot=<bool>              Removes the root system prefix from all exported signals (true, [false])
           --suppressPath=<bool>           Supresses path information in info messages; especially useful for testing (true, [false])
           --tempDir=<arg>                 Specifies the temp directory
           --timeout=<int>                 Specifies the maximum allowed time in seconds for running a simulation (0 disables)
           --tolerance=<double>            Specifies the relative tolerance
           --version [-v]                  Displays version information
           --wallTime=<bool>               Add wall time information for to the result file (true, [false])
           --workingDir=<arg>              Specifies the working directory

To use flag logLevel with option debug (--logLevel=1) or debug+trace (--logLevel=2) one needs to build OMSimulator with debug configuration enabled. Refer to the OMSimulator README on GitHub for further instructions.

Examples

OMSimulator --timeout 180 example.lua

OMSimulatorLib

This library is the core of OMSimulator and provides a C interface that can easily be utilized to handle co-simulation scenarios.

RunFile

Simulates a single FMU or SSP model.

oms_status_enu_t oms_RunFile(const char* filename);

addBus

Adds a bus to a given component.

oms_status_enu_t oms_addBus(const char* cref);

addConnection

Adds a new connection between connectors A and B. The connectors need to be specified as fully qualified component references, e.g., "model.system.component.signal".

oms_status_enu_t oms_addConnection(const char* crefA, const char* crefB);

The two arguments crefA and crefB get swapped automatically if necessary.

addConnector

Adds a connector to a given component.

oms_status_enu_t oms_addConnector(const char* cref, oms_causality_enu_t causality, oms_signal_type_enu_t type);

addConnectorToBus

Adds a connector to a bus.

oms_status_enu_t oms_addConnectorToBus(const char* busCref, const char* connectorCref);

addConnectorToTLMBus

Adds a connector to a TLM bus.

oms_status_enu_t oms_addConnectorToTLMBus(const char* busCref, const char* connectorCref, const char *type);

addExternalModel

Adds an external model to a TLM system.

oms_status_enu_t oms_addExternalModel(const char* cref, const char* path, const char* startscript);

addSignalsToResults

[deprecated: setSignalFilter is the recommended API]

Add all variables that match the given regex to the result file.

oms_status_enu_t oms_addSignalsToResults(const char* cref, const char* regex);

The second argument, i.e. regex, is considered as a regular expression (C++11). ".*" and "(.)*" can be used to hit all variables.

addSubModel

Adds a component to a system.

oms_status_enu_t oms_addSubModel(const char* cref, const char* fmuPath);

addSystem

Adds a (sub-)system to a model or system.

oms_status_enu_t oms_addSystem(const char* cref, oms_system_enu_t type);

addTLMBus

Adds a TLM bus.

oms_status_enu_t oms_addTLMBus(const char* cref, oms_tlm_domain_t domain, const int dimensions, const oms_tlm_interpolation_t interpolation);

addTLMConnection

Connects two TLM connectors.

oms_status_enu_t oms_addTLMConnection(const char* crefA, const char* crefB, double delay, double alpha, double linearimpedance, double angularimpedance);

compareSimulationResults

This function compares a given signal of two result files within absolute and relative tolerances.

int oms_compareSimulationResults(const char* filenameA, const char* filenameB, const char* var, double relTol, double absTol);

The following table describes the input values:

Input

Type

Description

filenameA

String

Name of first result file to compare.

filenameB

String

Name of second result file to compare.

var

String

Name of signal to compare.

relTol

Number

Relative tolerance.

absTol

Number

Absolute tolerance.

The following table describes the return values:

Type

Description

Integer

1 if the signal is considered as equal, 0 otherwise

copySystem

Copies a system.

oms_status_enu_t oms_copySystem(const char* source, const char* target);

delete

Deletes a connector, component, system, or model object.

oms_status_enu_t oms_delete(const char* cref);

deleteConnection

Deletes the connection between connectors crefA and crefB.

oms_status_enu_t oms_deleteConnection(const char* crefA, const char* crefB);

The two arguments crefA and crefB get swapped automatically if necessary.

deleteConnectorFromBus

Deletes a connector from a given bus.

oms_status_enu_t oms_deleteConnectorFromBus(const char* busCref, const char* connectorCref);

deleteConnectorFromTLMBus

Deletes a connector from a given TLM bus.

oms_status_enu_t oms_deleteConnectorFromTLMBus(const char* busCref, const char* connectorCref);

doStep

Simulates a macro step of the given composite model. The step size will be determined by the master algorithm and is limited by the definied minimal and maximal step sizes.

oms_status_enu_t oms_doStep(const char* cref);

export

Exports a composite model to a SPP file.

oms_status_enu_t oms_export(const char* cref, const char* filename);

exportDependencyGraphs

Export the dependency graphs of a given model to dot files.

oms_status_enu_t oms_exportDependencyGraphs(const char* cref, const char* initialization, const char* event, const char* simulation);

exportSSMTemplate

Exports all signals that have start values of one or multiple FMUs to a SSM file that are read from modelDescription.xml with a mapping entry. The mapping entry specifies a single mapping between a parameter in the source and a parameter of the system or component being parameterized. The mapping entry contains two attributes namely source and target. The source attribute will be empty and needs to be manually mapped by the users associated with the parameter name defined in the SSV file, the target contains the name of parameter in the system or component to be parameterized. The function can be called for a top level model or a certain FMU component. If called for a top level model, start values of all FMUs are exported to the SSM file. If called for a component, start values of just this FMU are exported to the SSM file.

oms_status_enu_t oms_exportSSMTemplate(const char* cref, const char* filename)

exportSSVTemplate

Exports all signals that have start values of one or multiple FMUs to a SSV file that are read from modelDescription.xml. The function can be called for a top level model or a certain FMU component. If called for a top level model, start values of all FMUs are exported to the SSV file. If called for a component, start values of just this FMU are exported to the SSV file.

oms_status_enu_t oms_exportSSVTemplate(const char* cref, const char* filename)

exportSnapshot

Lists the SSD representation of a given model, system, or component.

Memory is allocated for contents. The caller is responsible to free it using the C-API. The Lua and Python bindings take care of the memory and the caller doesn't need to call free.

oms_status_enu_t oms_exportSnapshot(const char* cref, char** contents);

extractFMIKind

Extracts the FMI kind of a given FMU from the file system.

oms_status_enu_t oms_extractFMIKind(const char* filename, oms_fmi_kind_enu_t* kind);

faultInjection

Defines a new fault injection block.

oms_status_enu_t oms_faultInjection(const char* signal, oms_fault_type_enu_t faultType, double faultValue);

type

Description"

oms_fault_type_bias

y = y.$original + faultValue

oms_fault_type_gain

y = y.$original * faultValue

oms_fault_type_const

y = faultValue

freeMemory

Free the memory allocated by some other API. Pass the object for which memory is allocated.

void oms_freeMemory(void* obj);

getBoolean

Get boolean value of given signal.

oms_status_enu_t oms_getBoolean(const char* cref, bool* value);

getBus

Gets the bus object.

oms_status_enu_t oms_getBus(const char* cref, oms_busconnector_t** busConnector);

getComponentType

Gets the type of the given component.

oms_status_enu_t oms_getComponentType(const char* cref, oms_component_enu_t* type);

getConnections

Get list of all connections from a given component.

oms_status_enu_t oms_getConnections(const char* cref, oms_connection_t*** connections);

getConnector

Gets the connector object of the given connector cref.

oms_status_enu_t oms_getConnector(const char* cref, oms_connector_t** connector);

getElement

Get element information of a given component reference.

oms_status_enu_t oms_getElement(const char* cref, oms_element_t** element);

getElements

Get list of all sub-components of a given component reference.

oms_status_enu_t oms_getElements(const char* cref, oms_element_t*** elements);

getFMUInfo

Returns FMU specific information.

oms_status_enu_t oms_getFMUInfo(const char* cref, const oms_fmu_info_t** fmuInfo);

getFixedStepSize

Gets the fixed step size. Can be used for the communication step size of co-simulation systems and also for the integrator step size in model exchange systems.

oms_status_enu_t oms_getFixedStepSize(const char* cref, double* stepSize);

getInteger

Get integer value of given signal.

oms_status_enu_t oms_getInteger(const char* cref, int* value);

getModelState

Gets the model state of the given model cref.

oms_status_enu_t oms_getModelState(const char* cref, oms_modelState_enu_t* modelState);

getReal

Get real value.

oms_status_enu_t oms_getReal(const char* cref, double* value);

getResultFile

Gets the result filename and buffer size of the given model cref.

oms_status_enu_t oms_getResultFile(const char* cref, char** filename, int* bufferSize);

getSignalFilter

Gets the signal filter of the given model cref.

oms_status_enu_t oms_getSignalFilter(const char* cref, char** regex);

getSolver

Gets the selected solver method of the given system.

oms_status_enu_t oms_getSolver(const char* cref, oms_solver_enu_t* solver);

getStartTime

Get the start time from the model.

oms_status_enu_t oms_getStartTime(const char* cref, double* startTime);

getStopTime

Get the stop time from the model.

oms_status_enu_t oms_getStopTime(const char* cref, double* stopTime);

getSubModelPath

Returns the path of a given component.

oms_status_enu_t oms_getSubModelPath(const char* cref, char** path);

getSystemType

Gets the type of the given system.

oms_status_enu_t oms_getSystemType(const char* cref, oms_system_enu_t* type);

getTLMBus

Gets the TLM bus objects of the given TLM bus cref.

oms_status_enu_t oms_getTLMBus(const char* cref, oms_tlmbusconnector_t** tlmBusConnector);

getTLMVariableTypes

Gets the type of an TLM variable.

oms_status_enu_t oms_getTLMVariableTypes(oms_tlm_domain_t domain, const int dimensions, const oms_tlm_interpolation_t interpolation, char ***types, char ***descriptions);

getTime

Get the current simulation time from the model.

oms_status_enu_t oms_getTime(const char* cref, double* time);

getTolerance

Gets the tolerance of a given system or component.

oms_status_enu_t oms_getTolerance(const char* cref, double* absoluteTolerance, double* relativeTolerance);

getVariableStepSize

Gets the step size parameters.

oms_status_enu_t oms_getVariableStepSize(const char* cref, double* initialStepSize, double* minimumStepSize, double* maximumStepSize);

getVersion

Returns the library's version string.

const char* oms_getVersion();

importFile

Imports a composite model from a SSP file.

oms_status_enu_t oms_importFile(const char* filename, char** cref);

importSnapshot

Loads a snapshot to restore a previous model state. The model must be in virgin model state, which means it must not be instantiated.

oms_status_enu_t oms_importSnapshot(const char* cref, const char* snapshot, char** newCref);

initialize

Initializes a composite model.

oms_status_enu_t oms_initialize(const char* cref);

instantiate

Instantiates a given composite model.

oms_status_enu_t oms_instantiate(const char* cref);

list

Lists the SSD representation of a given model, system, or component.

Memory is allocated for contents. The caller is responsible to free it using the C-API. The Lua and Python bindings take care of the memory and the caller doesn't need to call free.

oms_status_enu_t oms_list(const char* cref, char** contents);

listUnconnectedConnectors

Lists all unconnected connectors of a given system.

Memory is allocated for contents. The caller is responsible to free it using the C-API. The Lua and Python bindings take care of the memory and the caller doesn't need to call free.

oms_status_enu_t oms_listUnconnectedConnectors(const char* cref, char** contents);

loadSnapshot

Loads a snapshot to restore a previous model state. The model must be in virgin model state, which means it must not be instantiated.

oms_status_enu_t oms_loadSnapshot(const char* cref, const char* snapshot, char** newCref);

newModel

Creates a new and yet empty composite model.

oms_status_enu_t oms_newModel(const char* cref);

removeSignalsFromResults

[deprecated: setSignalFilter is the recommended API]

Removes all variables that match the given regex to the result file.

oms_status_enu_t oms_removeSignalsFromResults(const char* cref, const char* regex);

The second argument, i.e. regex, is considered as a regular expression (C++11). ".*" and "(.)*" can be used to hit all variables.

rename

Renames a model, system, or component.

oms_status_enu_t oms_rename(const char* cref, const char* newCref);

reset

Reset the composite model after a simulation run.

The FMUs go into the same state as after instantiation.

oms_status_enu_t oms_reset(const char* cref);

setActivationRatio

Experimental feature for setting the activation ratio of FMUs for experimenting with multi-rate master algorithms.

oms_status_enu_t experimental_setActivationRatio(const char* cref, int k);

setBoolean

Sets the value of a given boolean signal.

oms_status_enu_t oms_setBoolean(const char* cref, bool value);

setBusGeometry

oms_status_enu_t oms_setBusGeometry(const char* bus, const ssd_connector_geometry_t* geometry);

setCommandLineOption

Sets special flags.

oms_status_enu_t oms_setCommandLineOption(const char* cmd);

Available flags:

info:    Usage: OMSimulator [Options] [Lua script] [FMU] [SSP file]
         Options:
           --addParametersToCSV=<arg>      Export parameters to .csv file (true, [false])
           --algLoopSolver=<arg>           Specifies the alg. loop solver method ([fixedpoint], kinsol) used for algebraic loops spanning over multiple components.
           --clearAllOptions               Reset all flags to default values
           --deleteTempFiles=<bool>        Deletes temp files as soon as they are no longer needed ([true], false)
           --emitEvents=<bool>             Specifies whether events should be emitted or not ([true], false)
           --exportParametersInline=<arg>  Export ParameterBindings inline with .ssd file, 
           --fetchAllVars=<arg>            Workaround for certain FMUs that do not update all internal dependencies automatically
           --help [-h]                     Displays the help text
           --ignoreInitialUnknowns=<bool>  Ignore the initial unknowns from the modelDescription.xml (true, [false])
           --inputExtrapolation=<bool>     Enables input extrapolation using derivative information (true, [false])
           --intervals=<int> [-i]          Specifies the number of communication points (arg > 1)
           --logFile=<arg> [-l]            Specifies the logfile (stdout is used if no log file is specified)
           --logLevel=<int>                0 default, 1 debug, 2 debug+trace
           --maxEventIteration=<int>       Specifies the max. number of iterations for handling a single event
           --maxLoopIteration=<int>        Specifies the max. number of iterations for solving algebraic loops between system-level components. Internal algebraic loops of components are not affected.
           --mode=<arg> [-m]               Forces a certain FMI mode iff the FMU provides cs and me (cs, [me])
           --numProcs=<int> [-n]           Specifies the max. number of processors to use (0=auto, 1=default)
           --progressBar=<bool>            Shows a progress bar for the simulation progress in the terminal (true, [false])
           --realTime=<bool>               Experimental feature for (soft) real-time co-simulation (true, [false])
           --resultFile=<arg> [-r]         Specifies the name of the output result file
           --setInputDerivatives=<bool>    Deprecated; see '--inputExtrapolation'
           --skipCSVHeader=<arg>           Skip exporting the scv delimiter in the header (true, [false]), 
           --solver=<arg>                  Specifies the integration method (euler, [cvode])
           --solverStats=<bool>            Adds solver stats to the result file, e.g. step size; not supported for all solvers (true, [false])
           --startTime=<double> [-s]       Specifies the start time
           --stopTime=<double> [-t]        Specifies the stop time
           --stripRoot=<bool>              Removes the root system prefix from all exported signals (true, [false])
           --suppressPath=<bool>           Supresses path information in info messages; especially useful for testing (true, [false])
           --tempDir=<arg>                 Specifies the temp directory
           --timeout=<int>                 Specifies the maximum allowed time in seconds for running a simulation (0 disables)
           --tolerance=<double>            Specifies the relative tolerance
           --version [-v]                  Displays version information
           --wallTime=<bool>               Add wall time information for to the result file (true, [false])
           --workingDir=<arg>              Specifies the working directory

setConnectionGeometry

oms_status_enu_t oms_setConnectionGeometry(const char* crefA, const char* crefB, const ssd_connection_geometry_t* geometry);

setConnectorGeometry

Set geometry information to a given connector.

oms_status_enu_t oms_setConnectorGeometry(const char* cref, const ssd_connector_geometry_t* geometry);

setElementGeometry

Set geometry information to a given component.

oms_status_enu_t oms_setElementGeometry(const char* cref, const ssd_element_geometry_t* geometry);

setFixedStepSize

Sets the fixed step size. Can be used for the communication step size of co-simulation systems and also for the integrator step size in model exchange systems.

oms_status_enu_t oms_setFixedStepSize(const char* cref, double stepSize);

setInteger

Sets the value of a given integer signal.

oms_status_enu_t oms_setInteger(const char* cref, int value);

setLogFile

Redirects logging output to file or std streams. The warning/error counters are reset.

filename="" to redirect to std streams and proper filename to redirect to file.

oms_status_enu_t oms_setLogFile(const char* filename);

setLoggingCallback

Sets a callback function for the logging system.

void oms_setLoggingCallback(void (*cb)(oms_message_type_enu_t type, const char* message));

setLoggingInterval

Set the logging interval of the simulation.

oms_status_enu_t oms_setLoggingInterval(const char* cref, double loggingInterval);

setLoggingLevel

Enables/Disables debug logging (logDebug and logTrace).

0 default, 1 default+debug, 2 default+debug+trace

void oms_setLoggingLevel(int logLevel);

setMaxLogFileSize

Sets maximum log file size in MB. If the file exceeds this limit, the logging will continue on stdout.

void oms_setMaxLogFileSize(const unsigned long size);

setReal

Sets the value of a given real signal.

oms_status_enu_t oms_setReal(const char* cref, double value);

This function can be called in different model states:

  • Before instantiation: setReal can be used to set start values or to define initial unknowns (e.g. parameters, states). The values are not immediately applied to the simulation unit, since it isn’t actually instantiated.

  • After instantiation and before initialization: Same as before instantiation, but the values are applied immediately to the simulation unit.

  • After initialization: Can be used to force external inputs, which might cause discrete changes of continuous signals.

setRealInputDerivative

Sets the first order derivative of a real input signal.

This can only be used for CS-FMU real input signals.

oms_status_enu_t oms_setRealInputDerivative(const char* cref, double value);

setResultFile

Set the result file of the simulation.

oms_status_enu_t oms_setResultFile(const char* cref, const char* filename, int bufferSize);

The creation of a result file is omitted if the filename is an empty string.

setSignalFilter

This function specifies the signal filter. The signal filter is used to determine which signals will eventually be exported to the result file.

oms_status_enu_t oms_setSignalFilter(const char* cref, const char* regex);

The second argument, i.e. regex, is a regular expression (C++11). ".*" and "(.)*" can be used to hit all variables.

setSolver

Sets the solver method for the given system.

oms_status_enu_t oms_setSolver(const char* cref, oms_solver_enu_t solver);

setStartTime

Set the start time of the simulation.

oms_status_enu_t oms_setStartTime(const char* cref, double startTime);

setStopTime

Set the stop time of the simulation.

oms_status_enu_t oms_setStopTime(const char* cref, double stopTime);

setTLMBusGeometry

oms_status_enu_t oms_setTLMBusGeometry(const char* bus, const ssd_connector_geometry_t* geometry);

setTLMConnectionParameters

Simulates a composite model in its own thread.

oms_status_enu_t oms_setTLMConnectionParameters(const char* crefA, const char* crefB, const oms_tlm_connection_parameters_t* parameters);

setTLMPositionAndOrientation

Sets initial position and orientation for a TLM 3D interface.

oms_status_enu_t oms_setTLMPositionAndOrientation(cref, x1, x2, x3, A11, A12, A13, A21, A22, A23, A31, A32, A33);

setTLMSocketData

Sets data for TLM socket communication.

oms_status_enu_t oms_setTLMSocketData(const char* cref, const char* address, int managerPort, int monitorPort);

setTempDirectory

Set new temp directory.

oms_status_enu_t oms_setTempDirectory(const char* newTempDir);

setTolerance

Sets the tolerance for a given model or system.

oms_status_enu_t oms_setTolerance(const char* cref, double absoluteTolerance, double relativeTolerance);

Default values are 1e-4 for both relative and absolute tolerances.

A tolerance specified for a model is automatically applied to its root system, i.e. both calls do exactly the same:

oms_setTolerance("model", absoluteTolerance, relativeTolerance);
oms_setTolerance("model.root", absoluteTolerance, relativeTolerance);

Component, e.g. FMUs, pick up the tolerances from there system. That means it is not possible to define different tolerances for FMUs in the same system right now.

In a strongly coupled system (oms_system_sc), the relative tolerance is used for CVODE and the absolute tolerance is used to solve algebraic loops.

In a weakly coupled system (oms_system_wc), both the relative and absolute tolerances are used for the adaptive step master algorithms and the absolute tolerance is used to solve algebraic loops.

setVariableStepSize

Sets the step size parameters for methods with stepsize control.

oms_status_enu_t oms_getVariableStepSize(const char* cref, double* initialStepSize, double* minimumStepSize, double* maximumStepSize);

setWorkingDirectory

Set a new working directory.

oms_status_enu_t oms_setWorkingDirectory(const char* newWorkingDir);

simulate

Simulates a composite model.

oms_status_enu_t oms_simulate(const char* cref);

simulate_realtime

Experimental feature for (soft) real-time simulation.

oms_status_enu_t experimental_simulate_realtime(const char* ident);

stepUntil

Simulates a composite model until a given time value.

oms_status_enu_t oms_stepUntil(const char* cref, double stopTime);

terminate

Terminates a given composite model.

oms_status_enu_t oms_terminate(const char* cref);

OMSimulatorLua

This is a shared library that provides a Lua interface for the OMSimulatorLib library.

oms_setTempDirectory("./temp/")
oms_newModel("model")
oms_addSystem("model.root", oms_system_sc)

-- instantiate FMUs
oms_addSubModel("model.root.system1", "FMUs/System1.fmu")
oms_addSubModel("model.root.system2", "FMUs/System2.fmu")

-- add connections
oms_addConnection("model.root.system1.y", "model.root.system2.u")
oms_addConnection("model.root.system2.y", "model.root.system1.u")

-- simulation settings
oms_setResultFile("model", "results.mat")
oms_setStopTime("model", 0.1)
oms_setFixedStepSize("model.root", 1e-4)

oms_instantiate("model")
oms_setReal("model.root.system1.x_start", 2.5)

oms_initialize("model")
oms_simulate("model")
oms_terminate("model")
oms_delete("model")

RunFile

Simulates a single FMU or SSP model.

# not available

addBus

Adds a bus to a given component.

status = oms_addBus(cref)

addConnection

Adds a new connection between connectors A and B. The connectors need to be specified as fully qualified component references, e.g., "model.system.component.signal".

status = oms_addConnection(crefA, crefB)

The two arguments crefA and crefB get swapped automatically if necessary.

addConnector

Adds a connector to a given component.

status = oms_addConnector(cref, causality, type)

The second argument "causality", should be any of the following,

oms_causality_input
oms_causality_output
oms_causality_parameter
oms_causality_bidir
oms_causality_undefined

The third argument "type", should be any of the following,

oms_signal_type_real
oms_signal_type_integer
oms_signal_type_boolean
oms_signal_type_string
oms_signal_type_enum
oms_signal_type_bus

addConnectorToBus

Adds a connector to a bus.

status = oms_addConnectorToBus(busCref, connectorCref)

addConnectorToTLMBus

Adds a connector to a TLM bus.

status = oms_addConnectorToTLMBus(busCref, connectorCref, type)

addExternalModel

Adds an external model to a TLM system.

status = oms_addExternalModel(cref, path, startscript)

addSignalsToResults

[deprecated: setSignalFilter is the recommended API]

Add all variables that match the given regex to the result file.

status = oms_addSignalsToResults(cref, regex)

The second argument, i.e. regex, is considered as a regular expression (C++11). ".*" and "(.)*" can be used to hit all variables.

addSubModel

Adds a component to a system.

status = oms_addSubModel(cref, fmuPath)

addSystem

Adds a (sub-)system to a model or system.

status = oms_addSystem(cref, type)

addTLMBus

Adds a TLM bus.

status = oms_addTLMBus(cref, domain, dimensions, interpolation)

The second argument "domain", should be any of the following,

oms_tlm_domain_input
oms_tlm_domain_output
oms_tlm_domain_mechanical
oms_tlm_domain_rotational
oms_tlm_domain_hydraulic
oms_tlm_domain_electric

The fourth argument "interpolation", should be any of the following,

oms_tlm_no_interpolation
oms_tlm_coarse_grained
oms_tlm_fine_grained

addTLMConnection

Connects two TLM connectors.

status = oms_addTLMConnection(crefA, crefB, delay, alpha, linearimpedance, angularimpedance)

compareSimulationResults

This function compares a given signal of two result files within absolute and relative tolerances.

oms_compareSimulationResults(filenameA, filenameB, var, relTol, absTol)

The following table describes the input values:

Input

Type

Description

filenameA

String

Name of first result file to compare.

filenameB

String

Name of second result file to compare.

var

String

Name of signal to compare.

relTol

Number

Relative tolerance.

absTol

Number

Absolute tolerance.

The following table describes the return values:

Type

Description

Integer

1 if the signal is considered as equal, 0 otherwise

copySystem

Copies a system.

status = oms_copySystem(source, target)

delete

Deletes a connector, component, system, or model object.

status = oms_delete(cref)

deleteConnection

Deletes the connection between connectors crefA and crefB.

status = oms_deleteConnection(crefA, crefB)

The two arguments crefA and crefB get swapped automatically if necessary.

deleteConnectorFromBus

Deletes a connector from a given bus.

status = oms_deleteConnectorFromBus(busCref, connectorCref)

deleteConnectorFromTLMBus

Deletes a connector from a given TLM bus.

status = oms_deleteConnectorFromTLMBus(busCref, connectorCref)

doStep

Simulates a macro step of the given composite model. The step size will be determined by the master algorithm and is limited by the definied minimal and maximal step sizes.

-- not available

export

Exports a composite model to a SPP file.

status = oms_export(cref, filename)

exportDependencyGraphs

Export the dependency graphs of a given model to dot files.

status = oms_exportDependencyGraphs(cref, initialization, event, simulation)

exportSSMTemplate

Exports all signals that have start values of one or multiple FMUs to a SSM file that are read from modelDescription.xml with a mapping entry. The mapping entry specifies a single mapping between a parameter in the source and a parameter of the system or component being parameterized. The mapping entry contains two attributes namely source and target. The source attribute will be empty and needs to be manually mapped by the users associated with the parameter name defined in the SSV file, the target contains the name of parameter in the system or component to be parameterized. The function can be called for a top level model or a certain FMU component. If called for a top level model, start values of all FMUs are exported to the SSM file. If called for a component, start values of just this FMU are exported to the SSM file.

status = oms_exportSSMTemplate(cref, filename)

exportSSVTemplate

Exports all signals that have start values of one or multiple FMUs to a SSV file that are read from modelDescription.xml. The function can be called for a top level model or a certain FMU component. If called for a top level model, start values of all FMUs are exported to the SSV file. If called for a component, start values of just this FMU are exported to the SSV file.

status = oms_exportSSVTemplate(cref, filename)

exportSnapshot

Lists the SSD representation of a given model, system, or component.

Memory is allocated for contents. The caller is responsible to free it using the C-API. The Lua and Python bindings take care of the memory and the caller doesn't need to call free.

contents, status = oms_exportSnapshot(cref)

extractFMIKind

Extracts the FMI kind of a given FMU from the file system.

# not available

faultInjection

Defines a new fault injection block.

status = oms_faultInjection(cref, type, value)

type

Description"

oms_fault_type_bias

y = y.$original + faultValue

oms_fault_type_gain

y = y.$original * faultValue

oms_fault_type_const

y = faultValue

freeMemory

Free the memory allocated by some other API. Pass the object for which memory is allocated.

This function is neither needed nor available from the Lua interface.

getBoolean

Get boolean value of given signal.

value, status = oms_getBoolean(cref)

getBus

Gets the bus object.

# not available

getComponentType

Gets the type of the given component.

# not available

getConnections

Get list of all connections from a given component.

# not available

getConnector

Gets the connector object of the given connector cref.

# not available

getElement

Get element information of a given component reference.

# not available

getElements

Get list of all sub-components of a given component reference.

# not available

getFMUInfo

Returns FMU specific information.

# not available

getFixedStepSize

Gets the fixed step size. Can be used for the communication step size of co-simulation systems and also for the integrator step size in model exchange systems.

stepSize, status = oms_setFixedStepSize(cref)

getInteger

Get integer value of given signal.

value, status = oms_getInteger(cref)

getModelState

Gets the model state of the given model cref.

modelState, status = oms_getModelState(cref)

getReal

Get real value.

value, status = oms_getReal(cref)

getResultFile

Gets the result filename and buffer size of the given model cref.

# not available

getSignalFilter

Gets the signal filter of the given model cref.

# not available

getSolver

Gets the selected solver method of the given system.

solver, status = oms_getSolver(cref)

getStartTime

Get the start time from the model.

startTime, status = oms_getStartTime(cref)

getStopTime

Get the stop time from the model.

stopTime, status = oms_getStopTime(cref)

getSubModelPath

Returns the path of a given component.

# not available

getSystemType

Gets the type of the given system.

type, status = oms_getSystemType(cref)

getTLMBus

Gets the TLM bus objects of the given TLM bus cref.

# not available

getTLMVariableTypes

Gets the type of an TLM variable.

# not available

getTime

Get the current simulation time from the model.

time, status = oms_getTime(cref)

getTolerance

Gets the tolerance of a given system or component.

absoluteTolerance, relativeTolerance, status = oms_getTolerance(cref)

getVariableStepSize

Gets the step size parameters.

initialStepSize, minimumStepSize, maximumStepSize, status = oms_getVariableStepSize(cref)

getVersion

Returns the library's version string.

version = oms_getVersion()

importFile

Imports a composite model from a SSP file.

cref, status = oms_importFile(filename)

importSnapshot

Loads a snapshot to restore a previous model state. The model must be in virgin model state, which means it must not be instantiated.

newCref, status = oms_importSnapshot(cref, snapshot)

initialize

Initializes a composite model.

status = oms_initialize(cref)

instantiate

Instantiates a given composite model.

status = oms_instantiate(cref)

list

Lists the SSD representation of a given model, system, or component.

Memory is allocated for contents. The caller is responsible to free it using the C-API. The Lua and Python bindings take care of the memory and the caller doesn't need to call free.

contents, status = oms_list(cref)

listUnconnectedConnectors

Lists all unconnected connectors of a given system.

Memory is allocated for contents. The caller is responsible to free it using the C-API. The Lua and Python bindings take care of the memory and the caller doesn't need to call free.

contents, status = oms_listUnconnectedConnectors(cref)

loadSnapshot

Loads a snapshot to restore a previous model state. The model must be in virgin model state, which means it must not be instantiated.

newCref, status = oms_loadSnapshot(cref, snapshot)

newModel

Creates a new and yet empty composite model.

status = oms_newModel(cref)

removeSignalsFromResults

[deprecated: setSignalFilter is the recommended API]

Removes all variables that match the given regex to the result file.

status = oms_removeSignalsFromResults(cref, regex)

The second argument, i.e. regex, is considered as a regular expression (C++11). ".*" and "(.)*" can be used to hit all variables.

rename

Renames a model, system, or component.

status = oms_rename(cref, newCref)

reset

Reset the composite model after a simulation run.

The FMUs go into the same state as after instantiation.

status = oms_reset(cref)

setActivationRatio

Experimental feature for setting the activation ratio of FMUs for experimenting with multi-rate master algorithms.

status = experimental_setActivationRatio(cref, k)

setBoolean

Sets the value of a given boolean signal.

status = oms_setBoolean(cref, value)

setBusGeometry

# not available

setCommandLineOption

Sets special flags.

status = oms_setCommandLineOption(cmd)

Available flags:

info:    Usage: OMSimulator [Options] [Lua script] [FMU] [SSP file]
         Options:
           --addParametersToCSV=<arg>      Export parameters to .csv file (true, [false])
           --algLoopSolver=<arg>           Specifies the alg. loop solver method ([fixedpoint], kinsol) used for algebraic loops spanning over multiple components.
           --clearAllOptions               Reset all flags to default values
           --deleteTempFiles=<bool>        Deletes temp files as soon as they are no longer needed ([true], false)
           --emitEvents=<bool>             Specifies whether events should be emitted or not ([true], false)
           --exportParametersInline=<arg>  Export ParameterBindings inline with .ssd file, 
           --fetchAllVars=<arg>            Workaround for certain FMUs that do not update all internal dependencies automatically
           --help [-h]                     Displays the help text
           --ignoreInitialUnknowns=<bool>  Ignore the initial unknowns from the modelDescription.xml (true, [false])
           --inputExtrapolation=<bool>     Enables input extrapolation using derivative information (true, [false])
           --intervals=<int> [-i]          Specifies the number of communication points (arg > 1)
           --logFile=<arg> [-l]            Specifies the logfile (stdout is used if no log file is specified)
           --logLevel=<int>                0 default, 1 debug, 2 debug+trace
           --maxEventIteration=<int>       Specifies the max. number of iterations for handling a single event
           --maxLoopIteration=<int>        Specifies the max. number of iterations for solving algebraic loops between system-level components. Internal algebraic loops of components are not affected.
           --mode=<arg> [-m]               Forces a certain FMI mode iff the FMU provides cs and me (cs, [me])
           --numProcs=<int> [-n]           Specifies the max. number of processors to use (0=auto, 1=default)
           --progressBar=<bool>            Shows a progress bar for the simulation progress in the terminal (true, [false])
           --realTime=<bool>               Experimental feature for (soft) real-time co-simulation (true, [false])
           --resultFile=<arg> [-r]         Specifies the name of the output result file
           --setInputDerivatives=<bool>    Deprecated; see '--inputExtrapolation'
           --skipCSVHeader=<arg>           Skip exporting the scv delimiter in the header (true, [false]), 
           --solver=<arg>                  Specifies the integration method (euler, [cvode])
           --solverStats=<bool>            Adds solver stats to the result file, e.g. step size; not supported for all solvers (true, [false])
           --startTime=<double> [-s]       Specifies the start time
           --stopTime=<double> [-t]        Specifies the stop time
           --stripRoot=<bool>              Removes the root system prefix from all exported signals (true, [false])
           --suppressPath=<bool>           Supresses path information in info messages; especially useful for testing (true, [false])
           --tempDir=<arg>                 Specifies the temp directory
           --timeout=<int>                 Specifies the maximum allowed time in seconds for running a simulation (0 disables)
           --tolerance=<double>            Specifies the relative tolerance
           --version [-v]                  Displays version information
           --wallTime=<bool>               Add wall time information for to the result file (true, [false])
           --workingDir=<arg>              Specifies the working directory

setConnectionGeometry

# not available

setConnectorGeometry

Set geometry information to a given connector.

# not available

setElementGeometry

Set geometry information to a given component.

# not available

setFixedStepSize

Sets the fixed step size. Can be used for the communication step size of co-simulation systems and also for the integrator step size in model exchange systems.

status = oms_setFixedStepSize(cref, stepSize)

setInteger

Sets the value of a given integer signal.

status = oms_setInteger(cref, value)

setLogFile

Redirects logging output to file or std streams. The warning/error counters are reset.

filename="" to redirect to std streams and proper filename to redirect to file.

status = oms_setLogFile(filename)

setLoggingCallback

Sets a callback function for the logging system.

# not available

setLoggingInterval

Set the logging interval of the simulation.

status = oms_setLoggingInterval(cref, loggingInterval)

setLoggingLevel

Enables/Disables debug logging (logDebug and logTrace).

0 default, 1 default+debug, 2 default+debug+trace

oms_setLoggingLevel(logLevel)

setMaxLogFileSize

Sets maximum log file size in MB. If the file exceeds this limit, the logging will continue on stdout.

oms_setMaxLogFileSize(size)

setReal

Sets the value of a given real signal.

status = oms_setReal(cref, value)

This function can be called in different model states:

  • Before instantiation: setReal can be used to set start values or to define initial unknowns (e.g. parameters, states). The values are not immediately applied to the simulation unit, since it isn’t actually instantiated.

  • After instantiation and before initialization: Same as before instantiation, but the values are applied immediately to the simulation unit.

  • After initialization: Can be used to force external inputs, which might cause discrete changes of continuous signals.

setRealInputDerivative

Sets the first order derivative of a real input signal.

This can only be used for CS-FMU real input signals.

status = oms_setRealInputDerivative(cref, value)

setResultFile

Set the result file of the simulation.

status = oms_setResultFile(cref, filename)
status = oms_setResultFile(cref, filename, bufferSize)

The creation of a result file is omitted if the filename is an empty string.

setSignalFilter

This function specifies the signal filter. The signal filter is used to determine which signals will eventually be exported to the result file.

status = oms_setSignalFilter(cref, regex)

The second argument, i.e. regex, is a regular expression (C++11). ".*" and "(.)*" can be used to hit all variables.

setSolver

Sets the solver method for the given system.

status = oms_setSolver(cref, solver)

solver

Type

Description

oms_solver_sc_explicit_euler

sc-system

Explicit euler with fixed step size

oms_solver_sc_cvode

sc-system

CVODE with adaptive stepsize

oms_solver_wc_ma

wc-system

default master algorithm with fixed step size

oms_solver_wc_mav

wc-system

master algorithm with adaptive stepsize

oms_solver_wc_mav2

wc-system

master algorithm with adaptive stepsize (double-step)

setStartTime

Set the start time of the simulation.

status = oms_setStartTime(cref, startTime)

setStopTime

Set the stop time of the simulation.

status = oms_setStopTime(cref, stopTime)

setTLMBusGeometry

# not available

setTLMConnectionParameters

Simulates a composite model in its own thread.

# not available

setTLMPositionAndOrientation

Sets initial position and orientation for a TLM 3D interface.

status = oms_setTLMPositionAndOrientation(cref, x1, x2, x3, A11, A12, A13, A21, A22, A23, A31, A32, A33)

setTLMSocketData

Sets data for TLM socket communication.

status = oms_setTLMSocketData(cref, address, managerPort, monitorPort)

setTempDirectory

Set new temp directory.

status = oms_setTempDirectory(newTempDir)

setTolerance

Sets the tolerance for a given model or system.

status = oms_setTolerance(const char* cref, double tolerance)
status = oms_setTolerance(const char* cref, double absoluteTolerance, double relativeTolerance)

Default values are 1e-4 for both relative and absolute tolerances.

A tolerance specified for a model is automatically applied to its root system, i.e. both calls do exactly the same:

oms_setTolerance("model", absoluteTolerance, relativeTolerance);
oms_setTolerance("model.root", absoluteTolerance, relativeTolerance);

Component, e.g. FMUs, pick up the tolerances from there system. That means it is not possible to define different tolerances for FMUs in the same system right now.

In a strongly coupled system (oms_system_sc), the relative tolerance is used for CVODE and the absolute tolerance is used to solve algebraic loops.

In a weakly coupled system (oms_system_wc), both the relative and absolute tolerances are used for the adaptive step master algorithms and the absolute tolerance is used to solve algebraic loops.

setVariableStepSize

Sets the step size parameters for methods with stepsize control.

status = oms_getVariableStepSize(cref, initialStepSize, minimumStepSize, maximumStepSize)

setWorkingDirectory

Set a new working directory.

status = oms_setWorkingDirectory(newWorkingDir)

simulate

Simulates a composite model.

status = oms_simulate(cref)

simulate_realtime

Experimental feature for (soft) real-time simulation.

status = experimental_simulate_realtime(ident)

stepUntil

Simulates a composite model until a given time value.

status = oms_stepUntil(cref, stopTime)

terminate

Terminates a given composite model.

status = oms_terminate(cref)

OMSimulatorPython

This is a shared library that provides a Python interface for the OMSimulatorLib library.

from OMSimulator import OMSimulator

oms = OMSimulator()
oms.setTempDirectory("./temp/")
oms.newModel("model")
oms.addSystem("model.root", oms.system_sc)

# instantiate FMUs
oms.addSubModel("model.root.system1", "FMUs/System1.fmu")
oms.addSubModel("model.root.system2", "FMUs/System2.fmu")

# add connections
oms.addConnection("model.root.system1.y", "model.root.system2.u")
oms.addConnection("model.root.system2.y", "model.root.system1.u")

# simulation settings
oms.setResultFile("model", "results.mat")
oms.setStopTime("model", 0.1)
oms.setFixedStepSize("model.root", 1e-4)

oms.instantiate("model")
oms.setReal("model.root.system1.x_start", 2.5)

oms.initialize("model")
oms.simulate("model")
oms.terminate("model")
oms.delete("model")

RunFile

Simulates a single FMU or SSP model.

# not available

addBus

Adds a bus to a given component.

status = oms.addBus(cref)

addConnection

Adds a new connection between connectors A and B. The connectors need to be specified as fully qualified component references, e.g., "model.system.component.signal".

status = oms.addConnection(crefA, crefB)

The two arguments crefA and crefB get swapped automatically if necessary.

addConnector

Adds a connector to a given component.

status = oms.addConnector(cref, causality, type)

The second argument "causality", should be any of the following,

oms.input
oms.output
oms.parameter
oms.bidir
oms.undefined

The third argument "type", should be any of the following,

oms.signal_type_real
oms.signal_type_integer
oms.signal_type_boolean
oms.signal_type_string
oms.signal_type_enum
oms.signal_type_bus

addConnectorToBus

Adds a connector to a bus.

status = oms.addConnectorToBus(busCref, connectorCref)

addConnectorToTLMBus

Adds a connector to a TLM bus.

status = oms.addConnectorToTLMBus(busCref, connectorCref, type)

addExternalModel

Adds an external model to a TLM system.

status = oms.addExternalModel(cref, path, startscript)

addSignalsToResults

[deprecated: setSignalFilter is the recommended API]

Add all variables that match the given regex to the result file.

status = oms.addSignalsToResults(cref, regex)

The second argument, i.e. regex, is considered as a regular expression (C++11). ".*" and "(.)*" can be used to hit all variables.

addSubModel

Adds a component to a system.

status = oms.addSubModel(cref, fmuPath)

addSystem

Adds a (sub-)system to a model or system.

status = oms.addSystem(cref, type)

addTLMBus

Adds a TLM bus.

status = oms.addTLMBus(cref, domain, dimensions, interpolation)

The second argument "domain", should be any of the following,

oms.tlm_domain_input
oms.tlm_domain_output
oms.tlm_domain_mechanical
oms.tlm_domain_rotational
oms.tlm_domain_hydraulic
oms.tlm_domain_electric

The fourth argument "interpolation", should be any of the following,

oms.default
oms.coarsegrained
oms.finegrained

addTLMConnection

Connects two TLM connectors.

status = oms.addTLMConnection(crefA, crefB, delay, alpha, linearimpedance, angularimpedance)

compareSimulationResults

This function compares a given signal of two result files within absolute and relative tolerances.

oms.compareSimulationResults(filenameA, filenameB, var, relTol, absTol)

The following table describes the input values:

Input

Type

Description

filenameA

String

Name of first result file to compare.

filenameB

String

Name of second result file to compare.

var

String

Name of signal to compare.

relTol

Number

Relative tolerance.

absTol

Number

Absolute tolerance.

The following table describes the return values:

Type

Description

Integer

1 if the signal is considered as equal, 0 otherwise

copySystem

Copies a system.

status = oms.copySystem(source, target)

delete

Deletes a connector, component, system, or model object.

status = oms.delete(cref)

deleteConnection

Deletes the connection between connectors crefA and crefB.

status = oms.deleteConnection(crefA, crefB)

The two arguments crefA and crefB get swapped automatically if necessary.

deleteConnectorFromBus

Deletes a connector from a given bus.

status = oms.deleteConnectorFromBus(busCref, connectorCref)

deleteConnectorFromTLMBus

Deletes a connector from a given TLM bus.

status = oms.deleteConnectorFromTLMBus(busCref, connectorCref)

doStep

Simulates a macro step of the given composite model. The step size will be determined by the master algorithm and is limited by the definied minimal and maximal step sizes.

status = oms.doStep(cref)

export

Exports a composite model to a SPP file.

status = oms.export(cref, filename)

exportDependencyGraphs

Export the dependency graphs of a given model to dot files.

status = oms.exportDependencyGraphs(cref, initialization, event, simulation)

exportSSMTemplate

Exports all signals that have start values of one or multiple FMUs to a SSM file that are read from modelDescription.xml with a mapping entry. The mapping entry specifies a single mapping between a parameter in the source and a parameter of the system or component being parameterized. The mapping entry contains two attributes namely source and target. The source attribute will be empty and needs to be manually mapped by the users associated with the parameter name defined in the SSV file, the target contains the name of parameter in the system or component to be parameterized. The function can be called for a top level model or a certain FMU component. If called for a top level model, start values of all FMUs are exported to the SSM file. If called for a component, start values of just this FMU are exported to the SSM file.

status = oms.exportSSMTemplate(cref, filename)

exportSSVTemplate

Exports all signals that have start values of one or multiple FMUs to a SSV file that are read from modelDescription.xml. The function can be called for a top level model or a certain FMU component. If called for a top level model, start values of all FMUs are exported to the SSV file. If called for a component, start values of just this FMU are exported to the SSV file.

status = oms.exportSSVTemplate(cref, filename)

exportSnapshot

Lists the SSD representation of a given model, system, or component.

Memory is allocated for contents. The caller is responsible to free it using the C-API. The Lua and Python bindings take care of the memory and the caller doesn't need to call free.

contents, status = oms.exportSnapshot(cref)

extractFMIKind

Extracts the FMI kind of a given FMU from the file system.

# not available

faultInjection

Defines a new fault injection block.

status = oms.faultInjection(cref, type, value)

type

Description"

oms_fault_type_bias

y = y.$original + faultValue

oms_fault_type_gain

y = y.$original * faultValue

oms_fault_type_const

y = faultValue

freeMemory

Free the memory allocated by some other API. Pass the object for which memory is allocated.

oms.freeMemory(obj)

getBoolean

Get boolean value of given signal.

value, status = oms.getBoolean(cref)

getBus

Gets the bus object.

# not available

getComponentType

Gets the type of the given component.

# not available

getConnections

Get list of all connections from a given component.

# not available

getConnector

Gets the connector object of the given connector cref.

# not available

getElement

Get element information of a given component reference.

# not available

getElements

Get list of all sub-components of a given component reference.

# not available

getFMUInfo

Returns FMU specific information.

# not available

getFixedStepSize

Gets the fixed step size. Can be used for the communication step size of co-simulation systems and also for the integrator step size in model exchange systems.

stepSize, status = oms.getFixedStepSize(cref)

getInteger

Get integer value of given signal.

value, status = oms.getInteger(cref)

getModelState

Gets the model state of the given model cref.

# not available

getReal

Get real value.

value, status = oms.getReal(cref)

getResultFile

Gets the result filename and buffer size of the given model cref.

filename, bufferSize, status = oms.getResultFile(cref)

getSignalFilter

Gets the signal filter of the given model cref.

# not available

getSolver

Gets the selected solver method of the given system.

solver, status = oms.getSolver(cref)

getStartTime

Get the start time from the model.

startTime, status = oms.getStartTime(cref)

getStopTime

Get the stop time from the model.

stopTime, status = oms.getStopTime(cref)

getSubModelPath

Returns the path of a given component.

path, status = oms.getSubModelPath(cref)

getSystemType

Gets the type of the given system.

type, status = oms.getSystemType(cref)

getTLMBus

Gets the TLM bus objects of the given TLM bus cref.

# not available

getTLMVariableTypes

Gets the type of an TLM variable.

# not available

getTime

Get the current simulation time from the model.

time, status = oms.getTime(cref)

getTolerance

Gets the tolerance of a given system or component.

absoluteTolerance, relativeTolerance, status = oms.getTolerance(cref)

getVariableStepSize

Gets the step size parameters.

initialStepSize, minimumStepSize, maximumStepSize, status = oms.getVariableStepSize(cref)

getVersion

Returns the library's version string.

oms = OMSimulator()
oms.getVersion()

importFile

Imports a composite model from a SSP file.

cref, status = oms.importFile(filename)

importSnapshot

Loads a snapshot to restore a previous model state. The model must be in virgin model state, which means it must not be instantiated.

newCref, status = oms.importSnapshot(cref, snapshot)

initialize

Initializes a composite model.

status = oms.initialize(cref)

instantiate

Instantiates a given composite model.

status = oms.instantiate(cref)

list

Lists the SSD representation of a given model, system, or component.

Memory is allocated for contents. The caller is responsible to free it using the C-API. The Lua and Python bindings take care of the memory and the caller doesn't need to call free.

contents, status = oms.list(cref)

listUnconnectedConnectors

Lists all unconnected connectors of a given system.

Memory is allocated for contents. The caller is responsible to free it using the C-API. The Lua and Python bindings take care of the memory and the caller doesn't need to call free.

contents, status = oms.listUnconnectedConnectors(cref)

loadSnapshot

Loads a snapshot to restore a previous model state. The model must be in virgin model state, which means it must not be instantiated.

newCref, status = oms.loadSnapshot(cref, snapshot)

newModel

Creates a new and yet empty composite model.

status = oms.newModel(cref)

removeSignalsFromResults

[deprecated: setSignalFilter is the recommended API]

Removes all variables that match the given regex to the result file.

status = oms.removeSignalsFromResults(cref, regex)

The second argument, i.e. regex, is considered as a regular expression (C++11). ".*" and "(.)*" can be used to hit all variables.

rename

Renames a model, system, or component.

status = oms.rename(cref, newCref)

reset

Reset the composite model after a simulation run.

The FMUs go into the same state as after instantiation.

status = oms.reset(cref)

setActivationRatio

Experimental feature for setting the activation ratio of FMUs for experimenting with multi-rate master algorithms.

# not yet available

setBoolean

Sets the value of a given boolean signal.

status = oms.setBoolean(cref, value)

setBusGeometry

# not available

setCommandLineOption

Sets special flags.

status = oms.setCommandLineOption(cmd)

Available flags:

info:    Usage: OMSimulator [Options] [Lua script] [FMU] [SSP file]
         Options:
           --addParametersToCSV=<arg>      Export parameters to .csv file (true, [false])
           --algLoopSolver=<arg>           Specifies the alg. loop solver method ([fixedpoint], kinsol) used for algebraic loops spanning over multiple components.
           --clearAllOptions               Reset all flags to default values
           --deleteTempFiles=<bool>        Deletes temp files as soon as they are no longer needed ([true], false)
           --emitEvents=<bool>             Specifies whether events should be emitted or not ([true], false)
           --exportParametersInline=<arg>  Export ParameterBindings inline with .ssd file, 
           --fetchAllVars=<arg>            Workaround for certain FMUs that do not update all internal dependencies automatically
           --help [-h]                     Displays the help text
           --ignoreInitialUnknowns=<bool>  Ignore the initial unknowns from the modelDescription.xml (true, [false])
           --inputExtrapolation=<bool>     Enables input extrapolation using derivative information (true, [false])
           --intervals=<int> [-i]          Specifies the number of communication points (arg > 1)
           --logFile=<arg> [-l]            Specifies the logfile (stdout is used if no log file is specified)
           --logLevel=<int>                0 default, 1 debug, 2 debug+trace
           --maxEventIteration=<int>       Specifies the max. number of iterations for handling a single event
           --maxLoopIteration=<int>        Specifies the max. number of iterations for solving algebraic loops between system-level components. Internal algebraic loops of components are not affected.
           --mode=<arg> [-m]               Forces a certain FMI mode iff the FMU provides cs and me (cs, [me])
           --numProcs=<int> [-n]           Specifies the max. number of processors to use (0=auto, 1=default)
           --progressBar=<bool>            Shows a progress bar for the simulation progress in the terminal (true, [false])
           --realTime=<bool>               Experimental feature for (soft) real-time co-simulation (true, [false])
           --resultFile=<arg> [-r]         Specifies the name of the output result file
           --setInputDerivatives=<bool>    Deprecated; see '--inputExtrapolation'
           --skipCSVHeader=<arg>           Skip exporting the scv delimiter in the header (true, [false]), 
           --solver=<arg>                  Specifies the integration method (euler, [cvode])
           --solverStats=<bool>            Adds solver stats to the result file, e.g. step size; not supported for all solvers (true, [false])
           --startTime=<double> [-s]       Specifies the start time
           --stopTime=<double> [-t]        Specifies the stop time
           --stripRoot=<bool>              Removes the root system prefix from all exported signals (true, [false])
           --suppressPath=<bool>           Supresses path information in info messages; especially useful for testing (true, [false])
           --tempDir=<arg>                 Specifies the temp directory
           --timeout=<int>                 Specifies the maximum allowed time in seconds for running a simulation (0 disables)
           --tolerance=<double>            Specifies the relative tolerance
           --version [-v]                  Displays version information
           --wallTime=<bool>               Add wall time information for to the result file (true, [false])
           --workingDir=<arg>              Specifies the working directory

setConnectionGeometry

# not available

setConnectorGeometry

Set geometry information to a given connector.

# not available

setElementGeometry

Set geometry information to a given component.

# not available

setFixedStepSize

Sets the fixed step size. Can be used for the communication step size of co-simulation systems and also for the integrator step size in model exchange systems.

status = oms.setFixedStepSize(cref, stepSize)

setInteger

Sets the value of a given integer signal.

status = oms.setInteger(cref, value)

setLogFile

Redirects logging output to file or std streams. The warning/error counters are reset.

filename="" to redirect to std streams and proper filename to redirect to file.

status = oms.setLogFile(filename)

setLoggingCallback

Sets a callback function for the logging system.

# not available

setLoggingInterval

Set the logging interval of the simulation.

status = oms.setLoggingInterval(cref, loggingInterval)

setLoggingLevel

Enables/Disables debug logging (logDebug and logTrace).

0 default, 1 default+debug, 2 default+debug+trace

oms.setLoggingLevel(logLevel)

setMaxLogFileSize

Sets maximum log file size in MB. If the file exceeds this limit, the logging will continue on stdout.

oms.setMaxLogFileSize(size)

setReal

Sets the value of a given real signal.

status = oms.setReal(cref, value)

This function can be called in different model states:

  • Before instantiation: setReal can be used to set start values or to define initial unknowns (e.g. parameters, states). The values are not immediately applied to the simulation unit, since it isn’t actually instantiated.

  • After instantiation and before initialization: Same as before instantiation, but the values are applied immediately to the simulation unit.

  • After initialization: Can be used to force external inputs, which might cause discrete changes of continuous signals.

setRealInputDerivative

Sets the first order derivative of a real input signal.

This can only be used for CS-FMU real input signals.

status = oms.setRealInputDerivative(cref, value)

setResultFile

Set the result file of the simulation.

status = oms.setResultFile(cref, filename)
status = oms.setResultFile(cref, filename, bufferSize)

The creation of a result file is omitted if the filename is an empty string.

setSignalFilter

This function specifies the signal filter. The signal filter is used to determine which signals will eventually be exported to the result file.

status = oms.setSignalFilter(cref, regex)

The second argument, i.e. regex, is a regular expression (C++11). ".*" and "(.)*" can be used to hit all variables.

setSolver

Sets the solver method for the given system.

status = oms.setSolver(cref, solver)

solver

Type

Description

oms.solver_sc_explicit_euler

sc-system

Explicit euler with fixed step size

oms.solver_sc_cvode

sc-system

CVODE with adaptive stepsize

oms.solver_wc_ma

wc-system

default master algorithm with fixed step size

oms.solver_wc_mav

wc-system

master algorithm with adaptive stepsize

oms.solver_wc_mav2

wc-system

master algorithm with adaptive stepsize (double-step)

setStartTime

Set the start time of the simulation.

status = oms.setStartTime(cref, startTime)

setStopTime

Set the stop time of the simulation.

status = oms.setStopTime(cref, stopTime)

setTLMBusGeometry

# not available

setTLMConnectionParameters

Simulates a composite model in its own thread.

# not available

setTLMPositionAndOrientation

Sets initial position and orientation for a TLM 3D interface.

# not yet available

setTLMSocketData

Sets data for TLM socket communication.

# not yet available

setTempDirectory

Set new temp directory.

status = oms.setTempDirectory(newTempDir)

setTolerance

Sets the tolerance for a given model or system.

status = oms.setTolerance(const char* cref, double tolerance)
status = oms.setTolerance(const char* cref, double absoluteTolerance, double relativeTolerance)

Default values are 1e-4 for both relative and absolute tolerances.

A tolerance specified for a model is automatically applied to its root system, i.e. both calls do exactly the same:

oms_setTolerance("model", absoluteTolerance, relativeTolerance);
oms_setTolerance("model.root", absoluteTolerance, relativeTolerance);

Component, e.g. FMUs, pick up the tolerances from there system. That means it is not possible to define different tolerances for FMUs in the same system right now.

In a strongly coupled system (oms_system_sc), the relative tolerance is used for CVODE and the absolute tolerance is used to solve algebraic loops.

In a weakly coupled system (oms_system_wc), both the relative and absolute tolerances are used for the adaptive step master algorithms and the absolute tolerance is used to solve algebraic loops.

setVariableStepSize

Sets the step size parameters for methods with stepsize control.

status = oms.getVariableStepSize(cref, initialStepSize, minimumStepSize, maximumStepSize)

setWorkingDirectory

Set a new working directory.

status = oms.setWorkingDirectory(newWorkingDir)

simulate

Simulates a composite model.

status = oms.simulate(cref)

simulate_realtime

Experimental feature for (soft) real-time simulation.

# not yet available

stepUntil

Simulates a composite model until a given time value.

status = oms.stepUntil(cref, stopTime)

terminate

Terminates a given composite model.

status = oms.terminate(cref)

OpenModelicaScripting

This is a shared library that provides a OpenModelica Scripting interface for the OMSimulatorLib library.

loadOMSimulator();
oms_setTempDirectory("./temp/");
oms_newModel("model");
oms_addSystem("model.root", OpenModelica.Scripting.oms_system.oms_system_sc);

// instantiate FMUs
oms_addSubModel("model.root.system1", "FMUs/System1.fmu");
oms_addSubModel("model.root.system2", "FMUs/System2.fmu");

// add connections
oms_addConnection("model.root.system1.y", "model.root.system2.u");
oms_addConnection("model.root.system2.y", "model.root.system1.u");

// simulation settings
oms_setResultFile("model", "results.mat");
oms_setStopTime("model", 0.1);
oms_setFixedStepSize("model.root", 1e-4);

oms_instantiate("model");
oms_setReal("model.root.system1.x_start", 2.5);

oms_initialize("model");
oms_simulate("model");
oms_terminate("model");
oms_delete("model");
unloadOMSimulator();

RunFile

Simulates a single FMU or SSP model.

# not available

addBus

Adds a bus to a given component.

status := oms_addBus(cref);

addConnection

Adds a new connection between connectors A and B. The connectors need to be specified as fully qualified component references, e.g., "model.system.component.signal".

status := oms_addConnection(crefA, crefB);

The two arguments crefA and crefB get swapped automatically if necessary.

addConnector

Adds a connector to a given component.

status := oms_addConnector(cref, causality, type);

The second argument "causality", should be any of the following,

"OpenModelica.Scripting.oms_causality.oms_causality_input"
"OpenModelica.Scripting.oms_causality.oms_causality_output"
"OpenModelica.Scripting.oms_causality.oms_causality_parameter"
"OpenModelica.Scripting.oms_causality.oms_causality_bidir"
"OpenModelica.Scripting.oms_causality.oms_causality_undefined"

The third argument type, should be any of the following,

"OpenModelica.Scripting.oms_signal_type.oms_signal_type_real"
"OpenModelica.Scripting.oms_signal_type.oms_signal_type_integer"
"OpenModelica.Scripting.oms_signal_type.oms_signal_type_boolean"
"OpenModelica.Scripting.oms_signal_type.oms_signal_type_string"
"OpenModelica.Scripting.oms_signal_type.oms_signal_type_enum"
"OpenModelica.Scripting.oms_signal_type.oms_signal_type_bus"

addConnectorToBus

Adds a connector to a bus.

status := oms_addConnectorToBus(busCref, connectorCref);

addConnectorToTLMBus

Adds a connector to a TLM bus.

status := oms_addConnectorToTLMBus(busCref, connectorCref, type);

addExternalModel

Adds an external model to a TLM system.

status := oms_addExternalModel(cref, path, startscript);

addSignalsToResults

[deprecated: setSignalFilter is the recommended API]

Add all variables that match the given regex to the result file.

status := oms_addSignalsToResults(cref, regex);

The second argument, i.e. regex, is considered as a regular expression (C++11). ".*" and "(.)*" can be used to hit all variables.

addSubModel

Adds a component to a system.

status := oms_addSubModel(cref, fmuPath);

addSystem

Adds a (sub-)system to a model or system.

status := oms_addSystem(cref, type);

The second argument type, should be any of the following,

"OpenModelica.Scripting.oms_system.oms_system_none"
"OpenModelica.Scripting.oms_system.oms_system_tlm"
"OpenModelica.Scripting.oms_system.oms_system_sc"
"OpenModelica.Scripting.oms_system.oms_system_wc"

addTLMBus

Adds a TLM bus.

status := oms_addTLMBus(cref, domain, dimensions, interpolation);

The second argument "domain", should be any of the following,

"OpenModelica.Scripting.oms_tlm_domain.oms_tlm_domain_input"
"OpenModelica.Scripting.oms_tlm_domain.oms_tlm_domain_output"
"OpenModelica.Scripting.oms_tlm_domain.oms_tlm_domain_mechanical"
"OpenModelica.Scripting.oms_tlm_domain.oms_tlm_domain_rotational"
"OpenModelica.Scripting.oms_tlm_domain.oms_tlm_domain_hydraulic"
"OpenModelica.Scripting.oms_tlm_domain.oms_tlm_domain_electric"

The fourth argument "interpolation", should be any of the following,

"OpenModelica.Scripting.oms_tlm_interpolation.oms_tlm_no_interpolation"
"OpenModelica.Scripting.oms_tlm_interpolation.oms_tlm_coarse_grained"
"OpenModelica.Scripting.oms_tlm_interpolation.oms_tlm_fine_grained"

addTLMConnection

Connects two TLM connectors.

status := oms_addTLMConnection(crefA, crefB, delay, alpha, linearimpedance, angularimpedance);

compareSimulationResults

This function compares a given signal of two result files within absolute and relative tolerances.

status := oms_compareSimulationResults(filenameA, filenameB, var, relTol, absTol);

The following table describes the input values:

Input

Type

Description

filenameA

String

Name of first result file to compare.

filenameB

String

Name of second result file to compare.

var

String

Name of signal to compare.

relTol

Number

Relative tolerance.

absTol

Number

Absolute tolerance.

The following table describes the return values:

Type

Description

Integer

1 if the signal is considered as equal, 0 otherwise

copySystem

Copies a system.

status := oms_copySystem(source, target);

delete

Deletes a connector, component, system, or model object.

status := oms_delete(cref);

deleteConnection

Deletes the connection between connectors crefA and crefB.

status := oms_deleteConnection(crefA, crefB);

The two arguments crefA and crefB get swapped automatically if necessary.

deleteConnectorFromBus

Deletes a connector from a given bus.

status := oms_deleteConnectorFromBus(busCref, connectorCref);

deleteConnectorFromTLMBus

Deletes a connector from a given TLM bus.

status := oms_deleteConnectorFromTLMBus(busCref, connectorCref);

doStep

Simulates a macro step of the given composite model. The step size will be determined by the master algorithm and is limited by the definied minimal and maximal step sizes.

// not available

export

Exports a composite model to a SPP file.

status := oms_export(cref, filename);

exportDependencyGraphs

Export the dependency graphs of a given model to dot files.

status := oms_exportDependencyGraphs(cref, initialization, event, simulation);

exportSSMTemplate

Exports all signals that have start values of one or multiple FMUs to a SSM file that are read from modelDescription.xml with a mapping entry. The mapping entry specifies a single mapping between a parameter in the source and a parameter of the system or component being parameterized. The mapping entry contains two attributes namely source and target. The source attribute will be empty and needs to be manually mapped by the users associated with the parameter name defined in the SSV file, the target contains the name of parameter in the system or component to be parameterized. The function can be called for a top level model or a certain FMU component. If called for a top level model, start values of all FMUs are exported to the SSM file. If called for a component, start values of just this FMU are exported to the SSM file.

# not available

exportSSVTemplate

Exports all signals that have start values of one or multiple FMUs to a SSV file that are read from modelDescription.xml. The function can be called for a top level model or a certain FMU component. If called for a top level model, start values of all FMUs are exported to the SSV file. If called for a component, start values of just this FMU are exported to the SSV file.

# not available

exportSnapshot

Lists the SSD representation of a given model, system, or component.

Memory is allocated for contents. The caller is responsible to free it using the C-API. The Lua and Python bindings take care of the memory and the caller doesn't need to call free.

(contents, status) := oms_exportSnapshot(cref);

extractFMIKind

Extracts the FMI kind of a given FMU from the file system.

(kind,status) := oms_extractFMIKind(filename);

faultInjection

Defines a new fault injection block.

status := oms_faultInjection(cref, type, value);
The second argument type, can be any of the following described below

"OpenModelica.Scripting.oms_fault_type.oms_fault_type_bias"
"OpenModelica.Scripting.oms_fault_type.oms_fault_type_gain"
"OpenModelica.Scripting.oms_fault_type.oms_fault_type_const"

type

Description"

oms_fault_type_bias

y = y.$original + faultValue

oms_fault_type_gain

y = y.$original * faultValue

oms_fault_type_const

y = faultValue

freeMemory

Free the memory allocated by some other API. Pass the object for which memory is allocated.

This function is not needed for OpenModelicaScripting Interface

getBoolean

Get boolean value of given signal.

(value, status) := oms_getBoolean(cref);

getBus

Gets the bus object.

# not available

getComponentType

Gets the type of the given component.

# not available

getConnections

Get list of all connections from a given component.

# not available

getConnector

Gets the connector object of the given connector cref.

# not available

getElement

Get element information of a given component reference.

# not available

getElements

Get list of all sub-components of a given component reference.

# not available

getFMUInfo

Returns FMU specific information.

# not available

getFixedStepSize

Gets the fixed step size. Can be used for the communication step size of co-simulation systems and also for the integrator step size in model exchange systems.

(stepSize, status) := oms_setFixedStepSize(cref);

getInteger

Get integer value of given signal.

(value, status) := oms_getInteger(cref);

getModelState

Gets the model state of the given model cref.

(modelState, status) := oms_getModelState(cref);

getReal

Get real value.

(value, status) := oms_getReal(cref);

getResultFile

Gets the result filename and buffer size of the given model cref.

# not available

getSignalFilter

Gets the signal filter of the given model cref.

# not available

getSolver

Gets the selected solver method of the given system.

(solver, status) := oms_getSolver(cref);

getStartTime

Get the start time from the model.

(startTime, status) := oms_getStartTime(cref);

getStopTime

Get the stop time from the model.

(stopTime, status) := oms_getStopTime(cref);

getSubModelPath

Returns the path of a given component.

(path, status) := oms_getSubModelPath(cref);

getSystemType

Gets the type of the given system.

(type, status) := oms_getSystemType(cref);

getTLMBus

Gets the TLM bus objects of the given TLM bus cref.

# not available

getTLMVariableTypes

Gets the type of an TLM variable.

# not available

getTime

Get the current simulation time from the model.

(time, status) := oms_getTime(cref);

getTolerance

Gets the tolerance of a given system or component.

(absoluteTolerance, relativeTolerance, status) := oms_getTolerance(cref);

getVariableStepSize

Gets the step size parameters.

(initialStepSize, minimumStepSize, maximumStepSize, status) := oms_getVariableStepSize(cref);

getVersion

Returns the library's version string.

version := oms_getVersion();

importFile

Imports a composite model from a SSP file.

(cref, status) := oms_importFile(filename);

importSnapshot

Loads a snapshot to restore a previous model state. The model must be in virgin model state, which means it must not be instantiated.

status := oms_importSnapshot(cref, snapshot);

initialize

Initializes a composite model.

status := oms_initialize(cref);

instantiate

Instantiates a given composite model.

status := oms_instantiate(cref);

list

Lists the SSD representation of a given model, system, or component.

Memory is allocated for contents. The caller is responsible to free it using the C-API. The Lua and Python bindings take care of the memory and the caller doesn't need to call free.

(contents, status) := oms_list(cref);

listUnconnectedConnectors

Lists all unconnected connectors of a given system.

Memory is allocated for contents. The caller is responsible to free it using the C-API. The Lua and Python bindings take care of the memory and the caller doesn't need to call free.

(contents, status) := oms_listUnconnectedConnectors(cref);

loadSnapshot

Loads a snapshot to restore a previous model state. The model must be in virgin model state, which means it must not be instantiated.

status := oms_loadSnapshot(cref, snapshot);

newModel

Creates a new and yet empty composite model.

status := oms_newModel(cref);

removeSignalsFromResults

[deprecated: setSignalFilter is the recommended API]

Removes all variables that match the given regex to the result file.

status := oms_removeSignalsFromResults(cref, regex);

The second argument, i.e. regex, is considered as a regular expression (C++11). ".*" and "(.)*" can be used to hit all variables.

rename

Renames a model, system, or component.

status := oms_rename(cref, newCref);

reset

Reset the composite model after a simulation run.

The FMUs go into the same state as after instantiation.

status := oms_reset(cref);

setActivationRatio

Experimental feature for setting the activation ratio of FMUs for experimenting with multi-rate master algorithms.

# not yet available

setBoolean

Sets the value of a given boolean signal.

status := oms_setBoolean(cref, value);

setBusGeometry

# not available

setCommandLineOption

Sets special flags.

status := oms_setCommandLineOption(cmd);

Available flags:

info:    Usage: OMSimulator [Options] [Lua script] [FMU] [SSP file]
         Options:
           --addParametersToCSV=<arg>      Export parameters to .csv file (true, [false])
           --algLoopSolver=<arg>           Specifies the alg. loop solver method ([fixedpoint], kinsol) used for algebraic loops spanning over multiple components.
           --clearAllOptions               Reset all flags to default values
           --deleteTempFiles=<bool>        Deletes temp files as soon as they are no longer needed ([true], false)
           --emitEvents=<bool>             Specifies whether events should be emitted or not ([true], false)
           --exportParametersInline=<arg>  Export ParameterBindings inline with .ssd file, 
           --fetchAllVars=<arg>            Workaround for certain FMUs that do not update all internal dependencies automatically
           --help [-h]                     Displays the help text
           --ignoreInitialUnknowns=<bool>  Ignore the initial unknowns from the modelDescription.xml (true, [false])
           --inputExtrapolation=<bool>     Enables input extrapolation using derivative information (true, [false])
           --intervals=<int> [-i]          Specifies the number of communication points (arg > 1)
           --logFile=<arg> [-l]            Specifies the logfile (stdout is used if no log file is specified)
           --logLevel=<int>                0 default, 1 debug, 2 debug+trace
           --maxEventIteration=<int>       Specifies the max. number of iterations for handling a single event
           --maxLoopIteration=<int>        Specifies the max. number of iterations for solving algebraic loops between system-level components. Internal algebraic loops of components are not affected.
           --mode=<arg> [-m]               Forces a certain FMI mode iff the FMU provides cs and me (cs, [me])
           --numProcs=<int> [-n]           Specifies the max. number of processors to use (0=auto, 1=default)
           --progressBar=<bool>            Shows a progress bar for the simulation progress in the terminal (true, [false])
           --realTime=<bool>               Experimental feature for (soft) real-time co-simulation (true, [false])
           --resultFile=<arg> [-r]         Specifies the name of the output result file
           --setInputDerivatives=<bool>    Deprecated; see '--inputExtrapolation'
           --skipCSVHeader=<arg>           Skip exporting the scv delimiter in the header (true, [false]), 
           --solver=<arg>                  Specifies the integration method (euler, [cvode])
           --solverStats=<bool>            Adds solver stats to the result file, e.g. step size; not supported for all solvers (true, [false])
           --startTime=<double> [-s]       Specifies the start time
           --stopTime=<double> [-t]        Specifies the stop time
           --stripRoot=<bool>              Removes the root system prefix from all exported signals (true, [false])
           --suppressPath=<bool>           Supresses path information in info messages; especially useful for testing (true, [false])
           --tempDir=<arg>                 Specifies the temp directory
           --timeout=<int>                 Specifies the maximum allowed time in seconds for running a simulation (0 disables)
           --tolerance=<double>            Specifies the relative tolerance
           --version [-v]                  Displays version information
           --wallTime=<bool>               Add wall time information for to the result file (true, [false])
           --workingDir=<arg>              Specifies the working directory

setConnectionGeometry

# not available

setConnectorGeometry

Set geometry information to a given connector.

# not available

setElementGeometry

Set geometry information to a given component.

# not available

setFixedStepSize

Sets the fixed step size. Can be used for the communication step size of co-simulation systems and also for the integrator step size in model exchange systems.

status := oms_setFixedStepSize(cref, stepSize);

setInteger

Sets the value of a given integer signal.

status := oms_setInteger(cref, value);

setLogFile

Redirects logging output to file or std streams. The warning/error counters are reset.

filename="" to redirect to std streams and proper filename to redirect to file.

status := oms_setLogFile(filename);

setLoggingCallback

Sets a callback function for the logging system.

# not available

setLoggingInterval

Set the logging interval of the simulation.

status := oms_setLoggingInterval(cref, loggingInterval);

setLoggingLevel

Enables/Disables debug logging (logDebug and logTrace).

0 default, 1 default+debug, 2 default+debug+trace

oms_setLoggingLevel(logLevel);

setMaxLogFileSize

Sets maximum log file size in MB. If the file exceeds this limit, the logging will continue on stdout.

# not available

setReal

Sets the value of a given real signal.

status := oms_setReal(cref, value);

This function can be called in different model states:

  • Before instantiation: setReal can be used to set start values or to define initial unknowns (e.g. parameters, states). The values are not immediately applied to the simulation unit, since it isn’t actually instantiated.

  • After instantiation and before initialization: Same as before instantiation, but the values are applied immediately to the simulation unit.

  • After initialization: Can be used to force external inputs, which might cause discrete changes of continuous signals.

setRealInputDerivative

Sets the first order derivative of a real input signal.

This can only be used for CS-FMU real input signals.

status := oms_setRealInputDerivative(cref, value);

setResultFile

Set the result file of the simulation.

status := oms_setResultFile(cref, filename);
status := oms_setResultFile(cref, filename, bufferSize);

The creation of a result file is omitted if the filename is an empty string.

setSignalFilter

This function specifies the signal filter. The signal filter is used to determine which signals will eventually be exported to the result file.

status := oms_setSignalFilter(cref, regex);

The second argument, i.e. regex, is a regular expression (C++11). ".*" and "(.)*" can be used to hit all variables.

setSolver

Sets the solver method for the given system.

status := oms_setSolver(cref, solver);

The second argument "solver" should be any of the following,

"OpenModelica.Scripting.oms_solver.oms_solver_none"
"OpenModelica.Scripting.oms_solver.oms_solver_sc_min"
"OpenModelica.Scripting.oms_solver.oms_solver_sc_explicit_euler"
"OpenModelica.Scripting.oms_solver.oms_solver_sc_cvode"
"OpenModelica.Scripting.oms_solver.oms_solver_sc_max"
"OpenModelica.Scripting.oms_solver.oms_solver_wc_min"
"OpenModelica.Scripting.oms_solver.oms_solver_wc_ma"
"OpenModelica.Scripting.oms_solver.oms_solver_wc_mav"
"OpenModelica.Scripting.oms_solver.oms_solver_wc_assc"
"OpenModelica.Scripting.oms_solver.oms_solver_wc_mav2"
"OpenModelica.Scripting.oms_solver.oms_solver_wc_max"

setStartTime

Set the start time of the simulation.

status := oms_setStartTime(cref, startTime);

setStopTime

Set the stop time of the simulation.

status := oms_setStopTime(cref, stopTime);

setTLMBusGeometry

# not available

setTLMConnectionParameters

Simulates a composite model in its own thread.

# not available

setTLMPositionAndOrientation

Sets initial position and orientation for a TLM 3D interface.

status := oms_setTLMPositionAndOrientation(cref, x1, x2, x3, A11, A12, A13, A21, A22, A23, A31, A32, A33);

setTLMSocketData

Sets data for TLM socket communication.

status := oms_setTLMSocketData(cref, address, managerPort, monitorPort);

setTempDirectory

Set new temp directory.

status := oms_setTempDirectory(newTempDir);

setTolerance

Sets the tolerance for a given model or system.

status := oms_setTolerance(const char* cref, double tolerance);
status := oms_setTolerance(const char* cref, double absoluteTolerance, double relativeTolerance);

Default values are 1e-4 for both relative and absolute tolerances.

A tolerance specified for a model is automatically applied to its root system, i.e. both calls do exactly the same:

oms_setTolerance("model", absoluteTolerance, relativeTolerance);
oms_setTolerance("model.root", absoluteTolerance, relativeTolerance);

Component, e.g. FMUs, pick up the tolerances from there system. That means it is not possible to define different tolerances for FMUs in the same system right now.

In a strongly coupled system (oms_system_sc), the relative tolerance is used for CVODE and the absolute tolerance is used to solve algebraic loops.

In a weakly coupled system (oms_system_wc), both the relative and absolute tolerances are used for the adaptive step master algorithms and the absolute tolerance is used to solve algebraic loops.

setVariableStepSize

Sets the step size parameters for methods with stepsize control.

status := oms_getVariableStepSize(cref, initialStepSize, minimumStepSize, maximumStepSize);

setWorkingDirectory

Set a new working directory.

status := oms_setWorkingDirectory(newWorkingDir);

simulate

Simulates a composite model.

status := oms_simulate(cref);

simulate_realtime

Experimental feature for (soft) real-time simulation.

# not yet available

stepUntil

Simulates a composite model until a given time value.

status := oms_stepUntil(cref, stopTime);

terminate

Terminates a given composite model.

status := oms_terminate(cref);

Graphical Modelling

OMSimulator has an optional dependency to OpenModelica in order to utilize the graphical modelling editor OMEdit. This feature requires to install the full OpenModelica tool suite, which includes OMSimulator. The independent stand-alone version doesn't provide any graphical modelling editor.

See also FMI documentation.

_images/omedit_01.png

Figure 56 OMEdit MainWindow and Browsers.

New OMSimulator Model

A new and empty OMSimulator model can be created from the OMSimulator menu item.

_images/omedit_02.png

Figure 57 OMEdit: New OMSimulator Model

That will pop-up a dialog to enter the names of the model and the root system.

_images/omedit_03.png

Figure 58 OMEdit: New OMSimulator Model Dialog

Add System

A weakly coupled system (co-simulation) can integrate strongly coupled system (model exchange). Therefore, the weakly coupled system must to be selected from the Libraries Browser and the respective menu item can be selected:

_images/omedit_04.png

Figure 59 OMEdit: Add System

That will pop-up a dialog to enter the names of the new system.

_images/omedit_05.png

Figure 60 OMEdit: Add System Dialog

Add SubModel

A sub-model is typically an FMU, but it also can be result file. In order to import a sub-model, the respective system must be selected and the action can be selected from the menu bar:

_images/omedit_06.png

Figure 61 OMEdit: Add SubModel

That will pop-up a dialog to enter the names of the new sub-model.

_images/omedit_07.png

Figure 62 OMEdit: Add SubModel Dialog

Simulate

Select the simulate item from the OMSimulator menu.

SSP Support

Composite models are imported and exported in the System Structure Description (SSD) format, which is part of the System Structure and Parameterization (SSP) standard.

Bus connections are saved as annotations to the SSD file. Bus connectors are only allowed in weakly coupled and strongly coupled systems. Bus connections can exist in any system type. Bus connectors are used to hide SSD connectors and bus connections are used to hide existing SSD connections in the graphical user interface. It is not required that all connectors referenced in a bus are connected. One bus may be connected to multiple other buses, and also to SSD connectors.

The example below contains a root system with two subsystems, WC1 and WC2. Bus connector WC1.bus1 is connected to WC2.bus2. Bus connector WC2.bus2 is also connected to SSD connector WC1.C3.

<?xml version="1.0" encoding="UTF-8"?>
<ssd:SystemStructureDescription name="Test" version="Draft20180219">
  <ssd:System name="Root">
    <ssd:Elements>
      <ssd:System name="WC2">
        <ssd:Connectors>
          <ssd:Connector name="C1" kind="input" type="Real"/>
          <ssd:Connector name="C2" kind="output" type="Real"/>
        </ssd:Connectors>
        <ssd:Annotations>
          <ssc:Annotation type="org.openmodelica">
            <oms:Bus name="bus2">
              <oms:Signals>
                <oms:Signal name="C1"/>
                <oms:Signal name="C2"/>
              </oms:Signals>
            </oms:Bus>
          </ssc:Annotation>
        </ssd:Annotations>
      </ssd:System>
      <ssd:System name="WC1">
        <ssd:Connectors>
          <ssd:Connector name="C1" kind="output" type="Real"/>
          <ssd:Connector name="C2" kind="input" type="Real"/>
          <ssd:Connector name="C3" kind="input" type="Real"/>
        </ssd:Connectors>
        <ssd:Annotations>
          <ssc:Annotation type="org.openmodelica">
            <oms:Bus name="bus1">
              <oms:Signals>
                <oms:Signal name="C1"/>
                <oms:Signal name="C2"/>
              </oms:Signals>
            </oms:Bus>
          </ssc:Annotation>
        </ssd:Annotations>
      </ssd:System>
    </ssd:Elements>
    <ssd:Connections>
      <ssd:Connection startElement="WC2" startConnector="C1"
                      endElement="WC1" endConnector="C1"/>
      <ssd:Connection startElement="WC2" startConnector="C2"
                      endElement="WC1" endConnector="C2"/>
      <ssd:Connection startElement="WC2" startConnector="C2"
                      endElement="WC1" endConnector="C3"/>
    </ssd:Connections>
    <ssd:Annotations>
      <ssc:Annotation type="org.openmodelica">
        <oms:Connections>
          <oms:Connection startElement="WC1" startConnector="bus1"
                          endElement="WC2" endConnector="bus2"/>
          <oms:Connection startElement="WC2" startConnector="bus2"
                          endElement="WC1" endConnector="C3"/>
        </oms:Connections>
      </ssc:Annotation>
    </ssd:Annotations>
  </ssd:System>
</ssd:SystemStructureDescription>

TLM systems are only allowed on top-level. SSD annotations are used to specify the system type inside the ssd:SimulationInformation tag, as shown in the example below. Attributes ip, managerport and monitorport defines the socket communication, used both to exchange data with external tools and with internal simulation threads.

<?xml version="1.0"?>
<ssd:System name="tlm">
  <ssd:SimulationInformation>
   <ssd:Annotations>
      <ssd:Annotation type="org.openmodelica">
        <oms:TlmMaster ip="127.0.1.1" managerport="11111" monitorport="11121"/>
      </ssd:Annotation>
   </ssd:Annotations>
  </ssd:SimulationInformation>
  <ssd:Elements>
    <ssd:System name="weaklycoupled">
      <ssd:SimulationInformation>
        <ssd:FixedStepMaster description="oms-ma" stepSize="1e-1" />
      </ssd:SimulationInformation>
    </ssd:System>
  </ssd:Elements>
</ssd:System>

TLM connections are implemented without regular SSD connections. TLM connections are only allowed in TLM systems. TLM connectors are only allowed in weakly coupled or strongly coupled systems. Both connectors and connections are implemented as SSD annotations in the System tag.

The example below shows a TLM system containing two weakly coupled systems, wc1 and wc2. System wc1 contains two TLM connectors, one of type 1D signal and one of type 1D mechanical. System wc2 contains only a 1D signal type connector. The two 1D signal connectors are connected to each other in the TLM top-level system.

<?xml version="1.0"?>
<ssd:System name="tlm">
  <ssd:Elements>
    <ssd:System name="wc2">
      <ssd:Connectors>
        <ssd:Connector name="y" kind="input" type="Real" />
      </ssd:Connectors>
      <ssd:Annotations>
        <ssd:Annotation type="org.openmodelica">
          <oms:Bus name="bus2" type="tlm" domain="signal"
                   dimension="1" interpolation="none">
            <oms:Signals>
              <oms:Signal name="y" tlmType="value" />
            </oms:Signals>
          </oms:Bus>
        </ssd:Annotation>
      </ssd:Annotations>
    </ssd:System>
    <ssd:System name="wc1">
      <ssd:Connectors>
        <ssd:Connector name="y" kind="output" type="Real" />
        <ssd:Connector name="x" kind="output" type="Real" />
        <ssd:Connector name="v" kind="output" type="Real" />
        <ssd:Connector name="f" kind="input" type="Real" />
      </ssd:Connectors>
      <ssd:Annotations>
        <ssd:Annotation type="org.openmodelica">
          <oms:Bus name="bus1" type="tlm" domain="signal"
                   dimension="1" interpolation="none">
            <oms:Signals>
              <oms:Signal name="y" tlmType="value" />
            </oms:Signals>
          </oms:Bus>
          <oms:Bus name="bus2" type="tlm" domain="mechanical"
                   dimension="1" interpolation="none">
            <oms:Signals>
              <oms:Signal name="x" tlmType="state" />
              <oms:Signal name="v" tlmType="flow" />
              <oms:Signal name="f" tlmType="effort" />
            </oms:Signals>
          </oms:Bus>
        </ssd:Annotation>
      </ssd:Annotations>
    </ssd:System>
  </ssd:Elements>
  <ssd:Annotations>
    <ssd:Annotation type="org.openmodelica">
      <oms:Connections>
        <oms:Connection startElement="wc1" startConnector="bus1"
                        endElement="wc2" endConnector="bus2"
                        delay="0.001000" alpha="0.300000"
                        linearimpedance="100.000000"
                        angularimpedance="0.000000" />
      </oms:Connections>
    </ssd:Annotation>
  </ssd:Annotations>
</ssd:System>

Depending on the type of TLM bus connector (dimension, domain and interpolation), connectors need to be assigned to different tlm variable types. Below is the complete list of supported TLM bus types and their respective connectors.

1D signal

tlmType

causality

"value"

input/output

1D physical (no interpolation)

tlmType

causality

"state"

output

"flow"

output

"effort"

input

1D physical (coarse-grained interpolation)

tlmType

causality

"state"

output

"flow"

output

"wave"

input

"impedance"

input

1D physical (fine-grained interpolation)

tlmType

causality

"state"

output

"flow"

output

"wave1"

input

"wave2"

input

"wave3"

input

"wave4"

input

"wave5"

input

"wave6"

input

"wave7"

input

"wave8"

input

"wave9"

input

"wave10"

input

"time1"

input

"time2"

input

"time3"

input

"time4"

input

"time5"

input

"time6"

input

"time7"

input

"time8"

input

"time9"

input

"time10"

input

"impedance"

input

3D physical (no interpolation)

tlmType

causality

"state1"

output

"state2"

output

"state3"

output

"A11"

output

"A12"

output

"A13"

output

"A21"

output

"A22"

output

"A23"

output

"A31"

output

"A32"

output

"A33"

output

"flow1"

output

"flow2"

output

"flow3"

output

"flow4"

output

"flow5"

output

"flow6"

output

"effort1"

input

"effort2"

input

"effort3"

input

"effort4"

input

"effort5"

input

"effort6"

input

3D physical (coarse-grained interpolation)

tlmType

causality

"state1"

output

"state2"

output

"state3"

output

"A11"

output

"A12"

output

"A13"

output

"A21"

output

"A22"

output

"A23"

output

"A31"

output

"A32"

output

"A33"

output

"flow1"

output

"flow2"

output

"flow3"

output

"flow4"

output

"flow5"

output

"flow6"

output

"wave1"

input

"wave2"

input

"wave3"

input

"wave4"

input

"wave5"

input

"wave6"

input

"linearimpedance"

input

"angularimpedance"

input

3D physical (fine-grained interpolation)

tlmType

causality

"state1"

output

"state2"

output

"state3"

output

"A11"

output

"A12"

output

"A13"

output

"A21"

output

"A22"

output

"A23"

output

"A31"

output

"A32"

output

"A33"

output

"flow1"

output

"flow2"

output

"flow3"

output

"flow4"

output

"flow5"

output

"flow6"

output

"wave1_1"

input

"wave1_2"

input

"wave1_3"

input

"wave1_4"

input

"wave1_5"

input

"wave1_6"

input

"wave2_1"

input

"wave2_2"

input

"wave2_3"

input

"wave2_4"

input

"wave2_5"

input

"wave2_6"

input

"wave3_1"

input

"wave3_2"

input

"wave3_3"

input

"wave3_4"

input

"wave3_5"

input

"wave3_6"

input

"wave4_1"

input

"wave4_2"

input

"wave4_3"

input

"wave4_4"

input

"wave4_5"

input

"wave4_6"

input

"wave5_1"

input

"wave5_2"

input

"wave5_3"

input

"wave5_4"

input

"wave5_5"

input

"wave5_6"

input

"wave6_1"

input

"wave6_2"

input

"wave6_3"

input

"wave6_4"

input

"wave6_5"

input

"wave6_6"

input

"wave7_1"

input

"wave7_2"

input

"wave7_3"

input

"wave7_4"

input

"wave7_5"

input

"wave7_6"

input

"wave8_1"

input

"wave8_2"

input

"wave8_3"

input

"wave8_4"

input

"wave8_5"

input

"wave8_6"

input

"wave9_1"

input

"wave9_2"

input

"wave9_3"

input

"wave9_4"

input

"wave9_5"

input

"wave9_6"

input

"wave10_1"

input

"wave10_2"

input

"wave10_3"

input

"wave10_4"

input

"wave10_5"

input

"wave10_6"

input

"time1"

input

"time2"

input

"time3"

input

"time4"

input

"time5"

input

"time6"

input

"time7"

input

"time8"

input

"time9"

input

"time10"

input

"linearimpedance"

input

"angularimpedance"

input