Skip to content

Commit

Permalink
Merge pull request #225 from rl-institut/feature/report_max_power_in_plw
Browse files Browse the repository at this point in the history
report: add max_power_in_plw to summary
  • Loading branch information
stefansc1 authored Jan 2, 2025
2 parents fba55d1 + bfe42ee commit 3c23cec
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 16 deletions.
24 changes: 14 additions & 10 deletions simba/costs.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,8 +134,10 @@ def get_unit(self, key):
:return: Unit associated with the key
:rtype: str
"""
if "maximum_gc_power" == key:
if "power" in key:
return "kW"
elif "station_type" == key:
return "[-]"
elif "maximum Nr charging stations" == key:
return "[-]"
elif "total_km_per_year" == key:
Expand Down Expand Up @@ -184,7 +186,7 @@ def get_gc_cost_variables(self):
"""
return [
# various kpis and attributes
"station_type", "maximum_gc_power", "maximum Nr charging stations",
"station_type", "maximum_gc_power", "max_power_in_plw", "maximum Nr charging stations",
"total_km_per_year", "annual_kWh_from_grid", "annual_kWh_from_feed_in",

# investment costs
Expand Down Expand Up @@ -372,8 +374,11 @@ def set_electricity_costs(self):
'levies_fees_and_taxes_per_year', error_value)
self.costs_per_gc[gcID]["c_el_feed_in_remuneration_annual"] = costs_electricity.get(
'feed_in_remuneration_per_year', error_value)
self.costs_per_gc[gcID]["c_el_annual"] = costs_electricity.get('total_costs_per_year',
error_value)
self.costs_per_gc[gcID]["c_el_annual"] = costs_electricity.get(
'total_costs_per_year', error_value)
self.costs_per_gc[gcID]["max_power_in_plw"] = costs_electricity.get(
'peak_power_in_windows', error_value)

return self

def set_garage_costs(self):
Expand Down Expand Up @@ -633,10 +638,13 @@ def cumulate(self):
"""
# Cumulate gcs variables
for key in self.get_gc_cost_variables():
# skip special attributes
if key in ["station_type", "maximum_gc_power", "max_power_in_plw"]:
continue
# Vehicle costs cannot be cumulated since they might be double counted for vehicles
# with multiple depots. Instead, the vehicle costs were previously calculated in
# set_vehicle_costs_per_gc()
if key in ["c_vehicles", "c_vehicles_annual", "station_type"]:
if key in ["c_vehicles", "c_vehicles_annual"]:
continue
self.costs_per_gc[self.CUMULATED][key] = 0
for gc in self.costs_per_gc.keys() - [self.CUMULATED]:
Expand Down Expand Up @@ -713,8 +721,4 @@ def to_csv_lists(self):
except TypeError:
row.append(num)
output.append(row)

transposed_output = []
for column, _ in enumerate(output[0]):
transposed_output.append([row[column] for row in output])
return transposed_output
return output
21 changes: 15 additions & 6 deletions tests/test_simulate.py
Original file line number Diff line number Diff line change
Expand Up @@ -200,15 +200,24 @@ def test_mode_report(self, tmp_path):
# read out vehicle costs, procurement price must match
with (tmp_path / "report_1/summary_vehicles_costs.csv").open() as csvfile:
reader = DictReader(csvfile)
# save procurement costs and annual energy for each Station
station_data = {s: {"energy_costs": None, "energy_amount": None}
for s in reader.fieldnames if s.startswith("Station")}
for row in reader:
if row["parameter"] == "unit":
continue
energy = float(row["annual_kWh_from_grid"])
price = float(row["c_el_procurement_annual"])
if row["parameter"] == "c_el_procurement_annual":
for name in station_data:
station_data[name]["energy_costs"] = float(row[name])
if row["parameter"] == "annual_kWh_from_grid":
for name in station_data:
station_data[name]["energy_amount"] = float(row[name])
# check quotient: no energy must mean no cost, otherwise procurement price
for name in station_data:
energy = station_data[name]["energy_amount"]
cost = station_data[name]["energy_costs"]
if energy == 0:
assert price == 0
assert cost == 0, f"{name} has costs without energy"
else:
assert pytest.approx(price / energy) == procurement_price
assert pytest.approx(cost/energy) == procurement_price, f"{name}: procurement"

def test_empty_report(self, tmp_path):
# report with no rotations
Expand Down

0 comments on commit 3c23cec

Please sign in to comment.