States handling on Lag model
Analysis of the existing situation
In the lag model, upstream flows are added to the downstream flow with a delay. At the beginning of the simulation during this delay time, zero are currently added downstream because upstream flow before the beginning of the simulation are not known. This period can be regarded as a warming period with initial zero flow upstream which lasts few days (Few time steps for a daily time step model).
Requirements
The package airGRiwrm will need to run the model time step by time step without warming period (See in-wop/airGRiwrm#19 (closed)). So we need to be able to handle states of the Lag model both as initial states and states at the end of the simulation.
- the
IniStates
object embedded inRunOptions
should store a list of vector, each vector containing the flows during the delay time of the upstream flow. - the
OutputsModel
object should contains this same list in theStateEnd
item.
Lag model would not be the only hydraulic propagation model, so the implementation needs to be generic for other hydraulic propagation models.
Proposition of realisation
Storage
Adding a SD
item in both IniStates
object and StateEnd
item of OutputsModel
. Its contents will be model dependant. For the lag model it consists in a list ordered by the upstream connections and each item of the list will store the flow for the time steps during the delay time of each upstream flow.
Implementation
-
Modification of createIniStates
with a new parameterSD
defaultNULL
and copy this parameter in theIniStates
object -
Modification of CreateRunOptions
for handling the newSD
item -
Modification of RunModelLag
to use the hydraulic initial states provided byRunOptions
instead of zeros -
Modification of RunModelLag
to add hydraulic states at the end of the simulation inOutputsModel$StateEnd$SD