Download as pdf or txt
Download as pdf or txt
You are on page 1of 60

Modelling and simulation of integrated

energy systems

Edmund Widl, Peter Palensky, Jan Sören Schwarz


ERIGrid 2.0 / SINERGY / RESili8 Online Training Lecture Part 1

© The ERIGrid 2.0 Consortium


EU H2020 Programme GA No. 870620
Outline

• Part A: Introduction to co-simulation


→ What is co-simulation?
→ Why is co-simulation relevant for the assessment of future energy systems?

• Part B: Co-simulation with mosaik


→ Basics of using mosaik for co-simulation

• Part C: Example multi-energy network application


→ Assessment of a coupled thermo-electrical network

© The ERIGrid 2.0 Consortium


EU H2020 Programme GA No. 870620
Part A: Introduction to co-simulation

© The ERIGrid 2.0 Consortium


EU H2020 Programme GA No. 870620
Decarbonization of our Energy System
control, roles,
stability
operations stakeholders, relations

€€

© The ERIGrid 2.0 Consortium


EU H2020 Programme GA No. 870620
The Future Energy Systems Digital

Decarbonized,
renewable
Integrated

Distributed
© The ERIGrid 2.0 Consortium
EU H2020 Programme GA No. 870620 ERIGrid 2.0 MOOC: Multi-Energy Networks - Part I DD.MM.YYYY 5
Planning and operations

▪ Complex and large systems


▪ Difficult Decisions
⚫ Multi-disciplinary
⚫ Uncertainty
⚫ Complexity vs. time constraints
⚫ Multi-stakeholder
⚫ “Back-of-an-envelope”...?
© The ERIGrid 2.0 Consortium
EU H2020 Programme GA No. 870620 ERIGrid 2.0 MOOC: Multi-Energy Networks - Part I Image: NREL
DD.MM.YYYY 6
Support by numerical models
Digital Twin
⚫ During design phase
operate System Description
− Dimensioning MGMT

− Stability Data handling

− Interoperability check
Application environmental process
⚫ Support of operations data measurement

− Sanity/safety check
Environment
− Digital Twins act

Real System
⚫ Post-mortem forensics perceive

© The ERIGrid 2.0 Consortium


EU H2020 Programme GA No. 870620 MGMT: Management
Describing the future Energy Network(s)

physical world roles/behavior


continuous models game theory models
energy generation, transport, distribution, agents acting on behalf of a
consumption, etc. customer, market players, etc.
cyber-
physical
energy
information technology
system aggregate/stochastic
discrete models statistical models
controllers, communication infrastructure, weather, macro-view of many
software, etc. individual elements, etc.

© The ERIGrid 2.0 Consortium


EU H2020 Programme GA No. 870620
Future Energy System is...

⚫ Cyber-physical (discrete+continuous)
⚫ Multi-physical (heat, power, gas,…)
⚫ Multi-timescale (power electronics, hydraulics,…)
⚫ Complex (hidden states, emerging behavior)
⚫ Probabilistic (rare high impact events)

Good question, Einstein ...


→ how to model…?

© The ERIGrid 2.0 Consortium


EU H2020 Programme GA No. 870620
Options to model/simulate
⚫ (1) Squeeze all submodels into one tool, language,
solver, method
− n-1 submodels in wrong language
− Tedious, Error prone
− Brutal simplifications
⚫ (2) Universal tool
− Universal language, solver, etc.
− Performance problems
⚫ (3) Combine specialized languages, solvers, tools?

© The ERIGrid 2.0 Consortium


EU H2020 Programme GA No. 870620
Connecting models/tools!
Simulated system
Energy Market Simulator
⚫ Combine numerical
models and run solvers Car
Usage Communication
Network
Distribution
Grid
Simulator
concurrently Simulator Simulator

Power
⚫ Solve collaboratively Battery
Simulator
Electronics/
Controls
Simulator
⚫ Multi-disciplinary,
connected problems and
teams possible
⚫ “Co-Simulation”

© The ERIGrid 2.0 Consortium Real system


EU H2020 Programme GA No. 870620
Real-time Co-Simulation

⚫ Run in real-time (not faster,


not slower)
⚫ Implicit synchronization
⚫ Coupled (physical) variables
⚫ In the loop
− Controller
− Power HW
− People
− Software

