Combing GFL and GFM Inverters into one Inverter using smart inverter library

I am using Hypersim to model GFL and GFM using the smart inverter library. But I want to combine them into one inverter with both GFL and GFM control. How can I do that?

This is a common goal for microgrid and DER applications where an inverter needs to operate grid-connected (GFL) and transition to island mode (GFM). The Smart Inverter Library provides the building blocks, but a dual-mode inverter requires some custom assembly. Here’s how to approach it.

Why they’re separate in the library
GFL and GFM are fundamentally different control philosophies:

Grid Following (GFL)
Grid Forming (GFM)
Nature
Current source (follows grid)
Voltage source (forms grid)
Synchronization
PLL-based (locks to grid V/F)
Self-synchronized (droop/VSG)
Output reference
Current reference → duty ratio
Voltage reference (Uref)
Use case
Grid-connected, power injection
Islanded, voltage/frequency regulation
The library provides these as separate modular block chains — not a single pre-built dual-mode inverter. But the modular design makes it possible to build one.
Approach: dual control chains + mode-selection logic
Architecture:
┌─────────────────────┐
│ Mode Selector │
│ (grid status / │
│ external signal) │
└────────┬────────────┘

┌──────────────┼──────────────┐
▼ ▼
┌─────────────────┐ ┌─────────────────┐
│ GFL Control │ │ GFM Control │
│ Chain │ │ Chain │
└────────┬────────┘ └────────┬────────┘
│ │
└──────────┬───────────────────┘

┌─────────────────┐
│ MUX / Switch │
│ (selects Uref) │
└────────┬────────┘

┌─────────────────┐
│ Single Inverter│
│ (2L 3-phase) │
└─────────────────┘
Step-by-step implementation
Step 1 — Use one physical inverter plant model
Keep a single two-level three-phase inverter (average or switching model) with its LC filter. Both control chains will share this same power stage.
Step 2 — Instantiate both control chains in parallel
From the Smart Inverter Library, place both sets of blocks reading from the same voltage/current sensors:
GFL chain: Signal Conditioning → Secondary Control → Primary Control → Wave Reference
GFM chain: Signal Conditioning → Primary Control → Inner Control Loop → Reference Generation

Step 3 — Build mode-selection logic
Use standard logic/math blocks to select which chain drives the inverter’s Uref:
If (Mode == GFM):
Uref = GFM_Reference_Generation_output
Else:
Uref = GFL_Wave_Reference_output
The mode signal can be driven by:
An external digital input (manual switch)
An islanding detection algorithm (loss of grid → switch to GFM)
A PCC voltage/frequency threshold

Step 4 — Handle the transition (the hard part)
Seamless mode switching is the critical design challenge. Without proper handling, you’ll get large transients or loss of synchronization.
Transition
Challenge
Mitigation
GFL → GFM (grid loss)
Sudden shift from current-source to voltage-source
Pre-initialize GFM references to match current operating point (V, θ, ω) at the moment of switching
GFM → GFL (grid reconnect)
Must resynchronize with grid
PLL must re-lock before switching. Use a synch-check condition
Practical tips for smooth transitions:
Keep the GFM Primary Control running in tracking mode during GFL operation — internal states (angle, frequency) stay warm
Similarly, keep the GFL PLL running during GFM mode so it’s ready to resynchronize
Use a ramp transition (blend outputs over 1–2 cycles) rather than a hard switch to reduce discontinuities
Initialize the inactive chain’s integrators to the active chain’s operating point

Step 5 — Use the existing GFM + GFL interaction example as a reference
Open the example GFM_GFL_DER_Interaction from the Renewable Energy examples category in HYPERSIM. This model has both GFL and GFM DERs in the same microgrid. You can:
Study how each chain is configured
Extract the control blocks from one GFL DG and one GFM DG
Reconnect both to a single inverter plant model with the switching logic above

What the library does NOT provide out of the box
No pre-built dual-mode block — you must build the switching/transition logic yourself
No built-in islanding detection — implement your own (rate-of-change-of-frequency, voltage vector shift, or passive methods)
No automatic state initialization on mode change — you must explicitly pass the current operating point between chains

Where to find the blocks
All relevant blocks are documented in the HYPERSIM helpfile under:
Control Smart Inverter → overview of all GFL and GFM blocks
Examples → Renewable Energy → GFM and GFL DER Interaction example
Each individual block (GFM Inner Control Loop, GFL Secondary Control, etc.) has its own helpfile page with input/output descriptions

Access these from within HYPERSIM via Help → Help Topics → Smart Inverter Library.
Summary
The library gives you all the pieces — combining them into a dual-mode inverter requires:
Both control chains feeding one physical inverter
A mode-selection MUX switching the Uref output
Transition logic with state initialization and ramp blending
An islanding detection trigger or external mode signal

This is an advanced but achievable application of the library. Start from the GFM_GFL_DER_Interaction example, extract the blocks, and build your switching logic on top.

@Parija Thank you for your help. I will try it.

I have built GFL and GFM for one inverter as shown below. Could you please help me check whether it is OK?
Thank you.

Hi Vincent

Thank you for sharing your GFL/GFM inverter model.

Since it is difficult to properly validate the model based only on an image and short text description, I recommend contacting the OPAL-RT Support Center for your region. They will be able to review the model details more accurately and provide guidance specific to your setup.

Another suggestion would be to upload the model to the Community platform with the help of the support team, if possible. This would allow other users and experts to review it more effectively and contribute suggestions for improvement.

Thanks again for sharing, and we look forward to seeing more details on the model. :slight_smile:

@Parija Thank you. I have already post the hypersim model in the OPAL-RT community. You can found the hypersim model. Thank you.