odys.domain.conditions¶
Initial and final conditions of a run. Each condition references the asset it belongs to: GeneratorInitialState and GeneratorFinalState a generator, StorageInitialState and StorageFinalState a battery storage, and ElectricVehicleInitialState and ElectricVehicleFinalState an electric vehicle.
See Initial and final conditions in the User Guide.
Initial and final conditions of one optimization run.
An initial condition is the state of an asset just before the first timestep,
such as the output of a generator or the state of charge of a battery. A final
condition is a state the asset must reach at the last timestep. Conditions
belong to one run, not to the asset or to a scenario: they are the same in
every scenario and are passed to EnergySystem.
Each condition type references the kind of asset it belongs to, so it cannot
be attached to the wrong kind of asset. An initial condition is required
whenever the asset's results depend on it (required_for), so odys never
guesses a starting state.
Condition
¶
Bases: BaseModel, ABC
A state of one asset at the boundary of the optimization horizon.
Each condition type declares the asset types it applies to. Like entities,
a condition is checked against the run through validate_horizon and
validate_operating_conditions, which accept anything by default.
Source code in src/odys/domain/conditions.py
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 | |
entity
abstractmethod
property
¶
Return the asset this condition belongs to.
validate_horizon(horizon)
¶
Check that this condition fits the optimization horizon. The default accepts any horizon.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
horizon
|
Horizon
|
The time grid of the optimization. |
required |
Raises:
| Type | Description |
|---|---|
OdysValidationError
|
If the condition does not fit the horizon. |
Source code in src/odys/domain/conditions.py
54 55 56 57 58 59 60 61 62 | |
validate_operating_conditions(conditions)
¶
Check that this condition fits what its asset faces in one scenario. The default accepts anything.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
conditions
|
OperatingConditions
|
The horizon and the asset's profile values in one scenario. |
required |
Raises:
| Type | Description |
|---|---|
OdysValidationError
|
If the condition cannot be met in that scenario. |
Source code in src/odys/domain/conditions.py
64 65 66 67 68 69 70 71 72 | |
ConditionSet
¶
Bases: BaseModel
The initial and final conditions of one optimization run.
Owns the rule that spans conditions: each asset has at most one condition of each type.
Source code in src/odys/domain/conditions.py
476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 | |
conditions
property
¶
Return every initial condition, then every final condition.
get(kind, entity)
¶
Return the condition of the given type for the asset, if there is one.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
kind
|
type[ConditionT]
|
The condition type, such as |
required |
entity
|
Asset
|
The asset to look up. |
required |
Returns:
| Type | Description |
|---|---|
ConditionT | None
|
The asset's condition of that type, or None. |
Source code in src/odys/domain/conditions.py
502 503 504 505 506 507 508 509 510 511 512 513 514 515 | |
ElectricVehicleFinalState
¶
Bases: FinalCondition
State of charge an electric vehicle must have at the last timestep.
Source code in src/odys/domain/conditions.py
445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 | |
entity
property
¶
Return the electric vehicle this state belongs to.
ElectricVehicleInitialState
¶
Bases: InitialCondition
State of charge of an electric vehicle just before the first timestep. Always required.
A trip departing at t=0 must not require more state of charge than soc,
and its energy must fit in the starting charge above soc_min, since the
vehicle cannot charge before or during it.
Source code in src/odys/domain/conditions.py
383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 | |
entity
property
¶
Return the electric vehicle this state belongs to.
required_for(entity)
classmethod
¶
Return why an electric vehicle needs an initial state: its charge carries over between timesteps.
Source code in src/odys/domain/conditions.py
432 433 434 435 436 437 | |
FinalCondition
¶
Bases: Condition, ABC
The state an asset must reach at the last timestep.
Source code in src/odys/domain/conditions.py
91 92 | |
FlexibleLoadInitialState
¶
Bases: InitialCondition
Consumption of a flexible load just before the first timestep, and how long it has been on or off.
A load with a commitment is off if power is 0 and running otherwise; a
load without one is always running. A running power lies within the
load's min_load and max_load. time_in_state is how long a load with a
commitment has been in its state; it carries the minimum up or down time
over from before the horizon, and is required when the matching minimum
time is set.
Source code in src/odys/domain/conditions.py
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 333 334 335 | |
entity
property
¶
Return the flexible load this state belongs to.
is_on
property
¶
Return whether the load is running just before the first timestep: always without a commitment.
required_for(entity)
classmethod
¶
Return why a flexible load needs an initial state: a parameter linking one timestep to the next is set.
Source code in src/odys/domain/conditions.py
320 321 322 323 324 325 | |
validate_horizon(horizon)
¶
Check that the time in state spans a whole number of timesteps.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
horizon
|
Horizon
|
The time grid of the optimization. |
required |
Raises:
| Type | Description |
|---|---|
OdysValidationError
|
If the time in state is not a whole number of timesteps. |
Source code in src/odys/domain/conditions.py
303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 | |
GeneratorFinalState
¶
Bases: FinalCondition
Output a generator must have at the last timestep. A power of 0 means it is off.
Source code in src/odys/domain/conditions.py
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 | |
entity
property
¶
Return the generator this state belongs to.
validate_operating_conditions(conditions)
¶
Check that the final power fits the generator's available capacity at the last timestep.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
conditions
|
OperatingConditions
|
The horizon and the generator's available capacity in one scenario. |
required |
Raises:
| Type | Description |
|---|---|
OdysValidationError
|
If the final power exceeds the available capacity at the last timestep. |
Source code in src/odys/domain/conditions.py
225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 | |
GeneratorInitialState
¶
Bases: InitialCondition
Output of a generator just before the first timestep, and how long it has been on or off.
The generator is on if power is above 0 and off if it is 0. time_in_state
is how long it has been in that state; it carries the minimum up or down
time over from before the horizon, and is required when the matching
minimum time is set.
Source code in src/odys/domain/conditions.py
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 | |
entity
property
¶
Return the generator this state belongs to.
is_on
property
¶
Return whether the generator is on just before the first timestep.
required_for(entity)
classmethod
¶
Return why a generator needs an initial state: a parameter linking one timestep to the next is set.
Source code in src/odys/domain/conditions.py
194 195 196 197 198 199 | |
validate_horizon(horizon)
¶
Check that the time in state spans a whole number of timesteps.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
horizon
|
Horizon
|
The time grid of the optimization. |
required |
Raises:
| Type | Description |
|---|---|
OdysValidationError
|
If the time in state is not a whole number of timesteps. |
Source code in src/odys/domain/conditions.py
177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 | |
InitialCondition
¶
Bases: Condition, ABC
The state of an asset just before the first timestep.
Source code in src/odys/domain/conditions.py
75 76 77 78 79 80 81 82 83 84 85 86 87 88 | |
required_for(entity)
abstractmethod
classmethod
¶
Return why the asset needs this initial condition, or None if it is optional.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
entity
|
Asset
|
An asset of one of this condition's |
required |
Returns:
| Type | Description |
|---|---|
str | None
|
The reason, completing "needs a |
Source code in src/odys/domain/conditions.py
78 79 80 81 82 83 84 85 86 87 88 | |
StorageFinalState
¶
Bases: FinalCondition
State of charge a battery storage must have at the last timestep.
Source code in src/odys/domain/conditions.py
364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 | |
entity
property
¶
Return the battery storage this state belongs to.
StorageInitialState
¶
Bases: InitialCondition
State of charge of a battery storage just before the first timestep. Always required.
Source code in src/odys/domain/conditions.py
338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 | |
entity
property
¶
Return the battery storage this state belongs to.
required_for(entity)
classmethod
¶
Return why a battery storage needs an initial state: its charge carries over between timesteps.
Source code in src/odys/domain/conditions.py
351 352 353 354 355 356 | |