diff --git a/MANIFEST.in b/MANIFEST.in index f6bc07a6..9c31ce74 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -50,6 +50,8 @@ include premise/data/transport/car/*.csv include premise/data/transport/bus/*.csv include premise/data/transport/truck/*.csv include premise/data/transport/two-wheeler/*.csv +include premise/data/battery/*.csv +include premise/data/battery/*.yaml include premise/data/utils/*.csv include premise/data/utils/*.yml include premise/data/utils/*.yaml diff --git a/premise/data/additional_inventories/lci-battery-capacity.xlsx b/premise/data/additional_inventories/lci-battery-capacity.xlsx index 8d7afd27..e1a62683 100644 Binary files a/premise/data/additional_inventories/lci-battery-capacity.xlsx and b/premise/data/additional_inventories/lci-battery-capacity.xlsx differ diff --git a/premise/data/additional_inventories/lci-trucks.xlsx b/premise/data/additional_inventories/lci-trucks.xlsx index 3a6a3a56..c1f86834 100644 Binary files a/premise/data/additional_inventories/lci-trucks.xlsx and b/premise/data/additional_inventories/lci-trucks.xlsx differ diff --git a/premise/data/transport/battery_size.yaml b/premise/data/transport/battery_size.yaml new file mode 100644 index 00000000..56c1c9b8 --- /dev/null +++ b/premise/data/transport/battery_size.yaml @@ -0,0 +1,128 @@ +# battery size, in kWh +# for long-haul trucks +# provided by carculator_truck +# min: size for a range autonomy of 400 km +# max for a range autonomy of 800 km +# mean: value in between min and max +--- + +truck: + 3.5t: + 2020: + min: 160 + max: 383 + mean: 272 + 2030: + min: 134 + max: 300 + mean: 217 + 2040: + min: 120 + max: 267 + mean: 194 + 2050: + min: 108 + max: 236 + mean: 172 + 7.5t: + 2020: + min: 272 + max: 639 + mean: 456 + 2030: + min: 203 + max: 479 + mean: 341 + 2040: + min: 182 + max: 479 + mean: 330 + 2050: + min: 168 + max: 370 + mean: 269 + 18t: + 2020: + min: 394 + max: 1110 + mean: 752 + 2030: + min: 323 + max: 802 + mean: 562 + 2040: + min: 296 + max: 726 + mean: 511 + 2050: + min: 273 + max: 666 + mean: 470 + 26t: + 2020: + min: 509 + max: 1291 + mean: 900 + 2030: + min: 390 + max: 978 + mean: 684 + 2040: + min: 362 + max: 906 + mean: 634 + 2050: + min: 360 + max: 845 + mean: 603 + 32t: + 2020: + min: 660 + max: 1515 + mean: 1088 + 2030: + min: 550 + max: 1207 + mean: 879 + 2040: + min: 530 + max: 1124 + mean: 827 + 2050: + min: 490 + max: 1038 + mean: 764 + 40t: + 2020: + min: 665 + max: 1542 + mean: 1104 + 2030: + min: 550 + max: 1200 + mean: 875 + 2040: + min: 530 + max: 1123 + mean: 826 + 2050: + min: 490 + max: 1067 + mean: 779 + 60t: + 2020: + min: 835 + max: 1804 + mean: 1320 + 2030: + min: 670 + max: 1349 + mean: 1010 + 2040: + min: 630 + max: 1255 + mean: 942 + 2050: + min: 603 + max: 1188 + mean: 896 \ No newline at end of file diff --git a/premise/data/transport/vehicles_map.yaml b/premise/data/transport/vehicles_map.yaml index d49b3e1a..0b02ca44 100644 --- a/premise/data/transport/vehicles_map.yaml +++ b/premise/data/transport/vehicles_map.yaml @@ -43,32 +43,108 @@ truck: unit: ton kilometer name: transport, freight, lorry old_trucks: - remind: - transport, freight, lorry, unspecified: transport, freight, lorry, unspecified - transport, freight, lorry 16-32 metric ton: transport, freight, lorry, 26t gross weight, unspecified powertrain - transport, freight, lorry 28 metric ton, fatty acid methyl ester 100%: transport, freight, lorry, 26t gross weight, unspecified powertrain - transport, freight, lorry 3.5-7.5 metric ton: transport, freight, lorry, 3.5t gross weight, unspecified powertrain - transport, freight, lorry 7.5-16 metric ton: transport, freight, lorry, 7.5t gross weight, unspecified powertrain - transport, freight, lorry >32 metric ton: transport, freight, lorry, 40t gross weight, unspecified powertrain - transport, freight, lorry with reefer, cooling: transport, freight, lorry, unspecified - transport, freight, lorry with reefer, freezing: transport, freight, lorry, unspecified - transport, freight, lorry with refrigeration machine, 3.5-7.5 ton: transport, freight, lorry, 3.5t gross weight, unspecified powertrain - transport, freight, lorry with refrigeration machine, 7.5-16 ton: transport, freight, lorry, 7.5t gross weight, unspecified powertrain - transport, freight, lorry with refrigeration machine, cooling: transport, freight, lorry, unspecified - transport, freight, lorry with refrigeration machine, freezing: transport, freight, lorry, unspecified - image: - transport, freight, lorry, unspecified: transport, freight, lorry, unspecified - transport, freight, lorry 16-32 metric ton: transport, freight, lorry, 26t gross weight, unspecified powertrain - transport, freight, lorry 28 metric ton, fatty acid methyl ester 100%: transport, freight, lorry, 26t gross weight, unspecified powertrain - transport, freight, lorry 3.5-7.5 metric ton: transport, freight, lorry, 26t gross weight, unspecified powertrain - transport, freight, lorry 7.5-16 metric ton: transport, freight, lorry, 26t gross weight, unspecified powertrain - transport, freight, lorry >32 metric ton: transport, freight, lorry, 40t gross weight, unspecified powertrain - transport, freight, lorry with reefer, cooling: transport, freight, lorry, unspecified - transport, freight, lorry with reefer, freezing: transport, freight, lorry, unspecified - transport, freight, lorry with refrigeration machine, 3.5-7.5 ton: transport, freight, lorry, 26t gross weight, unspecified powertrain - transport, freight, lorry with refrigeration machine, 7.5-16 ton: transport, freight, lorry, 26t gross weight, unspecified powertrain - transport, freight, lorry with refrigeration machine, cooling: transport, freight, lorry, unspecified - transport, freight, lorry with refrigeration machine, freezing: transport, freight, lorry, unspecified + transport, freight, lorry 16-32 metric ton, EURO1: + remind: transport, freight, lorry, 26t gross weight, unspecified powertrain, long haul + image: transport, freight, lorry, 18t gross weight, unspecified powertrain, long haul + transport, freight, lorry 3.5-7.5 metric ton, EURO3: + remind: transport, freight, lorry, 7.5t gross weight, unspecified powertrain, long haul + image: transport, freight, lorry, 18t gross weight, unspecified powertrain, long haul + transport, freight, lorry 16-32 metric ton, EURO5: + remind: transport, freight, lorry, 26t gross weight, unspecified powertrain, long haul + image: transport, freight, lorry, 18t gross weight, unspecified powertrain, long haul + transport, freight, lorry >32 metric ton, EURO1: + remind: transport, freight, lorry, 40t gross weight, unspecified powertrain, long haul + image: transport, freight, lorry, 40t gross weight, unspecified powertrain, long haul + transport, freight, lorry 3.5-7.5 metric ton, EURO4: + remind: transport, freight, lorry, 7.5t gross weight, unspecified powertrain, long haul + image: transport, freight, lorry, 18t gross weight, unspecified powertrain, long haul + transport, freight, lorry, all sizes, EURO1 to generic market for transport, freight, lorry, unspecified: + remind: transport, freight, lorry, unspecified, long haul + image: transport, freight, lorry, unspecified, long haul + transport, freight, lorry 7.5-16 metric ton, EURO6: + remind: transport, freight, lorry, 18t gross weight, unspecified powertrain, long haul + image: transport, freight, lorry, 18t gross weight, unspecified powertrain, long haul + transport, freight, lorry 7.5-16 metric ton, EURO1: + remind: transport, freight, lorry, 18t gross weight, unspecified powertrain, long haul + image: transport, freight, lorry, 18t gross weight, unspecified powertrain, long haul + transport, freight, lorry, all sizes, EURO3 to generic market for transport, freight, lorry, unspecified: + remind: transport, freight, lorry, unspecified, long haul + image: transport, freight, lorry, unspecified, long haul + transport, freight, lorry 16-32 metric ton, EURO6: + remind: transport, freight, lorry, 26t gross weight, unspecified powertrain, long haul + image: transport, freight, lorry, 18t gross weight, unspecified powertrain, long haul + transport, freight, lorry 7.5-16 metric ton, EURO2: + remind: transport, freight, lorry, 18t gross weight, unspecified powertrain, long haul + image: transport, freight, lorry, 18t gross weight, unspecified powertrain, long haul + transport, freight, lorry 7.5-16 metric ton, EURO3: + remind: transport, freight, lorry, 18t gross weight, unspecified powertrain, long haul + image: transport, freight, lorry, 18t gross weight, unspecified powertrain, long haul + transport, freight, lorry 7.5-16 metric ton, EURO4: + remind: transport, freight, lorry, 18t gross weight, unspecified powertrain, long haul + image: transport, freight, lorry, 18t gross weight, unspecified powertrain, long haul + transport, freight, lorry 16-32 metric ton, EURO2: + remind: transport, freight, lorry, 26t gross weight, unspecified powertrain, long haul + image: transport, freight, lorry, 18t gross weight, unspecified powertrain, long haul + transport, freight, lorry >32 metric ton, EURO6: + remind: transport, freight, lorry, 40t gross weight, unspecified powertrain, long haul + image: transport, freight, lorry, 40t gross weight, unspecified powertrain, long haul + transport, freight, lorry 3.5-7.5 metric ton, EURO2: + remind: transport, freight, lorry, 7.5t gross weight, unspecified powertrain, long haul + image: transport, freight, lorry, 18t gross weight, unspecified powertrain, long haul + transport, freight, lorry 3.5-7.5 metric ton, EURO1: + remind: transport, freight, lorry, 7.5t gross weight, unspecified powertrain, long haul + image: transport, freight, lorry, 18t gross weight, unspecified powertrain, long haul + transport, freight, lorry, all sizes, EURO2 to generic market for transport, freight, lorry, unspecified: + remind: transport, freight, lorry, unspecified, long haul + image: transport, freight, lorry, unspecified, long haul + transport, freight, lorry 16-32 metric ton, unregulated: + remind: transport, freight, lorry, 26t gross weight, unspecified powertrain, long haul + image: transport, freight, lorry, 18t gross weight, unspecified powertrain, long haul + transport, freight, lorry >32 metric ton, unregulated: + remind: transport, freight, lorry, 40t gross weight, unspecified powertrain, long haul + image: transport, freight, lorry, 40t gross weight, unspecified powertrain, long haul + transport, freight, lorry >32 metric ton, EURO3: + remind: transport, freight, lorry, 40t gross weight, unspecified powertrain, long haul + image: transport, freight, lorry, 40t gross weight, unspecified powertrain, long haul + transport, freight, lorry 3.5-7.5 metric ton, unregulated: + remind: transport, freight, lorry, 7.5t gross weight, unspecified powertrain, long haul + image: transport, freight, lorry, 18t gross weight, unspecified powertrain, long haul + transport, freight, lorry 7.5-16 metric ton, EURO5: + remind: transport, freight, lorry, 18t gross weight, unspecified powertrain, long haul + image: transport, freight, lorry, 18t gross weight, unspecified powertrain, long haul + transport, freight, lorry 3.5-7.5 metric ton, EURO6: + remind: transport, freight, lorry, 7.5t gross weight, unspecified powertrain, long haul + image: transport, freight, lorry, 18t gross weight, unspecified powertrain, long haul + transport, freight, lorry 7.5-16 metric ton, unregulated: + remind: transport, freight, lorry, 18t gross weight, unspecified powertrain, long haul + image: transport, freight, lorry, 18t gross weight, unspecified powertrain, long haul + transport, freight, lorry 3.5-7.5 metric ton, EURO5: + remind: transport, freight, lorry, 7.5t gross weight, unspecified powertrain, long haul + image: transport, freight, lorry, 18t gross weight, unspecified powertrain, long haul + transport, freight, lorry >32 metric ton, EURO2: + remind: transport, freight, lorry, 40t gross weight, unspecified powertrain, long haul + image: transport, freight, lorry, 40t gross weight, unspecified powertrain, long haul + transport, freight, lorry 16-32 metric ton, EURO3: + remind: transport, freight, lorry, 26t gross weight, unspecified powertrain, long haul + image: transport, freight, lorry, 18t gross weight, unspecified powertrain, long haul + transport, freight, lorry, all sizes, EURO5 to generic market for transport, freight, lorry, unspecified: + remind: transport, freight, lorry, unspecified, long haul + image: transport, freight, lorry, unspecified, long haul + transport, freight, lorry, all sizes, EURO6 to generic market for transport, freight, lorry, unspecified: + remind: transport, freight, lorry, unspecified, long haul + image: transport, freight, lorry, unspecified, long haul + transport, freight, lorry 16-32 metric ton, EURO4: + remind: transport, freight, lorry, 26t gross weight, unspecified powertrain, long haul + image: transport, freight, lorry, 18t gross weight, unspecified powertrain, long haul + transport, freight, lorry >32 metric ton, EURO4: + remind: transport, freight, lorry, 40t gross weight, unspecified powertrain, long haul + image: transport, freight, lorry, 40t gross weight, unspecified powertrain, long haul + transport, freight, lorry >32 metric ton, EURO5: + remind: transport, freight, lorry, 40t gross weight, unspecified powertrain, long haul + image: transport, freight, lorry, 40t gross weight, unspecified powertrain, long haul + transport, freight, lorry, all sizes, unregulated to generic market for transport, freight, lorry, unspecified: + remind: transport, freight, lorry, unspecified, long haul + image: transport, freight, lorry, unspecified, long haul powertrain: fuel cell electric: FCEV diff --git a/premise/transport.py b/premise/transport.py index e6b166d7..235d4bee 100644 --- a/premise/transport.py +++ b/premise/transport.py @@ -86,6 +86,19 @@ def _update_vehicles(scenario, vehicle_type, version, system_model): return scenario +def get_battery_size() -> dict: + """ + Return a dictionary that contains the size of the battery + for each vehicle type and powertrain. + :return: dictionary with battery sizes + """ + with open( + DATA_DIR / "transport" / "battery_size.yaml", "r", encoding="utf-8" + ) as stream: + out = yaml.safe_load(stream) + return out + + def get_average_truck_load_factors() -> Dict[str, Dict[str, Dict[str, float]]]: """ Load average load factors for trucks @@ -373,6 +386,7 @@ def __init__( self.vehicle_fuel_map = mapping.generate_vehicle_fuel_map( transport_type=vehicle_type ) + self.battery_size = get_battery_size() # check if vehicle map is empty for v in self.vehicle_map.values(): @@ -418,6 +432,7 @@ def create_vehicle_markets(self) -> list: for new_ds in new_datasets: new_ds = self.adjust_transport_efficiency(new_ds) + if not self.is_in_index(new_ds): self.add_to_index(new_ds) self.database.append(new_ds) @@ -459,10 +474,21 @@ def create_vehicle_markets(self) -> list: ) ) + # if trucks, adjust battery size + if self.vehicle_type == "truck": + for ds in ws.get_many( + self.database, + ws.contains("name", "battery electric"), + ws.contains("name", "truck"), + ws.equals("unit", "unit"), + ): + self.adjust_battery_size(ds) + # if trucks, need to reconnect everything # loop through datasets that use truck transport if self.vehicle_type == "truck": - list_created_trucks = [(a["name"], a["location"]) for a in fleet_act] + + list_created_vehicles = [(v["name"], v["location"]) for v in fleet_act] for dataset in ws.get_many( self.database, @@ -471,37 +497,74 @@ def create_vehicle_markets(self) -> list: ): for exc in ws.technosphere( dataset, - ws.contains("name", "transport, freight, lorry"), + ws.either( + *[ + ws.equals("name", v) + for v in self.mapping["truck"]["old_trucks"] + ] + ), ws.equals("unit", "ton kilometer"), ): - key = [ - k - for k in self.mapping["truck"]["old_trucks"][self.model] - if k.lower() in exc["name"].lower() - ][0] - - if "input" in exc: - del exc["input"] - - if dataset["unit"] == "kilogram": - name = f"{self.mapping['truck']['old_trucks'][self.model][key]}, long haul" - loc = self.geo.ecoinvent_to_iam_location(dataset["location"]) - - if (name, loc) in list_created_trucks: - exc["name"] = name - else: - exc["name"] = ( - f"transport, freight, lorry, unspecified, long haul" - ) + + new_name = self.mapping["truck"]["old_trucks"][exc["name"]][ + self.model + ] + new_loc = self.geo.ecoinvent_to_iam_location(dataset["location"]) + + if (new_name, new_loc) in list_created_vehicles: + exc["name"] = new_name + exc["product"] = "transport, freight, lorry" + exc["location"] = new_loc else: + print(f"Could not find dataset for {new_name} in {new_loc}.") exc["name"] = ( "transport, freight, lorry, unspecified, long haul" ) + exc["product"] = "transport, freight, lorry" + exc["location"] = "World" - exc["product"] = "transport, freight, lorry" - exc["location"] = self.geo.ecoinvent_to_iam_location( - dataset["location"] - ) + # also we need to empty the old transport datasets + for dataset in ws.get_many( + self.database, + ws.either( + *[ws.equals("name", v) for v in self.mapping["truck"]["old_trucks"]] + ), + ): + dataset["exchanges"] = [ + e for e in dataset["exchanges"] if e["type"] == "production" + ] + dataset["comment"] = ( + "This dataset has been replaced by new fleet-average vehicles." + ) + + # add new truck as exchange + new_name = self.mapping["truck"]["old_trucks"][dataset["name"]][ + self.model + ] + new_loc = self.geo.ecoinvent_to_iam_location(dataset["location"]) + + if (new_name, new_loc) in list_created_vehicles: + new_exc = { + "name": new_name, + "product": "transport, freight, lorry", + "unit": "ton kilometer", + "location": new_loc, + "type": "technosphere", + "amount": 1, + "uncertainty type": 0, + } + else: + print(f"Could not find dataset for {new_name} in {new_loc}.") + new_exc = { + "name": "transport, freight, lorry, unspecified, long haul", + "product": "transport, freight, lorry", + "unit": "ton kilometer", + "location": "World", + "type": "technosphere", + "amount": 1, + "uncertainty type": 0, + } + dataset["exchanges"].append(new_exc) return fleet_act @@ -559,6 +622,62 @@ def adjust_transport_efficiency(self, dataset): return dataset + def adjust_battery_size(self, ds): + """ + Adjust battery size for truck datasets. + """ + + # detect size in name + size = [s for s in self.battery_size["truck"] if s in ds["name"]][0] + + print(self.battery_size["truck"][size]) + + if self.year <= min(self.battery_size["truck"][size].keys()): + mean_battery_size = self.battery_size["truck"][size][ + min(self.battery_size["truck"][size].keys()) + ]["mean"] + min_battery_size = self.battery_size["truck"][size][ + min(self.battery_size["truck"][size].keys()) + ]["min"] + max_battery_size = self.battery_size["truck"][size][ + min(self.battery_size["truck"][size].keys()) + ]["max"] + elif self.year >= max(self.battery_size["truck"][size].keys()): + mean_battery_size = self.battery_size["truck"][size][ + max(self.battery_size["truck"][size].keys()) + ]["mean"] + min_battery_size = self.battery_size["truck"][size][ + max(self.battery_size["truck"][size].keys()) + ]["min"] + max_battery_size = self.battery_size["truck"][size][ + max(self.battery_size["truck"][size].keys()) + ]["max"] + else: + mean_battery_size = np.interp( + self.year, + list(self.battery_size["truck"][size].keys()), + [v["mean"] for v in self.battery_size["truck"][size].values()], + ) + min_battery_size = np.interp( + self.year, + list(self.battery_size["truck"][size].keys()), + [v["min"] for v in self.battery_size["truck"][size].values()], + ) + max_battery_size = np.interp( + self.year, + list(self.battery_size["truck"][size].keys()), + [v["max"] for v in self.battery_size["truck"][size].values()], + ) + + for exc in ws.technosphere(ds, ws.contains("name", "market for battery")): + exc["amount"] = mean_battery_size + exc["uncertainty type"] = 5 + exc["loc"] = exc["amount"] + exc["minimum"] = min_battery_size + exc["maximum"] = max_battery_size + + ds["comment"] += f" Battery size adjusted to {mean_battery_size} kWh." + def write_log(self, dataset, status="created"): """ Write log file.