{
"cells": [
{
"cell_type": "markdown",
"id": "4cc91761",
"metadata": {},
"source": [
"(binary-pump-example)=\n",
"# Binary pumps\n",
"\n",
"This example is available in the following formats:\n",
"\n",
"- YAML\n",
" - [basic_pump.yaml](basic-pump-yaml)\n",
"- ASCII\n",
" - [basic_pump.ascii](basic-pump-ascii)\n",
"\n",
"pyshop code for adding pump is provided below, while the initial model is available in [basic_pump.py](basic-pump-py).\n",
"\n",
"## Introduction\n",
"\n",
"This example imports a basic model and adds a simple binary [pump](pump). By varying the sale price in the [market](market), we see that the watercourse pumps water to the upper [reservoir](reservoir) when the price is lower than its water value.\n",
"\n",
"## Imports"
]
},
{
"cell_type": "code",
"execution_count": 1,
"id": "6d8512d2",
"metadata": {
"Collapsed": "false"
},
"outputs": [],
"source": [
"#Necessary imports used in all examples\n",
"import pandas as pd\n",
"import plotly.graph_objs as go\n",
"import plotly.express as px\n",
"\n",
"from pyshop import ShopSession\n",
"\n",
"#Functions used in this example for building a basic SHOP model and running it\n",
"from basic_pump import build_model, run_model"
]
},
{
"cell_type": "markdown",
"id": "8e453dd6",
"metadata": {},
"source": [
"## Create a SHOP session and import basic model from file function"
]
},
{
"cell_type": "code",
"execution_count": 2,
"id": "3b1a3bc1",
"metadata": {
"Collapsed": "false"
},
"outputs": [
{
"data": {
"image/svg+xml": [
"\n",
"\n",
"\n",
"\n",
"\n"
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"#Create a standard ShopSession\n",
"shop=ShopSession()\n",
"#Build a basic SHOP model\n",
"build_model(shop)\n",
"#Display topology to the screen\n",
"display(shop.model.build_connection_tree())"
]
},
{
"cell_type": "markdown",
"id": "1ad2ec99",
"metadata": {},
"source": [
"## Add pumping capabilities\n",
"\n",
"Pumps can be added as pump objects, and need to be connected to a [plant](plant). We then apply attributes to the pump object. A binary pump only has a single operating point, which is specified by only supplying a single point in the [turbine efficiency curves](pump:turb_eff_curves). Note that the point may still change as a function of head. If the [p_min](pump:p_min) and [p_max](pump:p_max) attributes of the binary pump are set to be equal, the pump will always consume this amount of power. If the operation of the pump should only be constrained by the points defined in the turbine efficiency curves, p_min and p_max can be set to unconstraining values such as 0 and 10000, respectively. In the example below, consumption will also be bounded to be within 38 and 42 MW. Whereas you in the old ASCII format don't need to specify a maximum and minimum production for a binary pump, you need to explicitly add those attributes in addition to the nominal production in pyshop."
]
},
{
"cell_type": "code",
"execution_count": 3,
"id": "7f8c2c98",
"metadata": {},
"outputs": [],
"source": [
"p1p1=shop.model.pump.add_object(\"P1P1\")\n",
"p1p1.connect_to(shop.model.plant.Plant1)\n",
"p1p1.penstock.set(1)\n",
"p1p1.p_nom.set(40)\n",
"p1p1.p_min.set(38)\n",
"p1p1.p_max.set(42)\n",
"p1p1.startcost.set(500)\n",
"p1p1.gen_eff_curve.set(pd.Series([100,100], index=[0,50]))\n",
"p1p1.turb_eff_curves.set([pd.Series([87],index=[80],name=40),pd.Series([86],index=[70],name=50),pd.Series([85],index=[60],name=60)])"
]
},
{
"cell_type": "markdown",
"id": "f61efdca",
"metadata": {},
"source": [
"## Run SHOP"
]
},
{
"cell_type": "code",
"execution_count": 4,
"id": "2700bc3f",
"metadata": {},
"outputs": [],
"source": [
"run_model(shop)"
]
},
{
"cell_type": "markdown",
"id": "3fa80d71",
"metadata": {},
"source": [
"## Plots and results\n",
"\n",
"We observe that the pump is used in the first six hours of the period, where the market price is lower than the water value in the upper reservoir."
]
},
{
"cell_type": "code",
"execution_count": 5,
"id": "51c29a1f",
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
" \n",
" "
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"application/vnd.plotly.v1+json": {
"config": {
"plotlyServerURL": "https://plot.ly"
},
"data": [
{
"marker": {
"color": "rgb(33,102,172)"
},
"name": "Market price",
"type": "scatter",
"x": [
"2018-02-27T00:00:00",
"2018-02-27T01:00:00",
"2018-02-27T02:00:00",
"2018-02-27T03:00:00",
"2018-02-27T04:00:00",
"2018-02-27T05:00:00",
"2018-02-27T06:00:00",
"2018-02-27T07:00:00",
"2018-02-27T08:00:00",
"2018-02-27T09:00:00",
"2018-02-27T10:00:00",
"2018-02-27T11:00:00",
"2018-02-27T12:00:00",
"2018-02-27T13:00:00",
"2018-02-27T14:00:00",
"2018-02-27T15:00:00",
"2018-02-27T16:00:00",
"2018-02-27T17:00:00",
"2018-02-27T18:00:00",
"2018-02-27T19:00:00",
"2018-02-27T20:00:00",
"2018-02-27T21:00:00",
"2018-02-27T22:00:00",
"2018-02-27T23:00:00"
],
"y": [
19.99,
19.99,
19.99,
19.99,
19.99,
19.99,
39.99,
39.99,
39.99,
39.99,
39.99,
39.99,
39.99,
39.99,
39.99,
39.99,
39.99,
39.99,
39.99,
39.99,
39.99,
39.99,
39.99,
39.99
]
},
{
"line": {
"dash": "dot"
},
"marker": {
"color": "rgb(67,147,195)"
},
"name": "Water value of Reservoir1",
"type": "scatter",
"x": [
"2018-02-27T00:00:00",
"2018-02-27T01:00:00",
"2018-02-27T02:00:00",
"2018-02-27T03:00:00",
"2018-02-27T04:00:00",
"2018-02-27T05:00:00",
"2018-02-27T06:00:00",
"2018-02-27T07:00:00",
"2018-02-27T08:00:00",
"2018-02-27T09:00:00",
"2018-02-27T10:00:00",
"2018-02-27T11:00:00",
"2018-02-27T12:00:00",
"2018-02-27T13:00:00",
"2018-02-27T14:00:00",
"2018-02-27T15:00:00",
"2018-02-27T16:00:00",
"2018-02-27T17:00:00",
"2018-02-27T18:00:00",
"2018-02-27T19:00:00",
"2018-02-27T20:00:00",
"2018-02-27T21:00:00",
"2018-02-27T22:00:00",
"2018-02-27T23:00:00"
],
"y": [
39.7,
39.7,
39.7,
39.7,
39.7,
39.7,
39.7,
39.7,
39.7,
39.7,
39.7,
39.7,
39.7,
39.7,
39.7,
39.7,
39.7,
39.7,
39.7,
39.7,
39.7,
39.7,
39.7,
39.7
]
},
{
"line": {
"dash": "dot"
},
"marker": {
"color": "rgb(146,197,222)"
},
"name": "Water value of Reservoir2",
"type": "scatter",
"x": [
"2018-02-27T00:00:00",
"2018-02-27T01:00:00",
"2018-02-27T02:00:00",
"2018-02-27T03:00:00",
"2018-02-27T04:00:00",
"2018-02-27T05:00:00",
"2018-02-27T06:00:00",
"2018-02-27T07:00:00",
"2018-02-27T08:00:00",
"2018-02-27T09:00:00",
"2018-02-27T10:00:00",
"2018-02-27T11:00:00",
"2018-02-27T12:00:00",
"2018-02-27T13:00:00",
"2018-02-27T14:00:00",
"2018-02-27T15:00:00",
"2018-02-27T16:00:00",
"2018-02-27T17:00:00",
"2018-02-27T18:00:00",
"2018-02-27T19:00:00",
"2018-02-27T20:00:00",
"2018-02-27T21:00:00",
"2018-02-27T22:00:00",
"2018-02-27T23:00:00"
],
"y": [
0.0,
0.0,
0.0,
0.0,
0.0,
0.0,
0.0,
0.0,
0.0,
0.0,
0.0,
0.0,
0.0,
0.0,
0.0,
0.0,
0.0,
0.0,
0.0,
0.0,
0.0,
0.0,
0.0,
0.0
]
}
],
"layout": {
"template": {
"data": {
"bar": [
{
"error_x": {
"color": "#2a3f5f"
},
"error_y": {
"color": "#2a3f5f"
},
"marker": {
"line": {
"color": "#E5ECF6",
"width": 0.5
},
"pattern": {
"fillmode": "overlay",
"size": 10,
"solidity": 0.2
}
},
"type": "bar"
}
],
"barpolar": [
{
"marker": {
"line": {
"color": "#E5ECF6",
"width": 0.5
},
"pattern": {
"fillmode": "overlay",
"size": 10,
"solidity": 0.2
}
},
"type": "barpolar"
}
],
"carpet": [
{
"aaxis": {
"endlinecolor": "#2a3f5f",
"gridcolor": "white",
"linecolor": "white",
"minorgridcolor": "white",
"startlinecolor": "#2a3f5f"
},
"baxis": {
"endlinecolor": "#2a3f5f",
"gridcolor": "white",
"linecolor": "white",
"minorgridcolor": "white",
"startlinecolor": "#2a3f5f"
},
"type": "carpet"
}
],
"choropleth": [
{
"colorbar": {
"outlinewidth": 0,
"ticks": ""
},
"type": "choropleth"
}
],
"contour": [
{
"colorbar": {
"outlinewidth": 0,
"ticks": ""
},
"colorscale": [
[
0.0,
"#0d0887"
],
[
0.1111111111111111,
"#46039f"
],
[
0.2222222222222222,
"#7201a8"
],
[
0.3333333333333333,
"#9c179e"
],
[
0.4444444444444444,
"#bd3786"
],
[
0.5555555555555556,
"#d8576b"
],
[
0.6666666666666666,
"#ed7953"
],
[
0.7777777777777778,
"#fb9f3a"
],
[
0.8888888888888888,
"#fdca26"
],
[
1.0,
"#f0f921"
]
],
"type": "contour"
}
],
"contourcarpet": [
{
"colorbar": {
"outlinewidth": 0,
"ticks": ""
},
"type": "contourcarpet"
}
],
"heatmap": [
{
"colorbar": {
"outlinewidth": 0,
"ticks": ""
},
"colorscale": [
[
0.0,
"#0d0887"
],
[
0.1111111111111111,
"#46039f"
],
[
0.2222222222222222,
"#7201a8"
],
[
0.3333333333333333,
"#9c179e"
],
[
0.4444444444444444,
"#bd3786"
],
[
0.5555555555555556,
"#d8576b"
],
[
0.6666666666666666,
"#ed7953"
],
[
0.7777777777777778,
"#fb9f3a"
],
[
0.8888888888888888,
"#fdca26"
],
[
1.0,
"#f0f921"
]
],
"type": "heatmap"
}
],
"heatmapgl": [
{
"colorbar": {
"outlinewidth": 0,
"ticks": ""
},
"colorscale": [
[
0.0,
"#0d0887"
],
[
0.1111111111111111,
"#46039f"
],
[
0.2222222222222222,
"#7201a8"
],
[
0.3333333333333333,
"#9c179e"
],
[
0.4444444444444444,
"#bd3786"
],
[
0.5555555555555556,
"#d8576b"
],
[
0.6666666666666666,
"#ed7953"
],
[
0.7777777777777778,
"#fb9f3a"
],
[
0.8888888888888888,
"#fdca26"
],
[
1.0,
"#f0f921"
]
],
"type": "heatmapgl"
}
],
"histogram": [
{
"marker": {
"pattern": {
"fillmode": "overlay",
"size": 10,
"solidity": 0.2
}
},
"type": "histogram"
}
],
"histogram2d": [
{
"colorbar": {
"outlinewidth": 0,
"ticks": ""
},
"colorscale": [
[
0.0,
"#0d0887"
],
[
0.1111111111111111,
"#46039f"
],
[
0.2222222222222222,
"#7201a8"
],
[
0.3333333333333333,
"#9c179e"
],
[
0.4444444444444444,
"#bd3786"
],
[
0.5555555555555556,
"#d8576b"
],
[
0.6666666666666666,
"#ed7953"
],
[
0.7777777777777778,
"#fb9f3a"
],
[
0.8888888888888888,
"#fdca26"
],
[
1.0,
"#f0f921"
]
],
"type": "histogram2d"
}
],
"histogram2dcontour": [
{
"colorbar": {
"outlinewidth": 0,
"ticks": ""
},
"colorscale": [
[
0.0,
"#0d0887"
],
[
0.1111111111111111,
"#46039f"
],
[
0.2222222222222222,
"#7201a8"
],
[
0.3333333333333333,
"#9c179e"
],
[
0.4444444444444444,
"#bd3786"
],
[
0.5555555555555556,
"#d8576b"
],
[
0.6666666666666666,
"#ed7953"
],
[
0.7777777777777778,
"#fb9f3a"
],
[
0.8888888888888888,
"#fdca26"
],
[
1.0,
"#f0f921"
]
],
"type": "histogram2dcontour"
}
],
"mesh3d": [
{
"colorbar": {
"outlinewidth": 0,
"ticks": ""
},
"type": "mesh3d"
}
],
"parcoords": [
{
"line": {
"colorbar": {
"outlinewidth": 0,
"ticks": ""
}
},
"type": "parcoords"
}
],
"pie": [
{
"automargin": true,
"type": "pie"
}
],
"scatter": [
{
"fillpattern": {
"fillmode": "overlay",
"size": 10,
"solidity": 0.2
},
"type": "scatter"
}
],
"scatter3d": [
{
"line": {
"colorbar": {
"outlinewidth": 0,
"ticks": ""
}
},
"marker": {
"colorbar": {
"outlinewidth": 0,
"ticks": ""
}
},
"type": "scatter3d"
}
],
"scattercarpet": [
{
"marker": {
"colorbar": {
"outlinewidth": 0,
"ticks": ""
}
},
"type": "scattercarpet"
}
],
"scattergeo": [
{
"marker": {
"colorbar": {
"outlinewidth": 0,
"ticks": ""
}
},
"type": "scattergeo"
}
],
"scattergl": [
{
"marker": {
"colorbar": {
"outlinewidth": 0,
"ticks": ""
}
},
"type": "scattergl"
}
],
"scattermapbox": [
{
"marker": {
"colorbar": {
"outlinewidth": 0,
"ticks": ""
}
},
"type": "scattermapbox"
}
],
"scatterpolar": [
{
"marker": {
"colorbar": {
"outlinewidth": 0,
"ticks": ""
}
},
"type": "scatterpolar"
}
],
"scatterpolargl": [
{
"marker": {
"colorbar": {
"outlinewidth": 0,
"ticks": ""
}
},
"type": "scatterpolargl"
}
],
"scatterternary": [
{
"marker": {
"colorbar": {
"outlinewidth": 0,
"ticks": ""
}
},
"type": "scatterternary"
}
],
"surface": [
{
"colorbar": {
"outlinewidth": 0,
"ticks": ""
},
"colorscale": [
[
0.0,
"#0d0887"
],
[
0.1111111111111111,
"#46039f"
],
[
0.2222222222222222,
"#7201a8"
],
[
0.3333333333333333,
"#9c179e"
],
[
0.4444444444444444,
"#bd3786"
],
[
0.5555555555555556,
"#d8576b"
],
[
0.6666666666666666,
"#ed7953"
],
[
0.7777777777777778,
"#fb9f3a"
],
[
0.8888888888888888,
"#fdca26"
],
[
1.0,
"#f0f921"
]
],
"type": "surface"
}
],
"table": [
{
"cells": {
"fill": {
"color": "#EBF0F8"
},
"line": {
"color": "white"
}
},
"header": {
"fill": {
"color": "#C8D4E3"
},
"line": {
"color": "white"
}
},
"type": "table"
}
]
},
"layout": {
"annotationdefaults": {
"arrowcolor": "#2a3f5f",
"arrowhead": 0,
"arrowwidth": 1
},
"autotypenumbers": "strict",
"coloraxis": {
"colorbar": {
"outlinewidth": 0,
"ticks": ""
}
},
"colorscale": {
"diverging": [
[
0,
"#8e0152"
],
[
0.1,
"#c51b7d"
],
[
0.2,
"#de77ae"
],
[
0.3,
"#f1b6da"
],
[
0.4,
"#fde0ef"
],
[
0.5,
"#f7f7f7"
],
[
0.6,
"#e6f5d0"
],
[
0.7,
"#b8e186"
],
[
0.8,
"#7fbc41"
],
[
0.9,
"#4d9221"
],
[
1,
"#276419"
]
],
"sequential": [
[
0.0,
"#0d0887"
],
[
0.1111111111111111,
"#46039f"
],
[
0.2222222222222222,
"#7201a8"
],
[
0.3333333333333333,
"#9c179e"
],
[
0.4444444444444444,
"#bd3786"
],
[
0.5555555555555556,
"#d8576b"
],
[
0.6666666666666666,
"#ed7953"
],
[
0.7777777777777778,
"#fb9f3a"
],
[
0.8888888888888888,
"#fdca26"
],
[
1.0,
"#f0f921"
]
],
"sequentialminus": [
[
0.0,
"#0d0887"
],
[
0.1111111111111111,
"#46039f"
],
[
0.2222222222222222,
"#7201a8"
],
[
0.3333333333333333,
"#9c179e"
],
[
0.4444444444444444,
"#bd3786"
],
[
0.5555555555555556,
"#d8576b"
],
[
0.6666666666666666,
"#ed7953"
],
[
0.7777777777777778,
"#fb9f3a"
],
[
0.8888888888888888,
"#fdca26"
],
[
1.0,
"#f0f921"
]
]
},
"colorway": [
"#636efa",
"#EF553B",
"#00cc96",
"#ab63fa",
"#FFA15A",
"#19d3f3",
"#FF6692",
"#B6E880",
"#FF97FF",
"#FECB52"
],
"font": {
"color": "#2a3f5f"
},
"geo": {
"bgcolor": "white",
"lakecolor": "white",
"landcolor": "#E5ECF6",
"showlakes": true,
"showland": true,
"subunitcolor": "white"
},
"hoverlabel": {
"align": "left"
},
"hovermode": "closest",
"mapbox": {
"style": "light"
},
"paper_bgcolor": "white",
"plot_bgcolor": "#E5ECF6",
"polar": {
"angularaxis": {
"gridcolor": "white",
"linecolor": "white",
"ticks": ""
},
"bgcolor": "#E5ECF6",
"radialaxis": {
"gridcolor": "white",
"linecolor": "white",
"ticks": ""
}
},
"scene": {
"xaxis": {
"backgroundcolor": "#E5ECF6",
"gridcolor": "white",
"gridwidth": 2,
"linecolor": "white",
"showbackground": true,
"ticks": "",
"zerolinecolor": "white"
},
"yaxis": {
"backgroundcolor": "#E5ECF6",
"gridcolor": "white",
"gridwidth": 2,
"linecolor": "white",
"showbackground": true,
"ticks": "",
"zerolinecolor": "white"
},
"zaxis": {
"backgroundcolor": "#E5ECF6",
"gridcolor": "white",
"gridwidth": 2,
"linecolor": "white",
"showbackground": true,
"ticks": "",
"zerolinecolor": "white"
}
},
"shapedefaults": {
"line": {
"color": "#2a3f5f"
}
},
"ternary": {
"aaxis": {
"gridcolor": "white",
"linecolor": "white",
"ticks": ""
},
"baxis": {
"gridcolor": "white",
"linecolor": "white",
"ticks": ""
},
"bgcolor": "#E5ECF6",
"caxis": {
"gridcolor": "white",
"linecolor": "white",
"ticks": ""
}
},
"title": {
"x": 0.05
},
"xaxis": {
"automargin": true,
"gridcolor": "white",
"linecolor": "white",
"ticks": "",
"title": {
"standoff": 15
},
"zerolinecolor": "white",
"zerolinewidth": 2
},
"yaxis": {
"automargin": true,
"gridcolor": "white",
"linecolor": "white",
"ticks": "",
"title": {
"standoff": 15
},
"zerolinecolor": "white",
"zerolinewidth": 2
}
}
},
"title": {
"text": "Market price and water value of reservoirs"
},
"xaxis": {
"title": {
"text": "Time (Hour)"
}
},
"yaxis": {
"title": {
"text": "Price (€/MWh)"
}
}
}
},
"text/html": [
""
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"# Plot market price and water value of reservoirs\n",
"spot_price=shop.model.market.Day_Ahead.sale_price.get()\n",
"\n",
"fig = go.Figure()\n",
"colorscale = px.colors.sequential.RdBu_r\n",
"color = 1\n",
"fig.add_trace(go.Scatter(x=spot_price.index, marker_color = colorscale[color], y=spot_price.values, name=\"Market price\"))\n",
"\n",
"for rsv in shop.model.reservoir:\n",
" color+=1\n",
" end_water_value=rsv.energy_value_input.get()\n",
" water_value=pd.Series([end_water_value]*len(spot_price),index=spot_price.index)\n",
" curve_name=\"Water value of \"+rsv.get_name()\n",
" fig.add_trace(go.Scatter(x=water_value.index, y=water_value.values, marker_color = colorscale[color], name=curve_name, line=dict(dash=\"dot\")))\n",
" \n",
"fig.update_layout(title=\"Market price and water value of reservoirs\", xaxis_title=\"Time (Hour)\", yaxis_title=\"Price (€/MWh)\")\n",
"\n",
"fig.show()"
]
},
{
"cell_type": "code",
"execution_count": 6,
"id": "bd3ed9de",
"metadata": {},
"outputs": [
{
"data": {
"application/vnd.plotly.v1+json": {
"config": {
"plotlyServerURL": "https://plot.ly"
},
"data": [
{
"marker": {
"color": "rgb(234, 169, 189)"
},
"name": "Pump consumption",
"type": "bar",
"x": [
"2018-02-27T00:00:00",
"2018-02-27T01:00:00",
"2018-02-27T02:00:00",
"2018-02-27T03:00:00",
"2018-02-27T04:00:00",
"2018-02-27T05:00:00",
"2018-02-27T06:00:00",
"2018-02-27T07:00:00",
"2018-02-27T08:00:00",
"2018-02-27T09:00:00",
"2018-02-27T10:00:00",
"2018-02-27T11:00:00",
"2018-02-27T12:00:00",
"2018-02-27T13:00:00",
"2018-02-27T14:00:00",
"2018-02-27T15:00:00",
"2018-02-27T16:00:00",
"2018-02-27T17:00:00",
"2018-02-27T18:00:00",
"2018-02-27T19:00:00",
"2018-02-27T20:00:00",
"2018-02-27T21:00:00",
"2018-02-27T22:00:00",
"2018-02-27T23:00:00"
],
"y": [
40.04595537552806,
40.228167937412636,
40.39760546014121,
40.55456683059708,
40.69934578327797,
40.832230965482516,
0.0,
0.0,
0.0,
0.0,
0.0,
0.0,
0.0,
0.0,
0.0,
0.0,
0.0,
0.0,
0.0,
0.0,
0.0,
0.0,
0.0,
0.0
]
},
{
"marker": {
"color": "rgb(108, 33, 103)"
},
"name": "Generator production",
"type": "bar",
"x": [
"2018-02-27T00:00:00",
"2018-02-27T01:00:00",
"2018-02-27T02:00:00",
"2018-02-27T03:00:00",
"2018-02-27T04:00:00",
"2018-02-27T05:00:00",
"2018-02-27T06:00:00",
"2018-02-27T07:00:00",
"2018-02-27T08:00:00",
"2018-02-27T09:00:00",
"2018-02-27T10:00:00",
"2018-02-27T11:00:00",
"2018-02-27T12:00:00",
"2018-02-27T13:00:00",
"2018-02-27T14:00:00",
"2018-02-27T15:00:00",
"2018-02-27T16:00:00",
"2018-02-27T17:00:00",
"2018-02-27T18:00:00",
"2018-02-27T19:00:00",
"2018-02-27T20:00:00",
"2018-02-27T21:00:00",
"2018-02-27T22:00:00",
"2018-02-27T23:00:00"
],
"y": [
0.0,
0.0,
0.0,
0.0,
0.0,
0.0,
0.0,
0.0,
0.0,
24.99998307820389,
24.999980970811244,
24.99997854960181,
24.99997325739206,
24.999983292277694,
25.000029510792366,
25.153833645738057,
25.308239710057066,
25.463103109508296,
25.618257213874152,
25.77351010829958,
25.928640789392976,
26.08339470509483,
26.237478401831503,
26.39055337827637
]
}
],
"layout": {
"template": {
"data": {
"bar": [
{
"error_x": {
"color": "#2a3f5f"
},
"error_y": {
"color": "#2a3f5f"
},
"marker": {
"line": {
"color": "#E5ECF6",
"width": 0.5
},
"pattern": {
"fillmode": "overlay",
"size": 10,
"solidity": 0.2
}
},
"type": "bar"
}
],
"barpolar": [
{
"marker": {
"line": {
"color": "#E5ECF6",
"width": 0.5
},
"pattern": {
"fillmode": "overlay",
"size": 10,
"solidity": 0.2
}
},
"type": "barpolar"
}
],
"carpet": [
{
"aaxis": {
"endlinecolor": "#2a3f5f",
"gridcolor": "white",
"linecolor": "white",
"minorgridcolor": "white",
"startlinecolor": "#2a3f5f"
},
"baxis": {
"endlinecolor": "#2a3f5f",
"gridcolor": "white",
"linecolor": "white",
"minorgridcolor": "white",
"startlinecolor": "#2a3f5f"
},
"type": "carpet"
}
],
"choropleth": [
{
"colorbar": {
"outlinewidth": 0,
"ticks": ""
},
"type": "choropleth"
}
],
"contour": [
{
"colorbar": {
"outlinewidth": 0,
"ticks": ""
},
"colorscale": [
[
0.0,
"#0d0887"
],
[
0.1111111111111111,
"#46039f"
],
[
0.2222222222222222,
"#7201a8"
],
[
0.3333333333333333,
"#9c179e"
],
[
0.4444444444444444,
"#bd3786"
],
[
0.5555555555555556,
"#d8576b"
],
[
0.6666666666666666,
"#ed7953"
],
[
0.7777777777777778,
"#fb9f3a"
],
[
0.8888888888888888,
"#fdca26"
],
[
1.0,
"#f0f921"
]
],
"type": "contour"
}
],
"contourcarpet": [
{
"colorbar": {
"outlinewidth": 0,
"ticks": ""
},
"type": "contourcarpet"
}
],
"heatmap": [
{
"colorbar": {
"outlinewidth": 0,
"ticks": ""
},
"colorscale": [
[
0.0,
"#0d0887"
],
[
0.1111111111111111,
"#46039f"
],
[
0.2222222222222222,
"#7201a8"
],
[
0.3333333333333333,
"#9c179e"
],
[
0.4444444444444444,
"#bd3786"
],
[
0.5555555555555556,
"#d8576b"
],
[
0.6666666666666666,
"#ed7953"
],
[
0.7777777777777778,
"#fb9f3a"
],
[
0.8888888888888888,
"#fdca26"
],
[
1.0,
"#f0f921"
]
],
"type": "heatmap"
}
],
"heatmapgl": [
{
"colorbar": {
"outlinewidth": 0,
"ticks": ""
},
"colorscale": [
[
0.0,
"#0d0887"
],
[
0.1111111111111111,
"#46039f"
],
[
0.2222222222222222,
"#7201a8"
],
[
0.3333333333333333,
"#9c179e"
],
[
0.4444444444444444,
"#bd3786"
],
[
0.5555555555555556,
"#d8576b"
],
[
0.6666666666666666,
"#ed7953"
],
[
0.7777777777777778,
"#fb9f3a"
],
[
0.8888888888888888,
"#fdca26"
],
[
1.0,
"#f0f921"
]
],
"type": "heatmapgl"
}
],
"histogram": [
{
"marker": {
"pattern": {
"fillmode": "overlay",
"size": 10,
"solidity": 0.2
}
},
"type": "histogram"
}
],
"histogram2d": [
{
"colorbar": {
"outlinewidth": 0,
"ticks": ""
},
"colorscale": [
[
0.0,
"#0d0887"
],
[
0.1111111111111111,
"#46039f"
],
[
0.2222222222222222,
"#7201a8"
],
[
0.3333333333333333,
"#9c179e"
],
[
0.4444444444444444,
"#bd3786"
],
[
0.5555555555555556,
"#d8576b"
],
[
0.6666666666666666,
"#ed7953"
],
[
0.7777777777777778,
"#fb9f3a"
],
[
0.8888888888888888,
"#fdca26"
],
[
1.0,
"#f0f921"
]
],
"type": "histogram2d"
}
],
"histogram2dcontour": [
{
"colorbar": {
"outlinewidth": 0,
"ticks": ""
},
"colorscale": [
[
0.0,
"#0d0887"
],
[
0.1111111111111111,
"#46039f"
],
[
0.2222222222222222,
"#7201a8"
],
[
0.3333333333333333,
"#9c179e"
],
[
0.4444444444444444,
"#bd3786"
],
[
0.5555555555555556,
"#d8576b"
],
[
0.6666666666666666,
"#ed7953"
],
[
0.7777777777777778,
"#fb9f3a"
],
[
0.8888888888888888,
"#fdca26"
],
[
1.0,
"#f0f921"
]
],
"type": "histogram2dcontour"
}
],
"mesh3d": [
{
"colorbar": {
"outlinewidth": 0,
"ticks": ""
},
"type": "mesh3d"
}
],
"parcoords": [
{
"line": {
"colorbar": {
"outlinewidth": 0,
"ticks": ""
}
},
"type": "parcoords"
}
],
"pie": [
{
"automargin": true,
"type": "pie"
}
],
"scatter": [
{
"fillpattern": {
"fillmode": "overlay",
"size": 10,
"solidity": 0.2
},
"type": "scatter"
}
],
"scatter3d": [
{
"line": {
"colorbar": {
"outlinewidth": 0,
"ticks": ""
}
},
"marker": {
"colorbar": {
"outlinewidth": 0,
"ticks": ""
}
},
"type": "scatter3d"
}
],
"scattercarpet": [
{
"marker": {
"colorbar": {
"outlinewidth": 0,
"ticks": ""
}
},
"type": "scattercarpet"
}
],
"scattergeo": [
{
"marker": {
"colorbar": {
"outlinewidth": 0,
"ticks": ""
}
},
"type": "scattergeo"
}
],
"scattergl": [
{
"marker": {
"colorbar": {
"outlinewidth": 0,
"ticks": ""
}
},
"type": "scattergl"
}
],
"scattermapbox": [
{
"marker": {
"colorbar": {
"outlinewidth": 0,
"ticks": ""
}
},
"type": "scattermapbox"
}
],
"scatterpolar": [
{
"marker": {
"colorbar": {
"outlinewidth": 0,
"ticks": ""
}
},
"type": "scatterpolar"
}
],
"scatterpolargl": [
{
"marker": {
"colorbar": {
"outlinewidth": 0,
"ticks": ""
}
},
"type": "scatterpolargl"
}
],
"scatterternary": [
{
"marker": {
"colorbar": {
"outlinewidth": 0,
"ticks": ""
}
},
"type": "scatterternary"
}
],
"surface": [
{
"colorbar": {
"outlinewidth": 0,
"ticks": ""
},
"colorscale": [
[
0.0,
"#0d0887"
],
[
0.1111111111111111,
"#46039f"
],
[
0.2222222222222222,
"#7201a8"
],
[
0.3333333333333333,
"#9c179e"
],
[
0.4444444444444444,
"#bd3786"
],
[
0.5555555555555556,
"#d8576b"
],
[
0.6666666666666666,
"#ed7953"
],
[
0.7777777777777778,
"#fb9f3a"
],
[
0.8888888888888888,
"#fdca26"
],
[
1.0,
"#f0f921"
]
],
"type": "surface"
}
],
"table": [
{
"cells": {
"fill": {
"color": "#EBF0F8"
},
"line": {
"color": "white"
}
},
"header": {
"fill": {
"color": "#C8D4E3"
},
"line": {
"color": "white"
}
},
"type": "table"
}
]
},
"layout": {
"annotationdefaults": {
"arrowcolor": "#2a3f5f",
"arrowhead": 0,
"arrowwidth": 1
},
"autotypenumbers": "strict",
"coloraxis": {
"colorbar": {
"outlinewidth": 0,
"ticks": ""
}
},
"colorscale": {
"diverging": [
[
0,
"#8e0152"
],
[
0.1,
"#c51b7d"
],
[
0.2,
"#de77ae"
],
[
0.3,
"#f1b6da"
],
[
0.4,
"#fde0ef"
],
[
0.5,
"#f7f7f7"
],
[
0.6,
"#e6f5d0"
],
[
0.7,
"#b8e186"
],
[
0.8,
"#7fbc41"
],
[
0.9,
"#4d9221"
],
[
1,
"#276419"
]
],
"sequential": [
[
0.0,
"#0d0887"
],
[
0.1111111111111111,
"#46039f"
],
[
0.2222222222222222,
"#7201a8"
],
[
0.3333333333333333,
"#9c179e"
],
[
0.4444444444444444,
"#bd3786"
],
[
0.5555555555555556,
"#d8576b"
],
[
0.6666666666666666,
"#ed7953"
],
[
0.7777777777777778,
"#fb9f3a"
],
[
0.8888888888888888,
"#fdca26"
],
[
1.0,
"#f0f921"
]
],
"sequentialminus": [
[
0.0,
"#0d0887"
],
[
0.1111111111111111,
"#46039f"
],
[
0.2222222222222222,
"#7201a8"
],
[
0.3333333333333333,
"#9c179e"
],
[
0.4444444444444444,
"#bd3786"
],
[
0.5555555555555556,
"#d8576b"
],
[
0.6666666666666666,
"#ed7953"
],
[
0.7777777777777778,
"#fb9f3a"
],
[
0.8888888888888888,
"#fdca26"
],
[
1.0,
"#f0f921"
]
]
},
"colorway": [
"#636efa",
"#EF553B",
"#00cc96",
"#ab63fa",
"#FFA15A",
"#19d3f3",
"#FF6692",
"#B6E880",
"#FF97FF",
"#FECB52"
],
"font": {
"color": "#2a3f5f"
},
"geo": {
"bgcolor": "white",
"lakecolor": "white",
"landcolor": "#E5ECF6",
"showlakes": true,
"showland": true,
"subunitcolor": "white"
},
"hoverlabel": {
"align": "left"
},
"hovermode": "closest",
"mapbox": {
"style": "light"
},
"paper_bgcolor": "white",
"plot_bgcolor": "#E5ECF6",
"polar": {
"angularaxis": {
"gridcolor": "white",
"linecolor": "white",
"ticks": ""
},
"bgcolor": "#E5ECF6",
"radialaxis": {
"gridcolor": "white",
"linecolor": "white",
"ticks": ""
}
},
"scene": {
"xaxis": {
"backgroundcolor": "#E5ECF6",
"gridcolor": "white",
"gridwidth": 2,
"linecolor": "white",
"showbackground": true,
"ticks": "",
"zerolinecolor": "white"
},
"yaxis": {
"backgroundcolor": "#E5ECF6",
"gridcolor": "white",
"gridwidth": 2,
"linecolor": "white",
"showbackground": true,
"ticks": "",
"zerolinecolor": "white"
},
"zaxis": {
"backgroundcolor": "#E5ECF6",
"gridcolor": "white",
"gridwidth": 2,
"linecolor": "white",
"showbackground": true,
"ticks": "",
"zerolinecolor": "white"
}
},
"shapedefaults": {
"line": {
"color": "#2a3f5f"
}
},
"ternary": {
"aaxis": {
"gridcolor": "white",
"linecolor": "white",
"ticks": ""
},
"baxis": {
"gridcolor": "white",
"linecolor": "white",
"ticks": ""
},
"bgcolor": "#E5ECF6",
"caxis": {
"gridcolor": "white",
"linecolor": "white",
"ticks": ""
}
},
"title": {
"x": 0.05
},
"xaxis": {
"automargin": true,
"gridcolor": "white",
"linecolor": "white",
"ticks": "",
"title": {
"standoff": 15
},
"zerolinecolor": "white",
"zerolinewidth": 2
},
"yaxis": {
"automargin": true,
"gridcolor": "white",
"linecolor": "white",
"ticks": "",
"title": {
"standoff": 15
},
"zerolinecolor": "white",
"zerolinewidth": 2
}
}
},
"title": {
"text": "Pump consumption and generator production"
},
"xaxis": {
"title": {
"text": "Time (Hour)"
}
},
"yaxis": {
"title": {
"text": "Production/Consumption (MW)"
}
}
}
},
"text/html": [
""
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"# Plotting pump consumption and generator production\n",
"p1p1_consumption=shop.model.pump.P1P1.consumption.get()\n",
"p1g1_production=shop.model.generator.P1G1.production.get()\n",
"fig = go.Figure()\n",
"colorscale = px.colors.sequential.Magenta\n",
"fig.add_trace(go.Bar(x=p1p1_consumption.index, y=p1p1_consumption.values, name=\"Pump consumption\", marker_color=colorscale[1]))\n",
"fig.add_trace(go.Bar(x=p1g1_production.index, y=p1g1_production.values, name=\"Generator production\", marker_color=colorscale[6]))\n",
"fig.update_layout(title=\"Pump consumption and generator production\", xaxis_title=\"Time (Hour)\", yaxis_title=\"Production/Consumption (MW)\")"
]
},