Main Content

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.

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

None — If a variable has priority of none, the initialization algorithm starts at the beginning value for this variable but does not remember this value as it finds the solution for the system of equations. The solver does not try to satisfy any specific initial value for a variable with no priority.

Low — If a variable has low priority, the beginning value becomes a target for the algorithm and the algorithm tries to stay close to the target. 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.

High — If a variable has high priority, the beginning value becomes a target for the algorithm and the algorithm tries to meet the target exactly. The solver tries to find a solution where the actual initial values of all high-priority variables exactly satisfy their target values.

The default initialization priority, beginning value, and unit for each of the block
variables come from the underlying Simscape™ component file. For each individual block in your model, you can override these
default settings by opening the **Variables** tab of the block dialog box,
selecting the **Override** check box next to a variable name and specifying
your own values for that variable.

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.

Using the

**Variables**tab of the respective block dialog boxes, specify the variable targets for initialization, by setting the priority, target values, and units for block variables as required by your model.Open and refresh 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.

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.

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