{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Adding a region" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "The next step is to add a region which we will call `R2`, however, this could equally be called `USA` or `India`. These regions do not have any energy trade. This requires us to undertake a similar process as before of modifying the input simulation data. However, this time we will also have to change the ```settings.toml``` file to achieve this.\n", "\n", "The process to change the ```settings.toml``` file is relatively simple. We just have to add our new region to the ```regions``` variable, in the 4th line of the ```settings.toml``` file, like so:\n", "\n", " regions = [\"R1\", \"R2\"]\n", "\n", "The process to change the input files, however, takes a bit more time. To achieve this, there must be data for each of the sectors for the new region. This, therefore, requires the modification of every [input file](../inputs/index.rst).\n", "\n", "Due to space constraints, we will not show you how to edit all of the files. However, you can access the modified files [here](https://github.com/SGIModel/MUSE_OS/tree/main/docs/tutorial-code/3-add-region)." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Effectively, for this example, we will copy and paste the results for each of the input files from region `R1`, and change the name of the region for the new rows to `R2`. \n", "\n", "However, as we are increasing the demand by adding a region, as well as modifying the costs of technologies, it may be the case that a higher growth in technology is required. For example, there may be no possible solution to meet demand without increasing the ```windturbine``` maximum allowed limit. We will therefore increase the allowed limits for ```windturbine``` in region `R2`.\n", "\n", "We have placed two examples as to how to edit the residential sector below. Again, the edited data are highlighted in **bold**, with the original data in normal text. \n", "\n", "For the sake of brevity, we have omitted the entries for 2040 for the `CommIn.csv` file, however, just make sure to copy and paste the values for 2020 to 2040 here. The full file can be seen [here](https://github.com/SGIModel/MUSE_OS/blob/main/docs/tutorial-code/3-add-region/technodata/residential/CommIn.csv). \n", "\n", "The following file is the modified ```/technodata/residential/CommIn.csv``` file:\n", "\n", "|ProcessName|RegionName|Time|Level|electricity|gas|heat|CO2f|wind|\n", "|-|-|-|-|-|-|-|-|-|\n", "|Unit|-|Year|-|PJ/PJ|PJ/PJ|PJ/PJ|kt/PJ|PJ/PJ|\n", "|gasboiler|R1|2020|fixed|0|1.16|0|0|0|\n", "|heatpump|R1|2020|fixed|0.4|0|0|0|0|\n", "|**gasboiler**|**R2**|**2020**|**fixed**|**0**|**1.16**|**0**|**0**|**0**|\n", "|**heatpump**|**R2**|**2020**|**fixed**|**0.4**|**0**|**0**|**0**|**0**|\n", "|...|...|...|...|...|...|...|...|...|\n", "\n", "Whereas the following file is the modified ```/technodata/residential/ExistingCapacity.csv``` file:\n", "\n", "|ProcessName|RegionName|Unit|2020|2025|2030|2035|2040|2045|2050|\n", "|-|-|-|-|-|-|-|-|-|-|\n", "|gasboiler|R1|PJ/y|10|5|0|0|0|0|0|\n", "|heatpump|R1|PJ/y|0|0|0|0|0|0|0|\n", "|**gasboiler**|**R2**|**PJ/y**|**10**|**5**|**0**|**0**|**0**|**0**|**0**|\n", "|**heatpump**|**R2**|**PJ/y**|**0**|**0**|**0**|**0**|**0**|**0**|**0**|\n", "\n", "Below is the reduced ```/technodata/power/technodata.csv``` file, showing the increased capacity for ```windturbine``` in `R2`. For this, we highlight only the elements we changed from the rows in `R1`. The rest of the elements are the same for `R1` as they are for `R2`.\n", "\n", "Again, we don't show the entries for 2040, apart from the edited windturbine row, for the sake of brevity.\n", "\n", "|ProcessName|RegionName|Time|…|MaxCapacityAddition|MaxCapacityGrowth|TotalCapacityLimit|…|Agent2|\n", "|-|-|-|-|-|-|-|-|-|\n", "|Unit|-|Year|…|PJ|%|PJ|…|Retrofit|\n", "|gasCCGT|R1|2020|…|2|0.02|60|…|1|\n", "|windturbine|R1|2020|…|2|0.02|60|…|1|\n", "|solarPV|R1|2020|…|2|0.02|60|…|1|\n", "|gasCCGT|R2|2020|…|2|0.02|60|…|1|\n", "|windturbine|R2|2020|…|**5**|**0.05**|**100**|…|1|\n", "|windturbine|R2|2040|…|**5**|**0.05**|**100**|…|1|\n", "|solarPV|R2|2020|…|2|0.02|60|…|1|\n", "|...|...|...|...|...|...|...|...|...|\n", "\n", "Now, go ahead and amend all of the other input files for each of the sectors by copying and pasting the rows from `R1` and replacing the `RegionName` to `R2` for the new rows. All of the edited input files can be seen [here](https://github.com/SGIModel/MUSE_OS/tree/main/docs/tutorial-code/3-add-region)." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Again, we will run the results using the ```python -m pip muse settings.toml``` in anaconda prompt, and analyse the data as follows:" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "import matplotlib.pyplot as plt\n", "import pandas as pd\n", "import seaborn as sns" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "mca_capacity = pd.read_csv(\"../tutorial-code/3-add-region/Results/MCACapacity.csv\")\n", "\n", "for sector_name, sector_data in mca_capacity.groupby(\"sector\"):\n", " sector_capacity = (\n", " sector_data.groupby([\"year\", \"region\", \"technology\"]).sum().reset_index()\n", " )\n", " g = sns.FacetGrid(data=sector_capacity, col=\"region\")\n", " g.map_dataframe(\n", " lambda data, **kwargs: data.pivot(\n", " index=\"year\", columns=\"technology\", values=\"capacity\"\n", " ).plot(kind=\"bar\", stacked=True, ax=plt.gca())\n", " )\n", " g.add_legend()\n", " g.set_ylabels(\"Capacity (PJ)\")\n", " g.figure.suptitle(\"{} Sector:\".format(sector_name.capitalize()))\n", " g.figure.subplots_adjust(top=0.8)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Due to the similar natures of the two regions, with the parameters effectively copied and pasted between them, the results are very similar in both `R1` and `R2`. `gassupply1` drops significantly within the gas sector due to the carbon price profile. Which leads to the increasing demand of `heatpump` and falling demand of `gasboiler` in both region `R1` and `R2`. `windturbine` and `solarPV` increase significantly to match this demand of `heatpump`.\n", "\n", "Have a play around with the various costs data in the technodata files for each of the sectors and technologies to see if different scenarios emerge. Although be careful. In some cases, the constraints on certain technologies will make it impossible for the demand to be met and it will give you an error such as the following:\n", "\n", " message: 'The algorithm terminated successfully and determined that the problem is infeasible.'\n", "\n", "To avoid this error message you may have to relax the constraints in the technodata files. For instance, `MaxCapacityGrowth`." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Next steps" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "In the next section we modify the `settings.toml` file to change the timeslicing arrangements as well as project until 2040, instead of 2050, in two benchmark year time steps." ] } ], "metadata": { "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.9.18" } }, "nbformat": 4, "nbformat_minor": 4 }