> For the complete documentation index, see [llms.txt](https://www.opal-rt.com/docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://www.opal-rt.com/docs/smart-power-simulation-software-sps/get-started/specify-initial-conditions.md).

# Specify Initial Conditions

## Introduction

In this section, you

* learn what are the state variables of a Simulink® diagram containing SPS blocks,
* specify initial conditions for the electrical state variables.

### State Variables

The state variables of a Simulink diagram containing SPS blocks consist of:

* The electrical states associated to RLC branch-type SPS blocks. They are defined by the state-space representation of your model. See [Electrical State Variables](https://www.opal-rt.com/docs/smart-power-simulation-software-sps/simulation-and-analysis/analyze-a-simple-circuit.md#Electrical-State-Variables) for more details about the electrical states.
* The Simulink states of the SPS electrical models such as the Synchronous Machine block, the Saturable Transformer block, or the Three-Phase Dynamic Load block.
* The Simulink states of the other Simulink blocks of your model (controls, user-defined blocks, and other blocksets).

The following picture provides an example that contains the three types of state variables:

<figure><img src="https://799605156-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FdlNg8IbOdahCpFCyzxSN%2Fuploads%2Fgit-blob-ebc4eb28194eed6a357d09ee9702eb4fbf53a7bf%2FSchem_3state_variable.png?alt=media" alt=""><figcaption></figcaption></figure>

### Initial States

Initial conditions, which are applied to the entire system at the start of the simulation, are generally set in the blocks. Most of the Simulink blocks allow you to specify initial conditions. For the case of the electrical states, the SPS software automatically sets the initial values of the electrical states to start the simulation in steady state.

However, you can specify the initial conditions for the capacitor voltage and inductor currents in the mask of these blocks:

* the Series and Parallel RLC Branch blocks
* the Series and Parallel RLC Load blocks

The initial values entered in the mask of these blocks overwrite the default steady-state parameters calculated by the SPS software. In the same sense, you can overwrite initial conditions of the overall blocks by specifying them in the **Model Configuration Parameters**.

See the [power\_init](https://www.opal-rt.com/docs/smart-power-simulation-software-sps/blocks-functions-tools/simulation-and-analysis/power_init.md) function reference page for more details on how you can specify initial states for a Simulink diagram with SPS blocks.

## Specify initial electrical states with Powergui

{% stepper %}
{% step %}

### **Open the example and rename blocks**

Open the [Transient Analysis of a Linear Circuit example](https://www.opal-rt.com/docs/smart-power-simulation-software-sps/example-models/get-started-with-sps/transient-analysis-of-a-linear-circuit.md). Rename the RLC Branch blocks as shown in the figure.

<figure><img src="https://799605156-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FdlNg8IbOdahCpFCyzxSN%2Fuploads%2Fgit-blob-63e975836c8fb1493f01e5b8bc05a3ba4ce97fc0%2Finitialstate_add_powergui.png?alt=media" alt=""><figcaption></figcaption></figure>
{% endstep %}

{% step %}

### **Open Initial State tool**

Double-click the powergui block, open the **Tools tab**, and click **Initial State**. The initial values of the five electrical state variables (three inductor currents and two capacitor voltages) are displayed. These initial values correspond to the values that the software automatically sets to start the simulation in steady state.
{% endstep %}

{% step %}

### **Start simulation and observe steady state**

Open the Scope block and start the simulation. As the electrical state variables are automatically initialized, the system starts in steady state and sinusoidal waveforms are observed.
{% endstep %}

{% step %}

### **Change a capacitor initial voltage**

The initial value for the `STATE_D` state is set to 1.589e5 V. It corresponds to the initial capacitor voltage found in the `STATE_D` block. Open this block, select the Set the initial capacitor voltage parameter, then specify a capacitor initial voltage of -2e5 V. Click the OK button.
{% endstep %}

{% step %}

### **Refresh Initial States Tool**

Click the **From diagram** button of the Powergui Initial States Tool to refresh the display of initial states. The initial state of `STATE_D` block is now set to -2e5 V.
{% endstep %}

{% step %}

### **Run simulation and inspect transient**

Start the simulation. In the second trace of the Scope block, zoom around the transient at the beginning of the simulation. As expected, the model does not start in steady state, but the initial value for the capacitor voltage measured by the Voltage Measurement block is -2e5 V.
{% endstep %}

{% step %}

### **Set an inductor initial current**

Select the `STATE_A` state variable in the Initial States Tool list. In the Set selected electrical state field, set the initial inductor current to 50 A, and click Apply. Open the mask of the `STATE_A` block, and note that the Set the initial inductor current parameter is selected and the initial inductor current is set to 50 A. Run the simulation and observe the new transient caused by this new setting.
{% endstep %}
{% endstepper %}

## Forcing initial states to zero

{% stepper %}
{% step %}

### **Force electrical initial states to zero**

From the Initial State Tool window, select the To zero check box under Force initial electrical states, then click Apply. Restart the simulation and observe the transient when all the initial conditions start from zero.
{% endstep %}

{% step %}

### **Effect on block masks and reminder message**

Open the masks of the `STATE_C` and `STATE_A` blocks and note that even if initial conditions are still specified in these blocks, the setting for the initial states is forced to zero by the powergui block. A message is displayed at the command line to remind you every time you start the simulation that the electrical initial states of your model are forced to zero by the powergui block, which overwrites the block settings in your model.
{% endstep %}
{% endstepper %}

## Forcing initial states to steady state

{% stepper %}
{% step %}

### **Force electrical initial states to steady state**

From the Initial State Tool window, select the **To steady state** check box under Force initial electrical states, then click Apply.
{% endstep %}

{% step %}

### **Restart and observe steady state**

Restart the simulation and observe that the simulation starts in steady state. A message is displayed at the command line to remind you every time you start the simulation that the electrical initial states of your model are forced to steady state by the powergui block.
{% endstep %}
{% endstepper %}

{% hint style="info" %}
To return to the block settings, clear both check boxes under **Force initial electrical states**, then click Apply.
{% endhint %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://www.opal-rt.com/docs/smart-power-simulation-software-sps/get-started/specify-initial-conditions.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
