{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "\n", "*This notebook contains material from [Controlling Natural Watersheds](https://jckantor.github.io/Controlling-Natural-Watersheds);\n", "content is available [on Github](https://github.com/jckantor/Controlling-Natural-Watersheds.git).*" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "\n", "< [Lumped Parameter Model for Lake Dynamics](http://nbviewer.jupyter.org/github/jckantor/Controlling-Natural-Watersheds/blob/master/notebooks/05.01-Lumped_Parameter_Model_for_Lake_Dynamics.ipynb) | [Contents](toc.ipynb) | [Model Predictive Control](http://nbviewer.jupyter.org/github/jckantor/Controlling-Natural-Watersheds/blob/master/notebooks/05.03-Model_Predictive_Control.ipynb) >
"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Implementation of Rainy Lake Rule Curves with Feedback Control"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"* Direct Estimate of Rainy Lake Inflows using the Balance Equation\n",
"* Constructing a Simulation Data Set for Rainy Lake\n",
"* Matlab/Simulink Model\n",
"* Simulation Results"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Initialization"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Initilization of the graphics system and computational modules used in this IPython notebook."
]
},
{
"cell_type": "code",
"execution_count": 287,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"# Display graphics inline with the notebook\n",
"%matplotlib notebook\n",
"\n",
"# Standard Python modules\n",
"import numpy as np\n",
"import matplotlib.pyplot as plt\n",
"import matplotlib.dates as mdates\n",
"import pandas as pd\n",
"import os\n",
"import datetime\n",
"\n",
"# Modules to display images and data tables\n",
"from IPython.display import Image\n",
"from IPython.core.display import display\n",
"\n",
"# Data Directory\n",
"dir = '../data/'\n",
"img = '../images/'"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Direct Estimate of Rainy Lake Inflows using the Balance Equation"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"A crude estimate of inflows can be found starting with the balance equation\n",
"\n",
"$$A_{RL}\\frac{dH_{RL}}{dt} = I_{RL}(t) - O_{RL}(t)$$\n",
"\n",
"where the subscript RL refers to Rainy Lake, and $A$, $H$, $I$, and $O$ refer to area, lake level, inflow, and outflow, respectively. Discretizing in time\n",
"\n",
"$$\\frac{A_{RL}}{\\Delta t}\\left(H_{RL}(k+1)-H_{RL}(k)\\right) = I_{RL}(k) - O_{RL}(k)$$\n",
"\n",
"Since the sole output flow from Rainy Lake is through Rainy River, we can solve for inflow\n",
"\n",
"$$I_{RL}(k) = \\frac{A_{RL}}{\\Delta t}\\left(H_{RL}(k+1)-H_{RL}(k)\\right) + O_{RL}(k)$$\n",
"\n",
"The estimation method is sensitive to small errors in level measurement and therefore provides an estimate of the inflow plagued by excessive noise."
]
},
{
"cell_type": "code",
"execution_count": 288,
"metadata": {
"collapsed": false,
"scrolled": true
},
"outputs": [
{
"data": {
"application/javascript": [
"/* Put everything inside the global mpl namespace */\n",
"window.mpl = {};\n",
"\n",
"mpl.get_websocket_type = function() {\n",
" if (typeof(WebSocket) !== 'undefined') {\n",
" return WebSocket;\n",
" } else if (typeof(MozWebSocket) !== 'undefined') {\n",
" return MozWebSocket;\n",
" } else {\n",
" alert('Your browser does not have WebSocket support.' +\n",
" 'Please try Chrome, Safari or Firefox ≥ 6. ' +\n",
" 'Firefox 4 and 5 are also supported but you ' +\n",
" 'have to enable WebSockets in about:config.');\n",
" };\n",
"}\n",
"\n",
"mpl.figure = function(figure_id, websocket, ondownload, parent_element) {\n",
" this.id = figure_id;\n",
"\n",
" this.ws = websocket;\n",
"\n",
" this.supports_binary = (this.ws.binaryType != undefined);\n",
"\n",
" if (!this.supports_binary) {\n",
" var warnings = document.getElementById(\"mpl-warnings\");\n",
" if (warnings) {\n",
" warnings.style.display = 'block';\n",
" warnings.textContent = (\n",
" \"This browser does not support binary websocket messages. \" +\n",
" \"Performance may be slow.\");\n",
" }\n",
" }\n",
"\n",
" this.imageObj = new Image();\n",
"\n",
" this.context = undefined;\n",
" this.message = undefined;\n",
" this.canvas = undefined;\n",
" this.rubberband_canvas = undefined;\n",
" this.rubberband_context = undefined;\n",
" this.format_dropdown = undefined;\n",
"\n",
" this.image_mode = 'full';\n",
"\n",
" this.root = $('
"
]
}
],
"metadata": {
"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.7.3"
}
},
"nbformat": 4,
"nbformat_minor": 2
}