> 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/understand-preparation-and-parallel-simulation.md).

# Understand Preparation & Parallel Simulation

This page explains how HYPERSIM performs the **preparation and simulation of power systems** at the substation level. It describes the operations executed before the simulation starts, where model parameters and the initial admittance matrix are computed, and the sequence of calculations performed at each simulation time step to solve the node equation.

The page also introduces how HYPERSIM handles **nonlinear behavior, switching events, and parallel computation**, which enable efficient and scalable simulation of complex electrical networks.

## Preparation

To calculate the parameters of all power elements and build the substation node equation, the following preparation steps are performed:

* Read each element’s parameters from the parameter form
* Define node signals (voltages and currents)
* Define element signals, including:
  * voltages (excluding node voltages)
  * currents (source and historic)
  * control signals
* Compute the fixed part ***Y***<sub>***INI***</sub>, representing the initial admittance of all elements, along with other parameters required during simulation
* Initialize the substation admittance matrix ***Y*** using ***Y***<sub>***ini***</sub>
* Reorder ***Y*** so that elements with variable behavior only affect the lower-right portion of the matrix
* Download ***Y***<sub>***INI***</sub>: ***Y***<sub>***ini***</sub> and other required parameters to the simulation program

## Simulation

At each simulation time step, the following operations are performed to simulate power elements and solve the substation node equation:

* Determine switch commands (on/off states)
* Determine the actual states of switches
* If required (e.g., switch state changes or nonlinear operating point variations):
  * Identify the portion of the matrix ***Y*** that must be updated
  * Recalculate this portion of ***Y***
  * Update the LDU decomposition of the affected lower-right block of the matrix
* Compute source currents (voltage and current sources)
* Add source currents to the node current vector ***I***
* Solve the node equation: ***YV = I*** to obtain node voltages ***V***
* Check for changes in nonlinear elements:
  * Update their conductance ***Y***<sub>***add***</sub>
  * Update ***Y***<sub>***eq***</sub>***=Y***<sub>***ini***</sub>***+Y***<sub>***add***</sub>
* Compute element historic currents IhistI\_{hist} and other required signals
* Reset node current vector ***I*** to zero for the next iteration
* Add historic currents to ***I***<sub>***hist***</sub> to node current ***I***
* Execute control functions

## Parallel tasks in HYPERSIM®

As introduced in the **Model Lines in UCM** section, transmission lines are modeled as current sources in parallel with resistors at each end. These sources depend only on past voltage and current values, and interactions between line ends occur after a transmission delay.

Since electromagnetic signals propagate at approximately the speed of light (300,000 km/s), a 30 km line introduces a delay of about 100 µs.

This delay enables parallel computation in networks composed of substations and transmission lines:

* **Substation tasks**:
  * Solve node equations
  * Include line-end equivalents (current sources and resistors)
  * Execute simple control systems
* **Line tasks**:
  * Compute line equivalents independently at each end

Complex substations (e.g., HVAC–HVDC converters or generation stations) may include multiple tasks:

* one for solving the node equation
* additional ones for control systems

### Execution modes

* **Single-processor (non-real-time)**:
  * All tasks are executed sequentially on the same processor
* **Parallel processing systems**:
  * Tasks are distributed across processors using a task mapping algorithm based on:
    * execution time of each task
    * processor availability
    * communication requirements and bandwidth
    * I/O constraints

<figure><img src="https://3623212549-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FLxgTpoh7kyPmQ5vuyqD7%2Fuploads%2Fgit-blob-ebfd96e42ac3f77482b4f33c8251e3166f7bce09%2Fucm-prep.png?alt=media" alt=""><figcaption><p>Example of network structure and corresponding parallel tasks</p></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/create-user-coded-models-ucm/understand-preparation-and-parallel-simulation.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.
