AmesimKnowledge

Hybrid Co-simulation with the usercosim interface > API Documentation

Usercosim programming interface

void AMEInitModel (double time, double printInterval, double maxTimeStep, double tolerance, int errCtrl, int writeLevel, int extraDisconPrints, int runStats, int runType, int thesolvertype, int numInputs, int numOutputs, double *theInputs, double *theOutputs)
Initializes Simcenter Amesim model.
Parameters time initial time value. printInterval_output interval for Simcenter Amesim result file. maxTimeStep max timestep to be used in the model. tolerance tolerance value. errCtrl type of error check, mixed=0, relative= or absolute. writeLevel write level 0 for time, 1 for full and 2 for no output. extraDisconPrints extra discon prints if 1. runStats runstats if 1. runType run type, 8 for normal run. thesolvertype currently unused (set to zero). numInputs num inputs to the Simcenter Amesim model. numOutputs num outputs from the Simcenter Amesim model. theInputs vector with inputs to the Simcenter Amesim model. theOutputs vector with outputs from the Simcenter Amesim model.
See also AMETerminate()
int AMEdoAStep (double t, int numInputs, int numOutputs, const double * theInputs, double * theOutputs)
Integrates models until t, then retrieve model outputs and set input values.
Similar to AMEOutputs (double t, int numOutputs, const double * theOutputs) AMEInputs (int numInputs, const double * theInputs)
Parameters t final integration time. numInputs num inputs to the Simcenter Amesim model. numOutputs num outputs from the Simcenter Amesim model. theInputs vector with inputs to the Simcenter Amesim model. theOutputs vector with outputs from the Simcenter Amesim model.
See also AMEdoAStep2()
Returns 1 on success, 0 if an error occurred.
int AMEdoAStep2 (double t, int numInputs, int numOutputs, const double * theInputs, double * theOutputs)
Sets model input values, then integrate until t and send back model outputs.
Similar to AMEOutputs (double t, int numOutputs, const double * theOutputs) AMEInputs (int numInputs, const double * theInputs)
Parameters t final integration time. numInputs num inputs to the Simcenter Amesim model. numOutputs num outputs from the Simcenter Amesim model. theInputs vector with inputs to the Simcenter Amesim model. theOutputs vector with outputs from the Simcenter Amesim model.
See also AMEdoAStep()
Returns 1 on success, 0 if an error occurred.
int AMEInitSizes (int * numinputs, int * numoutput, int * numstates, int * numimplicit)
Gets sizes from the model.
Parameters numinputs number of inputs to the Simcenter Amesim model. numoutput number of outputs from the Simcenter Amesim model. numstates number of state variables in Simcenter Amesim model. numimplicit number of implicit variables in Simcenter Amesim model.
Returns 1 on success, 0 if an error occurred.
int AMEInstallfprintf (int newameInternalfprintf(FILE *fp, const char *fmt, va_list ap))
Simcenter Amesim models usually write status or error message to stdout and stderr. You can use your own function to print these messages. For instance, redirect message to a file.
Example Copy`/* define your own log function */ static FILE *logpf; static int amelogfprintf(FILE *fp, const char fmt, va_list ap) { int ans = 0; / redirect stdout and stderr toward the filedescriptor */ if( logpf != NULL && ((fp == stdout)
Parameters newameInternalfprintf pointer to the new printf function. See documentation of vfprintf for more information.
Returns 1 on success, 0 if an error occurred.
int AMEInputs (int numInputs, const double * theInputs)
Sets model input values for the current date.
Parameters numInputs num inputs to the Simcenter Amesim model. theInputs vector with inputs to the Simcenter Amesim model.
See also AMEOutputs()
Returns 1 on success, 0 if an error occurred.
int AMEOutputs (double t, int numInputs, const double * theOutputs)
Integrates until date t and then retrieve output values from the model.
Parameters t final integration time numOutputs num outputs from the Simcenter Amesim model. theOutputs vector with outputs from the Simcenter Amesim model.
See also AMEInputs()
Returns 1 on success, 0 if an error occurred.
int AMESetFinalTime (double time)
Integrates until date t and then retrieve output values from the model.
Parameters time max integration time.
Returns 1 on success, 0 if an error occurred.
int AMESetFinalTime (double time)
Integrates until date t and then retrieve output values from the model.
Parameters time max integration time.
Returns 1 on success, 0 if an error occurred.
void AMETerminate ()
Tells the model that the simulation is done. This call is mandatory before the next AMEInitModel().
See also AMEInitModel()
int AMEWorkingDir (char * dir)
By default, the shared library built with Simcenter Amesim searches for configuration, data and parameter files in the current working directory. To call the shared library from another directory, use AMEWorkingDir() to configure the path to the directory that contains configuration, data and parameter files.
Parameters dir path to the directory that contains Simcenter Amesim model files.
Returns 1 on success, 0 if an error occurred.

Source: https://docs.sw.siemens.com/en-US/doc/254352342/PL20250521841123434.amesim_collection.lib-cosim/xid1852782 · retrieved 2026-07-17