Skip to content

Commit

Permalink
Merge pull request polca#6 from romainsacchi/cement
Browse files Browse the repository at this point in the history
Cement
  • Loading branch information
romainsacchi authored Apr 7, 2020
2 parents faab64a + b0be6c4 commit 7b055c6
Show file tree
Hide file tree
Showing 40 changed files with 4,559 additions and 513 deletions.
3 changes: 2 additions & 1 deletion MANIFEST.in
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@ include rmnd_lca/data/*.csv
include rmnd_lca/data/Remind output files/*.mif
include rmnd_lca/data/Remind output files/*.csv
include rmnd_lca/data/additional_inventories/*.xlsx

include rmnd_lca/data/electricity/*.csv
include rmnd_lca/data/cement/*.csv
50 changes: 49 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,18 @@ and the file path to the ecospold files in `source_file_path`.
### Transform

A series of transformations can be performed on the extracted database.
Currently, only the transformation regarding electricity generation and distribution is implemented.
Currently, only the transformation regarding:
* electricity generation and distribution
* clinker and cement production
are implemented.

All the transformation functions can be executed like so:

```python
ndb.update_all()
```

But they can also be executed separately, as the following subsections show.

#### Electricity

Expand Down Expand Up @@ -156,6 +167,43 @@ returns
Note that logs of deleted and created electricity markets are created in
the `data/logs/` directory as MS Excel files, within rmnd_lca working directory.

#### Cement

The following function will:
* remove existing datasets for clinker production, clinker markets, cement production and cement markets
* replace them by regional production and market datasets
* for the new clinker production datasets, the following aspects are adjusted:
* the kiln technology mix (wet vs. semi-wet vs. dry, with or without pre-heater and pre-calciner),
* the kiln thermal efficiency,
* the fuel mix (fossil vs. biogenic),
* the fossil and biogenic CO2 emissions,
* the emission of pollutants (BC, CO, Hg, etc.)
* and the application of carbon capture, if needed
* for the new cement production datasets, the following aspects are adjusted: the power consumption (for grinding)
* for the new market datasets for average cement, the clinker-to-cement ratio is adjusted
* and relink cement-consuming activities to the newly created cement markets.

```python
ndb.update_cement_to_remind_data()
```
returns
```python
Log of deleted cement datasets saved in C:\Users\romai\Documents\GitHub\rmnd-lca\rmnd_lca\data\logs
Log of created cement datasets saved in C:\Users\romai\Documents\GitHub\rmnd-lca\rmnd_lca\data\logs
Create new clinker production datasets and delete old datasets
Create new clinker market datasets and delete old datasets
Adjust clinker-to-cement ratio in "unspecified cement" datasets
Create new cement production datasets and adjust electricity consumption
Create new cement market datasets
Relink cement production datasets to new clinker production datasets
Relink cement production datasets to new clinker market datasets
Relink cement market datasets to new cement production datasets
Relink activities to new cement datasets
```

Note that logs of deleted and created clinker and cement datasets are created in
the `data/logs/` directory as MS Excel files, within rmnd_lca working directory.

### Load (export back to brightway2)

Once the process is completed, the resulting database is registered back into the current Brightway2 project:
Expand Down
6 changes: 2 additions & 4 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
#
import os
import sys
sys.path.insert(0, os.path.abspath(".."))

sys.path.insert(0, os.path.abspath(".."))

# -- Project information -----------------------------------------------------

Expand All @@ -24,7 +24,6 @@
# The full version, including alpha/beta/rc tags
release = '0.0.1'


# -- General configuration ---------------------------------------------------

# Add any Sphinx extension module names here, as strings. They can be
Expand All @@ -45,7 +44,6 @@
# This pattern also affects html_static_path and html_extra_path.
exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store']


# -- Options for HTML output -------------------------------------------------

# The theme to use for HTML and HTML Help pages. See the documentation for
Expand All @@ -58,4 +56,4 @@
# so a file named "default.css" will overwrite the builtin "default.css".
html_static_path = ['_static']

#html_sidebars = { '**': ['globaltoc.html', 'relations.html', 'sourcelink.html', 'searchbox.html'] }
# html_sidebars = { '**': ['globaltoc.html', 'relations.html', 'sourcelink.html', 'searchbox.html'] }
4 changes: 3 additions & 1 deletion rmnd_lca/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,13 @@
"Electricity",
"BiofuelInventory",
"CarmaCCSInventory",
"Geomap"
"Geomap",
"DATA_DIR"
)
__version__ = (0, 0, 1)

from pathlib import Path

DATA_DIR = Path(__file__).resolve().parent / "data"
INVENTORY_DIR = Path(__file__).resolve().parent / "data" / "additional_inventories"

Expand Down
53 changes: 46 additions & 7 deletions rmnd_lca/activity_maps.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from . import DATA_DIR
import csv

REMIND_TO_ECOINVENT_EMISSION_FILEPATH = (DATA_DIR / "remind_to_ecoinvent_emission_mappping.csv")
REMIND_TO_ECOINVENT_EMISSION_FILEPATH = (DATA_DIR / "ecoinvent_to_gains_emission_mappping.csv")


class InventorySet:
Expand Down Expand Up @@ -34,6 +34,28 @@ class InventorySet:
"heat": {"fltr": "market for heat,"},
}

fuel_filters = {
"gas": {"fltr": "market for natural gas,", "mask": ["network", "burned"]},
"diesel": {"fltr": "market for diesel", "mask": ["burned", "electric"]},
"petrol": {"fltr": "market for petrol,", "mask": "burned"},
"hard coal": {"fltr": 'market for hard coal', 'mask': ['factory', 'plant', 'briquettes', 'ash']},
"lignite": {"fltr": 'market for lignite', 'mask': ['factory', 'plant', 'briquettes', 'ash']},
"petroleum coke": {"fltr": 'market for petroleum coke'},
"wood pellet": {"fltr": 'market for wood pellet', 'mask': ['factory']},
"natural gas, high pressure": {"fltr": 'market for natural gas, high pressure'},
"natural gas, low pressure": {"fltr": 'market for natural gas, low pressure'},
"heavy fuel oil": {"fltr": 'market for heavy fuel oil', 'mask': ['burned']},
"light fuel oil": {"fltr": 'market for light fuel oil'},
"biogas": {"fltr": 'biogas', 'mask': ['burned']},
"waste": {"fltr": {'reference product': ['waste plastic, mixture']},
'mask': ['market for', 'treatment', 'market group']},
"syngas": {"fltr": 'methane, from electrochemical methanation'},
"synfuel": {"fltr": 'Diesel production, Fischer Tropsch process'},
"hydrogen": {"fltr": 'Hydrogen, gaseous'},
"bioethanol": {"fltr": 'Ethanol from'},
"liquified petroleum gas": {"fltr": 'Liquefied petroleum gas production, from methanol-to-gas process'}
}

powerplant_filters = {
"Biomass IGCC CCS": {
"fltr": [
Expand Down Expand Up @@ -71,7 +93,7 @@ class InventorySet:
},
"Biomass CHP": {
"fltr": {
"name":[
"name": [
"heat and power co-generation, wood chips",
"heat and power co-generation, biogas",
],
Expand Down Expand Up @@ -120,8 +142,8 @@ class InventorySet:
"Oil": {
"fltr": {
"name": [
"electricity production, oil",
"heat and power co-generation, oil",
"electricity production, oil",
"heat and power co-generation, oil",
],
"reference product": "electricity"
},
Expand Down Expand Up @@ -163,7 +185,19 @@ def generate_powerplant_map(self):
"""
return self.generate_sets_from_filters(self.powerplant_filters)

def get_remind_to_ecoinvent_emissions(self):
def generate_fuel_map(self):
"""
Filter ecoinvent processes related to fuel supply.
:return: dictionary with fuel names as keys (see below) and
sets of related ecoinvent activities as values.
:rtype: dict
"""
return self.generate_sets_from_filters(self.fuel_filters)

@staticmethod
def get_remind_to_ecoinvent_emissions():
"""
Retrieve the correspondence between REMIND and ecoinvent emission labels.
:return: REMIND emission labels as keys and ecoinvent emission labels as values
Expand All @@ -184,7 +218,8 @@ def get_remind_to_ecoinvent_emissions(self):

return csv_dict

def act_fltr(self, db, fltr={}, mask={}, filter_exact=False, mask_exact=False):
@staticmethod
def act_fltr(db, fltr=None, mask=None, filter_exact=False, mask_exact=False):
"""Filter `db` for activities matching field contents given by `fltr` excluding strings in `mask`.
`fltr`: string, list of strings or dictionary.
If a string is provided, it is used to match the name field from the start (*startswith*).
Expand All @@ -207,6 +242,10 @@ def act_fltr(self, db, fltr={}, mask={}, filter_exact=False, mask_exact=False):
:rtype: list
"""
if fltr is None:
fltr = {}
if mask is None:
mask = {}
result = []

# default field is name
Expand Down Expand Up @@ -252,7 +291,7 @@ def generate_sets_from_filters(self, filtr):
Generate a dictionary with sets of activity names for
technologies from the filter specifications.
:param fltr: A dictionary with labels and filter conditions as given to
:param filtr:
:func:`activity_maps.InventorySet.act_fltr`.
:return: dictionary with the same keys as provided in filter
and a set of activity data set names as values.
Expand Down
Loading

0 comments on commit 7b055c6

Please sign in to comment.