© The ERIGrid 2.0 Consortium


Source: RTDS Technologies, “Real time digital simulation: Modelling renewable energy applications,” Feb. 2018.
EU H2020 Programme GA No. 870620
RT: Ancillary Services from Hydrolyzers

EMT system model

North Netherlands (year 2030)

© The ERIGrid 2.0 Consortium


EU H2020 Programme GA No. 870620
Non-real time: Co-Simulation Algorithm

⚫ Initialize simulators Sim 1 Sim 2 Sim 3 Sim 4

Solver
S S S
⚫ Exchange variables Model M M M

⚫ Sync time stepping


stepping variables

⚫ User interaction Co-Simulation Algorithm

parameters, start/stop results

User interface

© The ERIGrid 2.0 Consortium


EU H2020 Programme GA No. 870620
Co(upled) Simulation Workflow
Scenario Optimizer

⚫ Multiple simulators Initial states


create

Strategy
Parameters
Utility function
⚫ Multiple models u time series

− Coupled DAEs Scripting


Engine
⚫ How to link/sync? init result

⚫ Scenario Handling? Co-Simulation


y u
Solver Solver
FMU u y FMU
⚫ Interfaces? Model Model

y u y u
y u
Solver
FMU
u Model y

© The ERIGrid 2.0 Consortium


EU H2020 Programme GA No. 870620
Synchronization

⚫ Sync points = Simulator 1

Macro steps t

⚫ Exchange
variables
Simulator 2 t

Macro Micro
time step time step Data exchange

© The ERIGrid 2.0 Consortium


EU H2020 Programme GA No. 870620
Coupling principles

⚫ Explicit coupling exchanges data


at every external step once
⚫ Implicit coupling iterates each
external step until the system
converges
⚫ # external steps determines
error

© The ERIGrid 2.0 Consortium


EU H2020 Programme GA No. 870620
Co-Simulation Bottom Line

⚫ Coupled, coordinated simulators


⚫ Multi-everything possible...
⚫ RT co-sim vs. non-RT co-sim
⚫ Scenario handling?
⚫ Performance?

© The ERIGrid 2.0 Consortium


EU H2020 Programme GA No. 870620
Part B: Co-simulation with mosaik

© The ERIGrid 2.0 Consortium


EU H2020 Programme GA No. 870620
Co-simulation framework mosaik
▪ Main features
– Integration and re-use of
heterogeneous simulation
components
– Specification of simulation scenarios
– Coordination of data exchange and
scheduling
– Discrete time and discrete event
simulation
▪ Open source (LGPL): gitlab.com/mosaik
▪ Documentation: mosaik.readthedocs.io
© The ERIGrid 2.0 Consortium
EU H2020 Programme GA No. 870620 20
Mosaik ecosystem

▪ Simulation models
▪ Interfaces for simulation tools
(e.g., pandapower, PowerFactory)
▪ Wrappers for programming
languages (e.g., Java)
▪ Wrappers for standard interface
(e.g., fmi or OPC UA)
▪ Visualization and data storage
(e.g., HDF5, Influx+Grafana)

© The ERIGrid 2.0 Consortium


EU H2020 Programme GA No. 870620 21
Mosaik architecture
Part of mosaik

Provided by user
TCP
Connection Component/ Implemented
by
Sim-API
Simulator
User-defined
Sim- Component Connection
Model
Mosaik Core
Manager Interface
New integrated
Calls simulator

Scheduler

Executable co-
simulation setup
Calls
Scenario
Scenario-API
Implements Script

© The ERIGrid 2.0 Consortium


EU H2020 Programme GA No. 870620 22
Component API of mosaik

• Low-level API: Every tool


supporting TCP-sockets and JSON

• High-level API: Several easier


solutions for specific tools
• E.g., create a subclass of
mosaik_api.Simulator

© The ERIGrid 2.0 Consortium


EU H2020 Programme GA No. 870620 23
23
Component API of mosaik

© The ERIGrid 2.0 Consortium


