> 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/ehs/3.7/model-in-schematic-editor/optimize-the-ehs-circuit/select-and-tune-the-switching-method.md).

# Select & Tune the Switching Method

## Switching method

When configuring a [switch](https://www.opal-rt.com/docs/ehs/3.7/model-in-schematic-editor/library-blocks-reference/switches-blocks.md), a **switching method** must be selected

**Gen 4 firmware** uses the **Pejovic** switching method exclusively. Guidance on tuning the switch conductance (**Gs**) is provided below.

**Gen 5 firmware** supports two switching methods:

* **Quasi-Supra**
* **Pejovic**

The choice between these models depends on the circuit characteristics. The following guidelines can help you select the most appropriate switching method and tune its parameters.

## Pejovic method

The Pejovic method generally provides better numerical stability and is recommended for stiff circuits, particularly those containing power electronic devices such as IGBTs and diodes. However, it may introduce inaccuracies, including voltage oscillations, leakage currents during blocking states, or excessive losses at higher switching frequencies.

Due to its robust behavior, the Pejovic method is often a good starting point when configuring a model. If greater accuracy is required, quasi-supra switches can be used instead.

Pejovic switches depend only on the voltage and current at their terminals, whereas quasi-supra switches depend on all inputs of the sub-circuit to which they belong. As a result, Pejovic switches may be preferable in circuits containing many closely coupled switches, as they reduce interactions between switching devices that could otherwise lead to convergence problems.

### Tune the Pejovic switch conductance (Gs)

In the Pejovic switching method, the switch is represented by a finite conductance **Gs**. The value of **Gs** determines the equivalent impedance of the switch in both its open and closed states:

* A larger **Gs** reduces the impedance of a closed switch, improving conduction accuracy.
* A larger **Gs** also increases leakage current when the switch is open.
* A smaller **Gs** reduces open-state leakage but increases the impedance of the closed switch.

Choosing **Gs** therefore requires balancing open-state and closed-state accuracy.

#### Evaluate Gs for two-level inverters

For two-level inverter applications, a suitable value of **Gs** can be estimated from:

* The DC bus voltage
* The nominal RMS AC current

$$
G\_s=\frac{I^{AC}\_{RMS}}{V^{DC}}
$$

Once **Gs** and the eHS time step (**Ts**<sub>**eHS**</sub>) are known, the equivalent impedances of the open and closed switch states can be calculated and evaluated against the circuit requirements.

$$
C\_{Open}=T\_S{*{eHS}} \times G\_S \\\[8pt]
L*{Close} = \frac{T\_{S\_{eHS}}}{G\_S}
$$

The selected value should ensure that neither the open-state leakage nor the closed-state impedance significantly affects the simulation results.

#### Evaluate Gs for breakers

For breaker applications, selecting **Gs** involves finding an acceptable trade-off between:

* **C**<sub>**Open**</sub>, the equivalent open-state capacitance
* **L**<sub>**Close**</sub>, the equivalent closed-state inductance

$$
C\_{Open} = T\_{S\_{eHS}} \times G\_S\\\[8pt]
L\_{Close} = \frac{T\_{S\_{eHS}}}{G\_S}
$$

First, determine the nominal circuit impedance **Z**<sub>**Base**</sub> from the circuit rated power and voltage.

$$
Z\_{Base} = \frac{V\_{Base}}{I\_{Base}} =  \frac{P^{3 \emptyset}*{Base}}{3 \times (I*{Base})^2} = \frac{P^{1 \emptyset}*{Base}}{I*{Base}{}^2} = \frac{V\_{Base}{}^2}{P^{1 \emptyset}*{Base}} = \frac{3 \times (V*{Base})^2}{P^{3 \emptyset}\_{Base}}
$$

If an open-state leakage current of 1% is acceptable, the open-switch impedance should be approximately:

$$
Z\_{Open} = 100 \times Z\_{Base}
$$

Using the network frequency (**F**<sub>**grid**</sub>), compute the corresponding equivalent capacitance:

$$
C\_{Open} = \frac{1}{2 \pi \times F\_{grid} \times Z\_{Open}}
$$

The required **Gs** can then be derived from **C**<sup>**Open**</sup> and **Ts**<sub>**eHS**</sub>.

$$
G\_S = \frac{C\_{Open}}{T\_{S\_{eHS}}}
$$

Finally, calculate **LClose** to verify that it does not significantly affect the simulation results.

$$
L\_{Open} = \frac{T\_{S\_{eHS}}}{G\_S}
$$

If the breaker is connected in series with a physical inductance, **L**<sub>**Close**</sub> can be subtracted from that inductance to preserve the overall current response. However, this compensation may introduce errors in voltage magnitude and phase near the breaker.

In general, increasing **Z**<sub>**Open**</sub> reduces leakage current but increases **L**<sub>**Close**</sub>. A suitable balance must therefore be selected for the application.

## Quasi-Supra method <a href="#pejovic-model" id="pejovic-model"></a>

The Quasi-Supra method generally provides higher accuracy than the Pejovic method, but it is also less numerically stable and may, in some cases, lead to simulation divergence. It is particularly well suited for relay devices and fault studies involving breakers, ideal switches, and similar components.

It can also be used when the Pejovic method produces unsatisfactory results, such as excessive conduction losses or excessive leakage currents in the blocking state.

### Tune Quasi-Supra switch parameters

The Quasi-Supra switching method requires tuning of two parameters:

* **R**<sub>**damp**</sub>, which controls numerical damping.
* **Relax**, which controls the relaxation process used to improve convergence.

Proper tuning of these parameters is required to achieve a balance between numerical stability and simulation accuracy.

{% stepper %}
{% step %}

#### <sub>Tune Rdamp</sub>

The Quasi-Supra switch is represented by a controlled current source in parallel with a user-defined resistance (**R**<sub>**damp**</sub>).

The value of **R**<sub>**damp**</sub> influences both switching stability and transient accuracy:

* A larger **R**<sub>**damp**</sub> (closer to the blocking resistance, **R**<sub>**off**</sub>) improves the numerical stability of turn-off transitions.
* A smaller **R**<sub>**damp**</sub> (closer to the conducting resistance, **R**<sub>**on**</sub>) improves the numerical stability of turn-on transitions.

As a result, **R**<sub>**damp**</sub> should be chosen between these two extremes.

The transient voltage error is proportional to **R**<sub>**damp**</sub>, while the transient current error is inversely proportional to it. A suitable compromise can be estimated using:

$$
R\_{damp}=\frac{V\_{switch}}{I\_{switch}}
$$

where:

* **V**<sub>**switch**</sub> is the voltage across the switch immediately before turn-on.
* **I**<sub>**switch**</sub> is the current through the switch immediately before turn-off.
  {% endstep %}

{% step %}

#### <sub>Refine Rdamp by iteration</sub>

If **V**<sub>**switch**</sub> and **I**<sub>**switch**</sub> are not known before the simulation begins, start with an estimated **R**<sub>**damp**</sub> value and adjust it iteratively if excessive voltage or current errors are observed.
{% endstep %}

{% step %}

#### Tune Relax

The **Relax** parameter controls how quickly the switch transitions between its conducting and blocking states.

Increasing **Relax** reduces model stiffness and generally improves numerical stability. However, longer switching transitions increase switching losses and reduce accuracy.

A suitable value should therefore balance stability and accuracy for the application.

Typical values range from **0.1** for maximum performance and accuracy to **10** for maximum numerical stability.
{% 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/ehs/3.7/model-in-schematic-editor/optimize-the-ehs-circuit/select-and-tune-the-switching-method.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.
