Skip to content

Commit

Permalink
update script and fix bug in latest version
Browse files Browse the repository at this point in the history
  • Loading branch information
maurerle committed Jun 28, 2023
1 parent 19c7df2 commit b8c95d8
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 22 deletions.
4 changes: 2 additions & 2 deletions assume/units/powerplant.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ def __init__(
self.fuel_price = fuel_price
if type(co2_price) is pd.Series and len(co2_price) == 1:
co2_price = co2_price.item()
self.co2_price
self.co2_price = co2_price
self.price_forecast = (
pd.Series(0.0, index=self.index) if price_forecast.empty else price_forecast
)
Expand Down Expand Up @@ -214,7 +214,7 @@ def calculate_energy_operational_window(
"window": {"start": start, "end": end},
"current_power": {
"power": previous_power,
"marginal_cost": self.calc_marginal_cost(
"marginal_cost": self.calc_marginal_cost_with_partial_eff(
power_output=previous_power,
timestep=start,
),
Expand Down
30 changes: 15 additions & 15 deletions assume/world.py
Original file line number Diff line number Diff line change
Expand Up @@ -283,21 +283,21 @@ def creator(container):
else:
market_price_forecast = None

forecast_provider = ForecastProvider(
market_id=market_id,
price_forecast_df=market_price_forecast,
fuel_prices_df=fuel_prices_df,
vre_cf_df=vre_cf_df,
powerplants=powerplant_units,
demand_df=demand_df[f"demand_{market_id}"],
)
forecast_agent = RoleAgent(
self.container, suggested_aid=f"forecast_agent_{market_id}"
)
forecast_agent.add_role(forecast_provider)
self.forecast_providers[market_id] = forecast_provider

temp[market_id] = forecast_provider.price_forecast_df
# forecast_provider = ForecastProvider(
# market_id=market_id,
# price_forecast_df=market_price_forecast,
# fuel_prices_df=fuel_prices_df,
# vre_cf_df=vre_cf_df,
# powerplants=powerplant_units,
# demand_df=demand_df[f"demand_{market_id}"],
# )
# forecast_agent = RoleAgent(
# self.container, suggested_aid=f"forecast_agent_{market_id}"
# )
# forecast_agent.add_role(forecast_provider)
# self.forecast_providers[market_id] = forecast_provider

# temp[market_id] = forecast_provider.price_forecast_df

temp.to_csv(f"{path}/price_forecasts.csv", index=True)

Expand Down
16 changes: 11 additions & 5 deletions examples/paper.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,23 +56,29 @@ def plot_and_save_results():
## Data preparation
eom = df[df["name"] == "EOM"]
ltm = df[df["name"] == "LTM_OTC"].reset_index()
ltm.loc[0, "average_cost"] = None
xticks = list(ltm["simulation"])
# ltm.loc[0, "average_cost"] = None
xticks = list(eom["simulation"])
# xlabels = [f"{i}%" for i in range(0, 101, 10)]
xlabels = ["EOM", "EOM + LTM"]
plt.style.use("seaborn-v0_8")

fig, (ax1, ax2) = plt.subplots(2, 1)
# Total Dispatch cost
ax1.bar(eom["simulation"], eom["total_cost"], label="EOM")
ax1.bar(ltm["simulation"], ltm["total_cost"], bottom=eom["total_cost"], label="LTM")
eom_ltm = eom[eom.simulation == "ltm_case10"]
ax1.bar(
ltm["simulation"],
ltm["total_cost"],
bottom=eom_ltm["total_cost"],
label="LTM",
)
ax1.set_ylabel("Total dispatch cost \n per market [mill. $€$]")
ax1.set_xticks(xticks, xlabels)
ax1.legend()
# Total Average Cost
ax2.scatter(eom["simulation"], eom["average_cost"], label="EOM")
ax2.scatter(ltm["simulation"], ltm["average_cost"], label="LTM")
ax2.bar(ltm["simulation"], ltm["total_cost"] * 0)
ax2.bar(eom["simulation"], eom["total_cost"] * 0)
ax2.set_ylabel("Average cost \n for each scenario [$€/MWh$]")
# ax2.set_xlabel("Fraction of base load traded on LTM in percent")
ax2.set_xlabel("Selected electricity market design")
Expand Down Expand Up @@ -134,5 +140,5 @@ def plot_and_save_results():


if __name__ == "__main__":
run_cases()
# run_cases()
plot_and_save_results()

0 comments on commit b8c95d8

Please sign in to comment.