Skip to content

Commit

Permalink
Fix energy density values
Browse files Browse the repository at this point in the history
  • Loading branch information
romainsacchi committed Aug 6, 2024
1 parent 4251399 commit c7a69cf
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 166 deletions.
Binary file modified premise/data/additional_inventories/lci-hydrogen-distribution.xlsx
Binary file not shown.
11 changes: 9 additions & 2 deletions premise/heat.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,11 +139,11 @@ def regionalize_heat_production(self):

created_datasets = []

for heat_datasets in self.heat_techs.values():
for heat_tech, heat_datasets in self.heat_techs.items():
datasets = list(
ws.get_many(
self.database,
ws.either(*[ws.contains("name", n) for n in heat_datasets]),
ws.either(*[ws.equals("name", n) for n in heat_datasets]),
ws.equals("unit", "megajoule"),
ws.doesnt_contain_any("location", self.regions),
)
Expand All @@ -155,12 +155,19 @@ def regionalize_heat_production(self):

created_datasets.append(dataset["name"])

geo_mapping = None
if heat_tech == "heat, from natural gas (market)":
geo_mapping = {
r: "Europe without Switzerland" for r in self.regions
}

new_ds = self.fetch_proxies(
name=dataset["name"],
ref_prod=dataset["reference product"],
exact_name_match=True,
exact_product_match=True,
subset=datasets,
geo_mapping=geo_mapping,
)

if len(new_ds) == 0:
Expand Down
1 change: 1 addition & 0 deletions premise/iam_variables_mapping/heat_variables.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ heat, from natural gas (market):
fltr:
- market for heat, central or small-scale, natural gas
- market for heat, district or industrial, natural gas
mask: Jakobsberg

heat, from light fuel oil:
ecoinvent_aliases:
Expand Down
164 changes: 0 additions & 164 deletions premise/validation.py
Original file line number Diff line number Diff line change
Expand Up @@ -1845,167 +1845,3 @@ def run_biomass_checks(self):
self.check_biomass_markets()
self.check_residual_biomass_share()
self.save_log()


class TransportValidationNEW(BaseDatasetValidator):
def __init__(self, model, scenario, year, regions, database, iam_data):
super().__init__(model, scenario, year, regions, database)
self.iam_data = iam_data

def check_transport_markets(self):
# check that the transport markets inputs equal to 1

for ds in self.database:
if (
ds["name"].startswith("market for transport, ")
and ds["location"] in self.regions
# and ds["location"] != "World"
):
total = sum(
[
x["amount"]
for x in ds["exchanges"]
if x["type"] == "technosphere" and x["unit"] == "ton kilometer"
]
)
if total < 0.99 or total > 1.1:
message = f"Transport market {ds['name']} in {ds['location']} inputs sum to {total}."
self.log_issue(
ds,
"transport market inputs do not sum to 1",
message,
issue_type="major",
)

def check_vehicles(self):
for act in [
a
for a in self.database
if a["name"].startswith("transport, freight")
and ", unspecified powertrain" in a["name"]
]:
# check that all transport exchanges are differently named or are from a different location
names_locations = [
(exc["name"], exc["location"])
for exc in act["exchanges"]
if exc["type"] == "technosphere"
]
if len(names_locations) != len(set(names_locations)):
message = "Duplicate transport exchanges"
self.log_issue(
act, "duplicate transport exchanges", message, issue_type="major"
)

def check_vehicle_efficiency(
self,
vehicle_name,
fossil_minimum=0.0,
fossil_maximum=0.5,
elec_minimum=0.1,
elec_maximum=0.35,
):
# check that the efficiency of the car production datasets
# is within the expected range

for ds in self.database:
if "plugin" in ds["name"]:
continue

if ds["name"].startswith(vehicle_name) and ds["location"] in self.regions:
electricity_consumption = sum(
[
x["amount"]
for x in ds["exchanges"]
if x["name"].startswith("market group for electricity")
or x["name"].startswith("market for electricity")
and x["type"] == "technosphere"
]
)
if electricity_consumption > 0:
if (
electricity_consumption < elec_minimum
or electricity_consumption > elec_maximum
):
message = f"Electricity consumption per 100 km is incorrect: {electricity_consumption * 100}."
self.log_issue(
ds,
"electricity consumption too high",
message,
issue_type="major",
)

fuel_consumption = sum(
[
x["amount"]
for x in ds["exchanges"]
if x["name"].startswith("market for diesel")
or x["name"].startswith("market for petrol")
and x["type"] == "technosphere"
]
)

if fuel_consumption == 0:

fuel_consumption += sum(
[
x["amount"]
* (47.5 if x["unit"] == "kilogram" else 36)
/ 42.6
for x in ds["exchanges"]
if x["name"].startswith("market for natural gas")
or x["name"].startswith("market group for natural gas")
and x["type"] == "technosphere"
]
)

if fuel_consumption > 0:
if (
fuel_consumption < fossil_minimum
or fuel_consumption > fossil_maximum
):
message = f"Fuel consumption per 100 km is incorrect: {fuel_consumption * 100}."
self.log_issue(
ds,
"fuel consumption incorrect",
message,
issue_type="major",
)

# sum the amounts of Carbon dioxide (fossil and non-fossil)
# and make sure it is roughly equal to 3.15 kg CO2/kg diesel
co2 = sum(
[
x["amount"]
for x in ds["exchanges"]
if x["name"].startswith("Carbon dioxide")
and x["type"] == "biosphere"
and x.get("categories", [None])[0] == "air"
]
)
if not math.isclose(co2, 3.15 * fuel_consumption, rel_tol=0.1):
message = f"CO2 emissions per km are incorrect: {co2} instead of {3.15 * fuel_consumption}."
self.log_issue(
ds,
"CO2 emissions incorrect",
message,
issue_type="major",
)

def run_transport_checks(self):
self.check_transport_markets()
self.check_vehicles()
self.check_vehicle_efficiency(
vehicle_name="transport, freight, lorry",
fossil_minimum=0.0,
fossil_maximum=0.5,
elec_minimum=0.1,
elec_maximum=0.5,
)
self.check_vehicle_efficiency(
vehicle_name="transport, freight train",
fossil_minimum=0.0,
fossil_maximum=0.5,
elec_minimum=0.0,
elec_maximum=0.5,
)
self.save_log()

0 comments on commit c7a69cf

Please sign in to comment.