Energy System API¶
EnergySystem¶
Energy system configuration and optimization.
This module provides the EnergySystem class, the main entry point for configuring and optimizing energy systems.
EnergySystem
¶
Energy system configuration and optimization orchestrator.
This class provides a high-level interface for configuring and optimizing energy systems. It handles system validation, model building, and optimization execution through external solvers.
Source code in src/odys/energy_system.py
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 | |
__init__(portfolio, timestep, number_of_steps, power_unit, scenarios, markets=None)
¶
Initialize the energy system configuration and optimizer.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
portfolio
|
AssetPortfolio
|
The portfolio of energy assets (generators, batteries, etc.). |
required |
timestep
|
timedelta
|
Duration of each time period. |
required |
number_of_steps
|
int
|
Number of time steps. |
required |
power_unit
|
str
|
Unit used for power quantities ('W', 'kW', or 'MW'). |
required |
scenarios
|
Scenario | Sequence[StochasticScenario]
|
Sequence of stochastic scenarios. Probabilities must add up to 1. |
required |
markets
|
EnergyMarket | Sequence[EnergyMarket] | None
|
Optional energy markets in which assets can participate. |
None
|
Source code in src/odys/energy_system.py
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 | |
optimize()
¶
Optimize the energy system.
This method solves the pre-built algebraic model using HiGHS solver. The model is built during optimization from the energy system configuration.
Returns:
| Type | Description |
|---|---|
OptimizationResults
|
OptimizationResults containing the solution and metadata. |
Source code in src/odys/energy_system.py
56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 | |
Scenarios¶
Scenario definitions for energy system optimization models.
Scenario
¶
Bases: BaseModel
Scenario conditions.
Source code in src/odys/energy_system_models/scenarios.py
8 9 10 11 12 13 14 15 16 17 18 | |
StochasticScenario
¶
Bases: Scenario
Stochastic scenario conditions.
Source code in src/odys/energy_system_models/scenarios.py
21 22 23 24 25 | |
validate_sequence_of_stochastic_scenarios(scenarios)
¶
Validate that scenarios probabilities add up to 1.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
scenarios
|
Sequence[StochasticScenario]
|
Sequence of scenarios. |
required |
Raises:
| Type | Description |
|---|---|
ValueError
|
If sum of probabilities is different than 1. |
Source code in src/odys/energy_system_models/scenarios.py
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 | |
Assets¶
Base Asset¶
Base classes for energy system assets.
This module defines the base classes and interfaces for energy system assets including the EnergyAsset abstract base class.
EnergyAsset
¶
Bases: BaseModel, ABC
Base class for all energy system assets.
This abstract class defines the common interface for energy assets like generators, batteries, and other energy system components.
Source code in src/odys/energy_system_models/assets/base.py
12 13 14 15 16 17 18 19 20 21 | |
PowerGenerator¶
Power generator asset implementation.
This module provides the PowerGenerator class for modeling electrical generators in energy system optimization problems.
PowerGenerator
¶
Bases: EnergyAsset
Represents a power generator in the energy system.
This class models generators with various operational constraints including nominal power, variable costs, ramp rates, and startup/shutdown costs.
Source code in src/odys/energy_system_models/assets/generator.py
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 | |
Battery¶
Energy storage asset implementation.
This module provides the Battery class for modeling energy storage devices in energy system optimization problems.
Battery
¶
Bases: EnergyAsset
Represents a battery storage system in the energy system.
This class models batteries with various operational constraints including capacity, power limits, efficiency, state of charge, and degradation characteristics.
Source code in src/odys/energy_system_models/assets/storage.py
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 | |
Load¶
Load asset definitions for energy system models.
Load
¶
Bases: EnergyAsset
Represents a load asset in the energy system.
Source code in src/odys/energy_system_models/assets/load.py
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 | |
LoadType
¶
Bases: StrEnum
Load type enumeration.
Source code in src/odys/energy_system_models/assets/load.py
11 12 13 14 15 | |
AssetPortfolio¶
Asset portfolio management for energy systems.
This module provides the AssetPortfolio class for managing collections of energy system assets including generators, batteries, and other components.
AssetPortfolio
¶
A collection of energy system assets.
This class manages a portfolio of energy assets including generators, batteries, and other energy system components. It provides methods to add, retrieve, and filter assets by type.
Source code in src/odys/energy_system_models/assets/portfolio.py
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 | |
assets
property
¶
Get a read-only view of all assets in the portfolio.
Returns:
| Type | Description |
|---|---|
MappingProxyType[str, EnergyAsset]
|
A mapping proxy containing all assets indexed by name. |
batteries
property
¶
Get all batteries in the portfolio.
Returns:
| Type | Description |
|---|---|
tuple[Battery, ...]
|
A tuple containing all Battery assets. |
generators
property
¶
Get all power generators in the portfolio.
Returns:
| Type | Description |
|---|---|
tuple[PowerGenerator, ...]
|
A tuple containing all PowerGenerator assets. |
loads
property
¶
Get all the loads in the portfolio.
Returns:
| Type | Description |
|---|---|
tuple[Load, ...]
|
A tuple containing all Load assets. |
__init__()
¶
Initialize an empty asset portfolio.
Source code in src/odys/energy_system_models/assets/portfolio.py
26 27 28 | |
add_asset(asset)
¶
Add an energy asset to the portfolio.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
asset
|
EnergyAsset
|
The energy asset to add to the portfolio. |
required |
Raises:
| Type | Description |
|---|---|
ValueError
|
If an asset with the same name already exists. |
TypeError
|
If the asset is not an instance of EnergyAsset. |
Source code in src/odys/energy_system_models/assets/portfolio.py
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 | |
get_asset(name)
¶
Retrieve an asset from the portfolio by name.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The name of the asset to retrieve. |
required |
Returns:
| Type | Description |
|---|---|
EnergyAsset
|
The energy asset with the specified name. |
Raises:
| Type | Description |
|---|---|
KeyError
|
If no asset with the specified name exists. |
Source code in src/odys/energy_system_models/assets/portfolio.py
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 | |
Markets¶
Energy market definitions for energy system models.
EnergyMarket
¶
Bases: BaseModel
Represents an energy market in the energy system.
Source code in src/odys/energy_system_models/markets.py
16 17 18 19 20 21 22 23 24 25 26 27 | |
TradeDirection
¶
Bases: StrEnum
Direction of the market positions.
Source code in src/odys/energy_system_models/markets.py
8 9 10 11 12 13 | |
Validated Energy System¶
Validated energy system configuration.
This module provides the ValidatedEnergySystem class which validates and transforms user-provided energy system configurations into parameters suitable for the optimization model.
ValidatedEnergySystem
¶
Bases: BaseModel
Represents the complete energy system configuration with validation.
This class defines the energy system including the asset portfolio, demand profile, time discretization, and available capacity profiles. It performs comprehensive validation to ensure the system is feasible:
- Validates that capacity profile lengths match demand profile length
- Ensures available capacity profiles are only specified for generators
- Verifies that maximum available power can meet peak demand
- Checks that total energy capacity can meet total energy demand
Raises:
| Type | Description |
|---|---|
ValueError
|
If the system configuration is infeasible. |
TypeError
|
If available capacity is specified for non-generator assets. |
Source code in src/odys/energy_system_models/validated_energy_system.py
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 | |
energy_system_parameters
cached
property
¶
Parameters of the energy system.