EU H2020 Programme GA No. 870620 24
Meta data returned by init()
{ Simulator’s type:
'api_version': 'x.y‘,
• Time-based: Traditional mosaik 2 simulator with
'type': 'time-based'|'event-based'|'hybrid', self-stepping and persistent data
'models': {
• Event-based: Triggered by all attributes and non-
'ModelName': { persistent data
'params': ['param_1', ...],
• Hybrid: Attribute lists within ‘trigger’ and ‘non-
'attrs': ['attr_1', ...], persistent’ specify the behavior
'trigger': ['attr_1', ...],
'non-persistent': ['attr_2', ...],
Triggering attributes (optional):
}, • simulator will be stepped automatically as soon as
there’s new data available for this attribute
...
}, Non-persistent or transient attributes (optional):
} • data of these attributes is only valid for a single
time step
© The ERIGrid 2.0 Consortium
EU H2020 Programme GA No. 870620 25
Component API of mosaik

© The ERIGrid 2.0 Consortium


EU H2020 Programme GA No. 870620 26
Scheduling/Synchronization

▪ Time-based
self-stepping
Persistent output Superdense time / Same time loop:

▪ Event-based / hybrid

Triggered by
available data Data for future
time step

© The ERIGrid 2.0 Consortium


EU H2020 Programme GA No. 870620 27
Mosaik architecture
Part of mosaik

Provided by user
TCP
Connection Component/ Implemented
by
Sim-API
Simulator
User-defined
Sim- Component Connection
Model
Mosaik Core
Manager Interface
New integrated
Calls simulator

Scheduler

Executable co-
simulation setup
Calls
Scenario
Scenario-API
Implements Script

© The ERIGrid 2.0 Consortium


EU H2020 Programme GA No. 870620 28
Scenario API

▪ 1. Provide addresses of simulators to mosaik


import mosaik • Executable Python script

sims = {grid: Python, • Presented in pseudo code


house: Java,
PV: MATLAB,
control: Python}

world = mosaik.World(sims)

© The ERIGrid 2.0 Consortium


EU H2020 Programme GA No. 870620 29
Scenario API

▪ 2. Start simulator processes


gsim = world.start(grid) Simulator: Programm which
controls models of a specific
hsim = world.start(house) type or acts as an interface
to external tools (e.g.
pvsim = world.start(PV)
pandapower, HDF5, …)
csim = world.start(control)

© The ERIGrid 2.0 Consortium


EU H2020 Programme GA No. 870620 30
Scenario API

▪ 3. Instantiate model entities & parameterize


grid =
gsim.create(gridmodel,
param=topology)

houses =
hsim.create(housemodel, 4)

pvs =
pvsim.create(pvmodel, 2,
param=size)

ctrl =
csim.create(MAScontrol)

© The ERIGrid 2.0 Consortium


EU H2020 Programme GA No. 870620 31
Scenario API

▪ 4. Connect models via dataflow


connect(houses, grid,
‘active power’)

connect(pvs, grid,
‘active power’)

connect(ctrl[1&2],
houses[1&2],
‘setpoint’)

connect(ctrl[3&4], pvs,
‘setpoint’)

world.run(3600) Execute!

© The ERIGrid 2.0 Consortium


EU H2020 Programme GA No. 870620 32
Demo
▪ Tutorials as JupyterLab:
https://gitlab.com/mosaik/examples/mosaik-tutorials-on-binder

▪ Tutorials in Documentation:
https://mosaik.readthedocs.io/en/latest/tutorials

▪ More Demos:
https://gitlab.com/mosaik/examples

© The ERIGrid 2.0 Consortium


EU H2020 Programme GA No. 870620 33
Summary
▪ Integration and re-use of heterogeneous
simulation components
▪ Flexible specification of simulation scenarios
Code:
▪ Coordination of data exchange and
https://gitlab.com/mosaik
scheduling
▪ Discrete time and discrete event simulation Documentation:

▪ Open source (LGPL) https://mosaik.readthedocs.io/

▪ Extensive ecosystem of models, interfaces Get in contact:


and wrappers Mailing List: mosaik-users@lists.offis.de
Direct mail: mosaik@offis.de
Open issues in GitLab
© The ERIGrid 2.0 Consortium
EU H2020 Programme GA No. 870620 34
Part C: Example multi-energy network application

© The ERIGrid 2.0 Consortium


