{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Adding a service demand" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "In this section, we detail how to add a service demand to MUSE. \n", "\n", "In the residential sector, a service demand could be cooking. Houses require energy to cook food and a technology to service this demand, such as an electric stove. \n", "\n", "This process consists of setting a demand, either through inputs derived from the user or correlations of GDP and population which reflect the socio-economic development of a region or country. In addition, a technology must be added to service this new demand." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Addition of cooking demand" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Firstly, we must add the demand section. In this example, we will add a cooking preset demand. To achieve this, we will now edit the `Residential2020Consumption.csv` and `Residential2050Consumption.csv` files, found within the `technodata/preset/` directory.\n", "\n", "The `Residential2020Consumption.csv` file allows us to specify the demand in 2020 for each region and technology per timeslice. The `Residential2050Consumption.csv` file does the same but for the year 2050. The datapoints between these are interpolated.\n", "\n", "Firstly, we must add the new service demand: `cook` as a column in these two files. Next, we add the demand. Again, the modified entries are in bold:" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "||RegionName|ProcessName|Timeslice|electricity|gas|heat|CO2f|wind|**cook**|\n", "|-|-|-|-|-|-|-|-|-|-|\n", "|0|R1|gasboiler|1|0|0|1|0|0|**1**|\n", "|1|R1|gasboiler|2|0|0|1.5|0|0|**2**|\n", "|2|R1|gasboiler|3|0|0|1|0|0|**1**|\n", "|3|R1|gasboiler|4|0|0|1.5|0|0|**1.5**|\n", "|4|R1|gasboiler|5|0|0|3|0|0|**2**|\n", "|5|R1|gasboiler|6|0|0|2|0|0|**3**|\n", "|6|R1|gasboiler|7|0|0|2|0|0|**2**|\n", "|7|R1|gasboiler|8|0|0|2|0|0|**3**|\n", "|8|R2|gasboiler|1|0|0|1|0|0|**1**|\n", "|9|R2|gasboiler|2|0|0|1.5|0|0|**1**|\n", "|10|R2|gasboiler|3|0|0|1|0|0|**1**|\n", "|11|R2|gasboiler|4|0|0|1.5|0|0|**1.5**|\n", "|12|R2|gasboiler|5|0|0|3|0|0|**2**|\n", "|13|R2|gasboiler|6|0|0|2|0|0|**2**|\n", "|14|R2|gasboiler|7|0|0|2|0|0|**2.5**|\n", "|15|R2|gasboiler|8|0|0|2|0|0|**2**|\n", "\n", "\n", "\n" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "As can be seen, we only need to add a `cook` column in the file, as well as the demand level for each timeslice and each region. This can be seen through the addition of a positive number in the `cook` column.\n", "\n", "The process is very similar for the `Residential2050Consumption.csv` file, however, for this example, we often placed larger numbers to indicate higher demand in 2050. For the complete file see the link [here](https://github.com/SGIModel/MUSE_OS/blob/main/docs/tutorial-code/5-add-service-demand/1-exogenous-demand/technodata/preset/Residential2050Consumption.csv)." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Next, we must edit the files within the `input` folder. For this, we must add the `cook` service demand to each of these files.\n", "\n", "First, we will amend the `BaseYearExport.csv` and `BaseYearImport.csv` files. For this, we say that there is no import or export of the `cook` service demand. A brief example is outlined below for `BaseYearExport.csv`:\n", "\n", "|RegionName|Attribute|Time|electricity|gas|heat|CO2f|wind|solar|**cook**|\n", "|-|-|-|-|-|-|-|-|-|-|\n", "|Unit|-|Year|PJ|PJ|PJ|kt|PJ|PJ|**PJ**|\n", "|R1|Exports|2010|0|0|0|0|0|0|**0**|\n", "|...|...|...|...|...|...|...|...|...|**...**|\n", "|R2|Exports|2100|0|0|0|0|0|0|**0**|\n", "\n", "The same is true for the `BaseYearImport.csv` file:\n", "\n", "|RegionName|Attribute|Time|electricity|gas|heat|CO2f|wind|solar|**cook**|\n", "|-|-|-|-|-|-|-|-|-|-|\n", "|Unit|-|Year|PJ|PJ|PJ|kt|PJ|PJ|**PJ**|\n", "|R1|Imports|2010|0|0|0|0|0|0|**0**|\n", "|...|...|...|...|...|...|...|...|...|**...**|\n", "|R2|Imports|2100|0|0|0|0|0|0|**0**|\n", "\n" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Next, we must edit the `GlobalCommodities.csv` file. This is where we define the new commodity `cook`. It tells MUSE the commodity type, name, emissions factor of CO2 and heat rate, amongst other things. \n", "\n", "The example used for this tutorial is below: \n", "\n", "|Commodity|CommodityType|CommodityName|CommodityEmissionFactor_CO2|HeatRate|Unit|\n", "|-|-|-|-|-|-|\n", "|Electricity|Energy|electricity|0|1|PJ|\n", "|Gas|Energy|gas|56.1|1|PJ|\n", "|Heat|Energy|heat|0|1|PJ|\n", "|Wind|Energy|wind|0|1|PJ|\n", "|CO2fuelcomsbustion|Environmental|CO2f|0|1|kt|\n", "|Solar|Energy|solar|0|1|PJ|\n", "|**Cook**|**Energy**|**cook**|**0**|**1**|**PJ**|" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Finally, the `Projections.csv` file must be changed. This is a large file which details the expected cost of the technology in the first benchmark year of the simulation. Due to its size, we will only show two rows of the new column `cook`.\n", "\n", "|RegionName|Attribute|Time|…|**cook**|\n", "|-|-|-|-|-|\n", "|Unit|-|Year|…|**MUS\\$2010/PJ**|\n", "|R1|CommodityPrice|2010|…|**100**|\n", "|…|…|…|…|**…**|\n", "|R2|CommodityPrice|2100|…|**100**|\n", "\n", "We set every price of cook to be `100MUS$2010/PJ`" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Addition of cooking technology" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Next, we must add a technology to service this new demand. This is achieved through a similar process as the section in the [\"1. adding a new technology\"](add-solar.ipynb) section. However, we must be careful to specify the end-use of the technology as `cook`.\n", "\n", "For this example, we will add two competing technologies to service the cooking demand: `electric_stove` and `gas_stove` to the `Technodata.csv` file in `/technodata/residential/Technodata.csv`.\n", "\n", "Again for the interests of space, we have omitted the existing `gasboiler` and `heatpump` technologies. But we copy the `gasboiler` row for `R1` and paste it for the new `electric_stove` for both `R1` and `R2`. For `gas_stove` we copy and paste the data for `heatpump` from region `R1` for both `R1` and `R2`. \n", "\n", "An important modification, however, is specifying the end-use for these new technologies to be `cook` and not `heat`.\n", "\n", "|ProcessName|RegionName|Time|Level|cap_par|…|Fuel|EndUse|Agent2|\n", "|-|-|-|-|-|-|-|-|-|\n", "|Unit|-|Year|-|MUS$2010/PJ_a|…|-|-|Retrofit|\n", "|gasboiler|R1|2020|fixed|3.8|…|gas|heat|1|\n", "|...|...|...|...|...|...|...|...|...|\n", "|**electric_stove**|**R1**|**2020**|**fixed**|**3.8**|**…**|**electricity**|**cook**|**1**|\n", "|**electric_stove**|**R2**|**2020**|**fixed**|**3.8**|**…**|**electricity**|**cook**|**1**|\n", "|**gas_stove**|**R1**|**2020**|**fixed**|**8.8667**|**…**|**gas**|**cook**|**1**|\n", "|**gas_stove**|**R2**|**2020**|**fixed**|**8.8667**|**…**|**gas**|**cook**|**1**|\n", "\n", "\n", "As can be seen we have added two technologies, in the two regions with different `cap_par` costs. We specified their respective fuels, and the enduse for both is `cook`. For the full file please see [here](https://github.com/SGIModel/MUSE_OS/blob/main/docs/tutorial-code/5-add-service-demand/1-exogenous-demand/technodata/power/Technodata.csv)." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "We must also add the data for these new technologies to the following files:\n", "\n", "- `CommIn.csv`\n", "\n", "- `CommOut.csv`\n", "\n", "- `ExistingCapacity.csv`\n", "\n", "This is largely a similar process to the tutorial shown in [\"adding a new technology\"](add-solar.ipynb). We must add the input to each of the technologies (gas and electricity for `gas_stove` and `electric_stove` respectively), outputs of `cook` for both and the existing capacity for each technology in each region.\n", "\n", "Due to the additional demand for gas and electricity brought on by the new `cook` demand, it is necessary to relax the growth constraints for `gassupply1` in the `technodata/gas/technodata.csv` file. For this example, we set this file as follows:\n", "\n", "|ProcessName|RegionName|Time|…|MaxCapacityAddition|MaxCapacityGrowth|TotalCapacityLimit|…|Agent2|\n", "|-|-|-|-|-|-|-|-|-|\n", "|Unit|-|Year|…|PJ|%|PJ|…|Retrofit|\n", "|gassupply1|R1|2020|…|**100**|**5**|**500**|…|1|\n", "|gassupply1|R2|2020|…|**100**|**5**|**120**|…|1|\n", "\n", "To prevent repetition of the [\"adding a new technology\"](add-solar.ipynb) section, we will leave the full files [here](https://github.com/SGIModel/MUSE_OS/tree/main/docs/tutorial-code/5-add-service-demand/1-exogenous-demand). " ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Again, we run the simulation with our modified input files using the following command, in the relevant directory:\n", " \n", " python -m muse settings.toml\n", " \n", "Once this has run we are ready to visualise our results." ] }, { "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(\n", " \"../tutorial-code/5-add-service-demand/Results/MCACapacity.csv\"\n", ")\n", "mca_capacity.head()" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "for sector_name, sector_data in mca_capacity.groupby(\"sector\"):\n", " sector_capacity = (\n", " sector_data.groupby([\"technology\", \"region\", \"year\"]).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": [ "We can see our new technology, the `gas_stove` is used and the `electric_stove` is not used at all. Therefore, there is an increase in `gassupply1` to accommodate for this growth in demand. However, this is not enough to displace `windturbine` by `gasCCGT` in the power sector." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Next steps" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "In the next section we will use a regression function to estimate electricity demand from GDP and population data." ] } ], "metadata": { "kernelspec": { "display_name": "Python 3.9.0 ('muse39')", "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" }, "vscode": { "interpreter": { "hash": "22ff8bbda430c28f07def99f448c0c69dabbaf0c7d993cae69f87b3c458d04b2" } } }, "nbformat": 4, "nbformat_minor": 4 }