|
6 | 6 | from mescal.filesystem_constants import BW_PROJECT_NAME
|
7 | 7 |
|
8 | 8 | dummy_esm_db = [
|
| 9 | + { |
| 10 | + "name": "BATTERY, Construction", |
| 11 | + "reference product": "battery, Li-ion, LFP, rechargeable, prismatic", |
| 12 | + "location": "GLO", |
| 13 | + "database": "dummy_esm_db", |
| 14 | + "unit": "kilogram", |
| 15 | + "code": "00000", |
| 16 | + "exchanges": [ |
| 17 | + { |
| 18 | + "name": "BATTERY, Construction", |
| 19 | + "product": "battery, Li-ion, LFP, rechargeable, prismatic", |
| 20 | + "location": "GLO", |
| 21 | + "database": "dummy_esm_db", |
| 22 | + "type": "production", |
| 23 | + "amount": 1, |
| 24 | + "unit": "kilogram", |
| 25 | + "code": "00000" |
| 26 | + }, |
| 27 | + { |
| 28 | + "name": "market for battery, Li-ion, LFP, rechargeable, prismatic", |
| 29 | + "product": "battery, Li-ion, LFP, rechargeable, prismatic", |
| 30 | + "location": "GLO", |
| 31 | + "database": "ecoinvent-3.9.1-cutoff", |
| 32 | + "type": "technosphere", |
| 33 | + "amount": 1, |
| 34 | + "unit": "kilogram", |
| 35 | + "code": 'f22991a7a4e1d7ecfa81cdd7453e83d2', |
| 36 | + } |
| 37 | + ] |
| 38 | + }, |
9 | 39 | {
|
10 | 40 | "name": "TRAIN_FREIGHT_DIESEL_LOC, Construction",
|
11 | 41 | "reference product": "locomotive",
|
|
69 | 99 | ]
|
70 | 100 |
|
71 | 101 | mapping = [
|
| 102 | + ['BATTERY', 'Construction', 'battery, Li-ion, LFP, rechargeable, prismatic', |
| 103 | + 'market for battery, Li-ion, LFP, rechargeable, prismatic', 'GLO', 'ecoinvent-3.9.1-cutoff', '00000'], |
72 | 104 | ['TRAIN_FREIGHT_DIESEL_LOC', 'Construction', 'locomotive', 'locomotive production', 'RER',
|
73 | 105 | 'ecoinvent-3.9.1-cutoff', '00001'],
|
74 | 106 | ['TRAIN_FREIGHT_DIESEL_WAG', 'Construction', 'goods wagon', 'goods wagon production', 'RER',
|
|
80 | 112 | ]
|
81 | 113 |
|
82 | 114 | unit_conversion = [
|
| 115 | + ['BATTERY', 'Construction', 10, 'kilogram', 'kilowatt hour'], |
83 | 116 | ['TRAIN_FREIGHT_DIESEL_LOC', 'Construction', 2, 'unit', 'unit'],
|
84 | 117 | ['TRAIN_FREIGHT_DIESEL_WAG', 'Construction', 20, 'unit', 'unit'],
|
85 | 118 | ['TRAIN_FREIGHT_DIESEL', 'Construction', 2.5e-5, 'unit', 'ton kilometer per hour'],
|
86 | 119 | ]
|
87 | 120 |
|
88 | 121 | lifetime = [
|
| 122 | + ['BATTERY', 30, 20], |
89 | 123 | ['TRAIN_FREIGHT_DIESEL', 40, None],
|
90 | 124 | ['TRAIN_FREIGHT_DIESEL_LOC', None, 50],
|
91 | 125 | ['TRAIN_FREIGHT_DIESEL_WAG', None, 50],
|
@@ -128,21 +162,46 @@ def test_compute_impact_score():
|
128 | 162 | contribution_analysis=True,
|
129 | 163 | )
|
130 | 164 |
|
131 |
| - lcia_value = R[ |
| 165 | + lcia_value_train = R[ |
132 | 166 | (R.Impact_category == ('IPCC 2021', 'climate change', 'global warming potential (GWP100)'))
|
133 | 167 | & (R.Name == 'TRAIN_FREIGHT_DIESEL')
|
134 | 168 | & (R.Type == 'Construction')
|
135 | 169 | ].Value.iloc[0]
|
136 | 170 |
|
137 |
| - assert 44.40 <= lcia_value <= 44.41 |
| 171 | + assert 44.40 <= lcia_value_train <= 44.41 |
138 | 172 |
|
139 |
| - max_contrib = df_contrib_results[ |
| 173 | + contrib_train = df_contrib_results[ |
140 | 174 | (df_contrib_results.impact_category == ('IPCC 2021', 'climate change', 'global warming potential (GWP100)'))
|
141 | 175 | & (df_contrib_results.act_name == 'TRAIN_FREIGHT_DIESEL')
|
142 | 176 | & (df_contrib_results.act_type == 'Construction')
|
143 |
| - & (df_contrib_results.score == df_contrib_results.score.max()) |
144 | 177 | ]
|
145 | 178 |
|
146 |
| - assert max_contrib.ef_name.iloc[0] == 'Carbon dioxide, fossil' |
147 |
| - assert max_contrib.ef_categories.iloc[0] == ('air', 'non-urban air or from high stacks') |
148 |
| - assert 17.42 <= max_contrib.score.iloc[0] <= 17.43 |
| 179 | + max_contrib_train = contrib_train[ |
| 180 | + (contrib_train.score == contrib_train.score.max()) |
| 181 | + ] |
| 182 | + |
| 183 | + assert max_contrib_train.ef_name.iloc[0] == 'Carbon dioxide, fossil' |
| 184 | + assert max_contrib_train.ef_categories.iloc[0] == ('air', 'non-urban air or from high stacks') |
| 185 | + assert 17.42 <= max_contrib_train.score.iloc[0] <= 17.43 |
| 186 | + |
| 187 | + lcia_value_batt = R[ |
| 188 | + (R.Impact_category == ('IPCC 2021', 'climate change', 'global warming potential (GWP100)')) |
| 189 | + & (R.Name == 'BATTERY') |
| 190 | + & (R.Type == 'Construction') |
| 191 | + ].Value.iloc[0] |
| 192 | + |
| 193 | + assert 167.60 <= lcia_value_batt <= 167.61 |
| 194 | + |
| 195 | + contrib_batt = df_contrib_results[ |
| 196 | + (df_contrib_results.impact_category == ('IPCC 2021', 'climate change', 'global warming potential (GWP100)')) |
| 197 | + & (df_contrib_results.act_name == 'BATTERY') |
| 198 | + & (df_contrib_results.act_type == 'Construction') |
| 199 | + ] |
| 200 | + |
| 201 | + max_contrib_batt = contrib_batt[ |
| 202 | + (contrib_batt.score == contrib_batt.score.max()) |
| 203 | + ] |
| 204 | + |
| 205 | + assert max_contrib_batt.ef_name.iloc[0] == 'Carbon dioxide, fossil' |
| 206 | + assert max_contrib_batt.ef_categories.iloc[0] == ('air', 'non-urban air or from high stacks') |
| 207 | + assert 98.78 <= max_contrib_batt.score.iloc[0] <= 98.79 |
0 commit comments