{ "cells": [ { "cell_type": "markdown", "id": "fd9c946f", "metadata": {}, "source": [ "(pelton)=\n", "# Pelton units and forbidden zones" ] }, { "cell_type": "markdown", "id": "f4d0c264", "metadata": {}, "source": [ "This example illustrates how [generators](generator) can be modelled as Pelton units with multiple [needle_combinations](needle_combination). The same functionality can also be used to model generators with forbidden operating zones.\n", "\n", "The model setup for this example is available in the following format:\n", "- pyshop\n", " - [](pelton_model.py)" ] }, { "cell_type": "code", "execution_count": 1, "id": "caf60816", "metadata": {}, "outputs": [], "source": [ "import numpy as np\n", "import pandas as pd\n", "import plotly.graph_objs as go\n", "from plotly.subplots import make_subplots\n", "from pyshop import ShopSession\n", "\n", "#specific imports for this example\n", "from pelton_model import build_model, run_model, calc_p" ] }, { "cell_type": "markdown", "id": "da61afb5", "metadata": {}, "source": [ "## Create SHOP session and build a basic model\n", "This example features a single power plant below a reservoir with a single generator. The generator will be modelled as a Pelton unit." ] }, { "cell_type": "code", "execution_count": 2, "id": "b2474117", "metadata": {}, "outputs": [ { "data": { "image/svg+xml": [ "\n", "\n", "\n", "\n", "\n", "\n", "%3\n", "\n", "\n", "\n", "reservoir_Reservoir1\n", "\n", "Reservoir1\n", "\n", "\n", "\n", "plant_Plant1\n", "\n", "Plant1\n", "\n", "\n", "\n", "reservoir_Reservoir1->plant_Plant1\n", "\n", "\n", "\n", "\n", "generator_pelton\n", "\n", "generator_pelton\n", "\n", "\n", "\n", "plant_Plant1->generator_pelton\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, including generators\n", "display(shop.model.build_connection_tree(display_units=True))" ] }, { "cell_type": "markdown", "id": "3f59a48b", "metadata": {}, "source": [ "## Defining needle_combination objects\n", "\n", "To model a generator as a Pelton generator in SHOP, one only needs to connect one or more needle_combination objects to the generator. The attributes [p_min](needle_combination:p_min), [p_max](needle_combination:p_max), [p_nom](needle_combination:p_nom), and [turb_eff_curves](needle_combination:turb_eff_curves) are usually specified on the generator object, but the needle_combinations take over this role for Pelton units. It is therefore not necessary to add any of these attributes on the Pelton generator object itself. \n", "\n", "Two needle_combination objects are added to this generator, representing two legal production zones. The first needle_combination has an operating range from 7 to 17 MW, while the second needle_combination can produce between 30 and 45 MW. Note that the nominal production is set to the same value for both needle_combinations, though this is only relevant for droop calculations when delivering FCR [reserves](reserves)." ] }, { "cell_type": "code", "execution_count": 3, "id": "bcab7eae", "metadata": {}, "outputs": [], "source": [ "pelton = shop.model.generator[\"pelton\"]\n", "\n", "#Add first needle_combination, valid from 7 to 17 MW\n", "n1 = shop.model.needle_combination.add_object(\"N1\")\n", "n1.p_min.set(7)\n", "n1.p_max.set(17)\n", "n1.p_nom.set(45)\n", "\n", "q = [7.0, 30.0, 49.0]\n", "eff = [87.93, 93.52, 94.95]\n", "c1 = pd.Series(eff,index=q,name=40)\n", "\n", "q = [7.0, 30.0, 49.0]\n", "eff = [90.05, 94.09, 95.14]\n", "c2 = pd.Series(eff,index=q,name=42)\n", "\n", "q = [7.0, 30.0, 49.0]\n", "eff = [90.9, 94.35, 95.23]\n", "c3 = pd.Series(eff,index=q,name=45)\n", "\n", "q = [7.0, 30.0, 49.0]\n", "eff = [90.05, 94.09, 95.14]\n", "c4 = pd.Series(eff,index=q,name=48)\n", "\n", "q = [7.0, 30.0, 49.0]\n", "eff = [89.27, 93.88, 95.05]\n", "c5 = pd.Series(eff,index=q,name=50)\n", "\n", "n1.turb_eff_curves.set([c1, c2, c3, c4, c5])\n", "pelton.connect_to(n1)\n", "\n", "#Add second needle_combination, valid from 30 to 45 MW\n", "n2 = shop.model.needle_combination.add_object(\"N2\")\n", "n2.p_min.set(30)\n", "n2.p_max.set(45)\n", "n2.p_nom.set(45)\n", "\n", "q = [68.0, 79.0, 90.0]\n", "eff = [95.40, 95.48, 95.40]\n", "c1 = pd.Series(eff,index=q,name=40)\n", "\n", "q = [68.0, 79.0, 90.0, 95.0]\n", "eff = [95.54, 95.63, 95.54, 95.38]\n", "c2 = pd.Series(eff,index=q,name=42)\n", "\n", "q = [68.0, 79.0, 90.0, 98.0]\n", "eff = [95.61, 95.76, 95.61, 95.44]\n", "c3 = pd.Series(eff,index=q,name=45)\n", "\n", "q = [68.0, 79.0, 90.0, 99.0]\n", "eff = [95.54, 95.63, 95.54, 95.25]\n", "c4 = pd.Series(eff,index=q,name=48)\n", "\n", "q = [68.0, 79.0, 90.0, 100.0]\n", "eff = [95.47, 95.55, 95.47, 95.33]\n", "c5 = pd.Series(eff,index=q,name=50)\n", "\n", "n2.turb_eff_curves.set([c1, c2, c3, c4, c5])\n", "pelton.connect_to(n2)" ] }, { "cell_type": "markdown", "id": "60ba2db3", "metadata": {}, "source": [ "### Illegal discharge region\n", "The turbine efficiency curves for both of the needle_combination objects are plotted below. The figure shows that there will be an illegal discharge range between 49 and 68 m3/s since neither of the turbine efficiency curves are defined in this region. Pelton turbines may also have needle_combinations with overlapping turbine efficiency curves in SHOP." ] }, { "cell_type": "code", "execution_count": 4, "id": "7c1267da", "metadata": {}, "outputs": [ { "data": { "text/html": [ " \n", " " ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "application/vnd.plotly.v1+json": { "config": { "plotlyServerURL": "https://plot.ly" }, "data": [ { "line": { "color": "black" }, "marker": { "color": "red", "size": 10 }, "mode": "markers+lines", "name": "N1", "type": "scatter", "x": [ 7.0, 30.0, 49.0 ], "y": [ 87.93, 93.52, 94.95 ] }, { "line": { "color": "black" }, "marker": { "color": "red", "size": 10 }, "mode": "markers+lines", "showlegend": false, "type": "scatter", "x": [ 7.0, 30.0, 49.0 ], "y": [ 90.05, 94.09, 95.14 ] }, { "line": { "color": "black" }, "marker": { "color": "red", "size": 10 }, "mode": "markers+lines", "showlegend": false, "type": "scatter", "x": [ 7.0, 30.0, 49.0 ], "y": [ 90.9, 94.35, 95.23 ] }, { "line": { "color": "black" }, "marker": { "color": "red", "size": 10 }, "mode": "markers+lines", "showlegend": false, "type": "scatter", "x": [ 7.0, 30.0, 49.0 ], "y": [ 90.05, 94.09, 95.14 ] }, { "line": { "color": "black" }, "marker": { "color": "red", "size": 10 }, "mode": "markers+lines", "showlegend": false, "type": "scatter", "x": [ 7.0, 30.0, 49.0 ], "y": [ 89.27, 93.88, 95.05 ] }, { "line": { "color": "black" }, "marker": { "color": "blue", "size": 10 }, "mode": "markers+lines", "name": "N2", "type": "scatter", "x": [ 68.0, 79.0, 90.0 ], "y": [ 95.4, 95.48, 95.4 ] }, { "line": { "color": "black" }, "marker": { "color": "blue", "size": 10 }, "mode": "markers+lines", "showlegend": false, "type": "scatter", "x": [ 68.0, 79.0, 90.0, 95.0 ], "y": [ 95.54, 95.63, 95.54, 95.38 ] }, { "line": { "color": "black" }, "marker": { "color": "blue", "size": 10 }, "mode": "markers+lines", "showlegend": false, "type": "scatter", "x": [ 68.0, 79.0, 90.0, 98.0 ], "y": [ 95.61, 95.76, 95.61, 95.44 ] }, { "line": { "color": "black" }, "marker": { "color": "blue", "size": 10 }, "mode": "markers+lines", "showlegend": false, "type": "scatter", "x": [ 68.0, 79.0, 90.0, 99.0 ], "y": [ 95.54, 95.63, 95.54, 95.25 ] }, { "line": { "color": "black" }, "marker": { "color": "blue", "size": 10 }, "mode": "markers+lines", "showlegend": false, "type": "scatter", "x": [ 68.0, 79.0, 90.0, 100.0 ], "y": [ 95.47, 95.55, 95.47, 95.33 ] }, { "line": { "color": "gray", "dash": "dash" }, "mode": "lines", "showlegend": false, "type": "scatter", "x": [ 49, 49 ], "y": [ 88, 96 ] }, { "fill": "tonexty", "line": { "color": "gray", "dash": "dash" }, "mode": "lines", "name": "Illegal discharge zone", "type": "scatter", "x": [ 68, 68 ], "y": [ 88, 96 ] } ], "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": "Turbine efficiency curves" }, "xaxis": { "title": { "text": "Q [m3/s]" } }, "yaxis": { "title": { "text": "Efficiency [%]" } } } }, "text/html": [ "
" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "curves_1 = n1.turb_eff_curves.get()\n", "curves_2 = n2.turb_eff_curves.get()\n", "\n", "fig = go.Figure()\n", "fig.update_layout(title=\"Turbine efficiency curves\",xaxis_title=\"Q [m3/s]\",yaxis_title=\"Efficiency [%]\")\n", "\n", "for i,c in enumerate(curves_1):\n", " if i == 0:\n", " fig.add_trace(go.Scatter(x=c.index, y=c.values,mode='markers+lines',line_color=\"black\", marker = {'color': \"red\",'size': 10},name=\"N1\"))\n", " else:\n", " fig.add_trace(go.Scatter(x=c.index, y=c.values,mode='markers+lines',line_color=\"black\", marker = {'color': \"red\",'size': 10},showlegend=False))\n", "\n", "for i,c in enumerate(curves_2):\n", " if i == 0:\n", " fig.add_trace(go.Scatter(x=c.index, y=c.values,mode='markers+lines',line_color=\"black\", marker = {'color': \"blue\",'size': 10},name=\"N2\"))\n", " else:\n", " fig.add_trace(go.Scatter(x=c.index, y=c.values,mode='markers+lines',line_color=\"black\", marker = {'color': \"blue\",'size': 10},showlegend=False))\n", " \n", "fig.add_trace(go.Scatter(x=[49,49], y=[88,96],mode='lines',line={'color': \"gray\", 'dash':\"dash\"}, showlegend=False))\n", "fig.add_trace(go.Scatter(x=[68,68], y=[88,96],mode='lines',line={'color': \"gray\", 'dash':\"dash\"}, fill=\"tonexty\", name=\"Illegal discharge zone\"))\n", " \n", "fig.show()" ] }, { "cell_type": "markdown", "id": "28b328f1", "metadata": {}, "source": [ "### Illegal production region\n", "\n", "It is possible to calculate the resulting production for each point in the input turbine efficiency curves (the [generator efficiency](generator:gen_eff_curve) is set to a constant 98% on the generator object). Plotting these input PQ curves together with the p_min and p_max for both needle_combinations, shows that several of the points defined in the turbine efficiency curves will end up in the forbidden production region between 17 and 30 MW. This is not a problem, since SHOP ensures that both discharge and production limits are respected internally when building the PQ curve constraints. Note that the plotted curves are not used directly in SHOP, rather the PQ constraints are built for each time step by interpolating the turbine efficiency curves around the current operating point in q and h space.\n", "\n", "It is also possible to have needle_combinations with overlapping production zones in SHOP." ] }, { "cell_type": "code", "execution_count": 5, "id": "cb632074", "metadata": {}, "outputs": [ { "data": { "application/vnd.plotly.v1+json": { "config": { "plotlyServerURL": "https://plot.ly" }, "data": [ { "line": { "color": "black" }, "marker": { "color": "red", "size": 10 }, "mode": "markers+lines", "name": "N1", "type": "scatter", "x": [ 7.0, 30.0, 49.0 ], "y": [ 2.3669560152000004, 10.788990912, 17.891474076000005 ] }, { "line": { "color": "black" }, "marker": { "color": "red", "size": 10 }, "mode": "markers+lines", "showlegend": false, "type": "scatter", "x": [ 7.0, 30.0, 49.0 ], "y": [ 2.5452247086, 11.3974867692, 18.82363966056 ] }, { "line": { "color": "black" }, "marker": { "color": "red", "size": 10 }, "mode": "markers+lines", "showlegend": false, "type": "scatter", "x": [ 7.0, 30.0, 49.0 ], "y": [ 2.7527674230000008, 12.245337405000003, 20.187263936700003 ] }, { "line": { "color": "black" }, "marker": { "color": "red", "size": 10 }, "mode": "markers+lines", "showlegend": false, "type": "scatter", "x": [ 7.0, 30.0, 49.0 ], "y": [ 2.9088282384, 13.025699164800002, 21.512731040640006 ] }, { "line": { "color": "black" }, "marker": { "color": "red", "size": 10 }, "mode": "markers+lines", "showlegend": false, "type": "scatter", "x": [ 7.0, 30.0, 49.0 ], "y": [ 3.0037837410000003, 13.538153160000002, 22.387896405 ] }, { "line": { "color": "black" }, "marker": { "color": "blue", "size": 10 }, "mode": "markers+lines", "name": "N2", "type": "scatter", "x": [ 68.0, 79.0, 90.0 ], "y": [ 24.946657344000005, 29.006449718400003, 33.017634720000004 ] }, { "line": { "color": "black" }, "marker": { "color": "blue", "size": 10 }, "mode": "markers+lines", "showlegend": false, "type": "scatter", "x": [ 68.0, 79.0, 90.0, 95.0 ], "y": [ 26.232430029120007, 30.504620086920003, 34.7193926856, 36.5868733356 ] }, { "line": { "color": "black" }, "marker": { "color": "blue", "size": 10 }, "mode": "markers+lines", "showlegend": false, "type": "scatter", "x": [ 68.0, 79.0, 90.0, 98.0 ], "y": [ 28.126767790800002, 32.727951698400005, 37.22660442900001, 40.4635612752 ] }, { "line": { "color": "black" }, "marker": { "color": "blue", "size": 10 }, "mode": "markers+lines", "showlegend": false, "type": "scatter", "x": [ 68.0, 79.0, 90.0, 99.0 ], "y": [ 29.979920033280006, 34.86242295648, 39.679305926400005, 43.514750664000005 ] }, { "line": { "color": "black" }, "marker": { "color": "blue", "size": 10 }, "mode": "markers+lines", "showlegend": false, "type": "scatter", "x": [ 68.0, 79.0, 90.0, 100.0 ], "y": [ 31.206202524000005, 36.284644305, 41.30232687, 45.82417770000001 ] }, { "line": { "color": "gray", "dash": "dash" }, "mode": "lines", "name": "Production limits", "type": "scatter", "x": [ 0, 100 ], "y": [ 7.0, 7.0 ] }, { "line": { "color": "gray", "dash": "dash" }, "mode": "lines", "showlegend": false, "type": "scatter", "x": [ 0, 100 ], "y": [ 17.0, 17.0 ] }, { "fill": "tonexty", "line": { "color": "gray", "dash": "dash" }, "mode": "lines", "name": "Illegal production zone", "type": "scatter", "x": [ 0, 100 ], "y": [ 30.0, 30.0 ] }, { "line": { "color": "gray", "dash": "dash" }, "mode": "lines", "showlegend": false, "type": "scatter", "x": [ 0, 100 ], "y": [ 45.0, 45.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": "Input PQ curves" }, "xaxis": { "title": { "text": "Q [m3/s]" } }, "yaxis": { "title": { "text": "P [MW]" } } } }, "text/html": [ "
" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "p1_min = n1.p_min.get()\n", "p2_min = n2.p_min.get()\n", "p1_max = n1.p_max.get()\n", "p2_max = n2.p_max.get()\n", "\n", "fig = go.Figure()\n", "fig.update_layout(title=\"Input PQ curves\",xaxis_title=\"Q [m3/s]\",yaxis_title=\"P [MW]\")\n", "\n", "for i,c in enumerate(curves_1):\n", " p = calc_p(c) \n", " if i == 0:\n", " fig.add_trace(go.Scatter(x=c.index, y=p,mode='markers+lines',line_color=\"black\", marker = {'color': \"red\",'size': 10},name=\"N1\"))\n", " else:\n", " fig.add_trace(go.Scatter(x=c.index, y=p,mode='markers+lines',line_color=\"black\", marker = {'color': \"red\",'size': 10},showlegend=False))\n", "\n", "for i,c in enumerate(curves_2):\n", " p = calc_p(c)\n", " if i == 0:\n", " fig.add_trace(go.Scatter(x=c.index, y=p,mode='markers+lines',line_color=\"black\", marker = {'color': \"blue\",'size': 10},name=\"N2\"))\n", " else:\n", " fig.add_trace(go.Scatter(x=c.index, y=p,mode='markers+lines',line_color=\"black\", marker = {'color': \"blue\",'size': 10},showlegend=False))\n", "\n", "fig.add_trace(go.Scatter(x=[0,100], y=[p1_min,p1_min],mode='lines',line={'color': \"gray\", 'dash':\"dash\"}, name=\"Production limits\"))\n", "fig.add_trace(go.Scatter(x=[0,100], y=[p1_max,p1_max],mode='lines',line={'color': \"gray\", 'dash':\"dash\"}, showlegend=False))\n", "fig.add_trace(go.Scatter(x=[0,100], y=[p2_min,p2_min],mode='lines',line={'color': \"gray\", 'dash':\"dash\"}, fill=\"tonexty\", name=\"Illegal production zone\"))\n", "fig.add_trace(go.Scatter(x=[0,100], y=[p2_max,p2_max],mode='lines',line={'color': \"gray\", 'dash':\"dash\"}, showlegend=False))\n", " \n", "fig.show()" ] }, { "cell_type": "markdown", "id": "0f8e6e64", "metadata": {}, "source": [ "## Optimization results\n", "Let us now solve the model and inspect the resulting production and commitment choices." ] }, { "cell_type": "code", "execution_count": 6, "id": "eb3c6452", "metadata": {}, "outputs": [], "source": [ "run_model(shop)" ] }, { "cell_type": "markdown", "id": "e125944c", "metadata": {}, "source": [ "The optimized [production](generator:production) and [discharge](generator:discharge) from each hour in the 24 hour optimization is plotted together with the input PQ curves. Most of the results are stored on the same time series attributes as for the regular generator objects, see the documentation for a complete list of output attributes on the needle_combination level. Note that p_max for the lower needle_combination and p_min for the higher needle_combination are constraining in some hours." ] }, { "cell_type": "code", "execution_count": 7, "id": "986f6860", "metadata": {}, "outputs": [ { "data": { "application/vnd.plotly.v1+json": { "config": { "plotlyServerURL": "https://plot.ly" }, "data": [ { "line": { "color": "black" }, "marker": { "color": "red", "size": 10 }, "mode": "markers+lines", "name": "N1", "type": "scatter", "x": [ 7.0, 30.0, 49.0 ], "y": [ 2.3669560152000004, 10.788990912, 17.891474076000005 ] }, { "line": { "color": "black" }, "marker": { "color": "red", "size": 10 }, "mode": "markers+lines", "showlegend": false, "type": "scatter", "x": [ 7.0, 30.0, 49.0 ], "y": [ 2.5452247086, 11.3974867692, 18.82363966056 ] }, { "line": { "color": "black" }, "marker": { "color": "red", "size": 10 }, "mode": "markers+lines", "showlegend": false, "type": "scatter", "x": [ 7.0, 30.0, 49.0 ], "y": [ 2.7527674230000008, 12.245337405000003, 20.187263936700003 ] }, { "line": { "color": "black" }, "marker": { "color": "red", "size": 10 }, "mode": "markers+lines", "showlegend": false, "type": "scatter", "x": [ 7.0, 30.0, 49.0 ], "y": [ 2.9088282384, 13.025699164800002, 21.512731040640006 ] }, { "line": { "color": "black" }, "marker": { "color": "red", "size": 10 }, "mode": "markers+lines", "showlegend": false, "type": "scatter", "x": [ 7.0, 30.0, 49.0 ], "y": [ 3.0037837410000003, 13.538153160000002, 22.387896405 ] }, { "line": { "color": "black" }, "marker": { "color": "blue", "size": 10 }, "mode": "markers+lines", "name": "N2", "type": "scatter", "x": [ 68.0, 79.0, 90.0 ], "y": [ 24.946657344000005, 29.006449718400003, 33.017634720000004 ] }, { "line": { "color": "black" }, "marker": { "color": "blue", "size": 10 }, "mode": "markers+lines", "showlegend": false, "type": "scatter", "x": [ 68.0, 79.0, 90.0, 95.0 ], "y": [ 26.232430029120007, 30.504620086920003, 34.7193926856, 36.5868733356 ] }, { "line": { "color": "black" }, "marker": { "color": "blue", "size": 10 }, "mode": "markers+lines", "showlegend": false, "type": "scatter", "x": [ 68.0, 79.0, 90.0, 98.0 ], "y": [ 28.126767790800002, 32.727951698400005, 37.22660442900001, 40.4635612752 ] }, { "line": { "color": "black" }, "marker": { "color": "blue", "size": 10 }, "mode": "markers+lines", "showlegend": false, "type": "scatter", "x": [ 68.0, 79.0, 90.0, 99.0 ], "y": [ 29.979920033280006, 34.86242295648, 39.679305926400005, 43.514750664000005 ] }, { "line": { "color": "black" }, "marker": { "color": "blue", "size": 10 }, "mode": "markers+lines", "showlegend": false, "type": "scatter", "x": [ 68.0, 79.0, 90.0, 100.0 ], "y": [ 31.206202524000005, 36.284644305, 41.30232687, 45.82417770000001 ] }, { "line": { "color": "gray", "dash": "dash" }, "mode": "lines", "name": "Production limits", "type": "scatter", "x": [ 0, 100 ], "y": [ 7.0, 7.0 ] }, { "line": { "color": "gray", "dash": "dash" }, "mode": "lines", "showlegend": false, "type": "scatter", "x": [ 0, 100 ], "y": [ 17.0, 17.0 ] }, { "fill": "tonexty", "line": { "color": "gray", "dash": "dash" }, "mode": "lines", "name": "Illegal production zone", "type": "scatter", "x": [ 0, 100 ], "y": [ 30.0, 30.0 ] }, { "line": { "color": "gray", "dash": "dash" }, "mode": "lines", "showlegend": false, "type": "scatter", "x": [ 0, 100 ], "y": [ 45.0, 45.0 ] }, { "marker": { "color": "black", "size": 10 }, "mode": "markers", "name": "Optimization results", "type": "scatter", "x": [ 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, 41.448925881944554, 74.62380745404202, 74.98689606299587, 75.35627058872832, 79.0, 84.17304889435965, 89.17672557238942, 88.82982610254088 ], "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, 16.99990292748336, 29.999542406294132, 29.999513808997815, 29.999482896425764, 31.19027663400366, 32.85492801153321, 34.391957206091966, 34.074853202917055 ] } ], "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": "Input PQ curves with optimization results" }, "xaxis": { "title": { "text": "Q [m3/s]" } }, "yaxis": { "title": { "text": "P [MW]" } } } }, "text/html": [ "
" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "p = pelton.production.get()\n", "q = pelton.discharge.get()\n", "\n", "fig.add_trace(go.Scatter(x=q.values, y=p.values,mode='markers',marker = {'color': \"black\",'size': 10}, name=\"Optimization results\"))\n", "fig.update_layout(title=\"Input PQ curves with optimization results\")\n", "fig.show()" ] }, { "cell_type": "markdown", "id": "1305271e", "metadata": {}, "source": [ "The figure below shows a plot of the optimized production and the [committed needle_combination](generator:committed_out) in each hour. The unit is initially off, then needle 1 is committed in hour 16 before needle 2 is committed for the remaining hours. Note that there is no cost for switching between needle_combinations in the optimization, but [start cost](generator:startcost) and [stop cost](generator:stopcost) is still applied when turning the generator on and off." ] }, { "cell_type": "code", "execution_count": 8, "id": "19b35184", "metadata": {}, "outputs": [ { "data": { "application/vnd.plotly.v1+json": { "config": { "plotlyServerURL": "https://plot.ly" }, "data": [ { "marker": { "color": "black", "size": 10 }, "mode": "markers", "name": "Committed needle", "type": "scatter", "x": [ "2024-01-01T00:00:00", "2024-01-01T01:00:00", "2024-01-01T02:00:00", "2024-01-01T03:00:00", "2024-01-01T04:00:00", "2024-01-01T05:00:00", "2024-01-01T06:00:00", "2024-01-01T07:00:00", "2024-01-01T08:00:00", "2024-01-01T09:00:00", "2024-01-01T10:00:00", "2024-01-01T11:00:00", "2024-01-01T12:00:00", "2024-01-01T13:00:00", "2024-01-01T14:00:00", "2024-01-01T15:00:00", "2024-01-01T16:00:00", "2024-01-01T17:00:00", "2024-01-01T18:00:00", "2024-01-01T19:00:00", "2024-01-01T20:00:00", "2024-01-01T21:00:00", "2024-01-01T22:00:00", "2024-01-01T23:00:00" ], "xaxis": "x", "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, 1.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0 ], "yaxis": "y" }, { "mode": "lines", "name": "Production", "type": "scatter", "x": [ "2024-01-01T00:00:00", "2024-01-01T01:00:00", "2024-01-01T02:00:00", "2024-01-01T03:00:00", "2024-01-01T04:00:00", "2024-01-01T05:00:00", "2024-01-01T06:00:00", "2024-01-01T07:00:00", "2024-01-01T08:00:00", "2024-01-01T09:00:00", "2024-01-01T10:00:00", "2024-01-01T11:00:00", "2024-01-01T12:00:00", "2024-01-01T13:00:00", "2024-01-01T14:00:00", "2024-01-01T15:00:00", "2024-01-01T16:00:00", "2024-01-01T17:00:00", "2024-01-01T18:00:00", "2024-01-01T19:00:00", "2024-01-01T20:00:00", "2024-01-01T21:00:00", "2024-01-01T22:00:00", "2024-01-01T23:00:00" ], "xaxis": "x", "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, 16.99990292748336, 29.999542406294132, 29.999513808997815, 29.999482896425764, 31.19027663400366, 32.85492801153321, 34.391957206091966, 34.074853202917055 ], "yaxis": "y2" } ], "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": "Optimized production and needle number" }, "xaxis": { "anchor": "y", "domain": [ 0.0, 0.94 ], "tickformat": "%H:%M" }, "yaxis": { "anchor": "x", "domain": [ 0.0, 1.0 ], "title": { "text": "Needle number" } }, "yaxis2": { "anchor": "x", "overlaying": "y", "side": "right", "title": { "text": "Production [MW]" } } } }, "text/html": [ "
" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "committed_needle = pelton.committed_out.get()\n", "\n", "fig = make_subplots(specs=[[{\"secondary_y\": True}]])\n", "fig.update_layout(title=\"Optimized production and needle number\")\n", "fig.add_trace(go.Scatter(x=committed_needle.index, y=committed_needle.values, name=\"Committed needle\", mode=\"markers\",marker = {'color': \"black\",'size': 10}), secondary_y=False)\n", "fig.update_yaxes(title_text=\"Needle number\", secondary_y=False)\n", "fig.update_yaxes(title_text=\"Production [MW]\", secondary_y=True)\n", "fig.update_xaxes(tickformat=\"%H:%M\")\n", "fig.add_trace(go.Scatter(x=p.index,y=p.values,mode=\"lines\",name=\"Production\"),secondary_y=True)\n", "fig.show()" ] } ], "metadata": { "jupytext": { "text_representation": { "extension": ".md", "format_name": "myst", "format_version": 0.13, "jupytext_version": "1.15.2" } }, "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.12.9" }, "source_map": [ 12, 16, 24, 33, 38, 45, 53, 113, 118, 141, 149, 178, 183, 185, 189, 196, 200 ] }, "nbformat": 4, "nbformat_minor": 5 }