EU H2020 Programme GA No. 870620
Example Multi-Energy Network Application (1/5)

▪ system configuration overview:


– electrical network heat pump tank consumer

– thermal network e heat control voltage control


consumer

– consumers e t.
heat

– generation units grid

e t.

– power-to-heat facility power


grid

▪ simple on purpose: focus on


concept and use of co-simulation
for multi-energy systems
© The ERIGrid 2.0 Consortium
EU H2020 Programme GA No. 870620 ERIGrid 2.0 MOOC: Multi-Energy Networks - Part III 36
Example Multi-Energy Network Application (2/5)

▪ electrical network:
– 2 consecutive lines (0.3 km each) heat pump tank consumer
consumer
e heat control voltage control

– connected to external grid


e t.
heat
grid

▪ thermal network: e t.
power
grid
– 3 main consecutive pipes (supply
and return, 0.5 km each)
– connected to external grid

© The ERIGrid 2.0 Consortium


EU H2020 Programme GA No. 870620 ERIGrid 2.0 MOOC: Multi-Energy Networks - Part III 37
Example Multi-Energy Network Application (3/5)

▪ consumers:
– 2 consumers connected to both heat pump tank consumer
consumer
networks e heat control voltage control

– aggregated loads (electrical and e t.


heat
thermal) of an urban quarter grid

e t.
power
grid
▪ generation units:
– 2 PV systems with 150 kWel, peak
and 50 kWel, peak

© The ERIGrid 2.0 Consortium


EU H2020 Programme GA No. 870620 ERIGrid 2.0 MOOC: Multi-Energy Networks - Part III 38
Example Multi-Energy Network Application (4/5)

▪ power-to-heat facility
– heat pump and hot water storage tank
heat pump tank consumer
– couples both networks e heat control voltage control
consumer

▪ flex heat controller operates the e t.


heat
power-to-heat facility: grid

e t.
→ heat supply is covered entirely through power
grid
the external grid
or
→ power-to-heat facility supports by
discharging the tank

© The ERIGrid 2.0 Consortium


EU H2020 Programme GA No. 870620 ERIGrid 2.0 MOOC: Multi-Energy Networks - Part III 39
Example Multi-Energy Network Application (5/5)

▪ voltage controller uses power-


to-heat facility as controllable
heat pump tank consumer
load e heat control voltage control
consumer

– voltage is monitored e t.
heat
grid
– the power consumption setpoint
e t.
of the heat pump is adjusted power
grid

– when activated, the heat pump is


used to charge the tank with hot
water

© The ERIGrid 2.0 Consortium


EU H2020 Programme GA No. 870620 ERIGrid 2.0 MOOC: Multi-Energy Networks - Part III 40
Detailed View of Electrical Network

voltage
control

© The ERIGrid 2.0 Consortium


EU H2020 Programme GA No. 870620 ERIGrid 2.0 MOOC: Multi-Energy Networks - Part III 41
Detailed View of Thermal Network

e ternal
heat grid

heat
pump
evaporator

condenser
e consumer consumer bypass
heat
control tank

© The ERIGrid 2.0 Consortium


EU H2020 Programme GA No. 870620 ERIGrid 2.0 MOOC: Multi-Energy Networks - Part III 42
Voltage Controller

▪ voltage at bus_1 is monitored


▪ power consumption setpoint of heat pump is adjusted to keep voltage
within acceptable limits
ea a step o trol
opera o al
() d ()
p o strai ts ()
bus H

bus
()
pro ess

© The ERIGrid 2.0 Consortium


EU H2020 Programme GA No. 870620 ERIGrid 2.0 MOOC: Multi-Energy Networks - Part III 43
Flex Heat Controller

▪ regulate heat supply for thermal network


▪ operate power-to-heat facility to supply additional heat from the tank
▪ if required, heat pump is used to charge the tank, respecting the power
consumption threshold from the voltage controller
grid supply, hp off grid supply, hp on
H on
o e o e

o e o e
H o
grid tank supply, hp off grid tank supply, hp on

© The ERIGrid 2.0 Consortium


EU H2020 Programme GA No. 870620 ERIGrid 2.0 MOOC: Multi-Energy Networks - Part III 44
Simulation Benchmark

