> 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/hypersim/model-and-simulation/import-models-from-external-software-or-code/import-from-emtp/adjust-control-systems.md).

# Adjust Control Systems

This page provides guidelines to identify and proactively address control system modeling discrepancies between EMTP and HYPERSIM.

## Adjustment procedure

{% stepper %}
{% step %}

### Verify subsystem compatibility

1. Check if the EMTP model includes high-level subsystems (e.g., from Exciters and Governors libraries). These subsystems are composed of multiple basic blocks that may not all be supported in HYPERSIM. EMTP allows complex subsystem models built from various control blocks. In HYPERSIM, compatibility depends on whether all underlying blocks are supported. Unsupported or partially supported blocks may lead to incorrect behavior.
2. Verify that all basic components inside the subsystem are supported. Simplify or rebuild the subsystem using supported blocks when necessary. Refer to the list of [compatible components](https://www.opal-rt.com/docs/hypersim/model-and-simulation/import-models-from-external-software-or-code/import-from-emtp/compatible-components.md) and [partialy compatible components](https://www.opal-rt.com/docs/hypersim/model-and-simulation/import-models-from-external-software-or-code/import-from-emtp/partialy-compatible-components.md) for validation.
   {% endstep %}

{% step %}

### Identify algebraic loops in control systems

1. Check if the control system contains feedback loops. While EMTP solves control systems using iterative methods (e.g., Newton), handling algebraic loops naturally, HYPERSIM uses a **sequential (non-iterative) solver** for real-time performance. Algebraic loops are automatically broken using delay blocks, which introduce a one-time-step delay and initialize with zero history. This may cause **incorrect initialization or numerical oscillations**.
2. Identify feedback loops in the control system, inspect automatically inserted loop-breaking points (via HYPERSIM console), and ensure correct propagation of initial values across the loop.
   {% endstep %}

{% step %}

### Insert loop breaker blocks manually

1. Check if automatic loop breaking leads to unstable or oscillatory behavior. Automatically inserted delay blocks may not preserve correct initial conditions. This can result in **non-physical oscillations in control outputs**.
2. Insert loop breaker blocks manually:
   * **hyEMTP\_LoopBreaker** (pure connection)
   * **hyEMTP\_LoopBreakerDelay** (replaces delay)
   * Ensure the correct **history (initial value)** is propagated through the loop
   * Place loop breakers at appropriate locations in the feedback path
     {% endstep %}

{% step %}

### Validate mathematical expressions (f(u) blocks)

1. Check expressions used in **f(u)** control blocks. While EMTP accepts expressions with mismatched parentheses, HYPERSIM requires strictly valid syntax. Invalid expressions are rejected during model analysis.
2. Ensure all expressions have matching opening and closing parentheses.
3. Correct any invalid syntax before simulation.
   {% endstep %}
   {% endstepper %}

## Example: Resolving algebraic loop issues

This example illustrates how to manually adapt an **EMTP control subsystem** (Exciter ST1 from the *Exciters and Governors* library) to resolve **numerical oscillations caused by an algebraic loop** when simulating in HYPERSIM.

### Initial model setup

The test model consists of an ST1 exciter where the input **VREF** is defined as a step signal from **1 pu to 1.05 pu** at **t = 5 s:**

<figure><img src="https://3623212549-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FLxgTpoh7kyPmQ5vuyqD7%2Fuploads%2Fgit-blob-28ffd49fb8d5f51623c36804e973f78e35b8fd99%2Femtp-example-algeabric-loop-exciter.png?alt=media" alt=""><figcaption></figcaption></figure>

The exciter contains an internal **feedback loop:**

<figure><img src="https://3623212549-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FLxgTpoh7kyPmQ5vuyqD7%2Fuploads%2Fgit-blob-498b49e208ca5c9395a3276586b61db6734f2f53%2Femtp-example-internal-feedback-loop.png?alt=media" alt=""><figcaption></figcaption></figure>

### Observed issue in HYPERSIM

When the model is simulated in HYPERSIM:

* The solver detects an **algebraic loop** in the control system
* A **delay block (1 time step)** is automatically inserted to break the loop
* This delay block initializes its output to **0 at t = 0** and replaces the expected initial condition

As a result:

* The input **Vr** is incorrectly initialized (should be `Vin_ic`, but becomes 0)
* This causes **non-physical oscillations** in the output signal **EFD**

<figure><img src="https://3623212549-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FLxgTpoh7kyPmQ5vuyqD7%2Fuploads%2Fgit-blob-f0f3965731a249bef4c30d530d829f82a8cd311a%2Femtp-example-results.png?alt=media" alt=""><figcaption></figcaption></figure>

### Solution – Manual loop breaking

To resolve this issue, the algebraic loop must be broken **manually**, ensuring that the correct initial conditions are preserved.

The following blocks, located in `C:\OPAL-RT\HYPERSIM\%HYPERSIM_VERSION%\Windows\HyperWorksUI\HyLibs\hidden` can be used:

* **hyEMTP\_LoopBreaker**
  * Simple connection (gain = 1)
* **hyEMTP\_LoopBreakerDelay**
  * Replaces an existing delay block (1 time step)

To enable the library:

1. Copy `Control HYP_EMPT.clf` into the `HyLibs` folder
2. Restart HYPERSIM

### Solution 1 – Break the feedback loop

If the feedback gain (e.g., **Kf**) is equal to zero:

* There is no effective feedback loop
* The loop can be safely broken at the feedback path

<figure><img src="https://3623212549-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FLxgTpoh7kyPmQ5vuyqD7%2Fuploads%2Fgit-blob-90aa3b1628e031a6670ab134593df7bb88a9ef6b%2Femtp-example-break-feedback-loop.png?alt=media" alt=""><figcaption></figcaption></figure>

### Solution 2 – Insert loop breaker with history propagation

If the feedback loop must be preserved:

1. Insert a **loop breaker block** in the feedback path
2. Connect the correct **history value (Vin\_ic)** to the block input `h`

This ensures:

* Proper initialization of the control loop
* Correct propagation of upstream state values

<figure><img src="https://3623212549-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FLxgTpoh7kyPmQ5vuyqD7%2Fuploads%2Fgit-blob-ef1d40a1b4854c91706009c2563dc030f065f06f%2Femtp-example-insert-loop-breaker.png?alt=media" alt=""><figcaption></figcaption></figure>

### Results

After applying either solution:

* Numerical oscillations in **EFD** are eliminated
* The control response becomes stable and physically consistent

<figure><img src="https://3623212549-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FLxgTpoh7kyPmQ5vuyqD7%2Fuploads%2Fgit-blob-176d2a51114c05f3975cdd398b352a88361582ab%2Femtp-example-solution-results.png?alt=media" alt=""><figcaption></figcaption></figure>

Use the **HYPERSIM console** after circuit analysis to locate automatically broken loops. Then, identify loops that contain blocks with **initial conditions**, and ensure that these initial values are correctly transferred across the loop.

<figure><img src="https://3623212549-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FLxgTpoh7kyPmQ5vuyqD7%2Fuploads%2Fgit-blob-818ff4c0caaf66a99ffa12c79cb75874d609e57d%2Femtp-hypersim-console.png?alt=media" alt=""><figcaption></figcaption></figure>


---

# 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/hypersim/model-and-simulation/import-models-from-external-software-or-code/import-from-emtp/adjust-control-systems.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.
