mirror of
https://github.com/Akkudoktor-EOS/EOS.git
synced 2026-10-08 23:46:38 +00:00
* feat: adapt configuration for multi optimization algorithms Decouple configuration from optimization algorithm parameters. Add to_[algorithm]_param() methods to the configuration that derive optimization algorithm specific parameters from the configuration. Add x-scope tags to the configuration options that describe for which specific algorithms the configuration option is for. The whole device settings are restructured. There are now general settings for the device classes with the afore mentioned to_[algorithm]_param() methods. The general device settings got their own directory `devices/settings`. By this the parameter class also does not have to be a pydantic model which can be used for future optimization/ simulations speed up. Also the parameter class for a device is now part of the device module. This better decouples and also is the natural place for parameters of a device. Besides this feature there are also fixes and improvements: * feat: extend home appliance time window settings and simulation Home appliance can now be configured for multiple runs with per-cycle allowed time windows. The number of remaining cycles to plan is determined at runtime by reading the ``cycles_completed_measurement_key`` from the measurement store. * feat: specialiced CycleTimeWindowSequence for time window sequences Sequence of time windows associated to cycles. This model specializes ``ValueTimeWindowSequence`` so that the ``value`` field of each ``ValueTimeWindow`` encodes the **cycle index** (0-based integer) the window belongs to. Typical use: an appliance that must run ``n`` times per day, each run constrained to a distinct time window. Assign ``value=0`` to windows for the first cycle, ``value=1`` for the second, and so on. Multiple windows may share the same cycle index (their allowed regions are unioned). Windows with ``value=None`` are silently ignored by all cycle-aware methods. * fix: Make test_configmigrate also regard the _ANY_SENTENIEL in key values * chore: Make devices configurations a map instead of a list This makes config paths stable regardless of declaration order and lets each device settings class build its own config path from ``self.device_id`` without needing an external index. Tests are adapted likewise. Devices configurations are automatically migrated from lists to maps. * chore: rename levelized_cost_of_storage_kwh to levelized_cost_of_storage_amt kwh This better fits in the naming scheme and also makes clear the costs are money. Signed-off-by: Bobby Noelte <b0661n0e17e@gmail.com> * fix: runtime config update ignored by config file Runtime settings were handed back to pydantic-settings as init settings, which rank below the config file and the environment. Any key already present in EOS.config.json or in the environment silently discarded the update, so a bulk PUT /v1/config returned 200 without applying anything, while the granular PUT /v1/config/{path} endpoint kept working. Add a dedicated runtime settings source ranked directly below the command line arguments and record granular updates there as well, so both endpoints share one store that survives re-evaluation of the settings sources. Environment variables keep precedence over the config file for all keys that were not set at runtime. Also repairs revert_settings() and update(), which passed their data through the same init settings. Closes #1303 * fix: env vars ignored on first config build ConfigEOS.__init__ passed self as first positional argument to _setup, which forwards it to pydantic_settings.BaseSettings.__init__. Its first positional parameter is _case_sensitive, so the environment source matched the upper case variable names against the lower case field names and returned nothing. Environment settings only took effect after the next configuration setup. * docs: changelog for config priority fixes * fix(config): preserve device identities and storage costs during migration * fix(devices): preserve charge-rate typing and public import compatibility * ruff format fix * fix(config): satisfy typed device conversion and migration contracts * docs(config): refresh validated configuration prerequisite schemas --------- Signed-off-by: Bobby Noelte <b0661n0e17e@gmail.com> Co-authored-by: Bobby Noelte <b0661n0e17e@gmail.com> Co-authored-by: r0b2g1t <r0b2g1t@users.noreply.github.com>
346 lines
14 KiB
Markdown
346 lines
14 KiB
Markdown
% SPDX-License-Identifier: Apache-2.0
|
||
(resource-page)=
|
||
|
||
# Resources (Device Simulations)
|
||
|
||
## Concepts
|
||
|
||
The simulations for resources are leaning on general concepts of the [S2 standard].
|
||
|
||
### Control Types
|
||
|
||
The control of resources and such what a resource simulation will simulate follows three
|
||
basic control principles:
|
||
|
||
- Operation Mode Based Control (OMBC)
|
||
- Fill Rate Based Control (FRBC)
|
||
- Demand Driven Based Control (DDBC)
|
||
|
||
Although these control principles differ enough to separate them into three distinct control types,
|
||
there are some common aspects that make them similar:
|
||
|
||
- Operation Modes
|
||
- Transitions and
|
||
- Timers.
|
||
|
||
The objective for a control type is under which circumstances what things can be adjusted, and what
|
||
the constraints are for these adjustments. The three control types model a virtual, abstract resource
|
||
for simulation.
|
||
|
||
The abstract resource ignores all details of pyhsical device that are not relevant to energy
|
||
management. In addition, physical devices have an enormous variety in parameters, sensors, control
|
||
strategies, concerns, safeguards, and so on. It would be practically impossible to develop a
|
||
simulation that can
|
||
understand all the parameters of all the physical devices on the market. By making the resource more
|
||
abstract, its concepts can be translated to all sorts of physical devices, even though internally
|
||
they function very differently. As a consequence, it not always possible to make a 100% accurate
|
||
description of all the behaviors and constraints in these abstractions. But the abstractions used
|
||
in the control types are quite powerful, and should allow you to come pretty close.
|
||
|
||
The control types basically define how the simulated resource can be described. The user in the end
|
||
selects the proper desciption of a physical device using the configuration options provided for
|
||
resource simulations. The configuration sets how the simulated resource functions, what it can do and
|
||
what kind of constraints it has.
|
||
|
||
### Resource Simulation
|
||
|
||
Based on the description of this virtual resource, the resource simulation can make predictions of
|
||
what the physical device will do in certain situations, and when it is allowed to execute
|
||
instructions generated by the optimization as part of the energy management plan evaluation.
|
||
|
||
### Resource Status
|
||
|
||
Once the physical device has changed it's behavior, the resource simulation should be informed
|
||
to make the simulation change it's state accordingly.
|
||
|
||
The actual state of a pyhsical device may be reported to the resource simulation by the
|
||
**PUT** `/v1/resource/status` API endpoint.
|
||
|
||
## Battery
|
||
|
||
There is a wealth of possible battery operation modes:
|
||
|
||
<!-- pyml disable line-length -->
|
||
| Mode | Purpose / Behavior | Typical Trigger / Context |
|
||
| ------------------------- | --------------------------------------------------------------------------------------- | ---------------------------------------------------------------- |
|
||
| **IDLE** | Battery neither charges nor discharges (SOC stable). | No active control objective or power imbalance below thresholds. |
|
||
| **SELF_CONSUMPTION** | Charge from PV surplus and discharge to cover local load. | PV generation > load (charge) or load > PV (discharge). |
|
||
| **NON_EXPORT** | Charge from on-site or local surplus with the goal of minimizing or preventing energy export to the external grid. Discharging to the grid is not allowed. | Export limit reached and SOC < SOC_max. |
|
||
| **PEAK_SHAVING** | Discharge to keep grid import below a target threshold. | Predicted or measured site load exceeds peak limit. |
|
||
| **GRID_SUPPORT_EXPORT** | Discharge energy to grid for revenue (V2G, wholesale market, flexibility service). | Market or signal permits profitable export. |
|
||
| **GRID_SUPPORT_IMPORT** | Charge from grid to absorb surplus or provide up-regulation service. | Low-price or grid-support signal detected. |
|
||
| **FREQUENCY_REGULATION** | Rapid charge/discharge response to grid frequency deviations. | Active participation in frequency control. |
|
||
| **RAMP_RATE_CONTROL** | Smooth site-level power ramp rates by buffering fluctuations. | Sudden PV/load change exceeding ramp limit. |
|
||
| **RESERVE_BACKUP** | Maintain SOC ≥ reserve threshold to ensure backup capacity. | Resilience mode active, grid operational. |
|
||
| **OUTAGE_SUPPLY** | Islanded operation: power local loads using stored energy (and PV if available). | Grid failure detected. |
|
||
| **FORCED_CHARGE** | Manual or external control command to charge (e.g., pre-event, maintenance). No discharge. | Operator or optimizer command. |
|
||
| **FORCED_DISCHARGE** | Manual or external control command to discharge. No charge. | Operator or optimizer command. |
|
||
| **FAULT** | Battery unavailable due to fault, safety, or protection state. | Fault detected (thermal, voltage, comms, etc.). |
|
||
<!-- pyml enable line-length -->
|
||
|
||
The optimization algorithm, the device simulation and the configuration properties only support the
|
||
most important of these modes.
|
||
|
||
### Battery Simulation
|
||
|
||
The battery simulation assumes an idealized battery model. Under this model, the battery can be
|
||
operated in three discrete operation modes with fill rate based control (FRBC):
|
||
|
||
| **Operation Mode ID** | **Description** |
|
||
| ------------------------ | --------------------------------------------------------------------- |
|
||
| **SELF_CONSUMPTION** | Charge from local surplus and discharge to cover local load. |
|
||
| **NON_EXPORT** | Charge from local surplus and do not discharge. |
|
||
| **FORCED_CHARGE** | Charge. |
|
||
|
||
The **operation mode factor** (0.0–1.0) specifies the normalized power rate relative to the
|
||
battery's nominal maximum charge or discharge power. A value of 1.0 corresponds to full-rate
|
||
charging or discharging, while 0.0 indicates no power transfer. Intermediate values scale the power
|
||
proportionally.
|
||
|
||
The **fill level** (0.0–1.0) specifies the normalized fill level relative to the
|
||
battery's nominal maximum charge. A value of 1.0 corresponds to full while 0.0 indicates empty.
|
||
Intermediate values scale the fill level proportionally.
|
||
|
||
### Battery Configuration
|
||
|
||
### Battery Stati
|
||
|
||
To keep the battery simulation in synchonization with the actual stati of the battery the following
|
||
resource stati may be reported to EOS by the **PUT** `/v1/resource/status` API endpoint.
|
||
|
||
#### Battery FRBCActuatorStatus
|
||
|
||
The operation mode the battery is currently operated.
|
||
|
||
```json
|
||
{
|
||
"type": "FRBCActuatorStatus",
|
||
"active_operation_mode_id": "GRID_SUPPORT_IMPORT",
|
||
"operation_mode_factor": "0.375",
|
||
"previous_operation_mode_id": "SELF_CONSUMPTION",
|
||
"transistion_timestamp": "20250725T12:00:12"
|
||
}
|
||
```
|
||
|
||
#### Battery FRBCStorageStatus
|
||
|
||
The current battery state of charge (SoC).
|
||
|
||
```json
|
||
{
|
||
"type": "FRBCStorageStatus",
|
||
"present_fill_level": "0.88"
|
||
}
|
||
```
|
||
|
||
#### Battery PowerMeasurement
|
||
|
||
The current power that the battery is charged or discharged with \[W\].
|
||
|
||
```json
|
||
{
|
||
"type": "PowerMeasurement",
|
||
"measurement_timestamp": "20250725T12:00:12",
|
||
"values": [
|
||
{
|
||
"commodity_quantity": "ELECTRIC.POWER.L1",
|
||
"value": "887.5"
|
||
},
|
||
{
|
||
"commodity_quantity": "ELECTRIC.POWER.L2",
|
||
"value": "905.5"
|
||
},
|
||
{
|
||
"commodity_quantity": "ELECTRIC.POWER.L2",
|
||
"value": "1100.7"
|
||
},
|
||
]
|
||
}
|
||
```
|
||
|
||
For symmetric (or unknown) power distribution:
|
||
|
||
```json
|
||
{
|
||
"type": "PowerMeasurement",
|
||
"measurement_timestamp": "20250725T12:00:12",
|
||
"values": [
|
||
{
|
||
"commodity_quantity": "ELECTRIC.POWER.3_PHASE_SYM",
|
||
"value": "1000"
|
||
}
|
||
]
|
||
}
|
||
```
|
||
|
||
## Electric Vehicle
|
||
|
||
The electric vehicle is basically a battery with a reduced set of operation modes.
|
||
|
||
### Electric Vehicle Instructions
|
||
|
||
The electric vehicle control instructions assume an idealized EV battery model. Under this model,
|
||
the EV battery can be operated in two operation modes:
|
||
|
||
| **Operation Mode ID** | **Description** |
|
||
| --------------------- | ----------------------------------------------------------------------- |
|
||
| **IDLE** | Battery neither charges nor discharges; holds its state of charge. |
|
||
| **FORCED_CHARGE** | Charge at a specified power rate up to the allowable maximum. |
|
||
|
||
The **operation mode factor** (0.0–1.0) specifies the normalized power rate relative to the
|
||
battery's nominal maximum charge power. A value of 1.0 corresponds to full-rate charging, while 0.0
|
||
indicates no power transfer. Intermediate values scale the power proportionally.
|
||
|
||
## Home Appliance
|
||
|
||
The optimization algorithm supports one start of the home appliance within the optimization
|
||
horizon.
|
||
|
||
### Home Appliance Simulation
|
||
|
||
### GENETIC0 Home Appliance Configuration
|
||
|
||
Home appliance to run within the optimization horizon.
|
||
|
||
```json
|
||
{
|
||
"dishwasher1": {
|
||
"device_id": "dishwasher1",
|
||
"consumption_wh": 2000,
|
||
"duration_h": 3
|
||
}
|
||
}
|
||
```
|
||
|
||
Home appliance to run within a time window of 5 hours starting at 8:00 every day and another time
|
||
window of 3 hours starting at 15:00 every day. See
|
||
[Time Window Sequence Configuration](configtimewindow-page) for more information.
|
||
|
||
```json
|
||
{
|
||
"dishwasher1": {
|
||
"device_id": "dishwasher1",
|
||
"consumption_wh": 2000,
|
||
"duration_h": 3,
|
||
"time_windows": {
|
||
"windows": [
|
||
{
|
||
"start_time": "08:00",
|
||
"duration": "5 hours"
|
||
},
|
||
{
|
||
"start_time": "15:00",
|
||
"duration": "3 hours"
|
||
}
|
||
]
|
||
}
|
||
}
|
||
}
|
||
```
|
||
|
||
:::{admonition} Note
|
||
:class: note
|
||
The optimization algorithm always restricts to one start within the optimization horizon per
|
||
energy management run.
|
||
:::
|
||
|
||
### GENETIC Home Appliance Configuration
|
||
|
||
Home appliance to run once, unconstrained, within the optimization horizon:
|
||
|
||
```json
|
||
{
|
||
"dishwasher1": {
|
||
"device_id": "dishwasher1",
|
||
"consumption_wh": 2000,
|
||
"duration_h": 3,
|
||
"num_cycles": 1
|
||
}
|
||
}
|
||
```
|
||
|
||
Home appliance to run within a time window of 5 hours starting at 8:00. Each window's `value`
|
||
field carries the 0-based cycle index it applies to -- here there is only one cycle (index `0`),
|
||
so `num_cycles` does not need to be set explicitly; it is derived from the distinct cycle indices
|
||
found in `cycle_time_windows`. See
|
||
[ime Window Sequence Configuration](configimewindow-page) for more information.
|
||
|
||
```json
|
||
{
|
||
"dishwasher1": {
|
||
"device_id": "dishwasher1",
|
||
"consumption_wh": 2000,
|
||
"duration_h": 3,
|
||
"cycle_time_windows": {
|
||
"windows": [
|
||
{
|
||
"start_time": "08:00",
|
||
"duration": "5 hours",
|
||
"value": 0
|
||
}
|
||
]
|
||
}
|
||
}
|
||
}
|
||
```
|
||
|
||
Home appliance that must run **twice** per day, each run confined to its own time window --
|
||
cycle 0 in the morning (07:00, 5 hours), cycle 1 in the evening (17:00, 5 hours) -- with at least
|
||
1 hour idle between the two runs:
|
||
|
||
```json
|
||
{
|
||
"washing_machine1": {
|
||
"device_id": "washing_machine1",
|
||
"consumption_wh": 2000,
|
||
"duration_h": 2,
|
||
"min_cycle_gap_h": 1,
|
||
"cycle_time_windows": {
|
||
"windows": [
|
||
{
|
||
"start_time": "07:00",
|
||
"duration": "5 hours",
|
||
"value": 0
|
||
},
|
||
{
|
||
"start_time": "17:00",
|
||
"duration": "5 hours",
|
||
"value": 1
|
||
}
|
||
]
|
||
}
|
||
}
|
||
}
|
||
```
|
||
|
||
`min_cycle_gap_h` enforces a minimum idle time between the end of one cycle and the start of the
|
||
next; it defaults to `0`, which permits back-to-back runs. To let both cycles run anywhere in a
|
||
shared window instead of separate morning/evening slots, give both windows the same `start_time`
|
||
and `duration` but keep their distinct `value` (cycle index) -- the optimizer still places each
|
||
cycle independently within that shared window.
|
||
|
||
How many cycles remain to be scheduled on a given energy management run is read at runtime from
|
||
the measurement store, under the key configured in `cycles_completed_measurement_key` (defaults
|
||
to `{device_id}.cycles_completed`). This lets the optimizer skip cycles the appliance has already
|
||
completed earlier the same day.
|
||
|
||
:::{admonition} Note
|
||
:class: note
|
||
Unlike GENETIC0, the GENETIC algorithm can plan multiple cycles -- and therefore multiple starts
|
||
-- of the same appliance within a single energy management run, whenever `num_cycles` (or the
|
||
number of distinct cycle indices in `cycle_time_windows`) is greater than 1.
|
||
:::
|
||
|
||
### Home Appliance Instructions
|
||
|
||
The home appliance instructions assume an idealized home appliance model. Under this model,
|
||
the home appliance can be operated in two operation modes:
|
||
|
||
| **Operation Mode ID** | **Description** |
|
||
|-----------------------|-------------------------------------------------------------------------|
|
||
| **RUN** | The home appliance is started and runs until the end of it's power |
|
||
| | sequence. |
|
||
| **OFF** | The home appliance does not run. |
|
||
|
||
The **operation mode factor** (0.0–1.0) is ignored.
|