Model Initialization

There are two ways of saving the model initialization in SimulationX:

  • Save the initialization internally at the current Reset Point.
  • Save the initialization externally in a file.

The two methods should not be used at the same time.

Save the initialization internally at the current reset point

Saving the initialization internally enables you to define the current state of a model (at a Reset Point) as the initial state for further simulations. This might be useful, for example, if the steady-state solution of a model (calculated either by the transient (time-domain) or the steady-state solver) is used for further transient simulations (parameter variations, optimizations etc.). Defining such an initialization state (in the Simulation Control properties on the Reset Points page , "Save Initial State") triggers the following actions:

  • The start time parameter tStart is set to the time of the current Reset Point tRP, as otherwise the calculation would become inconsistent if the absolute time time is referenced somewhere in the model.
  • The status line "Initial state is active" is shown in the dialog.
  • After a reset, the model is initialized with the saved initial state automatically.

The initial values in the elements and connections of the model are disabled to ignore them in the next simulation, but the saved initialization state can be removed (Simulation ControlReset Points, "Remove Initial State"). This has the following effects:

  • The start time parameter tStart is reset to its original value.
  • The status line "Initial State is not active" is shown in the dialog.
  • After a reset, the model is not initialized.

A new simulation then uses the initial values in the elements and connections of the model again.

Save the initialization externally in a file

Alternatively, SimulationX can generate an initialization file that you can modify (values of parameters and variables) in order to adapt an existing model to your needs without changing the model itself. It can also be used to adjust start conditions for a more realistic behavior or to help the solver initialize the model properly even if the underlying equation system is strictly nonlinear. Apart from that you can save the state of a model at a certain point in time to an initialization file and have the simulation read it for a restart from this very point.

You can generate this initialization file (*.isi) with the button "Initialization Data" from the Export section in the ribbon menu. The initilaization file can be generated from either an unsimulated or simulated state and is model-specific. If generated from an unsimulated model, the file holds only the current parameter values, but no variables. If generated from a simulated model, the initializaiton file also includes the current values of the variables. The file is a simple text file with a Modelica-based syntax and can be modified with any text editor. It consists of lines of the form:

<Identifier>=<Value>

where <Identifier> denotes a parameter or variable in the model. In case the <Identifier> refers to a non-scalar variable, values can be given for each component separately, e.g. sphere1.Fa[1] = 3.5;. Non-scalar parameters can be assigned through an array expression with literals, e.g. rigidLink1.x0 = {1,0,0}.

The initialization file does not cover the entire state of the model. For example, the the buffer state of Modelica delay operators or the internal state of external objects are not included.

With the parameter userInitFile on the "General Parameters" tab in the model properties you can load and access your initialization file:

Figure 1: Section with userInitFile in the General Parameters

  • The userInitFile a string parameter and blank by default. The directory of the initialization file (*.isi) can be specified in the model properties. Backslashes must be masked with an additional backslash, e.g. "C:\\InitializationFiles\\Test.isi", or you browse for the file by clicking on the icon.
  • If a path is specified, the file is read every time the simulation is started. If reset points are used for the initialization, the initialization file takes priority, i.e. the data from the file overrides the data from the reset points.
  • When an initialization file is defined, the parameter consistentInitialConditions with the default value true becomes available and specifies whether consistent initial values are calculated after the initialization.
  • If consistentInitialConditions is set to false, no consistent initial values are calculated at the start of the simulation. This may cause unexpected simulation results if the values in the file where changed manually.
  • With consistentInitialConditions set to true, consistent initial values are computed and can overwrite the values in the initialization file.
  • The value of consistentInitialConditions is also stored in the initialization file (*.isi) and overrules the value specified in SimulationX, which makes it imperative to define the correct value also in the initialization file (*.isi).