Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add the new building DSM class #480

Open
wants to merge 19 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion assume/common/units_operator.py
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,13 @@ def get_actual_dispatch(

# TODO: this needs to be fixed. For now it is consuming too much time and is deactivated
# unit.calculate_generation_cost(start, now, "energy")
valid_outputs = ["soc", "cashflow", "marginal_costs", "total_costs"]
valid_outputs = [
"soc",
"ev_soc",
"cashflow",
"marginal_costs",
"total_costs",
]

for key in unit.outputs.keys():
for output in valid_outputs:
Expand Down
16 changes: 16 additions & 0 deletions assume/common/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -674,3 +674,19 @@ def suppress_output():
os.close(saved_stdout_fd)
os.close(saved_stderr_fd)
os.close(devnull)


def str_to_bool(val):
"""Convert a string representation of truth to True or False.

True values are 'y', 'yes', 't', 'true', 'on', and '1';
false values are 'n', 'no', 'f', 'false', 'off', and '0'.
Raises ValueError if 'val' is anything else.
"""
val = val.lower()
if val in {"y", "yes", "t", "true", "on", "1"}:
return True
elif val in {"n", "no", "f", "false", "off", "0"}:
return False
else:
raise ValueError(f"Invalid truth value: {val!r}")
4 changes: 2 additions & 2 deletions assume/strategies/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@
flexablePosCRMStorage,
)
from assume.strategies.naive_strategies import (
NaiveDASteelplantStrategy,
NaiveNegReserveStrategy,
NaivePosReserveStrategy,
NaiveProfileStrategy,
NaiveRedispatchSteelplantStrategy,
NaiveRedispatchStrategy,
NaiveSingleBidStrategy,
NaiveDSMStrategy,
)
from assume.strategies.manual_strategies import SimpleManualTerminalStrategy
from assume.strategies.dmas_powerplant import DmasPowerplantStrategy
Expand All @@ -40,7 +40,7 @@
"flexable_neg_crm_storage": flexableNegCRMStorage,
"flexable_pos_crm_storage": flexablePosCRMStorage,
"naive_redispatch": NaiveRedispatchStrategy,
"naive_da_steelplant": NaiveDASteelplantStrategy,
"naive_dsm": NaiveDSMStrategy,
"naive_steel_redispatch": NaiveRedispatchSteelplantStrategy,
"manual_strategy": SimpleManualTerminalStrategy,
"dmas_powerplant": DmasPowerplantStrategy,
Expand Down
26 changes: 22 additions & 4 deletions assume/strategies/naive_strategies.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ def calculate_bids(
end_all = product_tuples[-1][1]
previous_power = unit.get_output_before(start)
op_time = unit.get_operation_time(start)
min_power, max_power = unit.calculate_min_max_power(start, end_all)
_, max_power = unit.calculate_min_max_power(start, end_all)

current_power = unit.outputs["energy"].at[start]
marginal_cost = unit.calculate_marginal_cost(start, previous_power)
Expand All @@ -140,16 +140,34 @@ def calculate_bids(
return bids


class NaiveDASteelplantStrategy(BaseStrategy):
class NaiveDSMStrategy(BaseStrategy):
"""
A naive bidding strategy for Demand Side Management (DSM) units. It bids the marginal cost of the unit on the market
as bid price and the optimal power requirement as bid volume.
"""

def calculate_bids(
self,
unit: SupportsMinMax,
market_config: MarketConfig,
product_tuples: list[Product],
**kwargs,
) -> Orderbook:
"""
Takes information from a unit that the unit operator manages and
defines how it is dispatched to the market.

Args:
unit (SupportsMinMax): The unit to be dispatched.
market_config (MarketConfig): The market configuration.
product_tuples (list[Product]): The list of all products the unit can offer.

Returns:
Orderbook: The bids consisting of the start time, end time, only hours, price and volume.
"""

# calculate the optimal operation of the unit
unit.calculate_optimal_operation_if_needed()
unit.determine_optimal_operation_without_flex()

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

executing flexibility

bids = []
for product in product_tuples:
Expand All @@ -158,9 +176,9 @@ def calculate_bids(
and the volume of the product. Dispatch the order to the market.
"""
start = product[0]

volume = unit.opt_power_requirement.loc[start]
marginal_price = unit.calculate_marginal_cost(start, volume)

bids.append(
{
nick-harder marked this conversation as resolved.
Show resolved Hide resolved
"start_time": product[0],
Expand Down
2 changes: 2 additions & 0 deletions assume/units/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,13 @@
from assume.units.powerplant import PowerPlant
from assume.units.storage import Storage
from assume.units.steel_plant import SteelPlant
from assume.units.building import Building
from assume.units.dst_components import demand_side_technologies

unit_types: dict[str, BaseUnit] = {
"power_plant": PowerPlant,
"demand": Demand,
"storage": Storage,
"steel_plant": SteelPlant,
"building": Building,
}
Loading