
{
"cell_type": "code",
"execution_count": 7,
"id": "d74d037a",
"metadata": {},
"outputs": [
{
"data": {
"application/vnd.plotly.v1+json": {
"config": {
"plotlyServerURL": "https://plot.ly"
},
"data": [
{
"fill": "tozeroy",
"marker": {
"color": "rgb(33,102,172)"
},
"name": "Reservoir1 storage",
"type": "scatter",
"x": [
"2018-02-27T00:00:00",
"2018-02-27T01:00:00",
"2018-02-27T02:00:00",
"2018-02-27T03:00:00",
"2018-02-27T04:00:00",
"2018-02-27T05:00:00",
"2018-02-27T06:00:00",
"2018-02-27T07:00:00",
"2018-02-27T08:00:00",
"2018-02-27T09:00:00",
"2018-02-27T10:00:00",
"2018-02-27T11:00:00",
"2018-02-27T12:00:00",
"2018-02-27T13:00:00",
"2018-02-27T14:00:00",
"2018-02-27T15:00:00",
"2018-02-27T16:00:00",
"2018-02-27T17:00:00",
"2018-02-27T18:00:00",
"2018-02-27T19:00:00",
"2018-02-27T20:00:00",
"2018-02-27T21:00:00",
"2018-02-27T22:00:00",
"2018-02-27T23:00:00",
"2018-02-28T00:00:00"
],
"y": [
2.4,
2.686375605290242,
2.970195503070047,
3.251483690938283,
3.5302639604811206,
3.8065598986852662,
4.080394889348053,
4.116394889348053,
4.152394889348052,
4.188394889348052,
4.015719951133295,
3.8410185971550677,
3.664226663170541,
3.4852764292970586,
3.3040961676332716,
3.120609788799093,
2.933522251227805,
2.7427025413133164,
2.5480116137437627,
2.349301652923064,
2.146415239769869,
1.9391844079172063,
1.7274295698168425,
1.5109582897481977,
1.2895638729161556
]
},
{
"fill": "tozeroy",
"marker": {
"color": "rgb(67,147,195)"
},
"name": "Reservoir2 storage",
"type": "scatter",
"x": [
"2018-02-27T00:00:00",
"2018-02-27T01:00:00",
"2018-02-27T02:00:00",
"2018-02-27T03:00:00",
"2018-02-27T04:00:00",
"2018-02-27T05:00:00",
"2018-02-27T06:00:00",
"2018-02-27T07:00:00",
"2018-02-27T08:00:00",
"2018-02-27T09:00:00",
"2018-02-27T10:00:00",
"2018-02-27T11:00:00",
"2018-02-27T12:00:00",
"2018-02-27T13:00:00",
"2018-02-27T14:00:00",
"2018-02-27T15:00:00",
"2018-02-27T16:00:00",
"2018-02-27T17:00:00",
"2018-02-27T18:00:00",
"2018-02-27T19:00:00",
"2018-02-27T20:00:00",
"2018-02-27T21:00:00",
"2018-02-27T22:00:00",
"2018-02-27T23:00:00",
"2018-02-28T00:00:00"
],
"y": [
1.5,
1.249624394709758,
1.0018044969299533,
0.7565163090617171,
0.5137360395188794,
0.27344010131473373,
0.035605110651946464,
0.035605110651946464,
0.035605110651946464,
0.035605110651946464,
0.24428004886670354,
0.45498140284493066,
0.6677733368294573,
0.8827235707029394,
1.0999038323667265,
1.3193902112009048,
1.5424777487721928,
1.7692974586866814,
1.9999883862562353,
2.234698347076934,
2.4735847602301293,
2.716815592082792,
2.964570430183156,
3.2170417102518005,
3.474436127083843
]
}
],
"layout": {
"template": {
"data": {
"bar": [
{
"error_x": {
"color": "#2a3f5f"
},
"error_y": {
"color": "#2a3f5f"
},
"marker": {
"line": {
"color": "#E5ECF6",
"width": 0.5
},
"pattern": {
"fillmode": "overlay",
"size": 10,
"solidity": 0.2
}
},
"type": "bar"
}
],
"barpolar": [
{
"marker": {
"line": {
"color": "#E5ECF6",
"width": 0.5
},
"pattern": {
"fillmode": "overlay",
"size": 10,
"solidity": 0.2
}
},
"type": "barpolar"
}
],
"carpet": [
{
"aaxis": {
"endlinecolor": "#2a3f5f",
"gridcolor": "white",
"linecolor": "white",
"minorgridcolor": "white",
"startlinecolor": "#2a3f5f"
},
"baxis": {
"endlinecolor": "#2a3f5f",
"gridcolor": "white",
"linecolor": "white",
"minorgridcolor": "white",
"startlinecolor": "#2a3f5f"
},
"type": "carpet"
}
],
"choropleth": [
{
"colorbar": {
"outlinewidth": 0,
"ticks": ""
},
"type": "choropleth"
}
],
"contour": [
{
"colorbar": {
"outlinewidth": 0,
"ticks": ""
},
"colorscale": [
[
0.0,
"#0d0887"
],
[
0.1111111111111111,
"#46039f"
],
[
0.2222222222222222,
"#7201a8"
],
[
0.3333333333333333,
"#9c179e"
],
[
0.4444444444444444,
"#bd3786"
],
[
0.5555555555555556,
"#d8576b"
],
[
0.6666666666666666,
"#ed7953"
],
[
0.7777777777777778,
"#fb9f3a"
],
[
0.8888888888888888,
"#fdca26"
],
[
1.0,
"#f0f921"
]
],
"type": "contour"
}
],
"contourcarpet": [
{
"colorbar": {
"outlinewidth": 0,
"ticks": ""
},
"type": "contourcarpet"
}
],
"heatmap": [
{
"colorbar": {
"outlinewidth": 0,
"ticks": ""
},
"colorscale": [
[
0.0,
"#0d0887"
],
[
0.1111111111111111,
"#46039f"
],
[
0.2222222222222222,
"#7201a8"
],
[
0.3333333333333333,
"#9c179e"
],
[
0.4444444444444444,
"#bd3786"
],
[
0.5555555555555556,
"#d8576b"
],
[
0.6666666666666666,
"#ed7953"
],
[
0.7777777777777778,
"#fb9f3a"
],
[
0.8888888888888888,
"#fdca26"
],
[
1.0,
"#f0f921"
]
],
"type": "heatmap"
}
],
"heatmapgl": [
{
"colorbar": {
"outlinewidth": 0,
"ticks": ""
},
"colorscale": [
[
0.0,
"#0d0887"
],
[
0.1111111111111111,
"#46039f"
],
[
0.2222222222222222,
"#7201a8"
],
[
0.3333333333333333,
"#9c179e"
],
[
0.4444444444444444,
"#bd3786"
],
[
0.5555555555555556,
"#d8576b"
],
[
0.6666666666666666,
"#ed7953"
],
[
0.7777777777777778,
"#fb9f3a"
],
[
0.8888888888888888,
"#fdca26"
],
[
1.0,
"#f0f921"
]
],
"type": "heatmapgl"
}
],
"histogram": [
{
"marker": {
"pattern": {
"fillmode": "overlay",
"size": 10,
"solidity": 0.2
}
},
"type": "histogram"
}
],
"histogram2d": [
{
"colorbar": {
"outlinewidth": 0,
"ticks": ""
},
"colorscale": [
[
0.0,
"#0d0887"
],
[
0.1111111111111111,
"#46039f"
],
[
0.2222222222222222,
"#7201a8"
],
[
0.3333333333333333,
"#9c179e"
],
[
0.4444444444444444,
"#bd3786"
],
[
0.5555555555555556,
"#d8576b"
],
[
0.6666666666666666,
"#ed7953"
],
[
0.7777777777777778,
"#fb9f3a"
],
[
0.8888888888888888,
"#fdca26"
],
[
1.0,
"#f0f921"
]
],
"type": "histogram2d"
}
],
"histogram2dcontour": [
{
"colorbar": {
"outlinewidth": 0,
"ticks": ""
},
"colorscale": [
[
0.0,
"#0d0887"
],
[
0.1111111111111111,
"#46039f"
],
[
0.2222222222222222,
"#7201a8"
],
[
0.3333333333333333,
"#9c179e"
],
[
0.4444444444444444,
"#bd3786"
],
[
0.5555555555555556,
"#d8576b"
],
[
0.6666666666666666,
"#ed7953"
],
[
0.7777777777777778,
"#fb9f3a"
],
[
0.8888888888888888,
"#fdca26"
],
[
1.0,
"#f0f921"
]
],
"type": "histogram2dcontour"
}
],
"mesh3d": [
{
"colorbar": {
"outlinewidth": 0,
"ticks": ""
},
"type": "mesh3d"
}
],
"parcoords": [
{
"line": {
"colorbar": {
"outlinewidth": 0,
"ticks": ""
}
},
"type": "parcoords"
}
],
"pie": [
{
"automargin": true,
"type": "pie"
}
],
"scatter": [
{
"fillpattern": {
"fillmode": "overlay",
"size": 10,
"solidity": 0.2
},
"type": "scatter"
}
],
"scatter3d": [
{
"line": {
"colorbar": {
"outlinewidth": 0,
"ticks": ""
}
},
"marker": {
"colorbar": {
"outlinewidth": 0,
"ticks": ""
}
},
"type": "scatter3d"
}
],
"scattercarpet": [
{
"marker": {
"colorbar": {
"outlinewidth": 0,
"ticks": ""
}
},
"type": "scattercarpet"
}
],
"scattergeo": [
{
"marker": {
"colorbar": {
"outlinewidth": 0,
"ticks": ""
}
},
"type": "scattergeo"
}
],
"scattergl": [
{
"marker": {
"colorbar": {
"outlinewidth": 0,
"ticks": ""
}
},
"type": "scattergl"
}
],
"scattermapbox": [
{
"marker": {
"colorbar": {
"outlinewidth": 0,
"ticks": ""
}
},
"type": "scattermapbox"
}
],
"scatterpolar": [
{
"marker": {
"colorbar": {
"outlinewidth": 0,
"ticks": ""
}
},
"type": "scatterpolar"
}
],
"scatterpolargl": [
{
"marker": {
"colorbar": {
"outlinewidth": 0,
"ticks": ""
}
},
"type": "scatterpolargl"
}
],
"scatterternary": [
{
"marker": {
"colorbar": {
"outlinewidth": 0,
"ticks": ""
}
},
"type": "scatterternary"
}
],
"surface": [
{
"colorbar": {
"outlinewidth": 0,
"ticks": ""
},
"colorscale": [
[
0.0,
"#0d0887"
],
[
0.1111111111111111,
"#46039f"
],
[
0.2222222222222222,
"#7201a8"
],
[
0.3333333333333333,
"#9c179e"
],
[
0.4444444444444444,
"#bd3786"
],
[
0.5555555555555556,
"#d8576b"
],
[
0.6666666666666666,
"#ed7953"
],
[
0.7777777777777778,
"#fb9f3a"
],
[
0.8888888888888888,
"#fdca26"
],
[
1.0,
"#f0f921"
]
],
"type": "surface"
}
],
"table": [
{
"cells": {
"fill": {
"color": "#EBF0F8"
},
"line": {
"color": "white"
}
},
"header": {
"fill": {
"color": "#C8D4E3"
},
"line": {
"color": "white"
}
},
"type": "table"
}
]
},
"layout": {
"annotationdefaults": {
"arrowcolor": "#2a3f5f",
"arrowhead": 0,
"arrowwidth": 1
},
"autotypenumbers": "strict",
"coloraxis": {
"colorbar": {
"outlinewidth": 0,
"ticks": ""
}
},
"colorscale": {
"diverging": [
[
0,
"#8e0152"
],
[
0.1,
"#c51b7d"
],
[
0.2,
"#de77ae"
],
[
0.3,
"#f1b6da"
],
[
0.4,
"#fde0ef"
],
[
0.5,
"#f7f7f7"
],
[
0.6,
"#e6f5d0"
],
[
0.7,
"#b8e186"
],
[
0.8,
"#7fbc41"
],
[
0.9,
"#4d9221"
],
[
1,
"#276419"
]
],
"sequential": [
[
0.0,
"#0d0887"
],
[
0.1111111111111111,
"#46039f"
],
[
0.2222222222222222,
"#7201a8"
],
[
0.3333333333333333,
"#9c179e"
],
[
0.4444444444444444,
"#bd3786"
],
[
0.5555555555555556,
"#d8576b"
],
[
0.6666666666666666,
"#ed7953"
],
[
0.7777777777777778,
"#fb9f3a"
],
[
0.8888888888888888,
"#fdca26"
],
[
1.0,
"#f0f921"
]
],
"sequentialminus": [
[
0.0,
"#0d0887"
],
[
0.1111111111111111,
"#46039f"
],
[
0.2222222222222222,
"#7201a8"
],
[
0.3333333333333333,
"#9c179e"
],
[
0.4444444444444444,
"#bd3786"
],
[
0.5555555555555556,
"#d8576b"
],
[
0.6666666666666666,
"#ed7953"
],
[
0.7777777777777778,
"#fb9f3a"
],
[
0.8888888888888888,
"#fdca26"
],
[
1.0,
"#f0f921"
]
]
},
"colorway": [
"#636efa",
"#EF553B",
"#00cc96",
"#ab63fa",
"#FFA15A",
"#19d3f3",
"#FF6692",
"#B6E880",
"#FF97FF",
"#FECB52"
],
"font": {
"color": "#2a3f5f"
},
"geo": {
"bgcolor": "white",
"lakecolor": "white",
"landcolor": "#E5ECF6",
"showlakes": true,
"showland": true,
"subunitcolor": "white"
},
"hoverlabel": {
"align": "left"
},
"hovermode": "closest",
"mapbox": {
"style": "light"
},
"paper_bgcolor": "white",
"plot_bgcolor": "#E5ECF6",
"polar": {
"angularaxis": {
"gridcolor": "white",
"linecolor": "white",
"ticks": ""
},
"bgcolor": "#E5ECF6",
"radialaxis": {
"gridcolor": "white",
"linecolor": "white",
"ticks": ""
}
},
"scene": {
"xaxis": {
"backgroundcolor": "#E5ECF6",
"gridcolor": "white",
"gridwidth": 2,
"linecolor": "white",
"showbackground": true,
"ticks": "",
"zerolinecolor": "white"
},
"yaxis": {
"backgroundcolor": "#E5ECF6",
"gridcolor": "white",
"gridwidth": 2,
"linecolor": "white",
"showbackground": true,
"ticks": "",
"zerolinecolor": "white"
},
"zaxis": {
"backgroundcolor": "#E5ECF6",
"gridcolor": "white",
"gridwidth": 2,
"linecolor": "white",
"showbackground": true,
"ticks": "",
"zerolinecolor": "white"
}
},
"shapedefaults": {
"line": {
"color": "#2a3f5f"
}
},
"ternary": {
"aaxis": {
"gridcolor": "white",
"linecolor": "white",
"ticks": ""
},
"baxis": {
"gridcolor": "white",
"linecolor": "white",
"ticks": ""
},
"bgcolor": "#E5ECF6",
"caxis": {
"gridcolor": "white",
"linecolor": "white",
"ticks": ""
}
},
"title": {
"x": 0.05
},
"xaxis": {
"automargin": true,
"gridcolor": "white",
"linecolor": "white",
"ticks": "",
"title": {
"standoff": 15
},
"zerolinecolor": "white",
"zerolinewidth": 2
},
"yaxis": {
"automargin": true,
"gridcolor": "white",
"linecolor": "white",
"ticks": "",
"title": {
"standoff": 15
},
"zerolinecolor": "white",
"zerolinewidth": 2
}
}
},
"title": {
"text": "Reservoir trajectories "
},
"xaxis": {
"title": {
"text": "Time (Hour)"
}
},
"yaxis": {
"title": {
"text": "Volume (Mm3)"
}
}
}
},
"text/html": [
""
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"# Plotting reservoir trajectories\n",
"water_storage_rsv1=shop.model.reservoir.Reservoir1.storage.get()\n",
"water_storage_rsv2=shop.model.reservoir.Reservoir2.storage.get()\n",
"fig = go.Figure()\n",
"colorscale = px.colors.sequential.RdBu_r\n",
"fig.add_trace(go.Scatter(x=water_storage_rsv1.index, y=water_storage_rsv1.values, name=\"Reservoir1 storage\", marker_color=colorscale[1],fill='tozeroy'))\n",
"fig.add_trace(go.Scatter(x=water_storage_rsv2.index, y=water_storage_rsv2.values, name=\"Reservoir2 storage\", marker_color=colorscale[2],fill='tozeroy'))\n",
"fig.update_layout(title=\"Reservoir trajectories \", xaxis_title=\"Time (Hour)\", yaxis_title=\"Volume (Mm3)\")\n",
"fig.show()"
]
},