▪ example application has been


published as simulation
benchmark:

– detailed documentation

– 2 reference implementations of the


simulation setup

– available at:
https://github.com/ERIGrid2/benchmark-model-multi-energy-networks/tree/mooc-demo

© The ERIGrid 2.0 Consortium


EU H2020 Programme GA No. 870620 ERIGrid 2.0 MOOC: Multi-Energy Networks - Part III 45
Simulated Subsystems

▪ use co-simulation for simulating

lectrical etworkSim

oltage trlSim
multi-energy systems: bus

bus

– different domains (power, heat,


control) are covered by domain- hp
pump tank

specific simulation tools

ower oHeatSim

Fle Heat trlSim


pump cond

tank

– partitioning of system under test into


hp
pump tank hp hp

subsystems, each implemented by


dedicated simulators
pipe tank supply unc on tank return pipe return

hermal etworkSim
measurement signal

control signal

electrical connec on

thermal connec on

© The ERIGrid 2.0 Consortium


EU H2020 Programme GA No. 870620 ERIGrid 2.0 MOOC: Multi-Energy Networks - Part III 46
Simulated Subsystems

▪ use the mosaik co-simulation

lectrical etworkSim

oltage trlSim
framework: bus

bus

– pandapower for the electrical


subsystem hp
pump tank

ower oHeatSim

Fle Heat trlSim


pump cond

– standalone implementations of the tank

controllers’ logic in ython


hp
pump tank hp hp

– pandapipes / DisHeatLib for the pipe tank supply unc on tank return pipe return

hermal etworkSim
thermal domain measurement signal

control signal

electrical connec on

thermal connec on

© The ERIGrid 2.0 Consortium


EU H2020 Programme GA No. 870620 ERIGrid 2.0 MOOC: Multi-Energy Networks - Part III 47
Thermal Network Simulators

▪ simulation benchmarks provides 2 reference implementations using


different approaches for modelling thermal networks:

– Python package pandapipes


• developed at the Fraunhofer Institute for Energy Economics
and Energy System Technology (IEE) and the University of
Kassel

– Modelica library DisHeatLib


• developed at the AIT Austrian Institute of Technology

© The ERIGrid 2.0 Consortium


EU H2020 Programme GA No. 870620 ERIGrid 2.0 MOOC: Multi-Energy Networks - Part III 48
Comparison of Modeling Approaches (1/2)
pandapipes DisHeatLib

▪ implements pipe flow calculations ▪ implements plug flow calculations


(compare to load flow for electrical (with non-linear pressure drop
grids) relation)
– static or quasi-static analysis of – analysis of thermo-hydraulic
balanced fluid systems transients in fluid systems
– computation of temperature, – flow reversals & time-delayed
pressure and velocity distributions propagation of fluid properties in
in pipe networks the pipe system

© The ERIGrid 2.0 Consortium


EU H2020 Programme GA No. 870620 ERIGrid 2.0 MOOC: Multi-Energy Networks - Part III 49
Comparison of Modeling Approaches (2/2)
pandapipes DisHeatLib

© The ERIGrid 2.0 Consortium


EU H2020 Programme GA No. 870620 ERIGrid 2.0 MOOC: Multi-Energy Networks - Part III 50
Comparison of Tool Coupling Capabilities
pandapipes DisHeatLib

▪ so-called “controllers” implement the ▪ models can be exported as standalone


coupling points executable models according to the
– read values from one network Functional Mock-up Interface (FMI)
specification
– apply efficiency factors and unit
conversions ▪ enables a straightforward coupling
– write the results to another with any other FMI-compliant
network simulation tool
▪ for more advanced use cases,
pandapipes’ A I can be used for tool
coupling in Python
© The ERIGrid 2.0 Consortium
EU H2020 Programme GA No. 870620 ERIGrid 2.0 MOOC: Multi-Energy Networks - Part III 52
Comparison of Availability
pandapipes DisHeatLib

▪ publicly available open-source Python ▪ publicly available open-source


package Modelica library
▪ since Python is also a publicly available ▪ for compiling models created from the
open-source tool, pandapipes can be DisHeatLib to an executable, the
used without a commercial license proprietary Dymola tool is required
▪ in the future, a complete open-source
tool support through OpenModelica is
expected

