diff --git a/dev/Untitled1.ipynb b/dev/Untitled1.ipynb index d6e9667b..7b49e66e 100644 --- a/dev/Untitled1.ipynb +++ b/dev/Untitled1.ipynb @@ -81,10 +81,10 @@ " #{\"model\":\"remind\", \"pathway\":\"SSP2-Base\", \"year\":2010},\n", " #{\"model\":\"image\", \"pathway\":\"SSP2-Base\", \"year\":2020},\n", " #{\"model\":\"remind\", \"pathway\":\"SSP2-Base\", \"year\":2050},\n", - " #{\"model\":\"remind\", \"pathway\":\"SSP2-PkBudg1150\", \"year\":2050},\n", - " {\"model\":\"image\", \"pathway\":\"SSP2-RCP26\", \"year\":2040},\n", - " {\"model\":\"image\", \"pathway\":\"SSP2-RCP26\", \"year\":2060},\n", - " {\"model\":\"image\", \"pathway\":\"SSP2-RCP19\", \"year\":2050},\n", + " {\"model\":\"remind\", \"pathway\":\"SSP2-PkBudg1150\", \"year\":2050},\n", + " #{\"model\":\"image\", \"pathway\":\"SSP2-RCP26\", \"year\":2040},\n", + " #{\"model\":\"image\", \"pathway\":\"SSP2-RCP26\", \"year\":2060},\n", + " #{\"model\":\"image\", \"pathway\":\"SSP2-RCP19\", \"year\":2050},\n", " #{\"model\":\"image\", \"pathway\":\"SSP2-Base\", \"year\":2050},\n", " ],\n", " source_db=\"ecoinvent-3.10-cutoff\", # <-- name of the database in the BW2 project. Must be a string.\n", @@ -104,7 +104,7 @@ "name": "stderr", "output_type": "stream", "text": [ - "Processing scenarios: 100%|████████████| 3/3 [06:13<00:00, 124.63s/it]" + "Processing scenarios: 100%|█████████████| 1/1 [01:38<00:00, 98.83s/it]" ] }, { @@ -192,7 +192,7 @@ }, { "cell_type": "code", - "execution_count": 6, + "execution_count": 5, "id": "dff4efb1-69ab-4bd5-8d52-4038df180a85", "metadata": {}, "outputs": [ @@ -211,55 +211,7 @@ "text": [ "Writing activities to SQLite3 database:\n", "0% [##############################] 100% | ETA: 00:00:00\n", - "Total time elapsed: 00:00:41\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Title: Writing activities to SQLite3 database:\n", - " Started: 07/13/2024 18:54:03\n", - " Finished: 07/13/2024 18:54:45\n", - " Total time elapsed: 00:00:41\n", - " CPU %: 88.20\n", - " Memory %: 12.60\n", - "Created database: cement rcp26 2040\n", - "Running all checks...\n", - "Minor anomalies found: check the change report.\n" - ] - }, - { - "name": "stderr", - "output_type": "stream", - "text": [ - "Writing activities to SQLite3 database:\n", - "0% [##############################] 100% | ETA: 00:00:00\n", - "Total time elapsed: 00:00:52\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Title: Writing activities to SQLite3 database:\n", - " Started: 07/13/2024 19:03:00\n", - " Finished: 07/13/2024 19:03:53\n", - " Total time elapsed: 00:00:52\n", - " CPU %: 89.80\n", - " Memory %: 8.77\n", - "Created database: cement rcp26 2060\n", - "Running all checks...\n", - "Minor anomalies found: check the change report.\n" - ] - }, - { - "name": "stderr", - "output_type": "stream", - "text": [ - "Writing activities to SQLite3 database:\n", - "0% [##############################] 100% | ETA: 00:00:00\n", - "Total time elapsed: 00:00:53\n" + "Total time elapsed: 00:00:36\n" ] }, { @@ -267,12 +219,12 @@ "output_type": "stream", "text": [ "Title: Writing activities to SQLite3 database:\n", - " Started: 07/13/2024 19:12:37\n", - " Finished: 07/13/2024 19:13:30\n", - " Total time elapsed: 00:00:53\n", - " CPU %: 89.00\n", - " Memory %: 7.57\n", - "Created database: cement rcp19 2\n", + " Started: 07/13/2024 20:50:02\n", + " Finished: 07/13/2024 20:50:39\n", + " Total time elapsed: 00:00:36\n", + " CPU %: 90.50\n", + " Memory %: 11.02\n", + "Created database: ei_cutoff_3.10_remind_SSP2-PkBudg1150_2050 2024-07-13\n", "Generate scenario report.\n", "Report saved under /Users/romain/GitHub/premise/dev/export/scenario_report.\n", "Generate change report.\n", @@ -281,202 +233,413 @@ } ], "source": [ - "ndb.write_db_to_brightway([\"cement rcp26 2040\", \"cement rcp26 2060\", \"cement rcp19 2\"])" + "ndb.write_db_to_brightway()" ] }, { "cell_type": "code", - "execution_count": 7, + "execution_count": 8, "id": "a3b56b3f-9583-4c90-ad21-551c5530e27c", "metadata": {}, "outputs": [ { - "name": "stdout", - "output_type": "stream", - "text": [ - "aluminium, primary, liquid\n", - "cooling energy, at -25 °c\n", - "1,1-dimethylcyclopentane\n", - "aluminium, primary, liquid\n", - "cooling energy, at -45 °c\n", - "cooling energy, at -45 °c\n", - "cooling energy, at -25 °c\n", - "fraction 8 from naphtha separation\n", - "fraction 8 from naphtha separation\n", - "fraction 1 from naphtha separation\n", - "2,3-dimethylbutane\n", - "heptane\n", - "fraction 7 from naphtha separation\n", - "2,3-dimethylbutane\n", - "cooling energy, at -55 °c\n", - "heptane\n", - "electricity, low voltage\n", - "cooling energy, at -55 °c\n", - "cooling energy, at -15 °c\n", - "2-methylpentane\n", - "sawnwood, paraná pine, dried (u=10%)\n", - "hexane\n", - "hexane\n", - "residual wood, dry\n", - "formaldehyde\n", - "sawlog and veneer log, paraná pine, measured as solid wood under bark\n", - "cooling energy, at -25 °c\n", - "cooling energy, at -100 °c\n", - "ventilation duct, elbow 90°, steel, 100x50 mm\n", - "cooling energy, at -160 °c\n", - "cooling energy, at -15 °c\n", - "cooling energy, at -45 °c\n", - "steam, in chemical industry\n", - "ventilation duct, elbow 90°, steel, 100x50 mm\n", - "cooling energy, at -100 °c\n", - "sawnwood, paraná pine, dried (u=10%)\n", - "residual wood, dry\n", - "aluminium, primary, liquid\n", - "sawnwood, paraná pine, dried (u=10%)\n", - "sawlog and veneer log, paraná pine, measured as solid wood under bark\n", - "fraction 1 from naphtha separation\n", - "cooling energy, at -100 °c\n", - "sawlog and veneer log, paraná pine, measured as solid wood under bark\n", - "aluminium, primary, liquid\n", - "steam, in chemical industry\n", - "sawnwood, paraná pine, dried (u=10%)\n", - "2-methylpentane\n", - "sawnwood, paraná pine, dried (u=10%)\n", - "cooling energy, at -160 °c\n", - "fraction 7 from naphtha separation\n", - "ventilation duct, elbow 90°, steel, 100x50 mm\n", - "electricity, low voltage\n", - "1,1-dimethylcyclopentane\n", - "aluminium, primary, liquid\n", - "sawlog and veneer log, paraná pine, measured as solid wood under bark\n", - "formaldehyde\n", - "methylcyclopentane\n", - "methylcyclohexane\n", - "methylcyclopentane\n", - "methylcyclohexane\n", - "electricity, high voltage\n", - "electricity, high voltage\n", - "electricity, high voltage\n", - "electricity, high voltage\n", - "electricity, high voltage\n", - "electricity, high voltage\n", - "electricity, high voltage\n", - "electricity, high voltage\n", - "electricity, high voltage\n", - "electricity, high voltage\n", - "electricity, high voltage\n", - "electricity, high voltage\n", - "electricity, high voltage\n", - "electricity, high voltage\n", - "natural gas, high pressure\n", - "natural gas, high pressure\n", - "natural gas, high pressure\n", - "natural gas, high pressure\n", - "natural gas, high pressure\n", - "natural gas, high pressure\n", - "natural gas, high pressure\n", - "natural gas, high pressure\n", - "natural gas, high pressure\n", - "natural gas, high pressure\n", - "natural gas, high pressure\n", - "natural gas, high pressure\n", - "natural gas, high pressure\n", - "natural gas, high pressure\n", - "natural gas, high pressure\n", - "natural gas, high pressure\n", - "natural gas, high pressure\n", - "natural gas, high pressure\n", - "natural gas, high pressure\n", - "natural gas, high pressure\n", - "natural gas, high pressure\n", - "natural gas, high pressure\n", - "natural gas, high pressure\n", - "natural gas, high pressure\n", - "natural gas, high pressure\n", - "natural gas, high pressure\n", - "natural gas, high pressure\n", - "natural gas, high pressure\n", - "natural gas, high pressure\n", - "natural gas, high pressure\n", - "natural gas, high pressure\n", - "natural gas, high pressure\n", - "natural gas, high pressure\n", - "natural gas, high pressure\n", - "natural gas, high pressure\n", - "natural gas, high pressure\n", - "natural gas, high pressure\n", - "natural gas, high pressure\n", - "natural gas, high pressure\n", - "transport, passenger car\n", - "transport, passenger car\n", - "transport, passenger car\n", - "transport, passenger car\n", - "transport, passenger car\n", - "transport, passenger car\n", - "transport, passenger car\n", - "transport, passenger car\n", - "transport, passenger car\n", - "transport, passenger car\n", - "transport, passenger car\n", - "transport, passenger car\n", - "transport, passenger car\n", - "transport, freight, lorry\n", - "transport, freight, lorry\n", - "transport, freight, lorry\n", - "transport, freight, lorry\n", - "transport, freight, lorry\n", - "transport, freight, lorry\n", - "transport, freight, lorry\n", - "transport, freight, lorry\n", - "transport, freight, lorry\n", - "transport, freight, lorry\n", - "transport, freight, lorry\n", - "transport, freight, lorry\n", - "transport, freight, lorry\n", - "transport, freight, lorry\n", - "transport, freight, lorry\n", - "transport, freight, lorry\n", - "transport, freight, lorry\n", - "transport, freight, lorry\n", - "transport, freight, lorry\n", - "transport, freight, lorry\n", - "transport, freight, lorry\n", - "transport, freight, lorry\n", - "transport, freight, lorry\n", - "transport, freight, lorry\n", - "transport, freight, lorry\n", - "transport, freight, lorry\n", - "transport, freight, lorry\n", - "transport, freight, lorry\n", - "transport, freight, lorry\n", - "transport, freight, lorry\n", - "transport, freight, lorry\n", - "transport, freight, lorry\n", - "transport, freight, lorry\n", - "transport, freight, lorry\n", - "transport, freight, lorry\n", - "transport, freight, lorry\n", - "transport, freight, lorry\n", - "transport, freight, lorry\n", - "transport, passenger bus\n", - "transport, passenger bus\n", - "transport, passenger bus\n", - "transport, passenger bus\n", - "transport, passenger bus\n", - "transport, passenger bus\n", - "transport, passenger bus\n", - "transport, passenger bus\n", - "transport, passenger bus\n", - "transport, passenger bus\n", - "transport, passenger bus\n", - "transport, passenger bus\n", - "transport, passenger bus\n" - ] + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "
<xarray.DataArray 'value' (region: 13)> Size: 104B\n",
+       "array([0.24319538, 0.11075869, 0.37354394, 0.1023092 , 0.41335137,\n",
+       "       0.10468423, 0.19437585, 0.19803933, 0.10542634, 0.1051091 ,\n",
+       "       0.09484875, 0.39999575, 0.14865214])\n",
+       "Coordinates:\n",
+       "  * region     (region) object 104B 'CAZ' 'CHA' 'EUR' ... 'SSA' 'USA' 'World'\n",
+       "    year       int64 8B 2050\n",
+       "    variables  <U6 24B 'cement'
" + ], + "text/plain": [ + " Size: 104B\n", + "array([0.24319538, 0.11075869, 0.37354394, 0.1023092 , 0.41335137,\n", + " 0.10468423, 0.19437585, 0.19803933, 0.10542634, 0.1051091 ,\n", + " 0.09484875, 0.39999575, 0.14865214])\n", + "Coordinates:\n", + " * region (region) object 104B 'CAZ' 'CHA' 'EUR' ... 'SSA' 'USA' 'World'\n", + " year int64 8B 2050\n", + " variables list: dataset["exchanges"].append(ccs_exc) # Update CO2 exchanges - for exc in dataset["exchanges"]: - if ( - exc["name"].lower().startswith("carbon dioxide") - and exc["type"] == "biosphere" - ): + for exc in ws.biosphere( + dataset, + ws.contains("name", "Carbon dioxide"), + ): + if exc["name"] == "Carbon dioxide, fossil": exc["amount"] *= 1 - carbon_capture_rate - if "non-fossil" in exc["name"].lower(): - dataset["log parameters"].update( - { - "new biogenic CO2": exc["amount"], - } - ) - else: - dataset["log parameters"].update( - { - "new fossil CO2": exc["amount"], - } - ) + dataset["log parameters"].update( + { + "new fossil CO2": exc["amount"], + } + ) + + if exc["name"] == "Carbon dioxide, non-fossil": + exc["amount"] *= 1 - carbon_capture_rate + + dataset["log parameters"].update( + { + "new biogenic CO2": exc["amount"], + } + ) + + # add a flow of "Carbon dioxide, in air" to reflect + # the permanent storage of biogenic CO2 + biogenic_CO2_reduction = ( + dataset["log parameters"]["initial biogenic CO2"] + - dataset["log parameters"]["new biogenic CO2"] + ) + dataset["exchanges"].append( + { + "uncertainty type": 0, + "loc": biogenic_CO2_reduction, + "amount": biogenic_CO2_reduction, + "type": "biosphere", + "name": "Carbon dioxide, in air", + "unit": "kilogram", + "categories": ( + "natural resource", + "in air", + ), + "comment": "Permanent storage of biogenic CO2", + "input": ( + "biosphere3", + self.biosphere_dict[ + ( + "Carbon dioxide, in air", + "natural resource", + "in air", + "kilogram", + ) + ], + ), + } + ) dataset["exchanges"] = [v for v in dataset["exchanges"] if v]