Syntax
PrevTSValue
or PrevTSValue(Branch:VariableName)
or PrevTSValue(Branch:VariableName, TimeStepsPrevious)
or PrevTSValue(Branch:VariableName, TimeStepsPrevious,EndOfPreviousTSInterval)
or PrevTSValue(Branch:VariableName, TimeStepsPrevious,EndOfPreviousTSInterval,
FunctionToCompute)
or PrevTSValue(Branch:VariableName, TimeStepsPrevious,EndOfPreviousTSInterval,
FunctionToCompute, PercentileValue)
or PrevTSValue(MODFLOWVariableName[layer, row, column], TimeStepsPrevious,...)
Description
The PrevTSValue function can be used in two ways. One is to return results calculated in previous timesteps. The other is to return past or future values from Data variables. The parameters are:
Branch:VariableName: Name of branch and variable from which to read previous results. If omitted, then the result will be the value from the previous timestep of the current Branch:Variable.
TimeStepsPrevious: Number of previous time steps to look back. For example, a value of 1 returns the result from the previous time step, 2 returns the value from 2 time steps previous to the current time step, etc.. If omitted, the function will default to 1 time step previous.
EndOfPreviousTSInterval: The other end of the interval of time steps previous to use. For example, if TimeStepsPrevious is 1 and EndOfPreviousTSInterval is 4, then results are returned from the previous 4 time steps. If TimeStepsPrevious is 2 and EndOfPreviousTSInterval is 5, then results are returned from the interval from 2 time steps previous to 5 time steps previous (a total of 4 time steps). If omitted, the function will default to just the one time step specified by TimeStepsPrevious.
FunctionToCompute: Operation to execute on results: Sum, Average, Min, Max, Median, CV, Percentile. The function can be specified either by its name or by its numerical code: 0 for Sum, 1 for Average, 2 for Minimum, 3 for Maximum, 9 for Median, 8 for CV (coefficient of variation), and 7 for percentile. If omitted, the operation will be Sum.
PercentileValue: Only used if FunctionToCompute is Percentile. Values range from 0 to 100. If omitted, 0 will be used.
MODFLOWVariableName[layer, row, column]: To access MODFLOW results for individual cells, replace Branch:VariableName with MODFLOWVariableName[layer, row, column].
Examples
If( PrevTSValue > 15, PrevTSValue / 2, PrevTSValue + 1)
This example looks at the previous value of the current branch:variable. If it is greater than 15, then reduce by half. Otherwise, increase by 1.
PrevTSValue(Supply and Resources\River\Weaping River\Reservoirs\Central Reservoir:Storage Volume)
This example calculates Central Reservoir's storage from the previous month.
PrevTSValue(Supply and Resources\River\Weaping River\Reservoirs\Central Reservoir:Storage Volume, 3)
This example calculates Central Reservoir's storage from three months ago.
PrevTSValue(Demand Sites\South City:Unmet Demand, 1, 4)
This example calculates the sum of all unmet demands at South City for the previous 4 months.
PrevTSValue(Supply and Resources\River\Weaping River\Reservoirs\Central Reservoir:Storage Volume, 1, 4, Average)
This example calculates the storage in Central Reservoir, averaged over the previous four months (a moving average).
PrevTSValue(Supply and Resources\River\Weaping River\Reservoirs\Central Reservoir:Storage Volume, 1, 4, Minimum)
This example calculates the minimum storage in Central Reservoir over the previous four months.
PrevTSValue(Supply and Resources\River\Weaping River\Reservoirs\Central Reservoir:Storage Volume, 1, 4, Maximum)
This example calculates the maximum storage in Central Reservoir over the previous four months.
PrevTSValue(Supply and Resources\River\Weaping River\Reservoirs\Central Reservoir:Storage Volume, 1, 12, Median)
This example calculates the median (50% percentile) storage in Central Reservoir over the previous twelve months.
PrevTSValue(Supply and Resources\River\Weaping River\Reservoirs\Central Reservoir:Storage Volume, 1, 12, Percentile, 5)
This example calculates the 5% percentile storage value in Central Reservoir over the previous twelve months.
PrevTSValue(Cell Head[1,57,30], 1, 12, Minimum)
This example calculates the minimum groundwater head elevation of cell at layer 1, row 57, column 30 over the previous twelve months, as calculated by a linked MODFLOW model.
This function can also be used to return values from data variables found in the Data view, such as the "Top of Conservation" for reservoirs.
PrevTSValue(Supply and Resources\River\Weaping River\Reservoirs\North Reservoir:Top of Conservation, 1, 4, Average).
This example returns the average of the Top of Conservation variable for the North Reservoir over the four previous months.
The function can also be used to "look ahead" at a data variable. In this case, specify the time steps to look ahead as negative numbers for TimeStepsPrevious and EndOfPreviousTSInterval (because a negative number of timesteps previous means a positive number of timesteps ahead).
PrevTSValue(Supply and Resources\River\Weaping River:Headflow, -1, -4, Average)
This example returns the average headflow over the future four months.
Tip
To find out which result variables are available to use with PrevTSValue, go to the Branches tab of the Expression Builder, and drag a branch, such as a reservoir or groundwater node, to the expression area at the bottom. A menu will appear that lists all the available variables--data variables first, followed by the result variables. The result variables will include the notation "calculated result from previous timestep."