Skip to content

Commit

Permalink
Add exercises
Browse files Browse the repository at this point in the history
  • Loading branch information
willu47 committed Nov 11, 2020
1 parent 15b7229 commit 7ed2432
Show file tree
Hide file tree
Showing 2 changed files with 67 additions and 21 deletions.
86 changes: 66 additions & 20 deletions mj2383_lab3.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,32 @@
"\n",
"In this lab, we'll be using OSeMOSYS, but we'll be running it in the background using this Jupyter Notebook to control the input data, run the model and extract and visualise the results.\n",
"\n",
"If you click on the **Jupyter** logo in the top left-hand corner of the screen, you will see the folder structure containing the OSeMOSYS models used in this lab.\n",
"\n",
"In the `model` folder, you will find subfolders containing OSeMOSYS models of increasing complexity. Each subfolder contains a data folder in which you see a number of CSV (comma-separated value) files which you can edit directly in the browser. For example, you could edit the `CapitalCost` of technologies by editing the respective [CSV file](../edit/model/gas/data/CapitalCost.csv).\n",
"\n",
"[/model/gas/data/](CapitalCost.csv)\n",
"\n",
"Running a model is a two step process. Firstly, you need to create an OSeMOSYS datafile by running the following:\n",
"\n",
" !otoole convert datapackage datafile model/gas temp.txt\n",
" \n",
"Note you need the `!` prepended to the command (this tells the notebook to run this command using the shell rather than Python). Here we create datafile called `temp.txt` from the model data stored in `model/gas`.\n",
"\n",
"After generating the OSeMOSYS datafile (in this case, called `temp.txt`) we then solve the model using `glpsol`, which is the open-source solver provided by the GNU Math Programming kit.\n",
"\n",
" !glpsol -d temp.txt -m osemosys.txt > osemosys.log\n",
" \n",
"The results are then available in the `results` folder - see them [here](../tree/results). You should also check the `osemosys.log` file to ensure that the model ran correctly. View it [here](../edit/osemosys.log).\n",
"\n",
"In the stages below, we load data from the model inputs and results using a Python library called `pandas` and plot them in interactive charts.\n",
"\n",
"## Contents\n",
"\n",
"- [Stage 1](#Stage-1:-A-super-simple-supply-curve) - In this section, we expore a very simple model with a two-stage supply curve for natural gas to develop our economic interpretation of OSeMOSYS\n",
"- [Stage 2]() - We add complexity, by increasing the number of steps in our supply curve by adding resources. We explore what difference this makes to the electricity price under different conditions.\n",
"- [Stage 3]() - We add an emissions penalty, imposing a tax upon CO2\n",
"- [Stage 4]() - We add renewable technologies to the electricity sector, whose marginal cost of generation is 0. However, this creates a demand for backup capacity. How does this affect the marginal price of electricity?"
"- [Stage 2](#Stage-2:-Adding-Resources) - We add complexity, by increasing the number of steps in our supply curve by adding resources. We explore what difference this makes to the electricity price under different conditions.\n",
"- [Stage 3](#Stage-3:-A-tax-on-pollution) - We add an emissions penalty, imposing a tax upon CO2\n",
"- [Stage 4](#Stage-4:-Renewable-electricity-%22there's-no-such-thing-as-a-free-lunch%22) - We add renewable technologies to the electricity sector, whose marginal cost of generation is 0. However, this creates a demand for backup capacity. How does this affect the marginal price of electricity?"
]
},
{
Expand All @@ -46,9 +66,11 @@
"\n",
"First, let's have a think about the supply curve in this system.\n",
"\n",
"Shown on the left of the image, there are two natural gas resources. `GasExtraction` has a maximum production capacity of 6 PJ/year at a variable cost of €8/PJ. However, `GasImport` has no upper bound, but a higher cost of €12/PJ.\n",
"Shown on the left of the image, there are two natural gas resources. `GasExtraction` has a [maximum production capacity](../edit/model/gas/data/TotalAnnualMaxCapacity.csv) of 6 PJ/year at a [variable cost](../edit/model/gas/data/VariableCost.csv) of €8/PJ. However, `GasImport` has no upper bound, but a higher cost of €12/PJ.\n",
"\n",
"Plotted, this looks rather uninspiring, but at least gives an impression of a supply curve for natural gas.\n",
"\n",
"Plotted, this looks rather uninspiring, but at least gives an impression of a supply curve for natural gas.\n"
"__Run the next cell to view the graph__\n"
]
},
{
Expand All @@ -71,9 +93,19 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"In OSeMOSYS, supply must equal demand, and as the quantity demanded increases, supply increases accordingly. Given that our demand curve is a straight line (imagine a vertical line moving along the x-axis) the equilibrium point (where the lines cross) denotes the marginal cost of production and in this case is equal to the price.\n",
"In OSeMOSYS, supply of energy must equal demand for energy. As the quantity of energy demanded increases, energy supply increases accordingly. Given that our demand curve is a straight line (imagine a vertical line moving along the x-axis) the equilibrium point (where the lines cross) denotes the marginal cost of production and in this case is equal to the price.\n",
"\n",
"Within most energy systems, there are multiple markets for different, related, energy commodities. We can use our simple OSeMOSYS model to begin to understand these different energy markets, and how they relate to one another.\n",
"Within most energy systems, there are multiple markets for different, related, energy commodities. Later, we will use our simple OSeMOSYS model to begin to understand the innteractions between these different energy markets."
]
},
{
"cell_type": "markdown",
"metadata": {
"solution2": "hidden",
"solution2_first": true
},
"source": [
"### Exercise 1: Manual computing the marginal cost of electricity\n",
"\n",
"Think about how our simple supply curve for natural gas interacts with the demand for electricity. \n",
"\n",
Expand All @@ -84,21 +116,23 @@
},
{
"cell_type": "markdown",
"metadata": {},
"metadata": {
"solution2": "hidden"
},
"source": [
"That's right, it should be around €16/PJ. Of course, it won't be exactly that, because in OSeMOSYS the marginal cost of production of electricity will take into account all the inputs into the production, including:\n",
"- capital cost of the extra capacity required\n",
"- fixed operating cost\n",
"- any costs associated with emissions\n",
"\n",
"In addition, in OSeMOSYS, operating costs are discounted to the middle of the year, which is equivalent to a capital recovery factor of about 0.975 for the current year with a discount rate of 5%."
"In addition, in OSeMOSYS, operating costs are discounted to the middle of the year, which is equivalent to a capital recovery factor of about 0.975 for the current year with a discount rate of 5%.\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Using OSeMOSYS to compute the equilibrium price\n",
"### Exercise 2: Using OSeMOSYS to compute the equilibrium price\n",
"\n",
"We'll now run OSeMOSYS from this Jupyter Notebook to compute the equilibrium price:"
]
Expand Down Expand Up @@ -140,11 +174,29 @@
},
{
"cell_type": "markdown",
"metadata": {},
"metadata": {
"solution2": "hidden",
"solution2_first": true
},
"source": [
"**Q. Why is the production of `SEC_EL` higher than final electricity `FEL`?**"
]
},
{
"cell_type": "markdown",
"metadata": {
"solution2": "hidden"
},
"source": [
"Refer back to the original Figure of the simple energy system represented in this model. Secondary electricity (`SEC_EL`) is produced by the gas power station (`NGCC`) and transmitted through the transmission and distribution grid technology (`TD`). The distribution of electricity has 5% losses, which you can see in line 6 of the [`OutputActivityRatio.csv` file](../edit/model/gas/data/OutputActivityRatio.csv):\n",
"\n",
"**Q. Why is the production of `SEC_EL` higher than final electricity `FEL`?**\n",
"\n",
" SIMPLICITY,TD,FEL,1,2014,0.95"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Marginal Prices\n",
"\n",
"In OSeMOSYS, there is a key equation called a \"balancing constraint\". This ensures that energy is conserved. \n",
Expand Down Expand Up @@ -394,16 +446,10 @@
" \n",
" Once you've implemented the renewable technology, observe what happens to the supply cost curve."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"celltoolbar": "Raw Cell Format",
"kernelspec": {
"display_name": "Python 3",
"language": "python",
Expand Down
2 changes: 1 addition & 1 deletion postBuild
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
jupyter contrib nbextension install --user
jupyter nbextension enable exercise
jupyter nbextension enable exercise2
jupyter nbextension enable Exercise2
jupyter nbextension enable rubberband

0 comments on commit 7ed2432

Please sign in to comment.