> 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/power-systems-with-artemis/microgrid-control-and-ders.md).

# Microgrid Control & DERs

The **Microgrid Testbed Library** is a MATLAB-Simulink control library for managing distributed energy resources (DERs) in microgrid systems. It includes controllers for active and reactive power, curtailment management, load management, and protection functions, as well as configurable grid-support functions such as Volt-Var and Droop. The library allows simulation and testing of microgrid operation with both grid-connected and islanded conditions and supports real-time prototyping with DERs and loads. The library is included in the **ARTEMiS toolbox**.

## **Requirements**

### Simulator license

[Verify that an active RT-LAB license](https://www.opal-rt.com/docs/rt-lab/licensing-reference/simulator-license.md) with the following feature is installed on the simulator to execute simulations with Microgrid Testbed blocks on that simulator:

<table><thead><tr><th width="209.63629150390625">Feature Name</th><th width="183.5455322265625">Required Status</th><th>Description</th></tr></thead><tbody><tr><td>OP1420</td><td>enabled</td><td>microgrid control library</td></tr></tbody></table>

### Workstation license

[Verify that an active RT-LAB license](https://www.opal-rt.com/docs/rt-lab/licensing-reference/workstation-license.md) with the following feature is installed on the **workstation to execute simulations with Microgrid Testbed blocks in Simulink** and on a simulator:

<table><thead><tr><th width="209.63629150390625">Feature Name</th><th width="183.5455322265625">Required Status</th><th>Description</th></tr></thead><tbody><tr><td>OP1420</td><td>enabled</td><td>microgrid control library</td></tr></tbody></table>

## **Microgrid example model**

The library comes with a **special example model** demonstrating a complete microgrid system, which can be used for simulation, testing, and real-time prototyping.

<figure><img src="https://96827845-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNRdpSk8kjn20gXAexnt6%2Fuploads%2Fgit-blob-a3eac097fba42313599cba5a5f38cb7948b9c24b%2Fmicrogris-example-project.png?alt=media" alt=""><figcaption><p>Microgrid Model</p></figcaption></figure>

<figure><img src="https://96827845-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNRdpSk8kjn20gXAexnt6%2Fuploads%2Fgit-blob-83d3f69b2a27f337dc661c17b888f90f672101dd%2Fmicrogrid-controller-example-project.png?alt=media" alt=""><figcaption><p>Microgrid Controller</p></figcaption></figure>

The example model implements a microgrid comprising four DERs, including a [Photovoltaic Generation System](https://www.opal-rt.com/docs/rt-lab/simulink-blocks-reference/microgrid-testbed-library/photovoltaic-generation-system.md), a [Type-3 Wind Turbine](https://www.opal-rt.com/docs/rt-lab/simulink-blocks-reference/microgrid-testbed-library/type-3-wind-turbine.md), a [Diesel Generator](https://www.opal-rt.com/docs/rt-lab/simulink-blocks-reference/microgrid-testbed-library/diesel-generator.md), and a [Battery Energy Storage System (BESS)](https://www.opal-rt.com/docs/rt-lab/simulink-blocks-reference/microgrid-testbed-library/battery-energy-storage-system-bess.md), all of which are connected to a common 6.6 kV line-to-line bus through step-up transformers and breakers. The bus is connected to an infinite AC grid via a PCC breaker, emulating an external network. The microgrid also includes three types of loads: Critical Load, Sheddable Load, and Demand Response Load.

The model employs a suite of controllers to manage DER operation and overall microgrid behavior:

* [Active Power Controller](https://www.opal-rt.com/docs/rt-lab/simulink-blocks-reference/microgrid-testbed-library/active-power-controller.md): Generates power references for DERs, manages curtailment, load shedding, and grid import/export.
* [BESS Management:](https://www.opal-rt.com/docs/rt-lab/simulink-blocks-reference/microgrid-testbed-library/bess-management.md) Aggregates all components contributing to the BESS active power reference.
* [Reactive Power Controller](https://www.opal-rt.com/docs/rt-lab/simulink-blocks-reference/microgrid-testbed-library/reactive-power-controller.md): Generates reactive power references for DERs and distributes them proportionally based on DER reserve power.
* [Islanded Controller](https://www.opal-rt.com/docs/rt-lab/simulink-blocks-reference/microgrid-testbed-library/islanded-controller.md): Manages transitions between grid-connected and islanded modes, minimizing voltage and current deviations, and compensating for PCC phase shifts.
* [Curtailment Management](https://www.opal-rt.com/docs/rt-lab/simulink-blocks-reference/microgrid-testbed-library/curtailment-management.md): Distributes curtailment power among DERs and disconnects them if limits are exceeded.
* [Load Management Controller](https://www.opal-rt.com/docs/rt-lab/simulink-blocks-reference/microgrid-testbed-library/load-management-controller.md): Regulates active power flow through the PCC in grid-connected mode; user-adjustable settings are available.

### **DERs block settings**

* [Photovoltaic Generation System](https://www.opal-rt.com/docs/rt-lab/simulink-blocks-reference/microgrid-testbed-library/photovoltaic-generation-system.md): Receives P\_ref and Q\_ref from microgrid controllers; user-defined inputs include Irradiance (Ir\_ref, W/m²) and Temperature (T\_ref, °C), set to 500 and 25 by default. Curtail enable comes from **Curtailment Management**.
* [Type-3 Wind Turbine](https://www.opal-rt.com/docs/rt-lab/simulink-blocks-reference/microgrid-testbed-library/type-3-wind-turbine.md): Receives P\_ref and Q\_ref from controllers; Wind Speed reference is 12 m/s by default, adjustable to time-varying signals. Curtail enable from **Curtailment Management**.
* [Diesel Generator](https://www.opal-rt.com/docs/rt-lab/simulink-blocks-reference/microgrid-testbed-library/diesel-generator.md) and [Battery Energy Storage System (BESS)](https://www.opal-rt.com/docs/rt-lab/simulink-blocks-reference/microgrid-testbed-library/battery-energy-storage-system-bess.md): Receive P\_ref and Q\_ref from controllers; user-defined voltage reference (V\_ref) is 1 pu.
* PCC References: Active and reactive power references at the PCC are initially set to zero (no injection to external AC grid).

### **Loads**

* **Critical Load:** Must be fully serviced (set to 40 kW in the example).
* **Sheddable Load:** Can be fully shed if needed (set to 20 kW in the example).
* **Demand Response Load:** Adjustable through DR measures (set to 0 kW in the example).

Load references can be constant or time-varying profiles.

### **Simulation demonstration**

The simulation uses a 5 µs time step over 35 seconds. The model demonstrates active and reactive power generation by DERs, load consumption, and grid interaction. Key observations include:

* Microgrid stabilizes and synchronizes with the external AC grid in \~10 seconds at 50 Hz.
* Diesel Generator provides inertia and frequency support for the microgrid.
* DERs actively regulate voltage and reactive power while interacting with the external AC grid.
* Additional signals such as battery state-of-charge, curtailment activation, load shedding, islanding status, and PCC power flow are monitored.

Figures below illustrate:

* Active power of DERs and loads, and PCC power flow.
* Reactive power of DERs, voltage levels, and PCC reactive power.
* Battery state-of-charge, curtailment, demand response signals, load status, islanding status, and external AC grid interaction.

<figure><img src="https://96827845-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNRdpSk8kjn20gXAexnt6%2Fuploads%2Fgit-blob-2363e1a74356b936269577d123d9449a119ccd91%2Fsimulation-example-results.png?alt=media" alt=""><figcaption><p>Active power of DERs and loads, and PCC power flow</p></figcaption></figure>

<figure><img src="https://96827845-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNRdpSk8kjn20gXAexnt6%2Fuploads%2Fgit-blob-a4d458a8bb2bafa7f18133702e1d8a54e57e60f8%2Fsimulation-example-results2.png?alt=media" alt=""><figcaption><p>Reactive power of DERs, voltage levels, and PCC reactive power</p></figcaption></figure>

<figure><img src="https://96827845-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNRdpSk8kjn20gXAexnt6%2Fuploads%2Fgit-blob-812246d46a3bc9214e993ac3c8a9565c505cfe6f%2Fsimulation-example-results3.png?alt=media" alt=""><figcaption><p>Battery state-of-charge, curtailment, demand response signals, load status, islanding status, and external AC grid interaction</p></figcaption></figure>

This example model provides a comprehensive demonstration of microgrid operation under both grid-connected and islanded conditions and can be used as a reference for designing and testing new microgrid control strategies.


---

# 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/power-systems-with-artemis/microgrid-control-and-ders.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.
