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 
IniStatesobject embedded inRunOptionsshould store a list of vector, each vector containing the flows during the delay time of the upstream flow. - the 
OutputsModelobject should contains this same list in theStateEnditem. 
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 createIniStateswith a new parameterSDdefaultNULLand copy this parameter in theIniStatesobject - 
Modification of CreateRunOptionsfor handling the newSDitem - 
Modification of RunModelLagto use the hydraulic initial states provided byRunOptionsinstead of zeros - 
Modification of RunModelLagto add hydraulic states at the end of the simulation inOutputsModel$StateEnd$SD