Control Functions

"SimStartTime"

Returns the simulation start time as a DateTime value.

"SimTime"

Returns the current time of the simulation as a DateTime value.

Example: To get the month of the simulation time

"Month(SimTime())"

"SimTimeStep"

Returns the current time step size as a TimeSpan value.

Examples: To get the time step in seconds or hours

"TotalSeconds(SimTimeStep())"

"TotalHourss(SimTimeStep())"

"SimTimeSpan"

Returns the elapsed simulation time, i.e. the time since simulation start time, as a TimeSpan value.

Examples: To get the elapsed simulation time in seconds or hours

"TotalSeconds(SimTimeSpan())"

"TotalHourss(SimTimeSpan())"

"TableLookup"

Based on an input value it will do lookup in a table and return the looked-up value.

Usage:

"TableLookup('table-id', input)"

Arguments:

·         The table-id is a string that identifies the table to use. The table must be supplied to the Control Module, added to the set of TableInfos. Values in the input column of the table must be strictly monotonically increasing.

·         The input expression must return a double value. It is usually a sensor, but any expression returning a double value can be used.

Example:

"TableLookup('table1', [dischargeSensor])"

Remark:
In case the input value is outside the range of the input column in the table, the first/last value in the output column is used.

"TSLookup"

Based on the current simulation time it will do lookup in a time series.

Usage:

"TSLookup('ts-id')"

"TSLookup('ts-id', phaselag)"

Arguments:

·         The ts-id identifies the time series to use, by a file and an item name/number. It must be supplied to the Control Module, added to the set of TimeSeriesInfos.

·         The phaselag expression is a TimeSpan value used as offset from the current sim-ulation time, to look forwards/backwards in time. If the phaselag is a negative time span, it will look backwards in time.

Example:

"TSLookup('ts1')"

To lookup in the time series 1½ hour back in time from simulation time, use

"TSLookup('ts1', #-0.1:30:00#)"

"TSLookup('ts1', TimeSpanFromHours(-1.5))"

“TSFileLookup”

Based on the current simulation time it will do lookup in an external time series (.dfs0 file).

Usage:

“TSFileLookup('tsfilepath', 'tsItemName')”

