From c5f455d1704314770ac676aacee273459cbfe0e2 Mon Sep 17 00:00:00 2001
From: David <david.dorchies@inrae.fr>
Date: Mon, 31 Oct 2022 08:06:50 +0100
Subject: [PATCH] docs: Modify example RunModel.Supervision

Refs #100
---
 man-examples/CreateGRiwrm.R                   |  2 +
 man-examples/RunModel.Supervisor.R            | 43 +++++++++++--------
 man/CreateController.Rd                       | 43 +++++++++++--------
 man/CreateGRiwrm.Rd                           |  2 +
 man/CreateInputsModel.GRiwrm.Rd               |  2 +-
 man/CreateRunOptions.Rd                       |  2 +-
 man/CreateSupervisor.Rd                       | 43 +++++++++++--------
 man/RunModel.GRiwrmInputsModel.Rd             |  2 +-
 man/RunModel.Supervisor.Rd                    | 43 +++++++++++--------
 man/plot.GRiwrm.Rd                            |  2 +
 man/plot.GRiwrmOutputsModel.Rd                |  2 +-
 man/plot.Qm3s.Rd                              |  2 +-
 .../V06_Modelling_regulated_diversion.Rmd     |  6 +--
 13 files changed, 118 insertions(+), 76 deletions(-)

diff --git a/man-examples/CreateGRiwrm.R b/man-examples/CreateGRiwrm.R
index 718deb6..8a05e67 100644
--- a/man-examples/CreateGRiwrm.R
+++ b/man-examples/CreateGRiwrm.R
@@ -1,3 +1,5 @@
+library(airGRiwrm)
+
 #########################################
 # Network of 2 nodes distant of 150 km: #
 #########################################
diff --git a/man-examples/RunModel.Supervisor.R b/man-examples/RunModel.Supervisor.R
index 6eacf4f..7eb68c0 100644
--- a/man-examples/RunModel.Supervisor.R
+++ b/man-examples/RunModel.Supervisor.R
@@ -2,9 +2,9 @@
 # An example of reservoir management on an hypothetical dam at station "54095"
 # on the Severn river build to support low-flows at "54057"
 ###############################################################################
-# A minimum flow of 20 m3/s is maintained at the dam location and an extra-release
+# A minimum flow of 50 m3/s is maintained at the dam location and an extra-release
 # is provided when the flow at the downstream station "54057" cross a minimum
-# threshold of 45 m3/s. The dam has a storage capacity of 60 millions m3
+# threshold of 65 m3/s. The dam has a storage capacity of 650 millions m3
 ###############################################################################
 library(airGRiwrm)
 
@@ -57,6 +57,8 @@ sv <- CreateSupervisor(IM_severn)
 # The Supervisor variable is an environment which can be available in
 # the controller function for storing and exchange data during the simulation
 sv$Vres <- 0 # Reservoir storage time series
+# Record of the last decision to estimate the natural flow
+sv$lastU <- 0
 
 # Dam management is modeled by a controller
 # This controller usually releases Qmin and provides
