mosaik-emissions 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- mosaik_emissions-0.1.0/AUTHORS.txt +4 -0
- mosaik_emissions-0.1.0/CHANGELOG +10 -0
- mosaik_emissions-0.1.0/LICENSE +21 -0
- mosaik_emissions-0.1.0/PKG-INFO +162 -0
- mosaik_emissions-0.1.0/README.md +124 -0
- mosaik_emissions-0.1.0/mosaik_components/emissions/__init__.py +3 -0
- mosaik_emissions-0.1.0/mosaik_components/emissions/data/data.csv +494336 -0
- mosaik_emissions-0.1.0/mosaik_components/emissions/emission_simulator.py +163 -0
- mosaik_emissions-0.1.0/pyproject.toml +21 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2023 mosaik development team
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: mosaik-emissions
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Emissions simulator for Mosaik
|
|
5
|
+
License: LICENSE
|
|
6
|
+
Author: Danila Valko
|
|
7
|
+
Author-email: mosaik@offis.de
|
|
8
|
+
Requires-Python: >=3.9,<4.0
|
|
9
|
+
Classifier: License :: Other/Proprietary License
|
|
10
|
+
Classifier: Programming Language :: Python :: 3
|
|
11
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
12
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
13
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
15
|
+
Requires-Dist: arrow (>=1.3.0,<2.0.0)
|
|
16
|
+
Requires-Dist: mosaik (>=3.2.0,<4.0.0)
|
|
17
|
+
Requires-Dist: mosaik-api-v3 (>=3.0.7,<4.0.0)
|
|
18
|
+
Requires-Dist: numpy (>=1.26.1,<2.0.0)
|
|
19
|
+
Requires-Dist: pandas (>=2.1.2,<3.0.0)
|
|
20
|
+
Requires-Dist: tqdm (>=4.66.1,<5.0.0)
|
|
21
|
+
Description-Content-Type: text/markdown
|
|
22
|
+
|
|
23
|
+
This is a simulator that implements CO₂ emissions calculation for certain [mosaik] scenario and [pandapower] network configuration.
|
|
24
|
+
|
|
25
|
+
This simulator is still work in progress. In particular, not every desirable attribute is implemented yet. If you have need for a particular attribute, leave an [issue here].
|
|
26
|
+
|
|
27
|
+
[pandapower]: https://www.pandapower.org
|
|
28
|
+
[mosaik]: https://mosaik.offis.de
|
|
29
|
+
[issue here]: https://gitlab.com/mosaik/components/energy/mosaik-emissions/-/issues
|
|
30
|
+
|
|
31
|
+
## Methodology
|
|
32
|
+
|
|
33
|
+
CO₂ emissions are dynamically aggregated based on predefined pandapower network characteristics.
|
|
34
|
+
|
|
35
|
+
To obtain the emission factor for a particular fuel, we refer to [2006 IPCC](https://www.ipcc-nggip.iges.or.jp/public/2006gl/) and in particular to the chapter [Stationary Combustion](https://www.ipcc-nggip.iges.or.jp/public/2006gl/pdf/2_Volume2/V2_2_Ch2_Stationary_Combustion.pdf).
|
|
36
|
+
|
|
37
|
+
To obtain the carbon intensity depending on a country's energy mix, we refer to [OurWorldInData](https://ourworldindata.org/grapher/carbon-intensity-electricity?tab=table), which aggregates data from Ember's European Electricity Review and the Energy Institute's Statistical Review of World Energy.
|
|
38
|
+
|
|
39
|
+
For Germany, the state can be specified, in which case historical carbon intensity estimates from [co2map.de](https://co2map.de/) will be used.
|
|
40
|
+
|
|
41
|
+
### Units
|
|
42
|
+
|
|
43
|
+
* Power produced - [MW]
|
|
44
|
+
* Default emission factor - [tones CO₂eq. / MWh]
|
|
45
|
+
* Carbon intensity of the electricity - [tones CO₂eq. / MWh]
|
|
46
|
+
* Carbon emissions - [tones CO₂eq.]
|
|
47
|
+
|
|
48
|
+
## Installation and usage
|
|
49
|
+
|
|
50
|
+
```
|
|
51
|
+
pip install mosaik-emissions
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
If you don't want to install this through PyPI, you can use pip to install the requirements.txt file:
|
|
55
|
+
```
|
|
56
|
+
pip install -r requirements.txt # To use this, you have to install at least version 3.2.0 of mosaik.
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
The simulator uses `P[MW]` as an input and `E[tCO2eq]` as an output attribute.
|
|
60
|
+
For each connected *generator* or *external grid*, one of the parameters must be defined: the emission factor, the fuel used, the country, and the state, see *the configuration* section bellow. You can also use the *method* option, which is callable, directly transforms input data to output, and takes precedence over other options. Thus, each emissions model can be configured while creation by using `model_params`:
|
|
61
|
+
|
|
62
|
+
* method - callable that directly transforms input data to output
|
|
63
|
+
* co2_emission_factor - float number that directly represents conversion factor [tones CO₂eq. / MWh]
|
|
64
|
+
* fuel - string that matches with a certain type of fuel used to produce electricity
|
|
65
|
+
* state - string that matches with a certain state of the country to filter the carbon intensity database out, it shuld be defined along with the country
|
|
66
|
+
* country - string that matches with a country to filter the carbon intensity database out
|
|
67
|
+
* coefficient - float number that multiplies emissions output, default is 1.0
|
|
68
|
+
|
|
69
|
+
```
|
|
70
|
+
emission_config = {
|
|
71
|
+
'co2_emission_factor' : 0.385,
|
|
72
|
+
'fuel' : 'Natural Gas Liquids',
|
|
73
|
+
'country' : 'Germany',
|
|
74
|
+
'state' : 'SN', # it shuld be defined along with the country if so
|
|
75
|
+
'coefficient' : 2.0 # multiplies total emissions output
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
em = em_sim.Emission.create(1, **emission_config)
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
**Note**: the model applies the first option defined according to the order described, e.g. if `co2_emission_factor` is defined, it does not check `fuel` or `country`.
|
|
82
|
+
|
|
83
|
+
Specify simulators configurations within your scenario script:
|
|
84
|
+
```
|
|
85
|
+
sim_config = {
|
|
86
|
+
'Grid': {
|
|
87
|
+
'python': 'mosaik_components.pandapower:Simulator'
|
|
88
|
+
},
|
|
89
|
+
'Emissions': {
|
|
90
|
+
'python': 'mosaik_components.emissions:Simulator'
|
|
91
|
+
},
|
|
92
|
+
...
|
|
93
|
+
}
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
Initialize the pandapower grid and emissions simulator:
|
|
97
|
+
```
|
|
98
|
+
gridsim = world.start('Grid', step_size=STEP_SIZE)
|
|
99
|
+
em_sim = world.start('Emissions')
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
Instantiate model entities:
|
|
103
|
+
```
|
|
104
|
+
grid = gridsim.Grid(json=GRID_FILE)
|
|
105
|
+
em = em_sim.Emission.create(1, **emission_config)
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
Connect and run:
|
|
109
|
+
```
|
|
110
|
+
gens = [e for e in grid.children if e.type in ['Gen', 'ControlledGen']]
|
|
111
|
+
world.connect(gens[0], em[0], 'P[MW]')
|
|
112
|
+
world.run(until=END)
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
You can see the demo scenario in the `demo` folder.
|
|
116
|
+
|
|
117
|
+
## Possible configuration
|
|
118
|
+
|
|
119
|
+
To relate to an emission factor derived from the country's energy mix, the full name of the country should be provided (see [OurWorldInData](https://ourworldindata.org/grapher/carbon-intensity-electricity?tab=table)), e.g.:
|
|
120
|
+
- Germany
|
|
121
|
+
- Greece
|
|
122
|
+
- Iceland
|
|
123
|
+
- ...
|
|
124
|
+
|
|
125
|
+
For Germany certain states are available (see [co2map.de](https://co2map.de/)): DE (country average), BB, BW, BY, HE, MV, NI, NW, RP, SH, SL, SN, ST, TH
|
|
126
|
+
|
|
127
|
+
To relate to certain fuel type, the fuel name should be provided (see [Stationary Combustion](https://gitlab.com/mosaik/components/energy/mosaik-emissions/-/blob/main/misc/fuel_combustion.pdf?ref_type=heads), Table 2.2):
|
|
128
|
+
- Crude Oil
|
|
129
|
+
- Natural Gas Liquids
|
|
130
|
+
- Natural Gas
|
|
131
|
+
- Charcoal
|
|
132
|
+
- Gas/Diesel Oil
|
|
133
|
+
- Ethane
|
|
134
|
+
- ...
|
|
135
|
+
|
|
136
|
+
## Developer notes
|
|
137
|
+
|
|
138
|
+
Note that emission factor and carbon intensity of electricity values for specific fuels and countries are stored in `data/data.csv` with the units specified in the source and are converted internally once been called.
|
|
139
|
+
|
|
140
|
+
Raw data files and `data.csv` preparation notebook can be found in the `misc` folder.
|
|
141
|
+
|
|
142
|
+
## Sources and References
|
|
143
|
+
|
|
144
|
+
* Ember - Yearly Electricity Data (2023); Ember - European Electricity Review (2022); Energy Institute - Statistical Review of World Energy (2023) – with major processing by Our World in Data. “Carbon intensity of electricity generation” [dataset]. Ember, “Yearly Electricity Data”; Ember, “European Electricity Review”; Energy Institute, “Statistical Review of World Energy” [original data]. Retrieved February 27, 2024 from https://ourworldindata.org/grapher/carbon-intensity-electricity
|
|
145
|
+
|
|
146
|
+
* Hourly consumption-based CO2 emissions intensity in Germany / [co2map.de](https://co2map.de/), INATECH, University of Freiburg. Retrieved February 27, 2024 from https://api.co2map.de/docs
|
|
147
|
+
Changelog
|
|
148
|
+
=========
|
|
149
|
+
|
|
150
|
+
0.1.0 - 2024-04-08
|
|
151
|
+
------------------
|
|
152
|
+
|
|
153
|
+
- Carbon intensity from co2map.de was added
|
|
154
|
+
- Restructured as a mosaik component
|
|
155
|
+
- Readme and examples are added
|
|
156
|
+
- Initial release of version implemented by Danila Valko
|
|
157
|
+
|
|
158
|
+
Authors
|
|
159
|
+
=======
|
|
160
|
+
|
|
161
|
+
The adapter was initially developed by Danila Valko.
|
|
162
|
+
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
This is a simulator that implements CO₂ emissions calculation for certain [mosaik] scenario and [pandapower] network configuration.
|
|
2
|
+
|
|
3
|
+
This simulator is still work in progress. In particular, not every desirable attribute is implemented yet. If you have need for a particular attribute, leave an [issue here].
|
|
4
|
+
|
|
5
|
+
[pandapower]: https://www.pandapower.org
|
|
6
|
+
[mosaik]: https://mosaik.offis.de
|
|
7
|
+
[issue here]: https://gitlab.com/mosaik/components/energy/mosaik-emissions/-/issues
|
|
8
|
+
|
|
9
|
+
## Methodology
|
|
10
|
+
|
|
11
|
+
CO₂ emissions are dynamically aggregated based on predefined pandapower network characteristics.
|
|
12
|
+
|
|
13
|
+
To obtain the emission factor for a particular fuel, we refer to [2006 IPCC](https://www.ipcc-nggip.iges.or.jp/public/2006gl/) and in particular to the chapter [Stationary Combustion](https://www.ipcc-nggip.iges.or.jp/public/2006gl/pdf/2_Volume2/V2_2_Ch2_Stationary_Combustion.pdf).
|
|
14
|
+
|
|
15
|
+
To obtain the carbon intensity depending on a country's energy mix, we refer to [OurWorldInData](https://ourworldindata.org/grapher/carbon-intensity-electricity?tab=table), which aggregates data from Ember's European Electricity Review and the Energy Institute's Statistical Review of World Energy.
|
|
16
|
+
|
|
17
|
+
For Germany, the state can be specified, in which case historical carbon intensity estimates from [co2map.de](https://co2map.de/) will be used.
|
|
18
|
+
|
|
19
|
+
### Units
|
|
20
|
+
|
|
21
|
+
* Power produced - [MW]
|
|
22
|
+
* Default emission factor - [tones CO₂eq. / MWh]
|
|
23
|
+
* Carbon intensity of the electricity - [tones CO₂eq. / MWh]
|
|
24
|
+
* Carbon emissions - [tones CO₂eq.]
|
|
25
|
+
|
|
26
|
+
## Installation and usage
|
|
27
|
+
|
|
28
|
+
```
|
|
29
|
+
pip install mosaik-emissions
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
If you don't want to install this through PyPI, you can use pip to install the requirements.txt file:
|
|
33
|
+
```
|
|
34
|
+
pip install -r requirements.txt # To use this, you have to install at least version 3.2.0 of mosaik.
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
The simulator uses `P[MW]` as an input and `E[tCO2eq]` as an output attribute.
|
|
38
|
+
For each connected *generator* or *external grid*, one of the parameters must be defined: the emission factor, the fuel used, the country, and the state, see *the configuration* section bellow. You can also use the *method* option, which is callable, directly transforms input data to output, and takes precedence over other options. Thus, each emissions model can be configured while creation by using `model_params`:
|
|
39
|
+
|
|
40
|
+
* method - callable that directly transforms input data to output
|
|
41
|
+
* co2_emission_factor - float number that directly represents conversion factor [tones CO₂eq. / MWh]
|
|
42
|
+
* fuel - string that matches with a certain type of fuel used to produce electricity
|
|
43
|
+
* state - string that matches with a certain state of the country to filter the carbon intensity database out, it shuld be defined along with the country
|
|
44
|
+
* country - string that matches with a country to filter the carbon intensity database out
|
|
45
|
+
* coefficient - float number that multiplies emissions output, default is 1.0
|
|
46
|
+
|
|
47
|
+
```
|
|
48
|
+
emission_config = {
|
|
49
|
+
'co2_emission_factor' : 0.385,
|
|
50
|
+
'fuel' : 'Natural Gas Liquids',
|
|
51
|
+
'country' : 'Germany',
|
|
52
|
+
'state' : 'SN', # it shuld be defined along with the country if so
|
|
53
|
+
'coefficient' : 2.0 # multiplies total emissions output
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
em = em_sim.Emission.create(1, **emission_config)
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
**Note**: the model applies the first option defined according to the order described, e.g. if `co2_emission_factor` is defined, it does not check `fuel` or `country`.
|
|
60
|
+
|
|
61
|
+
Specify simulators configurations within your scenario script:
|
|
62
|
+
```
|
|
63
|
+
sim_config = {
|
|
64
|
+
'Grid': {
|
|
65
|
+
'python': 'mosaik_components.pandapower:Simulator'
|
|
66
|
+
},
|
|
67
|
+
'Emissions': {
|
|
68
|
+
'python': 'mosaik_components.emissions:Simulator'
|
|
69
|
+
},
|
|
70
|
+
...
|
|
71
|
+
}
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
Initialize the pandapower grid and emissions simulator:
|
|
75
|
+
```
|
|
76
|
+
gridsim = world.start('Grid', step_size=STEP_SIZE)
|
|
77
|
+
em_sim = world.start('Emissions')
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
Instantiate model entities:
|
|
81
|
+
```
|
|
82
|
+
grid = gridsim.Grid(json=GRID_FILE)
|
|
83
|
+
em = em_sim.Emission.create(1, **emission_config)
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
Connect and run:
|
|
87
|
+
```
|
|
88
|
+
gens = [e for e in grid.children if e.type in ['Gen', 'ControlledGen']]
|
|
89
|
+
world.connect(gens[0], em[0], 'P[MW]')
|
|
90
|
+
world.run(until=END)
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
You can see the demo scenario in the `demo` folder.
|
|
94
|
+
|
|
95
|
+
## Possible configuration
|
|
96
|
+
|
|
97
|
+
To relate to an emission factor derived from the country's energy mix, the full name of the country should be provided (see [OurWorldInData](https://ourworldindata.org/grapher/carbon-intensity-electricity?tab=table)), e.g.:
|
|
98
|
+
- Germany
|
|
99
|
+
- Greece
|
|
100
|
+
- Iceland
|
|
101
|
+
- ...
|
|
102
|
+
|
|
103
|
+
For Germany certain states are available (see [co2map.de](https://co2map.de/)): DE (country average), BB, BW, BY, HE, MV, NI, NW, RP, SH, SL, SN, ST, TH
|
|
104
|
+
|
|
105
|
+
To relate to certain fuel type, the fuel name should be provided (see [Stationary Combustion](https://gitlab.com/mosaik/components/energy/mosaik-emissions/-/blob/main/misc/fuel_combustion.pdf?ref_type=heads), Table 2.2):
|
|
106
|
+
- Crude Oil
|
|
107
|
+
- Natural Gas Liquids
|
|
108
|
+
- Natural Gas
|
|
109
|
+
- Charcoal
|
|
110
|
+
- Gas/Diesel Oil
|
|
111
|
+
- Ethane
|
|
112
|
+
- ...
|
|
113
|
+
|
|
114
|
+
## Developer notes
|
|
115
|
+
|
|
116
|
+
Note that emission factor and carbon intensity of electricity values for specific fuels and countries are stored in `data/data.csv` with the units specified in the source and are converted internally once been called.
|
|
117
|
+
|
|
118
|
+
Raw data files and `data.csv` preparation notebook can be found in the `misc` folder.
|
|
119
|
+
|
|
120
|
+
## Sources and References
|
|
121
|
+
|
|
122
|
+
* Ember - Yearly Electricity Data (2023); Ember - European Electricity Review (2022); Energy Institute - Statistical Review of World Energy (2023) – with major processing by Our World in Data. “Carbon intensity of electricity generation” [dataset]. Ember, “Yearly Electricity Data”; Ember, “European Electricity Review”; Energy Institute, “Statistical Review of World Energy” [original data]. Retrieved February 27, 2024 from https://ourworldindata.org/grapher/carbon-intensity-electricity
|
|
123
|
+
|
|
124
|
+
* Hourly consumption-based CO2 emissions intensity in Germany / [co2map.de](https://co2map.de/), INATECH, University of Freiburg. Retrieved February 27, 2024 from https://api.co2map.de/docs
|