FLEX-Operation
What It Does
FLEX-Operation models the hourly energy system dispatch of a single household over a full year (8,760 hours). Given a household’s technology configuration — heating system, PV, battery storage, EV, thermal tanks — and the corresponding demand and weather inputs, it calculates how the system operates hour by hour, along with the resulting energy consumption and cost.
The model runs each scenario ID independently and produces separate result files per scenario.
Ref vs. Opt: The Central Distinction
Every scenario is run in both modes (unless disabled), and the comparison between them is typically the core research output:
Reference mode (dispatch_ref.py) simulates a household with no smart control. Devices operate by simple, reactive rules:
The heat pump runs whenever space heating or hot water demand exceeds tank capacity.
The EV charges immediately when it arrives home.
The battery charges from PV surplus and discharges to cover load, following a basic priority order.
There is no lookahead, no price awareness.
Optimization mode (dispatch_opt.py) simulates a household with a Smart Energy Management System (SEMS). A Pyomo LP is solved for the full year simultaneously:
Objective: minimize total annual energy cost:
Flexible devices (battery, EV, thermal tanks, heat pump) are scheduled optimally given energy balance constraints, device capacity limits, and comfort bounds (room temperature, tank temperature).
The result represents the theoretical maximum value of full demand flexibility.
The difference in annual cost between Ref and Opt is the economic value of SEMS, which is reported in OperationResult_EnergyCostChange.
Technology Components
Each component is a dataclass defined in src/models/operation/components.py and parameterized via its own input table:
Component |
Key parameters |
|---|---|
|
Floor area, thermal conductances (Hop, Htr_w, Hve), window areas by orientation, supply temperature |
|
Type (heat pump / fuel boiler / district heating), COP/efficiency |
|
Backup electric resistance heater power and efficiency |
|
Size, thermal loss, min/max temperature |
|
Size, thermal loss, min/max temperature |
|
Cooling COP and rated power |
|
Installed capacity, orientation, hourly generation profile |
|
Capacity, charge/discharge efficiency and power limits |
|
Battery capacity, consumption rate, V2H capability, parking and driving profiles |
The presence or absence of each component is controlled by the scenario table — a NULL component ID means that technology is not installed.
The RC Thermal Model
Building thermal dynamics are modeled using a 5R1C simplified resistance-capacitance (RC) model based on ISO 13790. The equations are implemented in src/models/operation/rc_equations.py and used in both Ref and Opt dispatch.
The model tracks two temperatures: room air temperature (T_Room) and thermal mass temperature (T_BuildingMass). Solar gains, internal gains, ventilation heat recovery, and the heat pump output all enter as heat flows. In Opt mode, the thermal mass acts as an implicit thermal storage: the optimizer can pre-heat the building when electricity is cheap.
Inputs
Table |
Content |
|---|---|
|
Main scenario table — one row per scenario, links all component IDs |
|
Parameter tables for each technology (Battery, Boiler, Building, etc.) |
|
Hourly electricity, feed-in, and fuel price time series |
|
Hourly outdoor temperature and solar irradiance |
|
Hourly behavior profiles from FLEX-Behavior (optional) |
|
EV parking and driving distance profiles |
Outputs
Results are written per scenario (suffix _S{id}) and per mode (Ref / Opt):
Table |
Resolution |
Key variables |
|---|---|---|
|
Hourly |
|
|
Monthly |
Summed energy flows |
|
Annual |
Total energy and cost summary per scenario |
The full list of output variables and their aggregation rules is defined in src/models/operation/result_registry.py.
Key Code Locations
File |
Role |
|---|---|
|
Entry point — |
|
Loads all component parameters into the |
|
Rule-based reference dispatch logic |
|
LP optimization dispatch — calls Pyomo solver |
|
Shared physical state computation (energy flows, SoC updates) |
|
Pyomo model definition: sets, variables, constraints, objective |
|
Populates Pyomo parameters from scenario data |
|
Building thermal model equations |
|
Solver configuration (defaults to Gurobi) |
|
Defines which variables are saved and how they are aggregated |
How to Run
python -m projects.test_operation.main
Output is written to projects/test_operation/output/.