> 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/create-user-coded-models-ucm/model-substations-in-ucm.md).

# Model Substations in UCM

## Substation modeling overview

In each substation, there are passive components interpreted as RLC elements which can be linear or non-linear, circuit-breakers, different kinds of generation interpreted as voltage and current sources equipped with control systems.

Machines and motors are considered sources with control systems.

Besides control systems, other equipments are power elements working at the power system level voltages and currents.

## Node-based network solution

Power elements of a substation are interconnected together via nodes. Power elements are not simulated sequentially one by one but rather simultaneously all together in a single equation called the node equation:

$$
YV = I
$$

where:

* **Y** is the substation admittance matrix
* **V** is a vector of node voltages
* **I** is a vector of node currents (currents injected to nodes)

## Control systems

Control systems are modeled using the block diagram principle, either:

* graphically (HYPERSIM® block diagram and Simulink block diagram), or
* using C/C++ code

Their inputs can be node voltages and currents, while their outputs are used to control sources and switches.

## RLC element modeling

HYPERSIM, like EMTP, uses the trapezoidal integration technique.

That is:

$$
y(t) = \int\_{0}^{t} x(t),dt
$$

is evaluated as:

$$
y(t) = y(t - T) + \frac{T}{2} \left\[ x(t) + x(t - T) \right]
$$

where **T** is the calculation time step.

By the same rule, the derivative:

$$
\frac{dy(t)}{dt}
$$

is approximated as:

$$
\frac{y(t) - y(t - T)}{T} = \frac{1}{2} \left\[ x(t) + x(t - T) \right]
$$

### Inductor (L branch)

For an L branch connected between node kk and node mm, the following equation is applied:

$$
v\_k(t) - v\_m(t) = L \frac{d i\_{km}(t)}{dt}
$$

OR

$$
i\_{km}(t) = \frac{1}{L} \int\_{0}^{t} \left\[ v\_k(t) - v\_m(t) \right] dt
$$

Using trapezoidal integration:

$$
i\_{km}(t) = i\_{km}(t - T) + \frac{T}{2L}
\left\[ v\_k(t) - v\_m(t) + v\_k(t - T) - v\_m(t - T) \right]
$$

$$
i\_{km}(t) = \frac{v\_k(t) - v\_m(t)}{R\_{eq}} + i\_{hist}(t - T)
$$

with:

$$
R\_{eq} = \frac{2L}{T}
$$

$$
i\_{hist}(t - T) = i\_{km}(t - T) + \frac{v\_k(t - T) - v\_m(t - T)}{R\_{eq}}
$$

As shown, an ***L*** branch is equivalent to a resistor ***R***<sub>***eq***</sub> in parallel with a historic current source ***i***<sub>***hist***</sub>. The historic current depends only on previous time-step values.

For a fixed inductor, ***L*** is constant, ***R***<sub>***eq***</sub> is constant, and no need to recompute it at every time step.

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

### Capacitor (C branch)

The current of a C branch connected between nodes kk and mm is given by:

$$
i\_{km}(t) = C \frac{d}{dt}\left\[ v\_k(t) - v\_m(t) \right]
$$

Replacing the derivative:

$$
\frac{i\_{km}(t) + i\_{km}(t - T)}{2}
\= C \frac{\[v\_k(t) - v\_m(t)] - \[v\_k(t - T) - v\_m(t - T)]}{T}
$$

or:

$$
i\_{km}(t) = \frac{v\_k(t) - v\_m(t)}{R\_{eq}} + i\_{hist}
$$

with:

$$
R\_{eq} = \frac{T}{2C}
$$

$$
i\_{hist} = \frac{v\_m(t - T) - v\_k(t - T)}{R\_{eq}} - i\_{km}(t - T)
$$

The capacitor is also equivalent to a resistor ***R***<sub>***eq***</sub> in parallel with a historic current source.

For a fixed capacitor, ***R***<sub>***eq***</sub> is constant and the historic current is updated at each time step.

### Combined RLC branches

For any combination of RLC elements write the voltage-current relationship, replace integrals and derivatives using trapezoidal approximations and obtain an equivalent resistor ***R***<sub>***eq***</sub> and historic current source.

## Sources

### Current sources

A current source ***i*** flowing from node ***k*** to node ***m*** has the effect of removing a current ***i*** from node ***k*** and adding a current ***i*** to node ***m***.

### Voltage sources

Voltage sources with output impedances are converted into equivalent current sources using Thevenin–Norton transformation.

## Nonlinear elements

* Non-linear elements are treated as RLC elements, and are also equivalent to a resistor ***R***<sub>***eq***</sub> in parallel with a historic current ***i***<sub>***hist***</sub> (if it is not a pure resistor).
* Non-linearity is represented normally as a characteristic curve approximated by successive linear segments. Due to the non-linearity, ***R***<sub>***eq***</sub> is no longer constant and needs to be recalculated for each time step.
* Theoretically, this must be done based on the conditions of the actual time step, but HYPERSIM® does it based on conditions obtained at the last time step because the current results are not yet available.
* The change from one segment to the next can be one time-step delayed.
* It is therefore a good practice to define the non-linearity characteristic with a smooth change (more points where there are more changes and vice versa) to avoid searching.

HYPERSIM works rather with the conductance

$$
Y\_{eq} = \frac{1}{R\_{eq}}
$$

and splits it as follow:

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

$$
Y\_{eq} = Y\_{ini} + Y\_{add}
$$

where ***Y***<sub>***ini***</sub> is the fixed part used as initial condition and ***Y***<sub>***add***</sub> is the varying part used to update the conductance according to its operating point.


---

# 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/create-user-coded-models-ucm/model-substations-in-ucm.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.
