Skip to content

Commit

Permalink
fix equations
Browse files Browse the repository at this point in the history
  • Loading branch information
RolfHut committed Dec 11, 2024
1 parent 1261aca commit cbe6883
Showing 1 changed file with 78 additions and 13 deletions.
91 changes: 78 additions & 13 deletions book/1_modelling_intro_HBV/Exercise1.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
},
{
"cell_type": "code",
"execution_count": 1,
"execution_count": 2,
"metadata": {
"editable": true,
"slideshow": {
Expand Down Expand Up @@ -117,9 +117,11 @@
"\n",
"At first we will consider the reservoir without the external drivers ```P``` and ```E``` and we assume that Q is equal to:\n",
"\n",
"$$\n",
"\\begin{equation}\n",
"Q = k S ^\\alpha\n",
"\\end{equation}\n",
"$$\n",
"\n",
"Next to this, we also assmume a linear reservoir, so $\\alpha$ is equal to 1.\n",
"\n",
Expand All @@ -133,26 +135,35 @@
"\n",
"An simple example of a numerical solution is the explicit forward Euler method. This method calculates the state of a system at each time step considering the state of the system at the previous time step and rate of changes:\n",
"\n",
"$$\n",
"\\begin{equation}\n",
"S(t + \\Delta t) = F(S(t))\n",
"\\end{equation}\n",
"$$\n",
"\n",
"If we consider the linear reservoir problem without the external drivers, we obtain:\n",
"\n",
"$$\n",
"\\begin{equation}\n",
"\\frac{dS(t)}{dt} = -k S(t) ^\\alpha\n",
"\\end{equation}\n",
"$$\n",
"\n",
"The forward Euler method yields:\n",
"\n",
"$$\n",
"\\begin{equation}\n",
"\\frac{S(t + \\Delta t) - S(t)}{\\Delta t} = -kS(t)^\\alpha\n",
"\\end{equation}\n",
"$$\n",
"\n",
"This results in the numerical solution:\n",
"\n",
"$$\n",
"\\begin{equation}\n",
"S(t + \\Delta t) = S(t) + - k \\Delta t k S(t) ^\\alpha\n",
"\\end{equation}\n",
"$$\n",
"\n",
"Hence, if $ S(t) $ is known, $ S(t + \\Delta t) $ can be calculated in one iteration. The big assumption in the forward Euler model is that $ S\\left(t\\right) $ is relatively constant during the timestep. This may not always be true. If $S\\left(t\\right)$ changes fast smaller timesteps need to be used to not make too big of an error. Other, more complicated methods to numerically solve differential equations exist such as Runga-Kutta. See the material of the MUDE course for more information on those. In hydrology it is always important to weigh if the error introduced by your numerical scheme is significant compared to the error introduced by the fact that the model is not perfect to begin with."
]
Expand Down Expand Up @@ -187,7 +198,7 @@
},
{
"cell_type": "code",
"execution_count": 2,
"execution_count": 3,
"metadata": {
"editable": true,
"slideshow": {
Expand All @@ -207,8 +218,14 @@
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {},
"execution_count": 4,
"metadata": {
"editable": true,
"slideshow": {
"slide_type": ""
},
"tags": []
},
"outputs": [],
"source": [
"def analytical_solve():\n",
Expand All @@ -219,8 +236,14 @@
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"execution_count": 5,
"metadata": {
"editable": true,
"slideshow": {
"slide_type": ""
},
"tags": []
},
"outputs": [],
"source": [
"def numerical_solve():\n",
Expand All @@ -232,7 +255,13 @@
},
{
"cell_type": "markdown",
"metadata": {},
"metadata": {
"editable": true,
"slideshow": {
"slide_type": ""
},
"tags": []
},
"source": [
"### Part 3\n",
"\n",
Expand All @@ -244,13 +273,25 @@
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"metadata": {
"editable": true,
"slideshow": {
"slide_type": ""
},
"tags": []
},
"outputs": [],
"source": []
},
{
"cell_type": "markdown",
"metadata": {},
"metadata": {
"editable": true,
"slideshow": {
"slide_type": ""
},
"tags": []
},
"source": [
"## 2. Linear Reservoir with External Drivers\n",
"\n",
Expand All @@ -261,7 +302,13 @@
},
{
"cell_type": "markdown",
"metadata": {},
"metadata": {
"editable": true,
"slideshow": {
"slide_type": ""
},
"tags": []
},
"source": [
"### Part 4\n",
"\n",
Expand All @@ -273,13 +320,25 @@
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"metadata": {
"editable": true,
"slideshow": {
"slide_type": ""
},
"tags": []
},
"outputs": [],
"source": []
},
{
"cell_type": "markdown",
"metadata": {},
"metadata": {
"editable": true,
"slideshow": {
"slide_type": ""
},
"tags": []
},
"source": [
"### Bonus Question\n",
"\n",
Expand All @@ -289,7 +348,13 @@
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"metadata": {
"editable": true,
"slideshow": {
"slide_type": ""
},
"tags": []
},
"outputs": [],
"source": []
}
Expand Down

0 comments on commit cbe6883

Please sign in to comment.