> 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/rt-lab/model-and-simulation/phasor-domain-with-ephasorsim/set-phasor-settings-run-simulation.md).

# Set Phasor Settings & Run Simulation

## Introduction

When using ePHASORSIM, two different execution rates are involved:

* The **CPU model time step** configured in Simulink, which determines how often the surrounding model executes.
* The **ePHASORSIM time step** configured in the **ePHASORSIM Solver** block, which defines the internal solution step used by the phasor-domain solver (default: **10 ms**).

The ePHASORSIM solver is internally decoupled from the Simulink solver, so these two time steps do not need to match.

## Configure the phasor simulation settings

{% stepper %}
{% step %}

### Set the phasor time-step

In the **Simulation settings** tab of the **ePHASORSIM Solver** block, specify the **Time-step (seconds)** used by the ePHASORSIM solver. Click **Apply** to save the configuration.

Choose the ePHASORSIM time step based on the power-system dynamics and performance requirements (default: **10 ms**), not the Simulink execution rate.
{% endstep %}

{% step %}

### Select the number of partitions (optional)

In the **Simulation settings** tab of the **ePHASORSIM Solver** block, under **Dynamic simulation**, specify the **Number of Partitions**. Click **OK** a to save the configuration and close the block mask.

<figure><img src="https://96827845-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNRdpSk8kjn20gXAexnt6%2Fuploads%2Fgit-blob-b2b8e0db5c1fa70d0c9f7bf54c97f9e413dde991%2Feph-rtlab-partitions.png?alt=media" alt=""><figcaption></figcaption></figure>

This setting controls how the solver partitions the network admittance matrix for parallel execution. Increasing the number of partitions allows ePHASORSIM to distribute the network solution across multiple threads and CPU cores, subject to license availability. The optimal value depends on the network topology, model size, and available hardware; however, a common starting point is **5 to 7 partitions per available CPU core** (for example, **10–14 partitions** for **2 cores**). Small **models typically perform well with a single partition**, while larger models may benefit from additional partitions and parallel execution on multiple cores.

{% hint style="danger" %}
Parallel execution in ePHASORSIM requires the **EPHASOR\_PARTITION\_POWERSYSTEM**, **EPHASOR\_PARALLELIZE\_GENUNITS**, and **EPHASOR\_NUM\_CORES** license features on both the workstation and simulator licenses. The value of **EPHASOR\_NUM\_CORES** must be greater than or equal to the number of solver threads used by the simulation.
{% endhint %}
{% endstep %}

{% step %}

### Configure thread usage (optional)

To enable multi-core execution, define the `EPHASOR_THREADS` environment variable.

* On a **Windows workstation**, it is recommended to enable **Optimize Number of Threads** and let ePHASORSIM select a suitable thread configuration automatically. Alternatively, define `EPHASOR_THREADS` in the Windows environment variables before starting MATLAB.
* On a **simulator**, define `EPHASOR_THREADS` in the RT-LAB model environment variables.

<figure><img src="https://96827845-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNRdpSk8kjn20gXAexnt6%2Fuploads%2Fgit-blob-9fdb04bd12080d6e64abe0e24a1867bcb8f3d9bd%2Feph-rtlab-threads.png?alt=media" alt=""><figcaption></figcaption></figure>

The `EPHASOR_THREADS` environment variable specifies the CPU cores available to ePHASORSIM. On a **simulator (Linux)**, it defines the exact cores used by the simulation. On a **Windows workstation**, it determines only the number of cores available to ePHASORSIM; specific core assignment is not supported. Individual cores and ranges can be specified using a comma-separated list.

Examples:

* `EPHASOR_THREADS = 3` uses one core.
* `EPHASOR_THREADS = 2,3,5` uses three cores (core `2`, core `3` and core `5`).
* `EPHASOR_THREADS = 3-6` uses four cores (core `3`, core `4`, core `5` and core `6`).

{% hint style="danger" %}
Use cores `2` and above in `EPHASOR_THREADS`. Cores `0` and `1` are reserved by RT-LAB and should not be assigned to ePHASORSIM. Also avoid assigning cores that are already used by drivers, I/O tasks, ARTEMiS, or other real-time features.
{% endhint %}
{% endstep %}

{% step %}

### Connect the block interfaces and run simulation

With the simulation settings now defined, the model is ready to run.

Before starting the simulation, ensure that all **ePHASORSIM Solver** block ports are connected according to the I/O pins defined in the Excel configuration file. Any required inputs and outputs must be connected to the surrounding Simulink environment.

Once the connections have been verified, save the Simulink model and start the simulation.

* For **offline simulation**, run the model directly from Simulink.
* For **real-time simulation**, build, load, and execute the model from **RT-LAB** on the simulator.
  {% endstep %}
  {% endstepper %}

## Performance recommendations

* Start with a **10 ms** phasor time step.
* Use **1 partition** for small models.
* Increase partitions only after confirming performance benefits.
* Allocate dedicated CPU cores for large real-time models.
* Monitor execution margins after changing time step, partitions, or thread allocation.


---

# 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/rt-lab/model-and-simulation/phasor-domain-with-ephasorsim/set-phasor-settings-run-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.