© The ERIGrid 2.0 Consortium


EU H2020 Programme GA No. 870620 ERIGrid 2.0 MOOC: Multi-Energy Networks - Part III 53
DisHeatLib: Thermal Network Model
external grid connection consumers

pipe junctions

pipes (return & supply line)

© The ERIGrid 2.0 Consortium


EU H2020 Programme GA No. 870620 ERIGrid 2.0 MOOC: Multi-Energy Networks - Part III 54
DisHeatLib: Power-to-Heat Facility Model
storage tank
supply line

hydraulic loop:
hydraulic loop: • storage tank
• heat pump condenser • pump
• pump • supply line (feed hot water)
• storage tank • return line (draw cold water)

return line

heat pump

© The ERIGrid 2.0 Consortium


EU H2020 Programme GA No. 870620 ERIGrid 2.0 MOOC: Multi-Energy Networks - Part III 55
DisHeatLib: Thermal System Model

▪ thermal system model is exported as standalone executable binary (Functional Mock-up Unit, FMU)

tank temperature
(upper & lower layer)

heat pump
thermal system model
power consumption

PID controller
mass flow through heat
pump condenser setpoints from
flex heat controller

© The ERIGrid 2.0 Consortium


EU H2020 Programme GA No. 870620 ERIGrid 2.0 MOOC: Multi-Energy Networks - Part III 56
Hands-on Demo

available online via Binder:


https://mybinder.org/v2/gh/ERIGrid2/benchmark-model-multi-energy-networks/
mooc-demo?labpath=Welcome.ipynb

… or click
“launch binder”
on Github page

© The ERIGrid 2.0 Consortium


EU H2020 Programme GA No. 870620 ERIGrid 2.0 MOOC: Multi-Energy Networks - Part III 57
Hands-on Demo

Things you can explore when working with the online demo:
▪ Run the implementation based on pandapipes:
– compare results with the DisHeatLib implementation
▪ Take a look at the source code (advanced):
– How are Python-based simulators (pandapower,
pandapipes, controllers) integrated into mosaik?
– How is the FMU containing the DisHeatLib model
integrated into mosaik?

© The ERIGrid 2.0 Consortium


EU H2020 Programme GA No. 870620 ERIGrid 2.0 MOOC: Multi-Energy Networks - Part III 58
Conclusion

▪ co-simulation is a powerful approach for the assessment of multi-domain


energy systems

▪ the mosaik framework provides a versatile environment for co-simulation

▪ RIGrid .0’s multi-energy network benchmark provides a typical use case for
using co-simulation
– couple multiple domains: power, heat, control
– connect domain-specific simulators
– combined analysis of all domains in high detail

© The ERIGrid 2.0 Consortium


EU H2020 Programme GA No. 870620 ERIGrid 2.0 MOOC: Multi-Energy Networks - Part III 59
Links

▪ ERIGrid 2.0 multi-energy networks benchmark:


https://github.com/ERIGrid2/benchmark-model-multi-energy-networks/tree/mooc-demo
▪ ERIGrid 2.0 multi-energy networks benchmark online demo:
https://mybinder.org/v2/gh/ERIGrid2/benchmark-model-multi-energy-networks/mooc-
demo?labpath=Welcome.ipynb
▪ mosaik: https://mosaik.readthedocs.io/
▪ DisHeatLib: https://github.com/AIT-IES/DisHeatLib
▪ pandapipes: https://pandapipes.readthedocs.io
▪ pandapower: https://pandapower.readthedocs.io

© The ERIGrid 2.0 Consortium


EU H2020 Programme GA No. 870620 ERIGrid 2.0 MOOC: Multi-Energy Networks - Part III 60
Backup: Voltage Controller Implementation

▪ Python implementation
▪ straightforward procedural
implementation:
– simple calculations:
• voltage deviation
• step function residual
• power consumption setpoint for
heat pump
– simple logical comparisons:
• check deadband
• min/max of power consumption
setpoint
• ramp up/down constraints

© The ERIGrid 2.0 Consortium


EU H2020 Programme GA No. 870620 ERIGrid 2.0 MOOC: Multi-Energy Networks - Part III 61

You might also like