> 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/simulate-transients.md).

# Simulate Transients

## Introduction

In this section, you

* learn how to create an electrical subsystem
* simulate transients with a circuit breaker
* compare time domain simulation results with different line models
* learn how to discretize a circuit and compare results thus obtained with results from a continuous, variable time step algorithm

## Simulating transients with a circuit breaker

One of the main uses of SPS Software is to simulate transients in electrical circuits. This can be done with either mechanical switches (circuit breakers) or switches using power electronic devices.

{% stepper %}
{% step %}

### Open example model

Open the power\_gui example model.
{% endstep %}

{% step %}

### Add and configure breaker block

To simulate a line energization, add a Breaker block from the **SPS** > **Passives** library to the model and set the parameters as follows:

| Paramter                         | Value       |
| -------------------------------- | ----------- |
| **Breaker resistance Ron (Ohm)** | 0.001 Ω     |
| **Initial status**               | 0 (open)    |
| **Snubber resistance Rs (Ohm)**  | inf         |
| **Snubber capacitance Cs (F)**   | 0           |
| **Switching times**              | \[(1/60)/4] |
| {% endstep %}                    |             |

{% step %}

### Insert breaker in series

Insert the Breaker block in series with the sending end of the line, then rearrange the circuit 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-66c85a156be8fbc37bf83c7d30712e415933ccbe%2Fimage.png?alt=media" alt=""><figcaption></figcaption></figure>
{% endstep %}

{% step %}

### Log signals

Right-click the two lines that connect to the Scope 1 block and select Properties. In the dialog box, select **Log signal data** for the two signals and click **OK**. From the Simulation Data Inspector, select **Send Logged Workspace Data to Data Inspector**.
{% endstep %}

{% step %}

### Run with single-section PI model

Open the **150 km Line** block dialog box and set the number of sections to 1.\
Start the simulation.
{% endstep %}

{% step %}

### Run with 10-section PI model

Open the **150 km Line** block dialog box and change the number of sections from 1 to 10.\
Start the simulation.
{% endstep %}

{% step %}

### Replace with Distributed Parameters Line

Add a Distributed Parameters Line block from the **SPS** > **Passives** library. Set the number of phases to 1 and use the same R, L, C, and length parameters as the **150 km Line** block. Delete the **150 km Line** block and replace it with the Distributed Parameters Line block.\
Start the simulation.
{% endstep %}

{% step %}

### Compare waveforms

Compare the three waveforms obtained from the three line models. Open the Simulation Data Inspector. Select the Ub1 and Ub2 signals of Run 1, the Ub2 signals of Run 2, and Run 3. A zoom on these waveforms is shown in the next figure.

As expected from the frequency analysis performed during Analyze a Simple Circuit, the single PI model does not respond to frequencies higher than 229 Hz. The 10 PI section model gives better accuracy, although high-frequency oscillations are introduced by the discretization of the line. You can clearly see the propagation time delay of 1.03 ms associated with the distributed parameter line.

<figure><img src="https://799605156-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FdlNg8IbOdahCpFCyzxSN%2Fuploads%2Fgit-blob-e9770aec718bd59328cf1aaf11ff16985d0ec92a%2Fex_breakers_series_results.png?alt=media" alt=""><figcaption><p><strong>Receiving End Voltage Obtained with Three Different Line Models</strong></p></figcaption></figure>
{% endstep %}
{% endstepper %}

## Discretizing the Electrical System

An important product feature is its ability to simulate either with continuous, variable step integration algorithms or with discrete solvers. For small systems, variable time step algorithms are usually faster than fixed step methods, because the number of integration steps is lower. For large systems that contain many states or many nonlinear blocks such as power electronic switches, however, it is advantageous to discretize the electrical system.

When you discretize your system, the precision of the simulation is controlled by the time step. If you use too large a time step, the precision might not be sufficient. The only way to know if it is acceptable is to repeat the simulation with different time steps and find a compromise for the largest acceptable time step. Usually time steps of 20 µs to 50 µs give good results for simulation of switching transients on 50-Hz or 60-Hz power systems or on systems using line-commutated power electronic devices such as diodes and thyristors. You must reduce the time step for systems using forced-commutated power electronic switches. These devices, the insulated-gate bipolar transistor (IGBT), the field-effect transistor (FET), and the gate-turnoff thyristor (GTO) are operating at high switching frequencies.

For example, simulating a pulse-width-modulated (PWM) inverter operating at 8 kHz would require a time step of at most 1 µs.

{% stepper %}
{% step %}

### Open example and note discrete settings

Open the Neutral Point Clamp Inverter and Dead Time example.\
In the powergui block, note that the **Simulation type** is set to **Dicrete** and the **sample time** is set to 1e-6 s by the Ts variable defined in the Model Properties.\
Run a first simulation.
{% endstep %}

{% step %}

### Continuous simulation

To perform a continuous simulation, open the powergui block parameters dialog box and set **Simulation type** to Continuous. Select the `ode23tb` variable step solver in the Configuration Parameters dialog box.\
Simulate the model.
{% endstep %}

{% step %}

### Discrete simulation with 20 µs

In the powergui block, set **Simulation type** to Discrete. In the **InitFcn model callback** section of the **Model Properties**, specify Ts=20e-6s.\
Run the simulation.
{% endstep %}

{% step %}

### Compare results

Open the Simulation Data Inspector and compare the differences on the high-frequency transients.

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

The 1 µs compares reasonably well with the continuous simulation. However, increasing the time step to 20 µs produces appreciable errors. The 1 µs time step would therefore be acceptable for this circuit, while obtaining a gain on simulation speed.
{% endstep %}
{% endstepper %}


---

# 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/simulate-transients.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.
