Skip to content

Commit

Permalink
Adjust truck battery size
Browse files Browse the repository at this point in the history
  • Loading branch information
romainsacchi authored and romainsacchi committed Aug 21, 2024
1 parent 62189a9 commit 34d99d7
Show file tree
Hide file tree
Showing 7 changed files with 988 additions and 650 deletions.
641 changes: 624 additions & 17 deletions dev/Untitled.ipynb

Large diffs are not rendered by default.

692 changes: 113 additions & 579 deletions dev/Untitled1.ipynb

Large diffs are not rendered by default.

Binary file modified premise/data/additional_inventories/lci-battery-capacity.xlsx
Binary file not shown.
Binary file modified premise/data/additional_inventories/lci-trucks.xlsx
Binary file not shown.
41 changes: 41 additions & 0 deletions premise/data/transport/battery_size.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# battery size, in kWh
# for long-haul trucks
# provided by carculator_truck
---

truck:
3.5t:
2020: 382
2030: 300
2040: 268
2050: 236
7.5t:
2020: 640
2030: 480
2040: 480
2050: 370
18t:
2020: 1110
2030: 802
2040: 726
2050: 666
26t:
2020: 1292
2030: 978
2040: 906
2050: 845
32t:
2020: 1515
2030: 1207
2040: 1124
2050: 1040
40t:
2020: 1542
2030: 1200
2040: 1123
2050: 1066
60t:
2020: 1804
2030: 1350
2040: 1255
2050: 1188
128 changes: 102 additions & 26 deletions premise/data/transport/vehicles_map.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
136 changes: 108 additions & 28 deletions premise/transport.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,16 @@ 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
Expand Down Expand Up @@ -373,6 +383,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():
Expand Down Expand Up @@ -418,6 +429,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)
Expand Down Expand Up @@ -459,10 +471,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,
Expand All @@ -471,37 +494,68 @@ 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:
exc["name"] = (
"transport, freight, lorry, unspecified, long haul"
)
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

Expand Down Expand Up @@ -559,6 +613,32 @@ 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]

if self.year < min(self.battery_size["truck"][size].keys()):
battery_size = self.battery_size["truck"][size][min(self.battery_size["truck"][size].keys())]
elif self.year > max(self.battery_size["truck"][size].keys()):
battery_size = self.battery_size["truck"][size][max(self.battery_size["truck"][size].keys())]
else:
battery_size = np.interp(
self.year,
list(self.battery_size["truck"][size].keys()),
list(self.battery_size["truck"][size].values()),
)

for exc in ws.technosphere(ds, ws.contains("name", "market for battery")):
exc["amount"] = battery_size

ds["comment"] += f" Battery size adjusted to {battery_size} kWh."



def write_log(self, dataset, status="created"):
"""
Write log file.
Expand Down

0 comments on commit 34d99d7

Please sign in to comment.