
{
"cell_type": "markdown",
"id": "b1bd0ed8",
"metadata": {},
"source": [
"# File contents\n",
"\n",
"(basic-pump-py)=\n",
"## basic_pump.py "
]
},
{
"cell_type": "code",
"execution_count": 8,
"id": "f003a237",
"metadata": {
"Collapsed": "false",
"tags": [
"remove-input"
]
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"import pandas as pd\n",
"\n",
"def build_model(shop):\n",
" starttime=pd.Timestamp(\"2018-02-27 00:00:00\")\n",
" endtime=pd.Timestamp(\"2018-02-28 00:00:00\")\n",
" shop.set_time_resolution(starttime=starttime, endtime=endtime, timeunit=\"hour\")\n",
"\n",
" rsv1=shop.model.reservoir.add_object(\"Reservoir1\")\n",
" rsv1.hrl.set(100)\n",
" rsv1.lrl.set(90)\n",
" rsv1.max_vol.set(12)\n",
" rsv1.vol_head.set(pd.Series([90,100,101],index=[0,12,14]))\n",
"\n",
" plant1=shop.model.plant.add_object(\"Plant1\")\n",
" plant1.main_loss.set([0.0002])\n",
" plant1.penstock_loss.set([0.0001])\n",
" plant1.outlet_line.set(40)\n",
"\n",
" p1g1=shop.model.generator.add_object(\"P1G1\")\n",
" p1g1.connect_to(plant1)\n",
" p1g1.penstock.set(1)\n",
" p1g1.p_min.set(25)\n",
" p1g1.p_nom.set(100)\n",
" p1g1.p_max.set(100)\n",
" p1g1.startcost.set(500)\n",
" p1g1.gen_eff_curve.set(pd.Series([95,98], index=[0,100]))\n",
" p1g1.turb_eff_curves.set([pd.Series([80,95,90],index=[25,90,100],name=90),pd.Series([82,98,92],index=[25,90,100],name=100)])\n",
"\n",
" rsv2=shop.model.reservoir.add_object(\"Reservoir2\")\n",
" rsv2.hrl.set(50)\n",
" rsv2.lrl.set(40)\n",
" rsv2.max_vol.set(5)\n",
" rsv2.vol_head.set(pd.Series([40,50,51],index=[0,5,6]))\n",
"\n",
" river = shop.model.river.add_object(\"outlet\")\n",
" river.upstream_elevation.set(50)\n",
" river.flow_cost.set(10)\n",
"\n",
" rsv1.connect_to(plant1)\n",
" plant1.connect_to(rsv2)\n",
" rsv2.connect_to(river)\n",
"\n",
" rsv1.start_head.set(92)\n",
" rsv2.start_head.set(43)\n",
"\n",
" rsv1.inflow.set(10)\n",
" rsv2.inflow.set(0)\n",
"\n",
" rsv1.energy_value_input.set(39.7)\n",
" rsv2.energy_value_input.set(0)\n",
"\n",
" da=shop.model.market.add_object('Day_Ahead')\n",
" da.sale_price.set(pd.Series([19.99,39.99],index=[starttime,starttime+pd.Timedelta(hours=6)]))\n",
" da.buy_price.set(pd.Series([20.01,40.01],index=[starttime,starttime+pd.Timedelta(hours=6)]))\n",
" da.max_sale.set(9999)\n",
" da.max_buy.set(9999)\n",
" \n",
" \n",
"def run_model(shop):\n",
" shop.start_sim([],['3'])\n",
" shop.set_code(['inc'],[])\n",
" shop.start_sim([],['3'])\n"
]
}
],
"source": [
"with open('basic_pump.py', 'r') as f:\n",
" print(f.read())"
]
},