---
title: "`outfloweR`-Exercises"
author: "Thomas Petzoldt"
date: "`r Sys.Date()`"
bibliography: bib.bib
vignette: >
  %\VignetteIndexEntry{outfloweR: Exercises}
  %\VignetteEngine{quarto::html}
  %\VignetteEncoding{UTF-8}
---


```{r opts, echo = FALSE, message = FALSE}
## preload it to suppress messages
library("dplyr")
## make the example reproducible
set.seed(1234)
```

Preface
=======

This exercise depends on a so-called shiny-app that is currently found on:

[https://weblab.hydro.tu-dresden.de/app/outflower/](https://weblab.hydro.tu-dresden.de/app/outflower/)

Introduction
============

Let's assume a theoretical drinking water reservoir with a maximum depth of about 
50m and a volume of 60 Mio m^3^.

Due to varying meteorological and hydrological conditions, the onset and offset 
of stratification varies from year to year, with an average start and end day 
(given as day of year) given in Table @tbl-stratification.

|Year | Start (day) | End (day) |
|----:|------------:|----------:|
| 1990|  116        | 299       |
| 2000|  112        | 311       |
| 2010|  107        | 321       |
| 2020|  102        | 333       |
| 2025|  100        | 338       |

: Average start and end days of stratification in a reservoir {#tbl-stratification}


We see a clear trend of an elongated stratification due to climate warming. 
This effect has marked influence on water quality and the avaliablility of cold
hypolimnetic water for drinking water production.

Here we should also note, that while the start is mostly climate induced, the end day
is also influenced by management. So the end of the stratification is determined by either

* by cooling of the water column in autumn and in consequence thermal convection, or
* by management, when the hypolimnion volume is exhausted by water abstraction


This combined effect can be estimated by hydrophysical modeling,
see for example @Feldbauer2020. 

But as to the **outfloweR-App simulates only mass balance, we have to set the 
value for the onset and "final" end of stratification as input parameter, where 
the "final end" would be an approximate time of convection.

The volume-balance App is, however, able to estimate an earlier stratification 
end due to management. In such cases, temperature may still be relatively high 
with negative consequences to water quality and higher costs of drinking water
production in the water works.

Exercises
=========

In the following, let's explore the relationship between the **day** and the **initial 
volume** at the onset of stratification on the availability of hypolimnetic water.
Here we consider an earlier end of stratification as potentially negative for the water
quality. This is of course a simplification, because also other factors play a role that
need either to be measured or to be modeled with more complex hydrophysical and water quality models.

Nevertheless, the examples below can give some fundamental insights.

### Exercise 1

Let's assume we have the climate from 2000.

1. Determine the minimum initial volume, that is sufficient for maintaining 
stratification until October 1st (day 274) with standard management.
    a) in a normal year
    b) in a dry year
    c) in a wet year
2. Repeat the same experiment with strategy "Environmental discharge from epilimnion"


Task: Create a table summarizing your findings for both management strategies 
and all three year types. Discuss the results, providing evidence from the app's 
plots and numerical outputs. How can the surprising results of epilimnetic discharge 
in the dry year be explained? Look at the volume of the environmental discharge, 
possibly using a cumulative plot.

### Exercise 2


Let's assume we the climate from 2025.

1. Determine the minimum initial volume, that is sufficient for maintaining 
stratification until October 1st (day 274) with standard management.
    a) in a normal year
    b) in a dry year
    c) in a wet year
2. Repeat the same experiment with strategy "Environmental discharge from epilimnion"


**Task:** Create a table summarizing your findings. Discuss the results, again 
providing evidence from the app. How do these results compare to Exercise 1, 
and what insights do they provide about the climate trend? How can the surprising 
results of epilimnetic discharge in the dry year be explained?
<!--
as.Date("2001-09-30") - as.Date("2000-12-31")
-->

### Exercise 3


Let's assume we have wet year and an initial volume of 60 Mio m^3^:

1. How long will the stratification last
    a) for a year with the climate of 1990
    b) for a year with the climate of 2000
    c) for a year with the climate of 2025
2. Repeat the same experiment with strategy "Environmental discharge from epilimnion"
3. Now use the theoretical "summer flood" example to understand the result.


**Task:** Create a table summarizing your findings for all climate years and strategies. 
Why can the paradox be explained that high inflow in summer results in lower 
availability of high-quality hypolimnetic raw water?
Consider the "cold inflow to hypolimnion" strategy. 
It is not completely realistic, but points to another management option – 
how might it theoretically help?


### Exercise 4


In the examples above, fixed time series for inflows and outflows were used in a way,
so that the total volume was balanced. In a real reservoir, we should expect decreasing 
volume during the summer. The effect can be shown in the app using
"Constant in - and outflows".

What happens **in the standard strategy** in consecutive dry years:

* Inflow = 0.1, raw water = 0.1 and environmental outflow = 0.05 Mio m^3^

1. In the first year?
2. In a 2nd year with the same in- and outflows, but initial volume from the previous year?
3. in a 3rd year?

**Task:** Create a table summarizing the initial and final total and hypolimnion 
volumes and stratification durations for each year. 
Discuss the results. How does the reservoir's hypolimnion volume change over 
multiple dry years under this constant management strategy, and what implications 
does this have for water supply?




Acknowledgments
===============

Many thanks to Johannes Feldbauer for his contributions and discussion. 
This documentation was written using **knitr** [@knitr] and **Quarto**
[@quarto].


References
==========

<div id="refs"></div>

----


