odys.domain.entities.portfolio¶
Collection of energy assets (generators, storages, loads). Validates unique asset names and provides typed accessors by asset class.
See AssetPortfolio in the User Guide.
Asset portfolio management for energy systems.
This module provides the AssetPortfolio class, the collection of assets the user owns and operates.
AssetPortfolio
¶
A collection of assets the user owns and operates.
Assets are indexed by name, which must be unique. Markets are not assets
and are rejected; pass them to EnergySystem instead. Chargers and
electric vehicles must be both present or both absent: a vehicle can only
charge through a charger, and a charger without vehicles serves no purpose.
Source code in src/odys/domain/entities/portfolio.py
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 107 108 109 110 111 112 113 114 115 116 | |
assets
property
¶
Get a read-only view of all assets in the portfolio.
Returns:
| Type | Description |
|---|---|
MappingProxyType[str, Asset]
|
A mapping proxy containing all assets indexed by name. |
__init__(assets=None)
¶
Initialize an asset portfolio.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
assets
|
Iterable[Asset] | None
|
Iterable of assets to add to the portfolio. |
None
|
Raises:
| Type | Description |
|---|---|
OdysValidationError
|
If an entity is not an asset, if names are not unique, or if the portfolio has chargers without electric vehicles or the reverse. |
Source code in src/odys/domain/entities/portfolio.py
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 | |
assets_of(asset_type)
¶
Return all assets of the given type, in insertion order.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
asset_type
|
type[AssetT]
|
The asset class to filter by (subclasses included). |
required |
Returns:
| Type | Description |
|---|---|
tuple[AssetT, ...]
|
A tuple with every asset that is an instance of |
Source code in src/odys/domain/entities/portfolio.py
66 67 68 69 70 71 72 73 74 75 | |
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 |
|---|---|
Asset
|
The asset with the specified name. |
Raises:
| Type | Description |
|---|---|
OdysValidationError
|
If no asset with the specified name exists. |
Source code in src/odys/domain/entities/portfolio.py
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 | |