“TSFileLookup('tsfilepath', 'tsItemName', #+PhaseLagExpr#)”

Arguments:

·         The tsfilepath is the full path to the time series. Note that the syntax requires to use double \ symbols, as shown in the examples below.

·         The tsItemName identifies the item name/number from the selected file.

·         The phaselag expression is an optional TimeSpan value used as offset from the current simulation time, to look forward/backward in time. If the phaselag is a negative time span, it will look backwards in time.

Example:

"TSFileLookup('C:\\Data\\USDischarge.dfs0','Qobs')"

To lookup in the time series 1½ hour back in time from simulation time, use:

"TSFileLookup('C:\\Data\\USDischarge.dfs0', #-0.1:30:00#)"

"TSFileLookup('C:\\Data\\USDischarge.dfs0', TimeSpanFrom­Hours(-1.5))"

"TSTableLookup"

Based on the current simulation time it will do lookup in a table containing times in the input column

Usage:

"TSTableLookup('table-id')"

"TSTableLookup('table-id', phaselag)"

Arguments:

·         The table-id identifies the table, which must be supplied to the Control Module, added to the set of TableInfos. Values in the input column of the table must be strictly monotonically increasing. The input column can contain DateTimes values representing absolute time values, or double values representing the number of seconds since simulation start.

·         The phaselag expression is a TimeSpan value used as offset from the simulation time, to look forwards/backwards in time. If the phaselag is a negative time span, it will look backwards in time.

Example:

"TSTableLookup('tsTable1')"

To lookup in the time series 1½ hour back in time from simulation time, use

"TSTableLookup('tsTable1', #-0.1:30:00#)"

"TSTableLookup('tsTable1', TimeSpanFromHours(-1.5))"

Remark:
In case the table input values do not include the current simulation time, the first/last val-ue in the output column is used.

"PreviousInTime"

Based on an input value it will return the value as it was some time back.

Usage:

"PreviousInTime(input, timeBack)"

"PreviousInTime(input, timeBack, 'nointerp')"

Arguments:

·         The input expression must return a double value. It is often a sensor, but any ex-pression returning a double can be used.

·         The timeBack expression must be either a double or a TimeSpan value. A double value is interpreted as a number of hours.

·         The option nointerp will imply that time interpolation will not take place, but the first value just after the requested time will be used.

Examples: To get the value 1½ hour back in time

"PreviousInTime([dishargeSensor], 1.5)"

"PreviousInTime([dishargeSensor], #+0.1:30:00#)"

"TimeSinceChange"

Based on an input value it will record the time of the last change and return the time since that change. The return value is a TimeSpan value

Usage:

" TimeSinceChange(input)"

 

Arguments:

·         The input expression must return a double value. It is usually a sensor, but any expression returning a double value can be used.

Example:

"TimeSinceChange([GateLevelSensor])"

To get the number of hours since the gate changed:

"TotalHours(TimeSinceChange([GateLevelSensor]))"

Remarks:
This is relevant for gate levels or similar. For sensors that change every time step this function will always return zero.

"MinInTime"

Based on an input value it will return the minimum value within a specified time interval back in time from the current simulation time.

Usage:

"MinInTime(input, startTime, endTime)"

Arguments:

·         The input expression must return a double value. It is usually a sensor, but any expression returning a double value can be used.

·         The startTime expression must be either a double or a TimeSpan value. A double value is interpreted as a number of hours.

·         The endTime expression must be either a double or a TimeSpan value. A double value is interpreted as a number of hours.

The startTime must return a larger value than the end time.

Examples: To get the minimum value between 1½ and ½ hour from the cur­rent simulation time

"MinInTime([dischargeSensor], 1.5, 0.5)"

"MinInTime([dischargeSensor], #+0.1:30:00#, #+0.0:30:00#)"

"MaxInTime"

Based on an input value it will return the maximum value within a specified time interval back in time from the current simulation time.

Usage:

"MaxInTime(input, startTime, endTime)"

Arguments:

·         The input expression must return a double value. It is usually a sensor, but any expression returning a double value can be used.

·         The startTime expression must be either a double or a TimeSpan value. A double value is interpreted as a number of hours.

·         The endTime expression must be either a double or a TimeSpan value. A double value is interpreted as a number of hours.

The startTime must return a larger value than the end time.

Examples: To get the maximum value between 1½ and ½ hour from the cur­rent simulation time

"MaxInTime([dischargeSensor], 1.5, 0.5)"

"MaxInTime([dischargeSensor], #+0.1:30:00#, #+0.0:30:00#)"

"DiffInTime"

Based on an input value it will return the difference between the value at two specified times back in time from the current simulation time.

Usage:

"DiffInTime(input, startTime, endTime)"

Arguments:

·         The input expression must return a double value. It is usually a sensor, but any expression returning a double value can be used.

·         The startTime expression must be either a double or a TimeSpan value. A double value is interpreted as a number of hours.

·         The endTime expression must be either a double or a TimeSpan value. A double value is interpreted as a number of hours.

The startTime must return a larger value than the end time.

Examples: To get the difference in the value between 1½ and ½ hour from the current simulation time

"DiffInTime([dischargeSensor], 1.5, 0.5)"

"DiffInTime([dischargeSensor], #+0.1:30:00#, #+0.0:30:00#)"

"TimeDerivative"

Based on an input value it will return the time derivative over a specified time interval back in time from the current simulation time.

 

Usage:

"TimeDerivative(input, startTime, endTime)"

Arguments:

·         The input expression must return a double value. It is usually a sensor, but any expression returning a double value can be used.

·         The startTime expression must be either a double or a TimeSpan value. A double value is interpreted as a number of hours.

·         The endTime expression must be either a double or a TimeSpan value. A double value is interpreted as a number of hours.

The startTime must return a larger value than the end time.

Examples: To get the time derivative over one hour, from 1½ to ½ hour back in time from the current simulation time

"TimeDerivative ([dischargeSensor], 1.5, 0.5)"

"TimeDerivative ([dischargeSensor], #+0.1:30:00#, #+0.0:30:00#)"

"Average"

Based on an input value it will return the average value within a specified time interval back in time from the current simulation time.

Usage:

"Average(input, startTime, endTime)"

"Average(input, startTime, endTime, 'inside')"

Arguments:

·         The input expression must return a double value. It is usually a sensor, but any expression returning a double value can be used.

·         The startTime expression must be either a double or a TimeSpan value. A double value is interpreted as a number of hours.

·         The endTime expression must be either a double or a TimeSpan value. A double value is interpreted as a number of hours.

·         The option inside implies that only timesteps fully inside the time interval is included in the average.

The startTime must return a larger value than the end time.

 

Examples: To get the average value between 1½ and ½ hour from the current simulation time

"Average([dischargeSensor], 1.5, 0.5)"

"Average([dischargeSensor], #+0.1:30:00#, #+0.0:30:00#)"

"AverageIf"

Based on an input value it will return the average value within a specified time interval back in time from the current simulation time, including the value in the average if some condition is fulfilled.

Usage:

"AverageIf(input, condition, startTime, endTime)"

"AverageIf(input, condition, startTime, endTime, 'inside')"

Arguments:

·         The input expression must return a double value. It is usually a sensor, but any expression returning a double value can be used.

·         The condition expression must return a boolean value.

·         The startTime expression must be either a double or a TimeSpan value. A double value is interpreted as a number of hours.

·         The endTime expression must be either a double or a TimeSpan value. A double value is interpreted as a number of hours.

·         The option inside implies that only timesteps fully inside the time interval is in-cluded in the average.

The startTime must return a larger value than the end time.

Example: To get the minimum value between 1½ and ½ hour from the current simulation time

"AverageIf([dischargeSensor], [dischargeSensor] > 0, 1.5, 0.5)"

Remarks:
The condition is evaluated together with the input expression at every time step, and the input expression is only stored for processing if the condition at the current simulation time evaluates to true.

"Accumulate" and "TimeIntegrate"

Based on an input value it will accumulate/time integrate the value over time, either since start of simulation of within a specified time interval back in time from the current simulation time.

Usage:

"TimeIntegrate(input)"

"TimeIntegrate(input, startTime, endTime)"

"TimeIntegrate(input, startTime, endTime, 'inside')"

Arguments:

·         The input expression must return a double value. It is usually a sensor, but any expression returning a double value can be used.

·         The startTime expression must be either a double or a TimeSpan value. A double value is interpreted as a number of hours.

·         The endTime expression must be either a double or a TimeSpan value. A double value is interpreted as a number of hours.

·         The option inside implies that only timesteps fully inside the time interval is in-cluded in the average.

If the start/end times are not provided, accumulation/integration from simula­tion start time till current time is performed.

The startTime must return a larger value than the end time.

Examples: To get the minimum value between 1½ and ½ hour from the cur­rent simulation time

"TimeIntegrate([dischargeSensor], 1.5, 0.5)"

"TimeIntegrate([dischargeSensor], #+0.1:30:00#, #+0.0:30:00#)"

Remarks:
Accumulation and time-integration are two terms covering the same proce­dure. The term Accumulate is usually used for discharge type inputs, accu­mulating the total volume passing through some point. Time integration is used more generally

"AccumulateIf" and "TimeIntegrateIf"

Based on an input value it will accumulate/time integrate the value within a specified time interval back in time from the current simulation time, if some condition is fulfilled.

Usage:

"TimeIntegrateIf(input, condition, startTime, endTime)"

"TimeIntegrateIf(input, condition, startTime, endTime, 'inside')"

Arguments:

·         The input expression must return a double value. It is usually a sensor, but any expression returning a double value can be used.

·         The condition expression must return a boolean value.

·         The startTime expression must be either a double or a TimeSpan value. A double value is interpreted as a number of hours.

·         The endTime expression must be either a double or a TimeSpan value. A double value is interpreted as a number of hours.

·         The option inside implies that only timesteps fully inside the time interval is in-cluded in the average.

The startTime must return a larger value than the end time.

Example: To get the minimum value between 1½ and ½ hour from the current simulation time

"TimeIntegrateIf([dischargeSensor], [dischargeSensor] > 0, 1.5, 0.5)"

Remarks:
Accumulation and time-integration are two terms covering the same proce­dure. The term Accumulate is usually used for discharge type inputs, accu­mulating the total volume passing through some point. Time integration is used more generally.

The condition is evaluated together with the input expression at every time step, and the input value is only stored for processing if the condition at the current simulation time evaluates to true.