dove.core package#
dove.core
#
Core module for DOVE optimization framework.
This module provides the foundational classes and functions for building and managing energy system models in DOVE. It includes classes for components, resources, cash flows, and transfer functions. These classes are essential for defining the structure and behavior of energy systems and for performing optimization and simulation tasks.
- class dove.core.System[source]
Bases:
object
The main class for creating and managing energy system models.
A System represents a collection of components and resources that form an energy system. It provides methods for adding components and resources, validating the system configuration, and solving optimization problems.
- Parameters:
- __init__(components=None, resources=None, time_index=None)[source]
Initialize a System instance.
- Parameters:
components (list[Component] | None, optional) β The components to include in the system. If None, an empty list is used.
resources (list[Resource] | None, optional) β The resources to include in the system. If None, an empty list is used.
time_index (list[int] | None, optional) β The time periods for simulation. If None, [0] is used.
- Return type:
None
- add_component(comp)[source]
Add a component to the system.
- Parameters:
comp (Component) β The component to add.
- Returns:
The system instance for method chaining.
- Return type:
Self
- Raises:
ValueError β If the component validation fails (via verify method).
- add_resource(res)[source]
Add a resource to the system.
- Parameters:
res (Resource) β The resource to add.
- Returns:
The system instance for method chaining.
- Return type:
Self
- build()[source]
Build the system model.
This method is intended to construct the necessary optimization problem based on the system configuration.
- Raises:
NotImplementedError β This method is not yet implemented.
- Return type:
- solve(model_type='price_taker', **kw)[source]
Solve the system optimization problem.
- Parameters:
- Returns:
The optimization results.
- Return type:
Any
- Raises:
ValueError β If the specified model_type is not registered.
- summary()[source]
Print a summary of the system configuration.
Displays information about the number and names of components and resources, categorizes components into storage and non-storage types, and shows the time horizon length.
- Return type:
- verify_components_definition()[source]
Verify that components are valid.
Checks for: - Uniqueness of component names
- Raises:
ValueError β If component names are not unique
- Return type:
- verify_resources_definition()[source]
Verify that resources are valid.
Checks for: - Type of resources - Uniqueness of resource names
- Raises:
TypeError β If any resource is not of type Resource
ValueError β If resource names are not unique
- Return type:
- verify_time_series()[source]
Verify the integrity of the systemβs time series.
Checks for: - Consistency of time series lengths with the system time index
- Raises:
ValueError β If component capacity profile length doesnβt match time index length
- Return type:
- class dove.core.Component[source]
Bases:
ABC
A base component class for energy system modeling.
This abstract class defines the common interface and validation for components in an energy system. Components have time-dependent capacity constraints, can consume and produce resources, and can have associated cashflows.
- name
Unique identifier for the component.
- Type:
- max_capacity_profile
Time-dependent maximum operational capacity of the component.
- Type:
TimeDependent
- min_capacity_profile
Time-dependent minimum operational capacity; defaults to 0.0 for every timestep.
- Type:
TimeDependent
- capacity_resource
The resource that defines capacity, if any.
- Type:
Resource | None
- flexibility
Whether the componentβs operation is flexible or fixed in optimization.
- Type:
Literal[βflexβ, βfixedβ]
- transfer_fn
Function defining resource conversion logic.
- Type:
TransferFunc | None
Notes
This is an abstract base class that should be subclassed to implement specific component types like generators, grids, storage, etc.
- Parameters:
name (str)
max_capacity_profile (TimeDependent)
consumes (list[Resource])
produces (list[Resource])
min_capacity_profile (TimeDependent)
capacity_resource (Resource | None)
flexibility (Literal[βflexβ, βfixedβ])
cashflows (list[CashFlow])
transfer_fn (TransferFunc | None)
- __init__(*, name, max_capacity_profile, consumes=<factory>, produces=<factory>, min_capacity_profile=<factory>, capacity_resource=None, flexibility='flex', cashflows=<factory>, transfer_fn=None)
- Parameters:
name (str)
max_capacity_profile (TimeDependent)
consumes (list[Resource])
produces (list[Resource])
min_capacity_profile (TimeDependent)
capacity_resource (Resource | None)
flexibility (Literal[βflexβ, βfixedβ])
cashflows (list[CashFlow])
transfer_fn (TransferFunc | None)
- Return type:
None
- capacity_resource: Resource | None = None
- flexibility: Literal['flex', 'fixed'] = 'flex'
- transfer_fn: TransferFunc | None = None
- name: str
- max_capacity_profile: TimeDependent
- consumes: list[Resource]
- produces: list[Resource]
- min_capacity_profile: TimeDependent
- cashflows: list[CashFlow]
- class dove.core.Converter[source]
Bases:
Component
A Component subclass that converts resources from one type to another.
The Converter class represents components that consume one set of resources and produce another, potentially different set of resources.
- Parameters:
ramp_limit (float) β Maximum rate of change for the componentβs capacity utilization between timesteps as a percent of capacity. Must be a value between 0 and 1. Default is 1.0 (no limit).
ramp_freq (int) β Frequency at which ramp limitations are applied. Default is 0 (every timestep).
**kwargs (Any) β Additional keyword arguments to pass to the parent Component class.
Notes
A Converter requires a βcapacity_resourceβ to determine its capacity limits.
If not specified, the capacity_resource will be automatically determined: - If the component consumes and produces the same resource, that resource is used. - Otherwise, capacity_resource must be explicitly specified.
When resources differ between input and output, a transfer_fn is required to define the conversion relationship.
- Parameters:
name (str)
max_capacity_profile (TimeDependent)
consumes (list[Resource])
produces (list[Resource])
min_capacity_profile (TimeDependent)
capacity_resource (Resource | None)
flexibility (Literal[βflexβ, βfixedβ])
cashflows (list[CashFlow])
transfer_fn (TransferFunc | None)
- __init__(ramp_limit=1.0, ramp_freq=0, *, name, max_capacity_profile, consumes=<factory>, produces=<factory>, min_capacity_profile=<factory>, capacity_resource=None, flexibility='flex', cashflows=<factory>, transfer_fn=None)
- Parameters:
ramp_limit (float)
ramp_freq (int)
name (str)
max_capacity_profile (TimeDependent)
consumes (list[Resource])
produces (list[Resource])
min_capacity_profile (TimeDependent)
capacity_resource (Resource | None)
flexibility (Literal[βflexβ, βfixedβ])
cashflows (list[CashFlow])
transfer_fn (TransferFunc | None)
- Return type:
None
- ramp_freq: int = 0
- ramp_limit: float = 1.0
- name: str
- max_capacity_profile: TimeDependent
- consumes: list[Resource]
- produces: list[Resource]
- min_capacity_profile: TimeDependent
- cashflows: list[CashFlow]
- class dove.core.Sink[source]
Bases:
Component
A component that consumes a resource and acts as an endpoint in the DOVE system.
A Sink is a specialized Component that only consumes resources without producing any. It represents destinations where resources exit the system, such as exporters, consumers, or terminal points in a resource flow network.
- Parameters:
- Raises:
ValueError β If βproducesβ or βcapacity_resourceβ is found in the kwargs
Notes
By default a Sink creates a RatioTransfer function with a 1:1 ratio using the consumed resource as both input and mocked output.
- class dove.core.Source[source]
Bases:
Component
A Source component that produces a specified resource in the DOVE simulation.
This component acts as a resource generator or provider in the system simulation, producing a specific resource type with a configurable capacity.
- Parameters:
- Raises:
ValueError β If βconsumesβ or βcapacity_resourceβ is found in the kwargs
Notes
By default, a Source uses a RatioTransfer function with a 1:1 ratio, meaning it will output the same amount of resource as requested (up to its capacity limit).
- class dove.core.Storage[source]
Bases:
Component
Storage component for modeling energy storage systems.
This class represents a storage component in the energy system, capable of charging and discharging a specific resource.
- resource
The resource type that this storage can store.
- Type:
- rte
Round-trip efficiency, between 0 and 1. Defaults to 1.0.
- Type:
- max_charge_rate
Maximum charge rate as a fraction of capacity per time period, between 0 and 1. Defaults to 1.0.
- Type:
- max_discharge_rate
Maximum discharge rate as a fraction of capacity per time period, between 0 and 1. Defaults to 1.0.
- Type:
- initial_stored
Initial stored amount as a fraction of capacity, between 0 and 1. Defaults to 0.0.
- Type:
- periodic_level
If True, storage level at the end of the simulation must equal the initial level. Defaults to True.
- Type:
- \*\*kwargs
Additional keyword arguments to pass to the parent Component class. Itβs important to note that some Component attributes may not be applicable to Storage components, such as produces, consumes, and capacity_resource. These attributes are set automatically based on the resource parameter as necessary.
- Type:
Any
Notes
Storage components are treated differently from other components in terms of capacity and resource management. They can store energy for later use, and their operation is governed by the round-trip efficiency (rte) and charge/discharge rates.
- Parameters:
resource (Resource)
rte (float)
max_charge_rate (float)
max_discharge_rate (float)
initial_stored (float)
periodic_level (bool)
name (str)
max_capacity_profile (TimeDependent)
consumes (list[Resource])
produces (list[Resource])
min_capacity_profile (TimeDependent)
capacity_resource (Resource | None)
flexibility (Literal[βflexβ, βfixedβ])
cashflows (list[CashFlow])
transfer_fn (TransferFunc | None)
- __init__(resource, rte=1.0, max_charge_rate=1.0, max_discharge_rate=1.0, initial_stored=0.0, periodic_level=True, *, name, max_capacity_profile, consumes=<factory>, produces=<factory>, min_capacity_profile=<factory>, capacity_resource=None, flexibility='flex', cashflows=<factory>, transfer_fn=None)
- Parameters:
resource (Resource)
rte (float)
max_charge_rate (float)
max_discharge_rate (float)
initial_stored (float)
periodic_level (bool)
name (str)
max_capacity_profile (TimeDependent)
consumes (list[Resource])
produces (list[Resource])
min_capacity_profile (TimeDependent)
capacity_resource (Resource | None)
flexibility (Literal[βflexβ, βfixedβ])
cashflows (list[CashFlow])
transfer_fn (TransferFunc | None)
- Return type:
None
- initial_stored: float = 0.0
- max_charge_rate: float = 1.0
- max_discharge_rate: float = 1.0
- periodic_level: bool = True
- rte: float = 1.0
- resource: Resource
- name: str
- max_capacity_profile: TimeDependent
- consumes: list[Resource]
- produces: list[Resource]
- min_capacity_profile: TimeDependent
- cashflows: list[CashFlow]
- class dove.core.CashFlow[source]
Bases:
ABC
Abstract base class representing a financial cash flow.
This class serves as the foundation for different types of cash flows in the system. Cash flows have associated pricing profiles that can vary over time. If a price profile is not provided, it will default to using alpha as the fixed recurring value for the length of the simulation.
- Parameters:
name (str) β Identifier for the cash flow.
price_profile (TimeDependent, optional) β Time-dependent pricing data, defaults to empty list.
alpha (float, optional) β Scaling factor for the cash flow magnitude, defaults to 1.0.
dprime (float, optional) β Adjustment factor for price calculations, defaults to 1.0.
scalex (float, optional) β Horizontal scaling factor for time-dependent functions, defaults to 1.0.
price_is_levelized (bool, optional) β Flag indicating if the price is levelized, defaults to False. (Not Implemented)
sign (int, optional) β Direction of the cash flow (positive or negative), defaults to 0.
- __init__(name, price_profile=<factory>, alpha=1.0, dprime=1.0, scalex=1.0, price_is_levelized=False, sign=0)
-
alpha:
float
= 1.0
-
dprime:
float
= 1.0
-
price_is_levelized:
bool
= False
-
scalex:
float
= 1.0
-
sign:
int
= 0
-
name:
str
- class dove.core.Cost[source]
Bases:
CashFlow
Represents a negative cash flow or cost.
This class is a subclass of the CashFlow abstract base class that specifically represents costs or expenses. A Cost instance always has a negative sign, which is enforced by setting the sign class attribute to -1.
- sign
Fixed value of -1 to indicate that this cash flow represents a cost.
- Type:
Examples
A recurring cost of $1,000.00 per time period:
>>> cost = Cost(name="Recurring Cost", alpha=1000.0)
Note that not specifying a price_profile will default to using alpha as the fixed value for the length of the simulation.
A time-dependent cost with a specific price profile:
>>> cost = Cost( ... name="Time-Dependent Cost", ... price_profile=[0.5, 1.0, 1.5], ... alpha=1000.0)
- Parameters:
- __init__(name, price_profile=<factory>, alpha=1.0, dprime=1.0, scalex=1.0, price_is_levelized=False, sign=-1)
-
sign:
int
= -1
-
name:
str
- class dove.core.Resource[source]
Bases:
object
A class representing a resource in the system.
This class is used to model resources that can be allocated, managed, or tracked within the system. Each resource has a name and an optional unit of measurement.
- name
The unique name of the resource.
- Type:
- unit
The unit of measurement for the resource (e.g., βkgβ, βlitersβ, βpiecesβ). Defaults to None if the resource doesnβt have a specific unit. (Currently not used)
- Type:
str | None
-
name:
str
- class dove.core.Revenue[source]
Bases:
CashFlow
A class representing revenue in a financial context.
Revenue is a subclass of CashFlow with a positive sign (+1), indicating incoming cash flow. It represents income generated from the sale of goods, services, or other business activities.
- sign
The sign of the cash flow, set to +1 for revenue (incoming cash).
- Type:
- Parameters:
- __init__(name, price_profile=<factory>, alpha=1.0, dprime=1.0, scalex=1.0, price_is_levelized=False, sign=1)
-
sign:
int
= 1
-
name:
str
- class dove.core.RatioTransfer[source]
Bases:
object
A transfer class that enforces a ratio relationship between input and output resources.
This class models the conversion of one resource to another with a specified ratio. For example, it could represent energy conversion efficiency or material transformation.
- Parameters:
input_res (Resource) β The input resource object.
output_res (Resource) β The output resource object.
ratio (float, default=1.0) β The conversion ratio from input to output. A ratio of 1.0 means the output equals the input. A ratio of 0.9 means 90% of input becomes output (10% loss). A ratio > 1.0 means the output is amplified relative to input.
Examples
Create a transfer that converts electricity to heat with 95% efficiency:
>>> transfer = RatioTransfer( input_res=Resource("electricity"), output_res=Resource("heat"), ratio=0.95 )
Later, after component instantiation, the transfer can be used evaluate a constraint with dispatch activity values:
>>> transfer(inputs={"electricity": 100}, outputs={"heat": 95}) True
- __init__(input_res, output_res, ratio=1.0)
-
ratio:
float
= 1.0
-
input_res:
Resource
-
output_res:
Resource
- class dove.core.PolynomialTransfer[source]
Bases:
object
Represents a polynomial transfer function that maps input resources to output resources.
This class models a polynomial relationship between inputs and outputs, where the output is a sum of terms, each term being a coefficient multiplied by input resources raised to specified powers.
- Parameters:
terms (list[tuple[float, dict[Resource, int]]]) β A list of terms in the polynomial. Each term is represented as a tuple containing: - A coefficient (float) - A dictionary (dict[Resource, int]) mapping Resource objects to their exponents in the term.
Examples
A combined cycle power plant model with efficiency curve: output = 0.35 * natural_gas^1 + 0.05 * natural_gas^0.5 would be represented as:
>>> PolynomialTransfer([ (0.35, {natural_gas: 1}), (0.05, {natural_gas: 0.5}) ])
Submodules#
dove.core.cashflow module#
dove.core.cashflow
#
Module containing cash flow classes for financial modeling in DOVE.
This module defines classes for representing financial cash flows in energy system models, including both costs and revenues. These cash flows can vary over time and have configurable scaling factors.
Classes#
CashFlow: Abstract base class for all cash flows Cost: Represents expenses or negative cash flows Revenue: Represents income or positive cash flows
- class dove.core.cashflow.CashFlow[source]#
Bases:
ABC
Abstract base class representing a financial cash flow.
This class serves as the foundation for different types of cash flows in the system. Cash flows have associated pricing profiles that can vary over time. If a price profile is not provided, it will default to using alpha as the fixed recurring value for the length of the simulation.
- Parameters:
name (str) β Identifier for the cash flow.
price_profile (TimeDependent, optional) β Time-dependent pricing data, defaults to empty list.
alpha (float, optional) β Scaling factor for the cash flow magnitude, defaults to 1.0.
dprime (float, optional) β Adjustment factor for price calculations, defaults to 1.0.
scalex (float, optional) β Horizontal scaling factor for time-dependent functions, defaults to 1.0.
price_is_levelized (bool, optional) β Flag indicating if the price is levelized, defaults to False. (Not Implemented)
sign (int, optional) β Direction of the cash flow (positive or negative), defaults to 0.
- __init__(name, price_profile=<factory>, alpha=1.0, dprime=1.0, scalex=1.0, price_is_levelized=False, sign=0)#
- class dove.core.cashflow.Cost[source]#
Bases:
CashFlow
Represents a negative cash flow or cost.
This class is a subclass of the CashFlow abstract base class that specifically represents costs or expenses. A Cost instance always has a negative sign, which is enforced by setting the sign class attribute to -1.
Examples
A recurring cost of $1,000.00 per time period:
>>> cost = Cost(name="Recurring Cost", alpha=1000.0)
Note that not specifying a price_profile will default to using alpha as the fixed value for the length of the simulation.
A time-dependent cost with a specific price profile:
>>> cost = Cost( ... name="Time-Dependent Cost", ... price_profile=[0.5, 1.0, 1.5], ... alpha=1000.0)
- Parameters:
- __init__(name, price_profile=<factory>, alpha=1.0, dprime=1.0, scalex=1.0, price_is_levelized=False, sign=-1)#
- class dove.core.cashflow.Revenue[source]#
Bases:
CashFlow
A class representing revenue in a financial context.
Revenue is a subclass of CashFlow with a positive sign (+1), indicating incoming cash flow. It represents income generated from the sale of goods, services, or other business activities.
- Parameters:
- __init__(name, price_profile=<factory>, alpha=1.0, dprime=1.0, scalex=1.0, price_is_levelized=False, sign=1)#
dove.core.components module#
dove.core.components
#
Module containing component classes that form the basis of DOVE models.
Components are connected through resources they consume and produce, forming a directed graph that represents a system model. Each component can have associated cash flows to motivate the optimization and transfer functions that define how resources flow through the component.
Classes#
Component: Abstract base class for all components in a DOVE model
Source: Component that produces a resource
Sink: Component that consumes a resource
Converter: Component that transforms input resources into output resources
Storage: Component that can store a resource for later use
Types#
TimeDependent: Type alias for time series data (list of floats or NumPy array)
- class dove.core.components.Component[source]#
Bases:
ABC
A base component class for energy system modeling.
This abstract class defines the common interface and validation for components in an energy system. Components have time-dependent capacity constraints, can consume and produce resources, and can have associated cashflows.
- max_capacity_profile#
Time-dependent maximum operational capacity of the component.
- Type:
TimeDependent
- min_capacity_profile#
Time-dependent minimum operational capacity; defaults to 0.0 for every timestep.
- Type:
TimeDependent
- flexibility#
Whether the componentβs operation is flexible or fixed in optimization.
- Type:
Literal[βflexβ, βfixedβ]
- transfer_fn#
Function defining resource conversion logic.
- Type:
TransferFunc | None
Notes
This is an abstract base class that should be subclassed to implement specific component types like generators, grids, storage, etc.
- Parameters:
name (str)
max_capacity_profile (TimeDependent)
consumes (list[Resource])
produces (list[Resource])
min_capacity_profile (TimeDependent)
capacity_resource (Resource | None)
flexibility (Literal[βflexβ, βfixedβ])
cashflows (list[CashFlow])
transfer_fn (TransferFunc | None)
- name: str#
- max_capacity_profile: TimeDependent#
- consumes: list[Resource]#
- produces: list[Resource]#
- min_capacity_profile: TimeDependent#
- capacity_resource: Resource | None = None#
- flexibility: Literal['flex', 'fixed'] = 'flex'#
- cashflows: list[CashFlow]#
- transfer_fn: TransferFunc | None = None#
- __init__(*, name, max_capacity_profile, consumes=<factory>, produces=<factory>, min_capacity_profile=<factory>, capacity_resource=None, flexibility='flex', cashflows=<factory>, transfer_fn=None)#
- Parameters:
name (str)
max_capacity_profile (TimeDependent)
consumes (list[Resource])
produces (list[Resource])
min_capacity_profile (TimeDependent)
capacity_resource (Resource | None)
flexibility (Literal[βflexβ, βfixedβ])
cashflows (list[CashFlow])
transfer_fn (TransferFunc | None)
- Return type:
None
- class dove.core.components.Source[source]#
Bases:
Component
A Source component that produces a specified resource in the DOVE simulation.
This component acts as a resource generator or provider in the system simulation, producing a specific resource type with a configurable capacity.
- Parameters:
- Raises:
ValueError β If βconsumesβ or βcapacity_resourceβ is found in the kwargs
Notes
By default, a Source uses a RatioTransfer function with a 1:1 ratio, meaning it will output the same amount of resource as requested (up to its capacity limit).
- class dove.core.components.Sink[source]#
Bases:
Component
A component that consumes a resource and acts as an endpoint in the DOVE system.
A Sink is a specialized Component that only consumes resources without producing any. It represents destinations where resources exit the system, such as exporters, consumers, or terminal points in a resource flow network.
- Parameters:
- Raises:
ValueError β If βproducesβ or βcapacity_resourceβ is found in the kwargs
Notes
By default a Sink creates a RatioTransfer function with a 1:1 ratio using the consumed resource as both input and mocked output.
- class dove.core.components.Converter[source]#
Bases:
Component
A Component subclass that converts resources from one type to another.
The Converter class represents components that consume one set of resources and produce another, potentially different set of resources.
- Parameters:
ramp_limit (float) β Maximum rate of change for the componentβs capacity utilization between timesteps as a percent of capacity. Must be a value between 0 and 1. Default is 1.0 (no limit).
ramp_freq (int) β Frequency at which ramp limitations are applied. Default is 0 (every timestep).
**kwargs (Any) β Additional keyword arguments to pass to the parent Component class.
Notes
A Converter requires a βcapacity_resourceβ to determine its capacity limits.
If not specified, the capacity_resource will be automatically determined: - If the component consumes and produces the same resource, that resource is used. - Otherwise, capacity_resource must be explicitly specified.
When resources differ between input and output, a transfer_fn is required to define the conversion relationship.
- Parameters:
name (str)
max_capacity_profile (TimeDependent)
consumes (list[Resource])
produces (list[Resource])
min_capacity_profile (TimeDependent)
capacity_resource (Resource | None)
flexibility (Literal[βflexβ, βfixedβ])
cashflows (list[CashFlow])
transfer_fn (TransferFunc | None)
- ramp_limit: float = 1.0#
- ramp_freq: int = 0#
- __init__(ramp_limit=1.0, ramp_freq=0, *, name, max_capacity_profile, consumes=<factory>, produces=<factory>, min_capacity_profile=<factory>, capacity_resource=None, flexibility='flex', cashflows=<factory>, transfer_fn=None)#
- Parameters:
ramp_limit (float)
ramp_freq (int)
name (str)
max_capacity_profile (TimeDependent)
consumes (list[Resource])
produces (list[Resource])
min_capacity_profile (TimeDependent)
capacity_resource (Resource | None)
flexibility (Literal[βflexβ, βfixedβ])
cashflows (list[CashFlow])
transfer_fn (TransferFunc | None)
- Return type:
None
- name: str#
- max_capacity_profile: TimeDependent#
- consumes: list[Resource]#
- produces: list[Resource]#
- min_capacity_profile: TimeDependent#
- cashflows: list[CashFlow]#
- class dove.core.components.Storage[source]#
Bases:
Component
Storage component for modeling energy storage systems.
This class represents a storage component in the energy system, capable of charging and discharging a specific resource.
- max_charge_rate#
Maximum charge rate as a fraction of capacity per time period, between 0 and 1. Defaults to 1.0.
- Type:
- max_discharge_rate#
Maximum discharge rate as a fraction of capacity per time period, between 0 and 1. Defaults to 1.0.
- Type:
- initial_stored#
Initial stored amount as a fraction of capacity, between 0 and 1. Defaults to 0.0.
- Type:
- periodic_level#
If True, storage level at the end of the simulation must equal the initial level. Defaults to True.
- Type:
- \*\*kwargs
Additional keyword arguments to pass to the parent Component class. Itβs important to note that some Component attributes may not be applicable to Storage components, such as produces, consumes, and capacity_resource. These attributes are set automatically based on the resource parameter as necessary.
- Type:
Any
Notes
Storage components are treated differently from other components in terms of capacity and resource management. They can store energy for later use, and their operation is governed by the round-trip efficiency (rte) and charge/discharge rates.
- Parameters:
resource (Resource)
rte (float)
max_charge_rate (float)
max_discharge_rate (float)
initial_stored (float)
periodic_level (bool)
name (str)
max_capacity_profile (TimeDependent)
consumes (list[Resource])
produces (list[Resource])
min_capacity_profile (TimeDependent)
capacity_resource (Resource | None)
flexibility (Literal[βflexβ, βfixedβ])
cashflows (list[CashFlow])
transfer_fn (TransferFunc | None)
- resource: Resource#
- rte: float = 1.0#
- max_charge_rate: float = 1.0#
- max_discharge_rate: float = 1.0#
- initial_stored: float = 0.0#
- periodic_level: bool = True#
- __init__(resource, rte=1.0, max_charge_rate=1.0, max_discharge_rate=1.0, initial_stored=0.0, periodic_level=True, *, name, max_capacity_profile, consumes=<factory>, produces=<factory>, min_capacity_profile=<factory>, capacity_resource=None, flexibility='flex', cashflows=<factory>, transfer_fn=None)#
- Parameters:
resource (Resource)
rte (float)
max_charge_rate (float)
max_discharge_rate (float)
initial_stored (float)
periodic_level (bool)
name (str)
max_capacity_profile (TimeDependent)
consumes (list[Resource])
produces (list[Resource])
min_capacity_profile (TimeDependent)
capacity_resource (Resource | None)
flexibility (Literal[βflexβ, βfixedβ])
cashflows (list[CashFlow])
transfer_fn (TransferFunc | None)
- Return type:
None
- name: str#
- max_capacity_profile: TimeDependent#
- consumes: list[Resource]#
- produces: list[Resource]#
- min_capacity_profile: TimeDependent#
- cashflows: list[CashFlow]#
dove.core.resource module#
dove.core.resource
#
This module provides the Resource class for representing and managing system resources. Resources are fundamental entities that can be allocated, tracked, and managed within the DOVE system. Each resource is identified by a unique name and can optionally have an associated unit of measurement.
Classes#
Resource: A dataclass representing a system resource with a name and optional unit.
Examples
``` # Create a resource for electricity with kilowatt-hours as unit electricity = Resource(name=βelectricityβ, unit=βkWhβ)
# Create a resource without a specific unit labor = Resource(name=βlaborβ) ```
- class dove.core.resource.Resource[source]#
Bases:
object
A class representing a resource in the system.
This class is used to model resources that can be allocated, managed, or tracked within the system. Each resource has a name and an optional unit of measurement.
dove.core.system module#
dove.core.system
#
Module containing the System class for modeling energy systems.
The System class forms the central component of DOVE models, connecting resources and components in a coherent framework for optimization and simulation. The System manages time series data, component interactions, and provides methods for building and solving optimization problems.
Classes#
System: Main class for creating and managing DOVE energy system models.
- class dove.core.system.System[source]#
Bases:
object
The main class for creating and managing energy system models.
A System represents a collection of components and resources that form an energy system. It provides methods for adding components and resources, validating the system configuration, and solving optimization problems.
- Parameters:
- __init__(components=None, resources=None, time_index=None)[source]#
Initialize a System instance.
- Parameters:
components (list[Component] | None, optional) β The components to include in the system. If None, an empty list is used.
resources (list[Resource] | None, optional) β The resources to include in the system. If None, an empty list is used.
time_index (list[int] | None, optional) β The time periods for simulation. If None, [0] is used.
- Return type:
None
- summary()[source]#
Print a summary of the system configuration.
Displays information about the number and names of components and resources, categorizes components into storage and non-storage types, and shows the time horizon length.
- Return type:
- verify_components_definition()[source]#
Verify that components are valid.
Checks for: - Uniqueness of component names
- Raises:
ValueError β If component names are not unique
- Return type:
- verify_resources_definition()[source]#
Verify that resources are valid.
Checks for: - Type of resources - Uniqueness of resource names
- Raises:
TypeError β If any resource is not of type Resource
ValueError β If resource names are not unique
- Return type:
- verify_time_series()[source]#
Verify the integrity of the systemβs time series.
Checks for: - Consistency of time series lengths with the system time index
- Raises:
ValueError β If component capacity profile length doesnβt match time index length
- Return type:
- add_component(comp)[source]#
Add a component to the system.
- Parameters:
comp (Component) β The component to add.
- Returns:
The system instance for method chaining.
- Return type:
Self
- Raises:
ValueError β If the component validation fails (via verify method).
- add_resource(res)[source]#
Add a resource to the system.
- Parameters:
res (Resource) β The resource to add.
- Returns:
The system instance for method chaining.
- Return type:
Self
- build()[source]#
Build the system model.
This method is intended to construct the necessary optimization problem based on the system configuration.
- Raises:
NotImplementedError β This method is not yet implemented.
- Return type:
- solve(model_type='price_taker', **kw)[source]#
Solve the system optimization problem.
- Parameters:
- Returns:
The optimization results.
- Return type:
Any
- Raises:
ValueError β If the specified model_type is not registered.
dove.core.transfers module#
dove.core.transfers
#
Core transfer functions for resource conversion in the DOVE optimization framework.
This module provides classes that model mathematical relationships between input and output resources in energy systems. These transfer functions represent physical or economic transformations such as energy conversion, efficiency losses, or material transformations.
The module defines two main transfer function types: - RatioTransfer: Simple linear relationship between inputs and outputs (e.g., efficiency) - PolynomialTransfer: More complex non-linear relationship described by polynomial terms
These transfer functions can be used to model various energy conversion processes including power plants, heat exchangers, fuel cells, and other technologies where inputs are transformed into outputs with specific characteristics.
- class dove.core.transfers.RatioTransfer[source]#
Bases:
object
A transfer class that enforces a ratio relationship between input and output resources.
This class models the conversion of one resource to another with a specified ratio. For example, it could represent energy conversion efficiency or material transformation.
- Parameters:
input_res (Resource) β The input resource object.
output_res (Resource) β The output resource object.
ratio (float, default=1.0) β The conversion ratio from input to output. A ratio of 1.0 means the output equals the input. A ratio of 0.9 means 90% of input becomes output (10% loss). A ratio > 1.0 means the output is amplified relative to input.
Examples
Create a transfer that converts electricity to heat with 95% efficiency:
>>> transfer = RatioTransfer( input_res=Resource("electricity"), output_res=Resource("heat"), ratio=0.95 )
Later, after component instantiation, the transfer can be used evaluate a constraint with dispatch activity values:
>>> transfer(inputs={"electricity": 100}, outputs={"heat": 95}) True
- class dove.core.transfers.PolynomialTransfer[source]#
Bases:
object
Represents a polynomial transfer function that maps input resources to output resources.
This class models a polynomial relationship between inputs and outputs, where the output is a sum of terms, each term being a coefficient multiplied by input resources raised to specified powers.
- Parameters:
terms (list[tuple[float, dict[Resource, int]]]) β A list of terms in the polynomial. Each term is represented as a tuple containing: - A coefficient (float) - A dictionary (dict[Resource, int]) mapping Resource objects to their exponents in the term.
Examples
A combined cycle power plant model with efficiency curve: output = 0.35 * natural_gas^1 + 0.05 * natural_gas^0.5 would be represented as:
>>> PolynomialTransfer([ (0.35, {natural_gas: 1}), (0.05, {natural_gas: 0.5}) ])