{ "cells": [ { "cell_type": "markdown", "id": "a0ca9d15", "metadata": {}, "source": [ "(reservoir-dynamic-level-limit)=\n", "# Reservoir dynamic level limit\n", "\n", "This example illustrates how the [reservoir](reservoir) dynamic level limit constraint works. The dynamic level constraints imposes a maximum deviation between the lowest and highest reservoir [level](reservoir:head) within predefined time periods (e.g. max 15 cm deviation within each 24 hours in the optimization period). The constraints are similar to the reservoir limit level period ramping ([limit_level_period_ramping_up](reservoir:limit_level_period_ramping_up) and [limit_level_period_ramping_down](reservoir:limit_level_period_ramping_down)), except the constraint is on the maximum level difference within each time period instead of the maximum difference between consecutive time periods. \n", "\n", "The model setup for this example is available in the following format:\n", "- pyshop\n", " - [rsv_dynamic_level_limit.py](rsv_dynamic_level_limit.py)" ] }, { "cell_type": "code", "execution_count": 1, "id": "8810a6e1", "metadata": { "Collapsed": "false" }, "outputs": [ { "data": { "text/html": [ " \n", " " ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "#Necessary imports \n", "import pandas as pd\n", "import plotly.offline as py\n", "import plotly.graph_objs as go\n", "py.offline.init_notebook_mode(connected=True)\n", "from pyshop import ShopSession\n", "\n", "#Functions used in this example for building a basic SHOP model and running it, and for plotting the results\n", "from rsv_dynamic_level_limit import build_model, run_model, plot_period_levels" ] }, { "cell_type": "markdown", "id": "5ee26aca", "metadata": {}, "source": [ "## Create SHOP session and import basic model\n", "\n", "Our example model consists of one reservoir and one plant." ] }, { "cell_type": "code", "execution_count": 2, "id": "a56758c5", "metadata": { "Collapsed": "false" }, "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" ], "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", "\n", "#Display topology to the screen\n", "display(shop.model.build_connection_tree())" ] }, { "cell_type": "markdown", "id": "fceb10b6", "metadata": {}, "source": [ "## Run model without dynamic level constraints\n", "\n", "We ultimately want to impose a maximum of 40 cm deviation between min and max reservoir level within every consecutive four hour period of the optimization. In addition, the first four hour period started two hours before the start of our SHOP optimization. The reservoir level in the two hours before start is known to be 94.6 and 95 masl:" ] }, { "cell_type": "code", "execution_count": 3, "id": "7d58487b", "metadata": {}, "outputs": [], "source": [ "interval_length = 4*60 # Length of periods in minutes\n", "offset = 2*60 # Start time of the first whole 4 hour period relative to the start time (minutes)\n", "\n", "#get optimization start time\n", "starttime = shop.get_time_resolution()['starttime']\n", "# Historical reservoir level from measurements\n", "historical_level = pd.Series([94.6,95.0], index=[starttime - pd.Timedelta(hours = 2), starttime - pd.Timedelta(hours=1)])" ] }, { "cell_type": "markdown", "id": "1739d7bb", "metadata": {}, "source": [ "We start by running our model without any dynamic level limit constraints." ] }, { "cell_type": "code", "execution_count": 4, "id": "f07a9710", "metadata": { "Collapsed": "false" }, "outputs": [], "source": [ "run_model(shop)" ] }, { "cell_type": "markdown", "id": "8faebb43", "metadata": {}, "source": [ "We then plot the resulting reservoir level, and we see that the level variation is more than 0.4 m within all of the time periods. Note that the historical_level attribute is ignored in this initial run but is used for plotting purposes." ] }, { "cell_type": "code", "execution_count": 5, "id": "77d482f8", "metadata": { "Collapsed": "false" }, "outputs": [ { "data": { "application/vnd.plotly.v1+json": { "config": { "plotlyServerURL": "https://plot.ly" }, "data": [ { "name": "Reservoir level", "type": "scatter", "x": [ "2023-01-01T00:00:00", "2023-01-01T01:00:00", "2023-01-01T02:00:00", "2023-01-01T03:00:00", "2023-01-01T04:00:00", "2023-01-01T05:00:00", "2023-01-01T06:00:00", "2023-01-01T07:00:00", "2023-01-01T08:00:00", "2023-01-01T09:00:00", "2023-01-01T10:00:00", "2023-01-01T11:00:00", "2023-01-01T12:00:00", "2023-01-01T13:00:00", "2023-01-01T14:00:00", "2023-01-01T15:00:00", "2023-01-01T16:00:00", "2023-01-01T17:00:00", "2023-01-01T18:00:00", "2023-01-01T19:00:00", "2023-01-01T20:00:00", "2023-01-01T21:00:00", "2023-01-01T22:00:00", "2023-01-01T23:00:00", "2023-01-02T00:00:00" ], "y": [ 95.0, 95.03, 95.06, 95.09, 95.12, 94.88, 94.64, 94.4, 94.16, 93.92, 93.67999999999999, 93.44, 93.2, 92.96, 92.72, 92.47999999999999, 92.24, 92.0, 91.75999999999999, 91.52, 91.28, 91.03999999999999, 90.8, 90.56, 90.32 ] }, { "line": { "color": "blue", "dash": "dash" }, "mode": "lines", "name": "Historical level", "type": "scatter", "x": [ "2022-12-31T22:00:00", "2022-12-31T23:00:00", "2023-01-01T00:00:00" ], "y": [ 94.6, 95.0, 95.0 ] }, { "line": { "color": "darkred", "dash": "dash" }, "mode": "lines", "showlegend": false, "type": "scatter", "x": [ "2022-12-31T22:00:00", "2023-01-01T02:00:00" ], "y": [ 95.06, 95.06 ] }, { "line": { "color": "darkred", "dash": "dot" }, "mode": "lines", "showlegend": false, "type": "scatter", "x": [ "2022-12-31T22:00:00", "2023-01-01T02:00:00" ], "y": [ 94.6, 94.6 ] }, { "line": { "color": "red" }, "mode": "lines", "showlegend": false, "type": "scatter", "x": [ "2022-12-31T23:00:00", "2022-12-31T23:00:00" ], "y": [ 94.6, 95.06 ] }, { "mode": "text", "showlegend": false, "text": [ "Δh = 0.46" ], "textfont": { "color": "red" }, "textposition": "bottom center", "type": "scatter", "x": [ "2023-01-01T00:00:00" ], "y": [ 94.35 ] }, { "line": { "color": "black", "dash": "dot" }, "mode": "lines", "showlegend": false, "type": "scatter", "x": [ "2022-12-31T22:00:00", "2022-12-31T22:00:00" ], "y": [ 90.0, 96.12 ] }, { "line": { "color": "darkred", "dash": "dash" }, "mode": "lines", "showlegend": false, "type": "scatter", "x": [ "2023-01-01T02:00:00", "2023-01-01T06:00:00" ], "y": [ 95.12, 95.12 ] }, { "line": { "color": "darkred", "dash": "dot" }, "mode": "lines", "showlegend": false, "type": "scatter", "x": [ "2023-01-01T02:00:00", "2023-01-01T06:00:00" ], "y": [ 94.64, 94.64 ] }, { "line": { "color": "red" }, "mode": "lines", "showlegend": false, "type": "scatter", "x": [ "2023-01-01T03:00:00", "2023-01-01T03:00:00" ], "y": [ 94.64, 95.12 ] }, { "mode": "text", "showlegend": false, "text": [ "Δh = 0.48" ], "textfont": { "color": "red" }, "textposition": "bottom center", "type": "scatter", "x": [ "2023-01-01T04:00:00" ], "y": [ 94.39 ] }, { "line": { "color": "black", "dash": "dot" }, "mode": "lines", "showlegend": false, "type": "scatter", "x": [ "2023-01-01T02:00:00", "2023-01-01T02:00:00" ], "y": [ 90.0, 96.12 ] }, { "line": { "color": "darkred", "dash": "dash" }, "mode": "lines", "showlegend": false, "type": "scatter", "x": [ "2023-01-01T06:00:00", "2023-01-01T10:00:00" ], "y": [ 94.64, 94.64 ] }, { "line": { "color": "darkred", "dash": "dot" }, "mode": "lines", "showlegend": false, "type": "scatter", "x": [ "2023-01-01T06:00:00", "2023-01-01T10:00:00" ], "y": [ 93.67999999999999, 93.67999999999999 ] }, { "line": { "color": "red" }, "mode": "lines", "showlegend": false, "type": "scatter", "x": [ "2023-01-01T07:00:00", "2023-01-01T07:00:00" ], "y": [ 93.67999999999999, 94.64 ] }, { "mode": "text", "showlegend": false, "text": [ "Δh = 0.96" ], "textfont": { "color": "red" }, "textposition": "bottom center", "type": "scatter", "x": [ "2023-01-01T08:00:00" ], "y": [ 93.42999999999999 ] }, { "line": { "color": "black", "dash": "dot" }, "mode": "lines", "showlegend": false, "type": "scatter", "x": [ "2023-01-01T06:00:00", "2023-01-01T06:00:00" ], "y": [ 90.0, 96.12 ] }, { "line": { "color": "darkred", "dash": "dash" }, "mode": "lines", "showlegend": false, "type": "scatter", "x": [ "2023-01-01T10:00:00", "2023-01-01T14:00:00" ], "y": [ 93.67999999999999, 93.67999999999999 ] }, { "line": { "color": "darkred", "dash": "dot" }, "mode": "lines", "showlegend": false, "type": "scatter", "x": [ "2023-01-01T10:00:00", "2023-01-01T14:00:00" ], "y": [ 92.72, 92.72 ] }, { "line": { "color": "red" }, "mode": "lines", "showlegend": false, "type": "scatter", "x": [ "2023-01-01T11:00:00", "2023-01-01T11:00:00" ], "y": [ 92.72, 93.67999999999999 ] }, { "mode": "text", "showlegend": false, "text": [ "Δh = 0.96" ], "textfont": { "color": "red" }, "textposition": "bottom center", "type": "scatter", "x": [ "2023-01-01T12:00:00" ], "y": [ 92.47 ] }, { "line": { "color": "black", "dash": "dot" }, "mode": "lines", "showlegend": false, "type": "scatter", "x": [ "2023-01-01T10:00:00", "2023-01-01T10:00:00" ], "y": [ 90.0, 96.12 ] }, { "line": { "color": "darkred", "dash": "dash" }, "mode": "lines", "showlegend": false, "type": "scatter", "x": [ "2023-01-01T14:00:00", "2023-01-01T18:00:00" ], "y": [ 92.72, 92.72 ] }, { "line": { "color": "darkred", "dash": "dot" }, "mode": "lines", "showlegend": false, "type": "scatter", "x": [ "2023-01-01T14:00:00", "2023-01-01T18:00:00" ], "y": [ 91.75999999999999, 91.75999999999999 ] }, { "line": { "color": "red" }, "mode": "lines", "showlegend": false, "type": "scatter", "x": [ "2023-01-01T15:00:00", "2023-01-01T15:00:00" ], "y": [ 91.75999999999999, 92.72 ] }, { "mode": "text", "showlegend": false, "text": [ "Δh = 0.96" ], "textfont": { "color": "red" }, "textposition": "bottom center", "type": "scatter", "x": [ "2023-01-01T16:00:00" ], "y": [ 91.50999999999999 ] }, { "line": { "color": "black", "dash": "dot" }, "mode": "lines", "showlegend": false, "type": "scatter", "x": [ "2023-01-01T14:00:00", "2023-01-01T14:00:00" ], "y": [ 90.0, 96.12 ] }, { "line": { "color": "darkred", "dash": "dash" }, "mode": "lines", "showlegend": false, "type": "scatter", "x": [ "2023-01-01T18:00:00", "2023-01-01T22:00:00" ], "y": [ 91.75999999999999, 91.75999999999999 ] }, { "line": { "color": "darkred", "dash": "dot" }, "mode": "lines", "showlegend": false, "type": "scatter", "x": [ "2023-01-01T18:00:00", "2023-01-01T22:00:00" ], "y": [ 90.8, 90.8 ] }, { "line": { "color": "red" }, "mode": "lines", "showlegend": false, "type": "scatter", "x": [ "2023-01-01T19:00:00", "2023-01-01T19:00:00" ], "y": [ 90.8, 91.75999999999999 ] }, { "mode": "text", "showlegend": false, "text": [ "Δh = 0.96" ], "textfont": { "color": "red" }, "textposition": "bottom center", "type": "scatter", "x": [ "2023-01-01T20:00:00" ], "y": [ 90.55 ] }, { "line": { "color": "black", "dash": "dot" }, "mode": "lines", "showlegend": false, "type": "scatter", "x": [ "2023-01-01T18:00:00", "2023-01-01T18:00:00" ], "y": [ 90.0, 96.12 ] }, { "line": { "color": "darkred", "dash": "dash" }, "mode": "lines", "showlegend": false, "type": "scatter", "x": [ "2023-01-01T22:00:00", "2023-01-02T02:00:00" ], "y": [ 90.8, 90.8 ] }, { "line": { "color": "darkred", "dash": "dot" }, "mode": "lines", "showlegend": false, "type": "scatter", "x": [ "2023-01-01T22:00:00", "2023-01-02T02:00:00" ], "y": [ 90.32, 90.32 ] }, { "line": { "color": "red" }, "mode": "lines", "showlegend": false, "type": "scatter", "x": [ "2023-01-01T23:00:00", "2023-01-01T23:00:00" ], "y": [ 90.32, 90.8 ] }, { "mode": "text", "showlegend": false, "text": [ "Δh = 0.48" ], "textfont": { "color": "red" }, "textposition": "bottom center", "type": "scatter", "x": [ "2023-01-02T00:00:00" ], "y": [ 90.07 ] }, { "line": { "color": "black", "dash": "dot" }, "mode": "lines", "showlegend": false, "type": "scatter", "x": [ "2023-01-01T22:00:00", "2023-01-01T22:00:00" ], "y": [ 90.0, 96.12 ] }, { "line": { "color": "darkred", "dash": "dash" }, "mode": "lines", "name": "Max period level", "type": "scatter", "x": [ "2023-01-01T22:00:00", "2023-01-02T02:00:00" ], "y": [ 90.8, 90.8 ] }, { "line": { "color": "darkred", "dash": "dot" }, "mode": "lines", "name": "Min period level", "type": "scatter", "x": [ "2023-01-01T22:00:00", "2023-01-02T02:00:00" ], "y": [ 90.32, 90.32 ] }, { "line": { "color": "black", "dash": "dot" }, "mode": "lines", "name": "Period start", "type": "scatter", "x": [ "2023-01-01T22:00:00", "2023-01-01T22:00:00" ], "y": [ 90.0, 96.12 ] }, { "line": { "color": "grey", "dash": "dot" }, "mode": "lines", "name": "Optimization start", "type": "scatter", "x": [ "2023-01-01T00:00:00", "2023-01-01T00:00:00" ], "y": [ 90.0, 96.12 ] } ], "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": "Optimization without dynamic level limit constraints" }, "xaxis": { "title": { "text": "Time" } }, "yaxis": { "title": { "text": "masl" } } } }, "text/html": [ "
" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "rsv = shop.model.reservoir[\"Reservoir1\"]\n", "rsv.historical_level.set(historical_level)\n", "lrl = rsv.lrl.get()\n", "\n", "plot_period_levels(starttime, rsv, offset, interval_length, lrl, \"Optimization without dynamic level limit constraints\")" ] }, { "cell_type": "markdown", "id": "3ac96d8d", "metadata": {}, "source": [ "## Add dynamic level limit constraints\n", "\n", "We will now create a new SHOP instance and add the [dynamic_level_limit](reservoir:dynamic_level_limit) constraints. We define our fixed time periods to be four hours long, with an [offset](reservoir:dynamic_level_limit_offset) of two hours. The offset means that the first whole time period will start two hours after the start of the optimization period. The two initial hours are therefore part of a partially historic period that includes the two hours before optimization start. To ensure that the constraint is enforced correctly for this first period, historical reservoir level data must be provided through the reservoir attribute [historical_level](reservoir:historical_level).\n", "\n", "It is possible to define multiple dynamic reservoir limits with different period lengths (e.g. 40 cm over four hours and 100 cm over 168 hours) by adding more entries into each XY table in the dynamic_level_limit XYT. The time stamps in the XYT also makes it possible to change the constraint limits inside the optimization period, such as changing the four hour limit from 40 cm to 20 cm after 12 hours. This type of modelling is not shown in this example." ] }, { "cell_type": "code", "execution_count": 6, "id": "ff838e14", "metadata": { "Collapsed": "false" }, "outputs": [], "source": [ "shop2 = ShopSession()\n", "build_model(shop2)\n", "\n", "#set historical reservoir level\n", "shop.model.reservoir.Reservoir1.historical_level.set(historical_level)\n", "\n", "# 40 cm deviation limit\n", "limit = 0.4 \n", "\n", "#set dynamic level limit and offset\n", "dynamic_level_limit= [pd.Series(data=[limit], index=[interval_length], name=pd.Timestamp(starttime + pd.Timedelta(hours=0)))]\n", "dynamic_level_limit_offset = pd.Series(index=[starttime + pd.Timedelta(minutes=offset)], data=[interval_length])\n", "\n", "rsv = shop2.model.reservoir.Reservoir1\n", "rsv.dynamic_level_limit.set(dynamic_level_limit)\n", "rsv.dynamic_level_limit_offset.set(dynamic_level_limit_offset)\n", "\n", "#set historical reservoir level data\n", "rsv.historical_level.set(pd.Series([94.6,95.0], index=[starttime - pd.Timedelta(minutes = interval_length - offset), starttime - pd.Timedelta(hours=1)]))\n", "\n", "#run model\n", "run_model(shop2)" ] }, { "cell_type": "markdown", "id": "b75e703d", "metadata": {}, "source": [ "Again we plot the resulting reservoir levels. We see that now the level variation is equal to the maximum allowed value of 0.4 m within all of the time periods, including the very first time period for which the historical data is used." ] }, { "cell_type": "code", "execution_count": 7, "id": "e0c24b21", "metadata": { "Collapsed": "false" }, "outputs": [ { "data": { "application/vnd.plotly.v1+json": { "config": { "plotlyServerURL": "https://plot.ly" }, "data": [ { "name": "Reservoir level", "type": "scatter", "x": [ "2023-01-01T00:00:00", "2023-01-01T01:00:00", "2023-01-01T02:00:00", "2023-01-01T03:00:00", "2023-01-01T04:00:00", "2023-01-01T05:00:00", "2023-01-01T06:00:00", "2023-01-01T07:00:00", "2023-01-01T08:00:00", "2023-01-01T09:00:00", "2023-01-01T10:00:00", "2023-01-01T11:00:00", "2023-01-01T12:00:00", "2023-01-01T13:00:00", "2023-01-01T14:00:00", "2023-01-01T15:00:00", "2023-01-01T16:00:00", "2023-01-01T17:00:00", "2023-01-01T18:00:00", "2023-01-01T19:00:00", "2023-01-01T20:00:00", "2023-01-01T21:00:00", "2023-01-01T22:00:00", "2023-01-01T23:00:00", "2023-01-02T00:00:00" ], "y": [ 95.0, 94.955, 94.715, 94.67, 94.625, 94.55499999999999, 94.315, 94.27, 94.225, 94.15499999999999, 93.91499999999998, 93.86999999999998, 93.82499999999999, 93.755, 93.51499999999999, 93.46999999999998, 93.425, 93.35499999999998, 93.11499999999998, 93.06999999999998, 93.02499999999998, 92.95499999999997, 92.71499999999997, 92.55499999999996, 92.31499999999997 ] }, { "line": { "color": "blue", "dash": "dash" }, "mode": "lines", "name": "Historical level", "type": "scatter", "x": [ "2022-12-31T22:00:00", "2022-12-31T23:00:00", "2023-01-01T00:00:00" ], "y": [ 94.6, 95.0, 95.0 ] }, { "line": { "color": "darkred", "dash": "dash" }, "mode": "lines", "showlegend": false, "type": "scatter", "x": [ "2022-12-31T22:00:00", "2023-01-01T02:00:00" ], "y": [ 95.0, 95.0 ] }, { "line": { "color": "darkred", "dash": "dot" }, "mode": "lines", "showlegend": false, "type": "scatter", "x": [ "2022-12-31T22:00:00", "2023-01-01T02:00:00" ], "y": [ 94.6, 94.6 ] }, { "line": { "color": "red" }, "mode": "lines", "showlegend": false, "type": "scatter", "x": [ "2022-12-31T23:00:00", "2022-12-31T23:00:00" ], "y": [ 94.6, 95.0 ] }, { "mode": "text", "showlegend": false, "text": [ "Δh = 0.40" ], "textfont": { "color": "red" }, "textposition": "bottom center", "type": "scatter", "x": [ "2023-01-01T00:00:00" ], "y": [ 94.35 ] }, { "line": { "color": "black", "dash": "dot" }, "mode": "lines", "showlegend": false, "type": "scatter", "x": [ "2022-12-31T22:00:00", "2022-12-31T22:00:00" ], "y": [ 90.0, 96.0 ] }, { "line": { "color": "darkred", "dash": "dash" }, "mode": "lines", "showlegend": false, "type": "scatter", "x": [ "2023-01-01T02:00:00", "2023-01-01T06:00:00" ], "y": [ 94.715, 94.715 ] }, { "line": { "color": "darkred", "dash": "dot" }, "mode": "lines", "showlegend": false, "type": "scatter", "x": [ "2023-01-01T02:00:00", "2023-01-01T06:00:00" ], "y": [ 94.315, 94.315 ] }, { "line": { "color": "red" }, "mode": "lines", "showlegend": false, "type": "scatter", "x": [ "2023-01-01T03:00:00", "2023-01-01T03:00:00" ], "y": [ 94.315, 94.715 ] }, { "mode": "text", "showlegend": false, "text": [ "Δh = 0.40" ], "textfont": { "color": "red" }, "textposition": "bottom center", "type": "scatter", "x": [ "2023-01-01T04:00:00" ], "y": [ 94.065 ] }, { "line": { "color": "black", "dash": "dot" }, "mode": "lines", "showlegend": false, "type": "scatter", "x": [ "2023-01-01T02:00:00", "2023-01-01T02:00:00" ], "y": [ 90.0, 96.0 ] }, { "line": { "color": "darkred", "dash": "dash" }, "mode": "lines", "showlegend": false, "type": "scatter", "x": [ "2023-01-01T06:00:00", "2023-01-01T10:00:00" ], "y": [ 94.315, 94.315 ] }, { "line": { "color": "darkred", "dash": "dot" }, "mode": "lines", "showlegend": false, "type": "scatter", "x": [ "2023-01-01T06:00:00", "2023-01-01T10:00:00" ], "y": [ 93.91499999999998, 93.91499999999998 ] }, { "line": { "color": "red" }, "mode": "lines", "showlegend": false, "type": "scatter", "x": [ "2023-01-01T07:00:00", "2023-01-01T07:00:00" ], "y": [ 93.91499999999998, 94.315 ] }, { "mode": "text", "showlegend": false, "text": [ "Δh = 0.40" ], "textfont": { "color": "red" }, "textposition": "bottom center", "type": "scatter", "x": [ "2023-01-01T08:00:00" ], "y": [ 93.66499999999998 ] }, { "line": { "color": "black", "dash": "dot" }, "mode": "lines", "showlegend": false, "type": "scatter", "x": [ "2023-01-01T06:00:00", "2023-01-01T06:00:00" ], "y": [ 90.0, 96.0 ] }, { "line": { "color": "darkred", "dash": "dash" }, "mode": "lines", "showlegend": false, "type": "scatter", "x": [ "2023-01-01T10:00:00", "2023-01-01T14:00:00" ], "y": [ 93.91499999999998, 93.91499999999998 ] }, { "line": { "color": "darkred", "dash": "dot" }, "mode": "lines", "showlegend": false, "type": "scatter", "x": [ "2023-01-01T10:00:00", "2023-01-01T14:00:00" ], "y": [ 93.51499999999999, 93.51499999999999 ] }, { "line": { "color": "red" }, "mode": "lines", "showlegend": false, "type": "scatter", "x": [ "2023-01-01T11:00:00", "2023-01-01T11:00:00" ], "y": [ 93.51499999999999, 93.91499999999998 ] }, { "mode": "text", "showlegend": false, "text": [ "Δh = 0.40" ], "textfont": { "color": "red" }, "textposition": "bottom center", "type": "scatter", "x": [ "2023-01-01T12:00:00" ], "y": [ 93.26499999999999 ] }, { "line": { "color": "black", "dash": "dot" }, "mode": "lines", "showlegend": false, "type": "scatter", "x": [ "2023-01-01T10:00:00", "2023-01-01T10:00:00" ], "y": [ 90.0, 96.0 ] }, { "line": { "color": "darkred", "dash": "dash" }, "mode": "lines", "showlegend": false, "type": "scatter", "x": [ "2023-01-01T14:00:00", "2023-01-01T18:00:00" ], "y": [ 93.51499999999999, 93.51499999999999 ] }, { "line": { "color": "darkred", "dash": "dot" }, "mode": "lines", "showlegend": false, "type": "scatter", "x": [ "2023-01-01T14:00:00", "2023-01-01T18:00:00" ], "y": [ 93.11499999999998, 93.11499999999998 ] }, { "line": { "color": "red" }, "mode": "lines", "showlegend": false, "type": "scatter", "x": [ "2023-01-01T15:00:00", "2023-01-01T15:00:00" ], "y": [ 93.11499999999998, 93.51499999999999 ] }, { "mode": "text", "showlegend": false, "text": [ "Δh = 0.40" ], "textfont": { "color": "red" }, "textposition": "bottom center", "type": "scatter", "x": [ "2023-01-01T16:00:00" ], "y": [ 92.86499999999998 ] }, { "line": { "color": "black", "dash": "dot" }, "mode": "lines", "showlegend": false, "type": "scatter", "x": [ "2023-01-01T14:00:00", "2023-01-01T14:00:00" ], "y": [ 90.0, 96.0 ] }, { "line": { "color": "darkred", "dash": "dash" }, "mode": "lines", "showlegend": false, "type": "scatter", "x": [ "2023-01-01T18:00:00", "2023-01-01T22:00:00" ], "y": [ 93.11499999999998, 93.11499999999998 ] }, { "line": { "color": "darkred", "dash": "dot" }, "mode": "lines", "showlegend": false, "type": "scatter", "x": [ "2023-01-01T18:00:00", "2023-01-01T22:00:00" ], "y": [ 92.71499999999997, 92.71499999999997 ] }, { "line": { "color": "red" }, "mode": "lines", "showlegend": false, "type": "scatter", "x": [ "2023-01-01T19:00:00", "2023-01-01T19:00:00" ], "y": [ 92.71499999999997, 93.11499999999998 ] }, { "mode": "text", "showlegend": false, "text": [ "Δh = 0.40" ], "textfont": { "color": "red" }, "textposition": "bottom center", "type": "scatter", "x": [ "2023-01-01T20:00:00" ], "y": [ 92.46499999999997 ] }, { "line": { "color": "black", "dash": "dot" }, "mode": "lines", "showlegend": false, "type": "scatter", "x": [ "2023-01-01T18:00:00", "2023-01-01T18:00:00" ], "y": [ 90.0, 96.0 ] }, { "line": { "color": "darkred", "dash": "dash" }, "mode": "lines", "showlegend": false, "type": "scatter", "x": [ "2023-01-01T22:00:00", "2023-01-02T02:00:00" ], "y": [ 92.71499999999997, 92.71499999999997 ] }, { "line": { "color": "darkred", "dash": "dot" }, "mode": "lines", "showlegend": false, "type": "scatter", "x": [ "2023-01-01T22:00:00", "2023-01-02T02:00:00" ], "y": [ 92.31499999999997, 92.31499999999997 ] }, { "line": { "color": "red" }, "mode": "lines", "showlegend": false, "type": "scatter", "x": [ "2023-01-01T23:00:00", "2023-01-01T23:00:00" ], "y": [ 92.31499999999997, 92.71499999999997 ] }, { "mode": "text", "showlegend": false, "text": [ "Δh = 0.40" ], "textfont": { "color": "red" }, "textposition": "bottom center", "type": "scatter", "x": [ "2023-01-02T00:00:00" ], "y": [ 92.06499999999997 ] }, { "line": { "color": "black", "dash": "dot" }, "mode": "lines", "showlegend": false, "type": "scatter", "x": [ "2023-01-01T22:00:00", "2023-01-01T22:00:00" ], "y": [ 90.0, 96.0 ] }, { "line": { "color": "darkred", "dash": "dash" }, "mode": "lines", "name": "Max period level", "type": "scatter", "x": [ "2023-01-01T22:00:00", "2023-01-02T02:00:00" ], "y": [ 92.71499999999997, 92.71499999999997 ] }, { "line": { "color": "darkred", "dash": "dot" }, "mode": "lines", "name": "Min period level", "type": "scatter", "x": [ "2023-01-01T22:00:00", "2023-01-02T02:00:00" ], "y": [ 92.31499999999997, 92.31499999999997 ] }, { "line": { "color": "black", "dash": "dot" }, "mode": "lines", "name": "Period start", "type": "scatter", "x": [ "2023-01-01T22:00:00", "2023-01-01T22:00:00" ], "y": [ 90.0, 96.0 ] }, { "line": { "color": "grey", "dash": "dot" }, "mode": "lines", "name": "Optimization start", "type": "scatter", "x": [ "2023-01-01T00:00:00", "2023-01-01T00:00:00" ], "y": [ 90.0, 96.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": "Optimization with dynamic level limit constraints" }, "xaxis": { "title": { "text": "Time" } }, "yaxis": { "title": { "text": "masl" } } } }, "text/html": [ "
" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "plot_period_levels(starttime, rsv, offset, interval_length, lrl, \"Optimization with dynamic level limit constraints\")" ] }, { "cell_type": "markdown", "id": "2aed567e", "metadata": {}, "source": [ "Note that the final constraint period only contains two time steps within the optimization, since the total horizon is 24 hours long and an offset of two hours is used. The dynamic level limit constraint is still enforced on this final two hour long period." ] } ], "metadata": { "jupytext": { "text_representation": { "extension": ".md", "format_name": "myst", "format_version": 0.13, "jupytext_version": "1.17.2" } }, "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.11" }, "source_map": [ 12, 23, 35, 41, 51, 57, 65, 69, 73, 77, 85, 93, 118, 122, 126 ] }, "nbformat": 4, "nbformat_minor": 5 }