Skip to content

Commit

Permalink
spiceev interface updates #21
Browse files Browse the repository at this point in the history
  • Loading branch information
mosc5 committed Dec 15, 2022
1 parent 8697e23 commit 9fd6bac
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 5 deletions.
6 changes: 4 additions & 2 deletions scenarios/public_transport_base/charging_points.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,14 @@
"Marktplatz": {
"plug_types": ["inductive_ifak"],
"generator": ["pv", "south"],
"number_charging_points": 3
"number_charging_points": 3,
"grid_connection": 50
},
"Bahnhof": {
"plug_types": ["inductive_ifak"],
"generator": null,
"number_charging_points": 1
"number_charging_points": 1,
"grid_connection": 11
}
}
}
5 changes: 5 additions & 0 deletions src/advantage/location.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,11 @@ def available(self):
"""This methods checks availability."""
return None

def set_power(self, power: float):
if self.grid_info is None:
self.grid_info = {}
self.grid_info["power"] = power

def get_scenario_info(self, plug_types: List[str], point_id: Optional[str] = None):
"""Create SpiceEV scenario dict for this Location.
Expand Down
6 changes: 5 additions & 1 deletion src/advantage/simulation.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,10 @@ def __init__(
name, info["number_charging_points"], plug_types
)
self.locations[name].chargers.append(charger)
if "grid_connection" in info:
self.locations[name].set_power(float(info["grid_connection"]))
else:
self.locations[name].set_power(50.0)
# TODO add grid info to location here?
if not self.locations[name] in self.charging_locations:
self.charging_locations.append(self.locations[name])
Expand Down Expand Up @@ -312,7 +316,7 @@ def evaluate_charging_location(
charging_start + charging_time,
mock_vehicle,
)
charged_energy = 0 # TODO call spiceev with charging location
charged_energy = spiceev_scenario.socs[-1][0] - current_soc # type: ignore
charge_score = 1 - (consumption / charged_energy)
if charge_score <= 0:
return 0
Expand Down
2 changes: 1 addition & 1 deletion tests/test_spiceev_interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ def test_run_spice_ev(car, time_series, spot):
start_step = 5
time_stamp = step_to_timestamp(time_series, start_step)
spice_dict = get_spice_ev_scenario_dict(car, spot, "point_0", time_stamp, 10)
spice_dict["constants"]["vehicles"]["vehicle_name_0"]["connected_charging_station"] = "point_0"
spice_dict["constants"]["vehicles"]["car"]["connected_charging_station"] = "point_0"
scenario = run_spice_ev(spice_dict, "balanced")
# check if soc is higher than before
assert scenario.socs[-1][0] > car.soc # type: ignore
2 changes: 1 addition & 1 deletion tests/test_vehicle.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ def test_park_input_checks(car, time_series):


def test_scenario_info(car):
assert car.scenario_info["constants"]["vehicles"]["vehicle_name_0"]["soc"] == 0.5
assert car.scenario_info["constants"]["vehicles"]["car"]["soc"] == 0.5


def test_task_list_sanity(car):
Expand Down

0 comments on commit 9fd6bac

Please sign in to comment.