EMS Subsystem Simulation Model
This document specifies the equivalent functional models for the Energy Management System (EMS) subsystem. It covers the control blocks required by the Spain EMS requirements (REQ-EMS-01 through REQ-EMS-04 and REQ-EMS-07) in a human-readable format suitable for understanding and implementing in software.
(Note: REQ-EMS-05, REQ-EMS-06, and REQ-EMS-08 are excluded from this simulation model scope.)
(For automated code generation, refer to 04_ems_simulation_model_ai.md.)
Terms and Abbreviations
| Term / Abbreviation | Definition |
|---|---|
| EMS | Energy Management System |
| PCC | Point of Common Coupling (where plant connects to the grid) |
| PCS | Power Conversion System (BESS inverter/rectifier) |
| BMS | Battery Management System |
| PV | Photovoltaic Solar Generator |
| SoC | State of Charge (battery capacity ratio, 0.0 to 1.0) |
| P | Active Power (Watts or MW) |
| Q | Reactive Power (VAr or MVAr) |
| V | Voltage magnitude (Volts or kV) |
| f | Grid Frequency (Hz) |
| dP/dt | Rate of change of active power (MW/s or MW/min — ramp rate) |
| TSO/DSO | Transmission/Distribution System Operator (Grid regulator) |
| REQ-EMS | EMS Requirement identifier from Spain EMS specification |
System Overview
The EMS coordinates multiple generation and storage assets to achieve a desired power profile at the PCC, as commanded by the grid operator (TSO/DSO). It reads measurements from the grid and each asset, applies ramp and compliance constraints, and dispatches setpoints to each asset controller.
EMS Block Diagram
flowchart TD
TSO["TSO/DSO\n(Remote Operator)"]
subgraph EMS ["EMS Controllers"]
ModeMgr["1. Mode & Compliance Manager\n(REQ-EMS-01/02/07)"]
PCCLoop["2. PCC Tracking Controller\n(REQ-EMS-01/02)"]
RampLim["3. Ramp & Limit Manager\n(REQ-EMS-03)"]
Alloc["4. PV-Wind-BESS Coordinator\n(REQ-EMS-04)"]
AlarmMgr["5. Alarm & Event Manager\n(REQ-EMS-07)"]
end
subgraph MEAS ["Measurements (Inputs)"]
PCCMeas["PCC Meter\n(P, Q, V, f)"]
BESSmeas["BESS BMS\n(SoC, P_limits, Alarms)"]
PVmeas["PV Measurements\n(P_pv, availability)"]
Windmeas["Wind Measurements\n(P_wind, availability)"]
end
subgraph ASSETS ["Controllable Assets (Outputs)"]
PVInv["PV Inverter\n(P_pv_setpoint)"]
WindCtrl["Wind Controller\n(P_wind_setpoint)"]
PCSCtrl["BESS PCS\n(P_bess_setpoint)"]
end
TSO -->|"P/Q targets, Mode commands"| ModeMgr
PCCMeas -->|"P_pcc, Q_pcc, V, f"| PCCLoop
BESSmeas -->|"SoC, P_lim_chg, P_lim_dis"| RampLim
BESSmeas -->|"Alarms"| AlarmMgr
ModeMgr -->|"Active mode + targets"| PCCLoop
PCCLoop -->|"Plant-level ΔP response"| RampLim
RampLim -->|"Ramp-limited clipped ΔP"| Alloc
PVmeas -->|"Available P_pv"| Alloc
Windmeas -->|"Available P_wind"| Alloc
Alloc -->|"P setpoint"| PVInv
Alloc -->|"P setpoint"| WindCtrl
Alloc -->|"P setpoint"| PCSCtrl
AlarmMgr -->|"Safe state commands"| ModeMgr
AlarmMgr -->|"Trip/hold triggers"| Alloc
Signal Flow Summary
| Step | Action | Block Responsible |
|---|---|---|
| 1 | Grid operator sends power target | TSO/DSO → Mode Manager |
| 2 | Mode Manager selects P/Q/V/cosphi mode and validates conditions | Mode Manager |
| 3 | PCC Tracking Controller computes required plant ΔP from error | PCC Tracking Controller |
| 4 | Ramp & Limit Manager applies ramp rates and asset caps | Ramp & Limit Manager |
| 5 | Coordinator splits power demand among PV, Wind, and BESS | Coordinator |
| 6 | Setpoints sent to each asset | Coordinator → PCS / PV / Wind |
| 7 | Alarm manager monitors safety and forces fallback if needed | Alarm Manager → Mode Manager |
1. Mode and Compliance Manager (REQ-EMS-01, REQ-EMS-02, REQ-EMS-07)
The Mode Manager is the top-level supervisor. It selects which operating mode the plant runs in, validates that conditions are safe to operate, and manages fallback to a safe state when faults occur.
1.1 Operating Modes
| Mode ID | Mode Name | Controlled Variable | Use Case |
|---|---|---|---|
| MODE_P | Active Power Control | P at PCC | Track a MW setpoint from operator |
| MODE_Q | Reactive Power Control | Q at PCC | Track a MVAr setpoint from operator |
| MODE_PF | Power Factor (cosphi) Control | cosphi at PCC | Maintain a target power factor |
| MODE_V | Voltage Control | V at PCC | Support grid voltage within a band |
| MODE_OFF | Off / Safe State | None | All assets held at zero or minimum output |
| MODE_HOLD | Hold Last | Frozen setpoints | Communications loss or fault, freeze output |
1.2 Mode Transition Logic
The Mode Manager implements a simple state machine:
stateDiagram-v2
[*] --> MODE_OFF : Boot / Startup
MODE_OFF --> MODE_P : Enable command + P_target received
MODE_OFF --> MODE_Q : Enable command + Q_target received
MODE_OFF --> MODE_PF : Enable command + cosphi_target received
MODE_OFF --> MODE_V : Enable command + V_target received
MODE_P --> MODE_Q : Mode change command
MODE_P --> MODE_PF : Mode change command
MODE_P --> MODE_V : Mode change command
MODE_Q --> MODE_P : Mode change command
MODE_PF --> MODE_P : Mode change command
MODE_V --> MODE_P : Mode change command
MODE_P --> MODE_HOLD : Comms loss > timeout
MODE_Q --> MODE_HOLD : Comms loss > timeout
MODE_PF --> MODE_HOLD : Comms loss > timeout
MODE_V --> MODE_HOLD : Comms loss > timeout
MODE_HOLD --> MODE_OFF : Fault confirmed or manual reset
MODE_P --> MODE_OFF : Fault alarm (critical)
MODE_Q --> MODE_OFF : Fault alarm (critical)
MODE_PF --> MODE_OFF : Fault alarm (critical)
MODE_V --> MODE_OFF : Fault alarm (critical)
1.3 Enable Conditions (Pre-flight Checks)
Before accepting any mode other than MODE_OFF, the following must all be TRUE:
- PCC Meter communication OK (data age <
pcc_timeout) - BMS data OK and no critical alarms
- At least one asset is available
- Breaker status = CLOSED (from IED)
- No active
Fault_PCS_Tripor equivalent asset-level trip
1.4 Parameters
| Parameter | Description | Default |
|---|---|---|
comms_loss_timeout |
Seconds before transition to MODE_HOLD | 30 s |
recovery_delay |
Seconds to wait before re-enabling after a fault | 60 s |
P_target |
Active power setpoint from operator (MW). Positive = generation. | 0 MW |
Q_target |
Reactive power setpoint from operator (MVAr) | 0 MVAr |
cosphi_target |
Target power factor | 1.0 |
V_target |
Target PCC voltage magnitude (kV) | Site-specific |
2. PCC Tracking Controller (REQ-EMS-01, REQ-EMS-02)
The PCC Tracking Controller is a closed-loop feedback controller. It reads the actual power at the PCC and computes how much the total plant output must change to meet the setpoint.
2.1 Control Flow
flowchart LR
Ref["Target\n(P_target or Q_target)"]
Meas["PCC Measurement\n(P_pcc or Q_pcc)"]
Sum(("Σ\nerror"))
PI["PI Controller\n(or integrator)"]
Out["Plant ΔP command\n(to Ramp Manager)"]
Ref --> Sum
Meas -->|"(subtracted)"| Sum
Sum --> PI --> Out
2.2 Equations
Error calculation:
P_error = P_target - P_pcc
Proportional-Integral (PI) control output — discrete update at step k:
P_integral[k] = P_integral[k-1] + (P_error[k] * delta_t)
P_plant_cmd[k] = (Kp * P_error[k]) + (Ki * P_integral[k])
Apply the same structure for Q when in reactive power mode.
Anti-Windup: Clamp the integral term to prevent saturation:
P_integral[k] = clamp(P_integral[k], -P_integral_limit, +P_integral_limit)
2.3 Parameters
| Parameter | Description | Default |
|---|---|---|
Kp |
Proportional gain | 0.5 |
Ki |
Integral gain | 0.1 |
delta_t |
Control loop step size (s) | 0.5 s |
P_integral_limit |
Anti-windup clamp on integral term (MW) | Site P_max |
3. Ramp and Limit Manager (REQ-EMS-03)
The Ramp Manager enforces physical and regulatory ramp rate constraints on the plant power command before it reaches the Coordinator. It prevents sudden large steps in output that could destabilize the grid connection.
3.1 Ramp Rate Limiting
The output is not allowed to change faster than the configured ramp rate dP_max_rate (MW/s).
Discrete ramp filter — implement at each step k:
delta_max = dP_max_rate * delta_t
P_plant_ramped[k] = clamp(P_plant_cmd[k], P_plant_ramped[k-1] - delta_max, P_plant_ramped[k-1] + delta_max)
3.2 Constraint Application
After ramp limiting, apply hard power caps:
P_plant_limited = clamp(P_plant_ramped, P_plant_min, P_plant_max)
Where P_plant_max is the effective limit, which is the minimum of:
- Configured site export limit
- Sum of current available PV + Wind capacity
- BMS P_limit_discharge (when in discharge direction)
- BMS P_limit_charge (when in charge direction)
3.3 Parameters
| Parameter | Description | Default |
|---|---|---|
dP_max_rate |
Active power ramp rate limit (MW/s) | 0.1 MW/s |
dQ_max_rate |
Reactive power ramp rate limit (MVAr/s) | 0.1 MVAr/s |
P_plant_max |
Maximum export power (MW) | Site-specific |
P_plant_min |
Minimum power (negative = import, MW) | Site-specific |
4. PV-Wind-BESS Coordinator (REQ-EMS-04)
The Coordinator splits the total plant power command from the Ramp Manager among the three available asset types: PV, Wind, and BESS. It decides how much each asset contributes and whether BESS should charge from excess renewable generation.
4.1 Allocation Strategy Flow
flowchart TD
In["P_plant_limited\n(from Ramp Manager)"]
A{"P_plant_limited\n<= P_pv + P_wind\n(renewables sufficient?)"}
A -->|Yes: Curtail renewables| B["Calculate surplus:\nP_surplus = P_pv_avail + P_wind_avail - P_plant_limited"]
B --> C["Curtail PV and/or Wind:\nP_pv_setpoint < P_pv_avail\nor P_wind_setpoint < P_wind_avail"]
C --> D{"SoC < SoC_charge_trigger\nand P_surplus > 0?"}
D -->|Yes| E["Charge BESS with surplus:\nP_bess_setpoint = +P_surplus (capped by P_lim_chg)"]
D -->|No| F["BESS idle:\nP_bess_setpoint = 0"]
A -->|No: Need all renewables + BESS discharge| G["Use all renewables:\nP_pv_setpoint = P_pv_avail\nP_wind_setpoint = P_wind_avail"]
G --> H["BESS makes up the deficit:\nP_bess_setpoint = -(P_plant_limited - P_pv_avail - P_wind_avail)"]
H --> I["Cap to BMS limit:\nP_bess_setpoint = clamp(P_bess_setpoint, -P_lim_dis, +P_lim_chg)"]
4.2 Allocation Equations
Step 1 — Determine available renewable power:
P_renewable_avail = P_pv_avail + P_wind_avail
Step 2 — Calculate BESS demand:
P_bess_demand = P_plant_limited - P_renewable_avail
If P_bess_demand > 0 → BESS must discharge (Negative setpoint by convention: P_bess_setpoint = -P_bess_demand)
If P_bess_demand < 0 → Renewables exceed demand. Surplus can charge BESS or be curtailed.
Step 3 — Apply BESS limits (from BMS):
P_bess_setpoint = clamp(P_bess_setpoint, -P_limit_discharge, +P_limit_charge)
P_bess_setpoint = clamp(P_bess_setpoint, -S_max_pcs, +S_max_pcs)
Step 4 — Curtail renewables if needed:
P_curtail = P_renewable_avail - (P_plant_limited - P_bess_setpoint)
P_pv_setpoint = P_pv_avail - (P_curtail * pv_curtail_share)
P_wind_setpoint = P_wind_avail - (P_curtail * (1 - pv_curtail_share))
4.3 SoC-Based Charge Triggers
| Condition | Action |
|---|---|
SoC < SoC_charge_trigger AND P_surplus > 0 |
Charge BESS with available surplus |
SoC > SoC_discharge_disable |
Do not dispatch BESS for discharge |
SoC < SoC_discharge_minimum |
Force BESS to idle (protect battery) |
4.4 Parameters
| Parameter | Description | Default |
|---|---|---|
SoC_charge_trigger |
SoC below which BESS charges from surplus | 0.8 |
SoC_discharge_disable |
SoC above which BESS is not dispatched | 0.95 |
SoC_discharge_minimum |
SoC below which BESS is forced to idle | 0.1 |
pv_curtail_share |
Fraction of curtailment applied to PV (rest to Wind) | 0.5 |
5. Alarm and Event Manager (REQ-EMS-07)
The Alarm Manager monitors all incoming signals for fault conditions. When a critical alarm fires, it instructs the Mode Manager to transition to a safe state.
5.1 Safe State Behavior
| Condition | Safe State Action |
|---|---|
| BMS critical alarm | Force BESS setpoint = 0. Set asset available = FALSE. |
| PCC breaker open | Transition Mode Manager to MODE_OFF. |
| Asset comms loss > timeout | Transition to MODE_HOLD (freeze last setpoints). |
| Over/under frequency (f) | Activate frequency response mode or MODE_OFF. |
| Over/under voltage at PCC | Activate voltage support or MODE_OFF. |
5.2 Alarm Priority Levels
| Priority | Level Name | Required Action |
|---|---|---|
| 1 | Critical | Immediate safe state, log event with timestamp |
| 2 | Warning | Alert operator, record in event log, no immediate action |
| 3 | Advisory | Record in log for diagnostics, no action required |
5.3 Monitored Alarms
| Alarm ID | Signal | Condition | Priority |
|---|---|---|---|
| ALM-01 | BMS alarm flag | Any BMS critical alarm = TRUE | Critical |
| ALM-02 | PCC breaker status | Breaker = OPEN unexpectedly | Critical |
| ALM-03 | PCC meter comms | Data age > pcc_timeout |
Critical |
| ALM-04 | Asset comms (PCS/PV/Wind) | Data age > asset_timeout |
Warning |
| ALM-05 | Grid frequency | f < f_min or f > f_max |
Critical |
| ALM-06 | SoC low | SoC < SoC_discharge_minimum |
Warning |
| ALM-07 | SoC high | SoC > SoC_charge_disable |
Warning |
5.4 Parameters
| Parameter | Description | Default |
|---|---|---|
pcc_timeout |
PCC data age limit before alarm (s) | 5 s |
asset_timeout |
Asset comms timeout (s) | 10 s |
f_min |
Minimum normal frequency (Hz) | 49.0 Hz |
f_max |
Maximum normal frequency (Hz) | 51.0 Hz |
SoC_charge_disable |
SoC above which charging is blocked | 0.95 |
6. Interface Summary (Simulation Signals)
The table below summarises the key simulation signals at each EMS block boundary.
| Interface | From → To | Signals | Rate |
|---|---|---|---|
| IF-01 | PCC Meter → PCC Tracking Controller | P_pcc (MW), Q_pcc (MVAr), V_pcc (kV), f (Hz) | 0.5–1 s |
| IF-02 | BMS → Ramp Manager & Coordinator | SoC (0–1), P_lim_chg (MW), P_lim_dis (MW), alarms | 1–5 s |
| IF-03 | PV Measurement → Coordinator | P_pv_avail (MW), availability (bool) | 1 s |
| IF-04 | Wind Measurement → Coordinator | P_wind_avail (MW), availability (bool) | 1 s |
| IF-05 | Mode Manager → PCC Tracking Controller | Active mode, P_target (MW), Q_target (MVAr) | On change |
| IF-06 | PCC Tracking Controller → Ramp Manager | P_plant_cmd (MW) | 0.5 s |
| IF-07 | Ramp Manager → Coordinator | P_plant_limited (MW) | 0.5 s |
| IF-08 | Coordinator → PCS | P_bess_setpoint (MW) Positive=Charge | 0.5–2 s |
| IF-09 | Coordinator → PV Inverter | P_pv_setpoint (MW) | 0.5–2 s |
| IF-10 | Coordinator → Wind Controller | P_wind_setpoint (MW) | 0.5–2 s |
| IF-11 | Alarm Manager → Mode Manager | Alarm level, fault flags | Event-driven |
7. Calibratable Parameters — Summary Table
| Block | Parameter | Description | Default |
|---|---|---|---|
| Mode Manager | comms_loss_timeout |
Hold mode trigger (s) | 30 s |
| Mode Manager | recovery_delay |
Re-enable delay after fault (s) | 60 s |
| PCC Controller | Kp |
Proportional gain | 0.5 |
| PCC Controller | Ki |
Integral gain | 0.1 |
| PCC Controller | delta_t |
Control cycle period (s) | 0.5 s |
| Ramp Manager | dP_max_rate |
Active power ramp limit (MW/s) | 0.1 |
| Ramp Manager | dQ_max_rate |
Reactive power ramp limit (MVAr/s) | 0.1 |
| Coordinator | SoC_charge_trigger |
BESS charge from surplus threshold | 0.8 |
| Coordinator | SoC_discharge_minimum |
BESS forced idle threshold | 0.1 |
| Coordinator | pv_curtail_share |
Fraction of curtailment on PV | 0.5 |
| Alarm Manager | pcc_timeout |
PCC data staleness limit (s) | 5 s |
| Alarm Manager | f_min |
Min grid frequency (Hz) | 49.0 |
| Alarm Manager | f_max |
Max grid frequency (Hz) | 51.0 |
8. Requirements Traceability
| REQ ID | Requirement Intent | Covered By |
|---|---|---|
| REQ-EMS-01 | Active power control at PCC | Sections 1, 2, 3, 4 |
| REQ-EMS-02 | Reactive power / cosphi / voltage control at PCC | Sections 1 (modes), 2 (Q control) |
| REQ-EMS-03 | Ramp rate management | Section 3 |
| REQ-EMS-04 | PV-BESS coordination | Section 4 |
| REQ-EMS-07 | Fault behavior / safe state | Section 5 |
| ~~REQ-EMS-05~~ | ~~Telemeasurement variables~~ | Excluded from this model |
| ~~REQ-EMS-06~~ | ~~Update rate and continuity~~ | Excluded from this model |
| ~~REQ-EMS-08~~ | ~~Logging and traceability~~ | Excluded from this model |