About Variable Initialization

Initializing Block Variables for Model Simulation

At the beginning of simulation (t = 0), the solver computes the initial conditions to determine the simulation starting point, as described in Initial Conditions Computation. Finding a solution means finding initial values for all system variables. You can affect the initial conditions computation by block-level variable initialization, that is, by specifying the priority and target initial values for certain variables on the Variables tab of the respective block dialog boxes.

The values you specify during block-level variable initialization are not the actual values of the respective variables, but rather their target values at the beginning of simulation (t = 0). Depending on the results of the solve, some of these targets may or may not be satisfied.

The solver tries to find a solution that:

  • Exactly satisfies all the model equations

  • Exactly satisfies all the high-priority targets

  • Approximates the low-priority targets as closely as possible (as a result, some of the low-priority targets might be satisfied exactly, the others are approximated)

If the solver cannot find a solution that exactly satisfies all the high-priority targets, it issues a warning and enters the second stage of the solve process, where it tries to find a solution by approximating both the high-priority and the low-priority targets as closely as possible.

If you have selected the Start simulation from steady state check box in the Solver block dialog box, the solver attempts to find the steady state (when the system variables are no longer changing with time). If the steady-state solve succeeds, the state found is some steady state (within tolerance), but not necessarily the state expected from the given initial conditions. In other words, if simulation starts from steady state, even the high-priority variable targets might no longer be satisfied at the start of simulation. However, if the model has more than one steady state, the variable targets you specify can affect which steady-state solution is selected by the solver.

After you initialize the block variables and prior to simulating the model, you can open the Variable Viewer to see which of the variable targets have been satisfied. The Variable Viewer displays the actual initial values of the variables obtained as a result of the solve, along with the variable target values, priority, and other information about the variable. For details, see Variable Viewer.

Variable Initialization Priority

During block-level variable initialization, you specify the variable initial target (value and unit) and the initialization priority. The priority can be one of the following:

  • High — If a variable has high priority, the solver tries to find a solution where the actual initial value of this variable exactly satisfies its target value.

  • Low — If a variable has low priority, the solver tries to approximate the target value of this variable as closely as possible when finding a solution. Depending on the results of the solve for high-priority variables, some of the low-priority targets might be met exactly, the others are approximated.

  • None — A variable has no initialization priority when its Specify check box is cleared, and the Priority, Value, and Unit fields display Unused. This does not mean that the variable itself is not used in the initialization process, only that its target is not used. The solver finds initial values for all system variables, but if a variable has priority of none, (i.e. Unused), the solver does not try to satisfy any specific initial value for this variable when solving the system.

When you specify too many high-priority targets for system variables, it is possible to over-specify your model. In this case, the solver might not be able to find a solution that exactly satisfies all the high-priority targets, or even fail to find a solution altogether. For an example of how you can deal with over-specification by using the Variable Viewer and changing the variable priority and targets, see Initialize Variables for a Mass-Spring-Damper System.

For detailed information on how to specify variable priority and targets in block dialog boxes, see Set Priority and Initial Target for Block Variables.

Suggested Workflow

  1. Using the Variables tab of the respective block dialog boxes, specify which variable targets should be used for initialization and set their priority, target values, and units.

  2. Open the Variable Viewer to see which of the initial targets have been satisfied. Although the viewer does not simulate the model, it runs the simulation for 0 seconds to initialize it, and therefore the model must be in an executable state.

  3. If initialization fails, or you are not satisfied with the results, iterate by changing the block variable target values and priority, then refreshing the viewer.

  4. When satisfied with initialization, run the simulation to see the results.

Related Examples

More About

Was this topic helpful?