@@ -70,15 +72,20 @@ sv$Vres <- 0 # Reservoir storage time series
 factoryDamLogic <- function(sv, Vmin, Vmax, Qmin, Qthreshold) {
   function(Y) {
     # Filling of the reservoir
-    sv$Vres <- c(sv$Vres, tail(sv$Vres, 1) + Y[1])
+    V <- sv$Vres[length(sv$Vres)] + Y[1]
+    # Estimate natural flow at low-flow support location
+    Qnat <- Y[2] - sv$lastU
     # The release is the max between: overflow, low-flow support and minimum flow
-    U <- U <- max(tail(sv$Vres, 1) - Vmax, Qthreshold - Y[2], Qmin)
-    sv$Vres[length(sv$Vres)] <- tail(sv$Vres, 1) - U
-    if (tail(sv$Vres, 1) < Vmin) {
+    U <- max(V - Vmax, Qthreshold - Qnat, Qmin)
+    V <- V - U
+    if (V < Vmin) {
       # Reservoir is empty
-      U <- U - (Vmin - tail(sv$Vres, 1))
-      sv$Vres[length(sv$Vres)] <- Vmin
+      U <- U - (Vmin - V)
+      V <- Vmin
     }
+    # Record state of the reservoir and release
+    sv$Vres[length(sv$Vres) + 1] <- V
+    sv$lastU <- U
     return(U)
   }
 }
@@ -87,17 +94,17 @@ factoryDamLogic <- function(sv, Vmin, Vmax, Qmin, Qthreshold) {
 funDamLogic <- factoryDamLogic(
   sv = sv, # The Supervisor which store the states of reservoir storage
   Vmin = 0, # Minimum volume in the reservoir (m3)
-  Vmax = 60 * 1E6, # Maximum volume in the reservoir (m3)
-  Qmin = 20 * 86400, # Min flow to maintain downstream the reservoir (m3/day)
-  Qthreshold = 45 * 86400 # Min flow threshold to support at station 54057 (m3/day)
+  Vmax = 650 * 1E6, # Maximum volume in the reservoir (m3)
+  Qmin = 50 * 86400, # Min flow to maintain downstream the reservoir (m3/day)
+  Qthreshold = 65 * 86400 # Min flow threshold to support at station 54057 (m3/day)
 )
 
 CreateController(sv, "DamRelease", Y = c("54095", "54057"), U = c("Dam"), FUN = funDamLogic)
 
 # GRiwrmRunOptions object simulation of the hydrological year 2002-2003
 IndPeriod_Run <- which(
-  DatesR >= as.POSIXct("2002-10-15", tz = "UTC") &
-  DatesR <= as.POSIXct("2003-10-15", tz = "UTC")
+  DatesR >= as.POSIXct("2002-11-01", tz = "UTC") &
+  DatesR <= as.POSIXct("2003-11-01", tz = "UTC")
 )
 IndPeriod_WarmUp <- seq.int(IndPeriod_Run[1] - 366, IndPeriod_Run[1] - 1)
 RO_severn <- CreateRunOptions(
@@ -111,14 +118,16 @@ P_severn <- readRDS(system.file("vignettes", "ParamV02.RDS", package = "airGRiwr
 
 # The Supervisor is used instead of InputsModel for running the model
 OM_dam <- RunModel(sv,
-                      RunOptions = RO_severn,
-                      Param = P_severn)
+                   RunOptions = RO_severn,
+                   Param = P_severn)
 
 # Plotting the time series of flows and reservoir storage
 oldpar <- par(mfrow=c(2,1), mar = c(2.5,4,1,1))
 plot(attr(OM_dam, "Qm3s")[, c("DatesR", "54095", "Dam", "54057")],
      ylim = c(0, 200))
 Vres <- data.frame(DatesR = attr(OM_dam, "Qm3s")$DatesR,
-                   V_reservoir = sv$Vres)
-plot.Qm3s(Vres)
+                   V_reservoir = sv$Vres / 1E6)
+plot.Qm3s(Vres,
+          main = "Simulated reservoir storage",
+          ylab = expression("Storage (Mm"^"3" * ")"))
 par(oldpar)
diff --git a/man/CreateController.Rd b/man/CreateController.Rd
index 93c1021..ea3ff25 100644
--- a/man/CreateController.Rd
+++ b/man/CreateController.Rd
@@ -47,9 +47,9 @@ at their location for the current time step of calculation of the model.
 # An example of reservoir management on an hypothetical dam at station "54095"
 # on the Severn river build to support low-flows at "54057"
 ###############################################################################
-# A minimum flow of 20 m3/s is maintained at the dam location and an extra-release
+# A minimum flow of 50 m3/s is maintained at the dam location and an extra-release
 # is provided when the flow at the downstream station "54057" cross a minimum
-# threshold of 45 m3/s. The dam has a storage capacity of 60 millions m3
+# threshold of 65 m3/s. The dam has a storage capacity of 650 millions m3
 ###############################################################################
 library(airGRiwrm)
 
@@ -102,6 +102,8 @@ sv <- CreateSupervisor(IM_severn)
 # The Supervisor variable is an environment which can be available in
 # the controller function for storing and exchange data during the simulation
 sv$Vres <- 0 # Reservoir storage time series
+# Record of the last decision to estimate the natural flow
+sv$lastU <- 0
 
 # Dam management is modeled by a controller
 # This controller usually releases Qmin and provides
@@ -115,15 +117,20 @@ sv$Vres <- 0 # Reservoir storage time series
 factoryDamLogic <- function(sv, Vmin, Vmax, Qmin, Qthreshold) {
   function(Y) {
     # Filling of the reservoir
-    sv$Vres <- c(sv$Vres, tail(sv$Vres, 1) + Y[1])
+    V <- sv$Vres[length(sv$Vres)] + Y[1]
+    # Estimate natural flow at low-flow support location
+    Qnat <- Y[2] - sv$lastU
     # The release is the max between: overflow, low-flow support and minimum flow
-    U <- U <- max(tail(sv$Vres, 1) - Vmax, Qthreshold - Y[2], Qmin)
-    sv$Vres[length(sv$Vres)] <- tail(sv$Vres, 1) - U
-    if (tail(sv$Vres, 1) < Vmin) {
+    U <- max(V - Vmax, Qthreshold - Qnat, Qmin)
+    V <- V - U
+    if (V < Vmin) {
       # Reservoir is empty
-      U <- U - (Vmin - tail(sv$Vres, 1))
-      sv$Vres[length(sv$Vres)] <- Vmin
+      U <- U - (Vmin - V)
+      V <- Vmin
     }
+    # Record state of the reservoir and release
+    sv$Vres[length(sv$Vres) + 1] <- V
+    sv$lastU <- U
     return(U)
   }
 }
@@ -132,17 +139,17 @@ factoryDamLogic <- function(sv, Vmin, Vmax, Qmin, Qthreshold) {
 funDamLogic <- factoryDamLogic(
   sv = sv, # The Supervisor which store the states of reservoir storage
   Vmin = 0, # Minimum volume in the reservoir (m3)
-  Vmax = 60 * 1E6, # Maximum volume in the reservoir (m3)
-  Qmin = 20 * 86400, # Min flow to maintain downstream the reservoir (m3/day)
-  Qthreshold = 45 * 86400 # Min flow threshold to support at station 54057 (m3/day)
+  Vmax = 650 * 1E6, # Maximum volume in the reservoir (m3)
+  Qmin = 50 * 86400, # Min flow to maintain downstream the reservoir (m3/day)
+  Qthreshold = 65 * 86400 # Min flow threshold to support at station 54057 (m3/day)
 )
 
 CreateController(sv, "DamRelease", Y = c("54095", "54057"), U = c("Dam"), FUN = funDamLogic)
 
 # GRiwrmRunOptions object simulation of the hydrological year 2002-2003
 IndPeriod_Run <- which(
-  DatesR >= as.POSIXct("2002-10-15", tz = "UTC") &
-  DatesR <= as.POSIXct("2003-10-15", tz = "UTC")
+  DatesR >= as.POSIXct("2002-11-01", tz = "UTC") &
+  DatesR <= as.POSIXct("2003-11-01", tz = "UTC")
 )
 IndPeriod_WarmUp <- seq.int(IndPeriod_Run[1] - 366, IndPeriod_Run[1] - 1)
 RO_severn <- CreateRunOptions(
@@ -156,15 +163,17 @@ P_severn <- readRDS(system.file("vignettes", "ParamV02.RDS", package = "airGRiwr
 
 # The Supervisor is used instead of InputsModel for running the model
 OM_dam <- RunModel(sv,
-                      RunOptions = RO_severn,
-                      Param = P_severn)
+                   RunOptions = RO_severn,
+                   Param = P_severn)
 
 # Plotting the time series of flows and reservoir storage
 oldpar <- par(mfrow=c(2,1), mar = c(2.5,4,1,1))
 plot(attr(OM_dam, "Qm3s")[, c("DatesR", "54095", "Dam", "54057")],
      ylim = c(0, 200))
 Vres <- data.frame(DatesR = attr(OM_dam, "Qm3s")$DatesR,
-                   V_reservoir = sv$Vres)
-plot.Qm3s(Vres)
+                   V_reservoir = sv$Vres / 1E6)
+plot.Qm3s(Vres,
+          main = "Simulated reservoir storage",
+          ylab = expression("Storage (Mm"^"3" * ")"))
 par(oldpar)
 }
diff --git a/man/CreateGRiwrm.Rd b/man/CreateGRiwrm.Rd
index f2ee4db..cce3bc9 100644
--- a/man/CreateGRiwrm.Rd
+++ b/man/CreateGRiwrm.Rd
@@ -75,6 +75,8 @@ diversion
 }
 }
 \examples{
+library(airGRiwrm)
+
 #########################################
 # Network of 2 nodes distant of 150 km: #
 #########################################
diff --git a/man/CreateInputsModel.GRiwrm.Rd b/man/CreateInputsModel.GRiwrm.Rd
index 9a438b0..f77b5ce 100644
--- a/man/CreateInputsModel.GRiwrm.Rd
+++ b/man/CreateInputsModel.GRiwrm.Rd
@@ -142,7 +142,7 @@ db <- data.frame(id = c("Reservoir", "GaugingDown"),
 
 # Create GRiwrm object from the data.frame
 griwrm <- CreateGRiwrm(db)
-str(griwrm)
+plot(griwrm)
 
 # Formatting observations for the hydrological models
 # Each input data should be a matrix or a data.frame with the good id in the name of the column
diff --git a/man/CreateRunOptions.Rd b/man/CreateRunOptions.Rd
index 51c0478..b2765e8 100644
--- a/man/CreateRunOptions.Rd
+++ b/man/CreateRunOptions.Rd
@@ -85,7 +85,7 @@ db <- data.frame(id = c("Reservoir", "GaugingDown"),
 
 # Create GRiwrm object from the data.frame
 griwrm <- CreateGRiwrm(db)
-str(griwrm)
+plot(griwrm)
 
 # Formatting observations for the hydrological models
 # Each input data should be a matrix or a data.frame with the good id in the name of the column
diff --git a/man/CreateSupervisor.Rd b/man/CreateSupervisor.Rd
index 053aa41..526ff37 100644
--- a/man/CreateSupervisor.Rd
+++ b/man/CreateSupervisor.Rd
@@ -29,9 +29,9 @@ Creation of a Supervisor for handling regulation in a model
 # An example of reservoir management on an hypothetical dam at station "54095"
 # on the Severn river build to support low-flows at "54057"
 ###############################################################################
-# A minimum flow of 20 m3/s is maintained at the dam location and an extra-release
+# A minimum flow of 50 m3/s is maintained at the dam location and an extra-release
 # is provided when the flow at the downstream station "54057" cross a minimum
-# threshold of 45 m3/s. The dam has a storage capacity of 60 millions m3
+# threshold of 65 m3/s. The dam has a storage capacity of 650 millions m3
 ###############################################################################
 library(airGRiwrm)
 
@@ -84,6 +84,8 @@ sv <- CreateSupervisor(IM_severn)
 # The Supervisor variable is an environment which can be available in
 # the controller function for storing and exchange data during the simulation
 sv$Vres <- 0 # Reservoir storage time series
+# Record of the last decision to estimate the natural flow
+sv$lastU <- 0
 
 # Dam management is modeled by a controller
 # This controller usually releases Qmin and provides
@@ -97,15 +99,20 @@ sv$Vres <- 0 # Reservoir storage time series
 factoryDamLogic <- function(sv, Vmin, Vmax, Qmin, Qthreshold) {
   function(Y) {
     # Filling of the reservoir
-    sv$Vres <- c(sv$Vres, tail(sv$Vres, 1) + Y[1])
+    V <- sv$Vres[length(sv$Vres)] + Y[1]
+    # Estimate natural flow at low-flow support location
+    Qnat <- Y[2] - sv$lastU
     # The release is the max between: overflow, low-flow support and minimum flow
-    U <- U <- max(tail(sv$Vres, 1) - Vmax, Qthreshold - Y[2], Qmin)
-    sv$Vres[length(sv$Vres)] <- tail(sv$Vres, 1) - U
-    if (tail(sv$Vres, 1) < Vmin) {
+    U <- max(V - Vmax, Qthreshold - Qnat, Qmin)
+    V <- V - U
+    if (V < Vmin) {
       # Reservoir is empty
-      U <- U - (Vmin - tail(sv$Vres, 1))
-      sv$Vres[length(sv$Vres)] <- Vmin
+      U <- U - (Vmin - V)
+      V <- Vmin
     }
+    # Record state of the reservoir and release
+    sv$Vres[length(sv$Vres) + 1] <- V
+    sv$lastU <- U
     return(U)
   }
 }
@@ -114,17 +121,17 @@ factoryDamLogic <- function(sv, Vmin, Vmax, Qmin, Qthreshold) {
 funDamLogic <- factoryDamLogic(
   sv = sv, # The Supervisor which store the states of reservoir storage
   Vmin = 0, # Minimum volume in the reservoir (m3)
-  Vmax = 60 * 1E6, # Maximum volume in the reservoir (m3)
-  Qmin = 20 * 86400, # Min flow to maintain downstream the reservoir (m3/day)
-  Qthreshold = 45 * 86400 # Min flow threshold to support at station 54057 (m3/day)
+  Vmax = 650 * 1E6, # Maximum volume in the reservoir (m3)
+  Qmin = 50 * 86400, # Min flow to maintain downstream the reservoir (m3/day)
+  Qthreshold = 65 * 86400 # Min flow threshold to support at station 54057 (m3/day)
 )
 
 CreateController(sv, "DamRelease", Y = c("54095", "54057"), U = c("Dam"), FUN = funDamLogic)
 
 # GRiwrmRunOptions object simulation of the hydrological year 2002-2003
 IndPeriod_Run <- which(
-  DatesR >= as.POSIXct("2002-10-15", tz = "UTC") &
-  DatesR <= as.POSIXct("2003-10-15", tz = "UTC")
+  DatesR >= as.POSIXct("2002-11-01", tz = "UTC") &
+  DatesR <= as.POSIXct("2003-11-01", tz = "UTC")
 )
 IndPeriod_WarmUp <- seq.int(IndPeriod_Run[1] - 366, IndPeriod_Run[1] - 1)
 RO_severn <- CreateRunOptions(
@@ -138,15 +145,17 @@ P_severn <- readRDS(system.file("vignettes", "ParamV02.RDS", package = "airGRiwr
 
 # The Supervisor is used instead of InputsModel for running the model
 OM_dam <- RunModel(sv,
-                      RunOptions = RO_severn,
-                      Param = P_severn)
+                   RunOptions = RO_severn,
+                   Param = P_severn)
 
 # Plotting the time series of flows and reservoir storage
 oldpar <- par(mfrow=c(2,1), mar = c(2.5,4,1,1))
 plot(attr(OM_dam, "Qm3s")[, c("DatesR", "54095", "Dam", "54057")],
      ylim = c(0, 200))
 Vres <- data.frame(DatesR = attr(OM_dam, "Qm3s")$DatesR,
-                   V_reservoir = sv$Vres)
-plot.Qm3s(Vres)
+                   V_reservoir = sv$Vres / 1E6)
+plot.Qm3s(Vres,
+          main = "Simulated reservoir storage",
+          ylab = expression("Storage (Mm"^"3" * ")"))
 par(oldpar)
 }
diff --git a/man/RunModel.GRiwrmInputsModel.Rd b/man/RunModel.GRiwrmInputsModel.Rd
index a877345..9d42232 100644
--- a/man/RunModel.GRiwrmInputsModel.Rd
+++ b/man/RunModel.GRiwrmInputsModel.Rd
@@ -63,7 +63,7 @@ db <- data.frame(id = c("Reservoir", "GaugingDown"),
 
 # Create GRiwrm object from the data.frame
 griwrm <- CreateGRiwrm(db)
-str(griwrm)
+plot(griwrm)
 
 # Formatting observations for the hydrological models
 # Each input data should be a matrix or a data.frame with the good id in the name of the column
diff --git a/man/RunModel.Supervisor.Rd b/man/RunModel.Supervisor.Rd
index 540bc33..cf6ae03 100644
--- a/man/RunModel.Supervisor.Rd
+++ b/man/RunModel.Supervisor.Rd
@@ -26,9 +26,9 @@ RunModel function for a GRiwrmInputsModel object
 # An example of reservoir management on an hypothetical dam at station "54095"
 # on the Severn river build to support low-flows at "54057"
 ###############################################################################
-# A minimum flow of 20 m3/s is maintained at the dam location and an extra-release
+# A minimum flow of 50 m3/s is maintained at the dam location and an extra-release
 # is provided when the flow at the downstream station "54057" cross a minimum
-# threshold of 45 m3/s. The dam has a storage capacity of 60 millions m3
+# threshold of 65 m3/s. The dam has a storage capacity of 650 millions m3
 ###############################################################################
 library(airGRiwrm)
 
@@ -81,6 +81,8 @@ sv <- CreateSupervisor(IM_severn)
 # The Supervisor variable is an environment which can be available in
 # the controller function for storing and exchange data during the simulation
 sv$Vres <- 0 # Reservoir storage time series
+# Record of the last decision to estimate the natural flow
+sv$lastU <- 0
 
 # Dam management is modeled by a controller
 # This controller usually releases Qmin and provides
@@ -94,15 +96,20 @@ sv$Vres <- 0 # Reservoir storage time series
 factoryDamLogic <- function(sv, Vmin, Vmax, Qmin, Qthreshold) {
   function(Y) {
     # Filling of the reservoir
-    sv$Vres <- c(sv$Vres, tail(sv$Vres, 1) + Y[1])
+    V <- sv$Vres[length(sv$Vres)] + Y[1]
+    # Estimate natural flow at low-flow support location
+    Qnat <- Y[2] - sv$lastU
     # The release is the max between: overflow, low-flow support and minimum flow
-    U <- U <- max(tail(sv$Vres, 1) - Vmax, Qthreshold - Y[2], Qmin)
-    sv$Vres[length(sv$Vres)] <- tail(sv$Vres, 1) - U
-    if (tail(sv$Vres, 1) < Vmin) {
+    U <- max(V - Vmax, Qthreshold - Qnat, Qmin)
+    V <- V - U
+    if (V < Vmin) {
       # Reservoir is empty
-      U <- U - (Vmin - tail(sv$Vres, 1))
-      sv$Vres[length(sv$Vres)] <- Vmin
+      U <- U - (Vmin - V)
+      V <- Vmin
     }
+    # Record state of the reservoir and release
+    sv$Vres[length(sv$Vres) + 1] <- V
+    sv$lastU <- U
     return(U)
   }
 }
@@ -111,17 +118,17 @@ factoryDamLogic <- function(sv, Vmin, Vmax, Qmin, Qthreshold) {
 funDamLogic <- factoryDamLogic(
   sv = sv, # The Supervisor which store the states of reservoir storage
   Vmin = 0, # Minimum volume in the reservoir (m3)
-  Vmax = 60 * 1E6, # Maximum volume in the reservoir (m3)
-  Qmin = 20 * 86400, # Min flow to maintain downstream the reservoir (m3/day)
-  Qthreshold = 45 * 86400 # Min flow threshold to support at station 54057 (m3/day)
+  Vmax = 650 * 1E6, # Maximum volume in the reservoir (m3)
+  Qmin = 50 * 86400, # Min flow to maintain downstream the reservoir (m3/day)
+  Qthreshold = 65 * 86400 # Min flow threshold to support at station 54057 (m3/day)
 )
 
 CreateController(sv, "DamRelease", Y = c("54095", "54057"), U = c("Dam"), FUN = funDamLogic)
 
 # GRiwrmRunOptions object simulation of the hydrological year 2002-2003
 IndPeriod_Run <- which(
-  DatesR >= as.POSIXct("2002-10-15", tz = "UTC") &
-  DatesR <= as.POSIXct("2003-10-15", tz = "UTC")
+  DatesR >= as.POSIXct("2002-11-01", tz = "UTC") &
+  DatesR <= as.POSIXct("2003-11-01", tz = "UTC")
 )
 IndPeriod_WarmUp <- seq.int(IndPeriod_Run[1] - 366, IndPeriod_Run[1] - 1)
 RO_severn <- CreateRunOptions(
@@ -135,15 +142,17 @@ P_severn <- readRDS(system.file("vignettes", "ParamV02.RDS", package = "airGRiwr
 
 # The Supervisor is used instead of InputsModel for running the model
 OM_dam <- RunModel(sv,
-                      RunOptions = RO_severn,
-                      Param = P_severn)
+                   RunOptions = RO_severn,
+                   Param = P_severn)
 
 # Plotting the time series of flows and reservoir storage
 oldpar <- par(mfrow=c(2,1), mar = c(2.5,4,1,1))
 plot(attr(OM_dam, "Qm3s")[, c("DatesR", "54095", "Dam", "54057")],
      ylim = c(0, 200))
 Vres <- data.frame(DatesR = attr(OM_dam, "Qm3s")$DatesR,
-                   V_reservoir = sv$Vres)
-plot.Qm3s(Vres)
+                   V_reservoir = sv$Vres / 1E6)
+plot.Qm3s(Vres,
+          main = "Simulated reservoir storage",
+          ylab = expression("Storage (Mm"^"3" * ")"))
 par(oldpar)
 }
diff --git a/man/plot.GRiwrm.Rd b/man/plot.GRiwrm.Rd
index ff59579..427e3c3 100644
--- a/man/plot.GRiwrm.Rd
+++ b/man/plot.GRiwrm.Rd
@@ -41,6 +41,8 @@ This function only works inside RStudio because the HTMLwidget produced by Diagr
 is not handled on some platforms
 }
 \examples{
+library(airGRiwrm)
+
 #########################################
 # Network of 2 nodes distant of 150 km: #
 #########################################
diff --git a/man/plot.GRiwrmOutputsModel.Rd b/man/plot.GRiwrmOutputsModel.Rd
index a2f12a0..0ea11c6 100644
--- a/man/plot.GRiwrmOutputsModel.Rd
+++ b/man/plot.GRiwrmOutputsModel.Rd
@@ -63,7 +63,7 @@ db <- data.frame(id = c("Reservoir", "GaugingDown"),
 
 # Create GRiwrm object from the data.frame
 griwrm <- CreateGRiwrm(db)
-str(griwrm)
+plot(griwrm)
 
 # Formatting observations for the hydrological models
 # Each input data should be a matrix or a data.frame with the good id in the name of the column
diff --git a/man/plot.Qm3s.Rd b/man/plot.Qm3s.Rd
index 2bb899b..74f969c 100644
--- a/man/plot.Qm3s.Rd
+++ b/man/plot.Qm3s.Rd
@@ -94,7 +94,7 @@ db <- data.frame(id = c("Reservoir", "GaugingDown"),
 
 # Create GRiwrm object from the data.frame
 griwrm <- CreateGRiwrm(db)
-str(griwrm)
+plot(griwrm)
 
 # Formatting observations for the hydrological models
 # Each input data should be a matrix or a data.frame with the good id in the name of the column
diff --git a/vignettes/V06_Modelling_regulated_diversion.Rmd b/vignettes/V06_Modelling_regulated_diversion.Rmd
index 1ccc7d4..cc82cc5 100644
--- a/vignettes/V06_Modelling_regulated_diversion.Rmd
+++ b/vignettes/V06_Modelling_regulated_diversion.Rmd
@@ -151,7 +151,7 @@ CreateController(sv,
 First we need to create a `GRiwrmRunOptions` object and load the parameters calibrated in the vignette "V02_Calibration_SD_model":
 
 ```{r}
-# Running simulation between 2002 and 2005
+# Running simulation on year 2003
 IndPeriod_Run <- which(
   DatesR >= as.POSIXct("2003-03-01", tz = "UTC") & 
     DatesR <= as.POSIXct("2004-01-01", tz = "UTC")
@@ -163,8 +163,8 @@ RunOptions <- CreateRunOptions(IM_div,
 ParamV02 <- readRDS(system.file("vignettes", "ParamV02.RDS", package = "airGRiwrm"))
 ```
 
-The node "54029" was initially an upstream node. As it receive water from "54001"
-it is no longer an upstream node and need a parameter for routing its upstream 
+The node "54029" was initially an upstream node. As it receives water from "54001"
+it is no longer an upstream node and needs a parameter for routing its upstream 
 flows. We arbitrary say that the velocity in the channel between "54001" and 
 "54029" is 1 m/s.
 
-- 
GitLab