
{
"cell_type": "markdown",
"id": "637da79f",
"metadata": {},
"source": [
"(basic-pump-yaml)=\n",
"## basic_pump.yaml "
]
},
{
"cell_type": "code",
"execution_count": 9,
"id": "0784d910",
"metadata": {
"Collapsed": "false",
"tags": [
"remove-input"
]
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"time:\n",
" starttime: 2018-02-27 00:00:00\n",
" endtime: 2018-02-28 00:00:00\n",
" timeunit: hour\n",
" timeresolution:\n",
" 2018-02-27 00:00:00: 1\n",
"model:\n",
" reservoir:\n",
" Reservoir1:\n",
" max_vol: 12\n",
" lrl: 90\n",
" hrl: 100\n",
" vol_head:\n",
" ref: 0\n",
" x:\n",
" - 0\n",
" - 12\n",
" - 14\n",
" y:\n",
" - 90\n",
" - 100\n",
" - 101\n",
" start_head: 92\n",
" inflow:\n",
" 2018-02-27 00:00:00: 10\n",
" energy_value_input: 39.7\n",
" Reservoir2:\n",
" max_vol: 5\n",
" lrl: 40\n",
" hrl: 50\n",
" vol_head:\n",
" ref: 0\n",
" x:\n",
" - 0\n",
" - 5\n",
" - 6\n",
" y:\n",
" - 40\n",
" - 50\n",
" - 51\n",
" start_head: 43\n",
" inflow:\n",
" 2018-02-27 00:00:00: 0\n",
" plant:\n",
" Plant1:\n",
" outlet_line: 40\n",
" main_loss:\n",
" - 0.0002\n",
" penstock_loss:\n",
" - 0.0001\n",
" generator:\n",
" P1G1:\n",
" penstock: 1\n",
" p_min: 25\n",
" p_max: 100\n",
" p_nom: 100\n",
" gen_eff_curve:\n",
" ref: 0\n",
" x:\n",
" - 0\n",
" - 100\n",
" y:\n",
" - 95\n",
" - 98\n",
" turb_eff_curves:\n",
" - ref: 90\n",
" x:\n",
" - 25\n",
" - 90\n",
" - 100\n",
" y:\n",
" - 80\n",
" - 95\n",
" - 90\n",
" - ref: 100\n",
" x:\n",
" - 25\n",
" - 90\n",
" - 100\n",
" y:\n",
" - 82\n",
" - 98\n",
" - 92\n",
" startcost:\n",
" 2018-02-27 00:00:00: 500\n",
" river:\n",
" outlet:\n",
" upstream_elevation: 50\n",
" flow_cost:\n",
" 2018-02-27 00:00:00: 10\n",
" market:\n",
" Day_Ahead:\n",
" max_buy:\n",
" 2018-02-27 00:00:00: 9999\n",
" max_sale:\n",
" 2018-02-27 00:00:00: 9999\n",
" buy_price:\n",
" 2018-02-27 00:00:00: 20.01\n",
" 2018-02-27 06:00:00: 40.01\n",
" sale_price:\n",
" 2018-02-27 00:00:00: 19.99\n",
" 2018-02-27 06:00:00: 39.99\n",
" pump:\n",
" P1P1:\n",
" penstock: 1\n",
" p_min: 38\n",
" p_max: 42\n",
" p_nom: 40\n",
" gen_eff_curve:\n",
" ref: 0\n",
" x:\n",
" - 0\n",
" - 50\n",
" y:\n",
" - 100\n",
" - 100\n",
" turb_eff_curves:\n",
" - ref: 40\n",
" x:\n",
" - 80\n",
" y:\n",
" - 87\n",
" - ref: 50\n",
" x:\n",
" - 70\n",
" y:\n",
" - 86\n",
" - ref: 60\n",
" x:\n",
" - 60\n",
" y:\n",
" - 85\n",
" startcost:\n",
" 2018-02-27 00:00:00: 500\n",
"connections:\n",
" - from: Reservoir1\n",
" to: Plant1\n",
" - from: P1G1\n",
" to: Plant1\n",
" - from: P1P1\n",
" to: Plant1\n",
" - from: Plant1\n",
" to: Reservoir2\n",
" - from: Reservoir2\n",
" to: outlet\n",
"commands:\n",
" - start sim 3\n",
" - set code /inc\n",
" - start sim 3\n"
]
}
],
"source": [
"shop.dump_yaml(file_path='basic_pump.yaml',input_only=True)\n",
"\n",
"with open('basic_pump.yaml', 'r') as f:\n",
" print(f.read())"
]
},
{
"cell_type": "markdown",
"id": "33c7eaf2",
"metadata": {},
"source": [
"(basic-pump-ascii)=\n",
"## basic_pump.ascii "
]
},
{
"cell_type": "code",
"execution_count": 10,
"id": "9c6c4efb",
"metadata": {
"Collapsed": "false",
"tags": [
"remove-input"
]
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"OPTIMIZATION time\n",
"#Start_time End_time Time_unit\n",
"20180227000000 20180228000000 HOUR\n",
"\n",
"OPTIMIZATION time_resolution\n",
"#Id Number Start_Time Time_unit Period Data_type Y_unit Pts\n",
"0 0 20180227000000 HOUR 876000000 -1 HOUR 1\n",
"#time y_value\n",
"20180227000000000 1\n",
"\n",
"RESERVOIR declaration Reservoir1\n",
"\n",
"RESERVOIR max_vol Reservoir1\n",
"12\n",
"\n",
"RESERVOIR lrl Reservoir1\n",
"90\n",
"\n",
"RESERVOIR hrl Reservoir1\n",
"100\n",
"\n",
"RESERVOIR vol_head Reservoir1\n",
"#Id Number Referance Pts X_unit Y_unit\n",
"0 0 0 3 MM3 METER\n",
"#x_values y_value\n",
"0 90\n",
"12 100\n",
"14 101\n",
"\n",
"RESERVOIR start_head Reservoir1\n",
"92\n",
"\n",
"RESERVOIR inflow Reservoir1\n",
"#Id Number Start_Time Time_unit Period Data_type Y_unit Pts\n",
"0 0 20180227000000000 HOUR 876000000 -1 M3/S 1\n",
"#time y_value\n",
"20180227000000000 10\n",
"\n",
"RESERVOIR energy_value_input Reservoir1\n",
"39.7\n",
"\n",
"RESERVOIR declaration Reservoir2\n",
"\n",
"RESERVOIR max_vol Reservoir2\n",
"5\n",
"\n",
"RESERVOIR lrl Reservoir2\n",
"40\n",
"\n",
"RESERVOIR hrl Reservoir2\n",
"50\n",
"\n",
"RESERVOIR vol_head Reservoir2\n",
"#Id Number Referance Pts X_unit Y_unit\n",
"0 0 0 3 MM3 METER\n",
"#x_values y_value\n",
"0 40\n",
"5 50\n",
"6 51\n",
"\n",
"RESERVOIR start_head Reservoir2\n",
"43\n",
"\n",
"RESERVOIR inflow Reservoir2\n",
"#Id Number Start_Time Time_unit Period Data_type Y_unit Pts\n",
"0 0 20180227000000000 HOUR 876000000 -1 M3/S 1\n",
"#time y_value\n",
"20180227000000000 0\n",
"\n",
"PLANT declaration Plant1\n",
"\n",
"PLANT prod_area Plant1\n",
"#Id Number Start_Time Time_unit Period Data_type Y_unit Pts\n",
"0 0 20180227000000000 HOUR 876000000 -1 NO_UNIT 1\n",
"#time y_value\n",
"20180227000000000 1\n",
"\n",
"PLANT outlet_line Plant1\n",
"40\n",
"\n",
"PLANT main_loss Plant1\n",
"0.0002 \n",
"\n",
"PLANT penstock_loss Plant1\n",
"0.0001 \n",
"\n",
"GENERATOR declaration P1G1\n",
"\n",
"GENERATOR penstock P1G1\n",
"1\n",
"\n",
"GENERATOR p_min P1G1\n",
"25\n",
"\n",
"GENERATOR p_max P1G1\n",
"100\n",
"\n",
"GENERATOR p_nom P1G1\n",
"100\n",
"\n",
"GENERATOR gen_eff_curve P1G1\n",
"#Id Number Referance Pts X_unit Y_unit\n",
"0 0 0 2 MW %\n",
"#x_values y_value\n",
"0 95\n",
"100 98\n",
"\n",
"GENERATOR turb_eff_curves P1G1\n",
"#Id Number Referance Pts X_unit Y_unit\n",
"0 0 90 3 M3/S %\n",
"#x_values y_value\n",
"25 80\n",
"90 95\n",
"100 90\n",
"\n",
"GENERATOR turb_eff_curves P1G1\n",
"#Id Number Referance Pts X_unit Y_unit\n",
"0 0 100 3 M3/S %\n",
"#x_values y_value\n",
"25 82\n",
"90 98\n",
"100 92\n",
"\n",
"GENERATOR startcost P1G1\n",
"#Id Number Start_Time Time_unit Period Data_type Y_unit Pts\n",
"0 0 20180227000000000 HOUR 876000000 -1 NOK 1\n",
"#time y_value\n",
"20180227000000000 500\n",
"\n",
"PUMP declaration P1P1\n",
"\n",
"PUMP penstock P1P1\n",
"1\n",
"\n",
"PUMP p_min P1P1\n",
"38\n",
"\n",
"PUMP p_max P1P1\n",
"42\n",
"\n",
"PUMP p_nom P1P1\n",
"40\n",
"\n",
"PUMP gen_eff_curve P1P1\n",
"#Id Number Referance Pts X_unit Y_unit\n",
"0 0 0 2 MW %\n",
"#x_values y_value\n",
"0 100\n",
"50 100\n",
"\n",
"PUMP turb_eff_curves P1P1\n",
"#Id Number Referance Pts X_unit Y_unit\n",
"0 0 40 1 M3/S %\n",
"#x_values y_value\n",
"80 87\n",
"\n",
"PUMP turb_eff_curves P1P1\n",
"#Id Number Referance Pts X_unit Y_unit\n",
"0 0 50 1 M3/S %\n",
"#x_values y_value\n",
"70 86\n",
"\n",
"PUMP turb_eff_curves P1P1\n",
"#Id Number Referance Pts X_unit Y_unit\n",
"0 0 60 1 M3/S %\n",
"#x_values y_value\n",
"60 85\n",
"\n",
"PUMP startcost P1P1\n",
"#Id Number Start_Time Time_unit Period Data_type Y_unit Pts\n",
"0 0 20180227000000000 HOUR 876000000 -1 NOK 1\n",
"#time y_value\n",
"20180227000000000 500\n",
"\n",
"MARKET declaration Day_Ahead\n",
"\n",
"MARKET max_buy Day_Ahead\n",
"#Id Number Start_Time Time_unit Period Data_type Y_unit Pts\n",
"0 0 20180227000000000 HOUR 876000000 -1 MW 1\n",
"#time y_value\n",
"20180227000000000 9999\n",
"\n",
"MARKET max_sale Day_Ahead\n",
"#Id Number Start_Time Time_unit Period Data_type Y_unit Pts\n",
"0 0 20180227000000000 HOUR 876000000 -1 MW 1\n",
"#time y_value\n",
"20180227000000000 9999\n",
"\n",
"MARKET buy_price Day_Ahead\n",
"#Id Number Start_Time Time_unit Period Data_type Y_unit Pts\n",
"0 0 20180227000000000 HOUR 876000000 -1 NOK/MWH 2\n",
"#time y_value\n",
"20180227000000000 20.01\n",
"20180227060000000 40.01\n",
"\n",
"MARKET sale_price Day_Ahead\n",
"#Id Number Start_Time Time_unit Period Data_type Y_unit Pts\n",
"0 0 20180227000000000 HOUR 876000000 -1 NOK/MWH 2\n",
"#time y_value\n",
"20180227000000000 19.99\n",
"20180227060000000 39.99\n",
"\n",
"RIVER declaration outlet\n",
"\n",
"RIVER upstream_elevation outlet\n",
"50\n",
"\n",
"RIVER flow_cost outlet\n",
"#Id Number Start_Time Time_unit Period Data_type Y_unit Pts\n",
"0 0 20180227000000000 HOUR 876000000 -1 NOK/M3/S 1\n",
"#time y_value\n",
"20180227000000000 10\n",
"\n",
"# From_type/To_type from_name To_name\n",
"CONNECT GENERATOR/PLANT P1G1 Plant1\n",
"CONNECT RESERVOIR/PLANT Reservoir1 Plant1\n",
"CONNECT PLANT/RESERVOIR Plant1 Reservoir2\n",
"CONNECT RESERVOIR/RIVER Reservoir2 outlet\n",
"CONNECT PUMP/PLANT P1P1 Plant1\n",
"\n",
"\n"
]
}
],
"source": [
"with open('basic_pump.ascii', 'r') as f:\n",
" print(f.read())"
]
}
],
"metadata": {
"jupytext": {
"text_representation": {
"extension": ".md",
"format_name": "myst",
"format_version": 0.13,
"jupytext_version": "1.14.6"
}
},
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"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.12.9"
},
"source_map": [
12,
32,
44,
48,
57,
63,
73,
77,
79,
85,
106,
117,
127,
134,
140,
145,
153,
158
]
},
"nbformat": 4,
"nbformat_minor": 5
}