Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Custom Functions

Allows you to create your own expression and then import it for use in the Function manager. Refer to Source Plugins. The Parameter count column refers to the number of arguments used in the function.

Figure 13. Function Editor (Custom Functions)

Time of Evaluation

Functions are evaluated at the start of each time-step. 3.5.0 Simulation phases shows details of all phases involved in a simulation time-step and Basic Concepts provides a diagrammatic representation.

  • start of the ordering phase;
  • end of the ordering phase;
  • start of the flow distribution phase; or
  • end of the flow distribution phase.
Info
iconfalse
Note: The Function Editor dialog allows you to link two resource assessment systems using the Time of Evaluation tab. Normally, fields in the function editor are lagged by a time-step (that is, they get their value from the last time-step to use in the current time-step). Enabling the During Resource Assessment checkbox results in the resource assessment system linked parameters being executed within the current time-step. As long as the resource assessment system appears above another resource assessment system in the hierarchical list, the values will be up-to-date in the time-step. Conversely, if one resource assessment system appears below a linked resource assessment system, its values will be lagged by a time-step.

Date ranges

All events occurring during a time-step are independent, such as when a function is evaluated, or when the model variable on which the function depends is updated. You can choose the times in which to carry out certain actions. Tables 11 and 12 define the options which are available by default.

If none of the default options is appropriate, you can define your own date ranges using one of the options from the Date range type popup menu (Figure 15).

Table 11. Function manager (date range instances)

Date Range

Meaning

Current Time-step

The most-recently-updated value.

Current Iteration

Only applicable to NetLP. The value updated during the last iteration of the solver.

Current Day

For a daily model, this is a synonym for Current Time-step. For a sub-daily model, it is the sum of the values for the current day.

This Month

For a monthly model, this is a synonym for Current Time-step. For a sub-monthly model, it is the sum of the values for the current month.

This Calendar Year

For a yearly model, this is a synonym for Current Time-step. For a sub-yearly model, it is the sum of the values for the current calendar year.

This Water Year To Date

For a yearly model, this is a synonym for Current Time-step. For a sub-yearly model, it is the sum of the values for the current water year.

Last Time-step

The value of the variable at the completion of the previous iteration of the model.

Previous Day

For a daily model, this is a synonym for Last Time-step. For a sub-daily model, it is the sum of the values for the previous day.

Last Month

For a monthly model, this is a synonym for Last Time-step. For a sub-monthly model, it is the sum of the values for the previous month.

Last Calendar Year

For a yearly model, this is a synonym for Last Time-step. For a sub-yearly model, it is the sum of the values for the previous calendar year.

Last Water Year

For a yearly model, this is a synonym for Last Time-step. For a sub-yearly model, it is the sum of the values for the previous water year.

To calculate a particular date in the water year using the calendar date functions, you can use $now.dayofyear+184 (to indicate the next calendar year) for example, or $now.dayofyear-181 (represents the current calendar year). 

 

Table 12. Function manager (date range sets)

Date Range

Meaning

Example of use

Last Hundred Time-steps

The set of values from the model for the previous 100 iterations.

Lookup($var,35)
(finds 35th value)

Last Seven Days

For a daily or monthly model, this is the set of the values from the last seven time-steps. For a sub-daily model, it is the set of the average daily values for each of the previous seven days.

Average($var)

Previous 30 Days

For a daily or monthly model, this is the set of the values from the last 30 time-steps. For a sub-daily model, it is the set of the average daily values for each of the previous 30 days.

Average($var)

Last 365 Days

For a daily or monthly model, this is the set of the values from the last 365 time-steps. For a sub-daily model, it is the set of the average daily values for each of the previous 365 days.

Average($var)

Custom date ranges fall into three categories:

  • Date Range Calendar (Figure 13) allows you to define a precise start and end date during which the model variable is considered to be valid. Enabling the Is Recurring checkbox ignores the years. In other words, the period between [start day/start month] and [end day/end month] is valid for every year during model execution.
  • Date Range Period (Figure 14) allows you to specify the date range in terms of a period of time that is relative to the current time-step. A period can range from one hour to one year and is controlled via the Period popup menu. The number of periods included in the range is controlled by the X periods ago(start) and Y periods ago(end) fields where end ≥ start. A value of zero refers to the current period. For example:
    • Daily period where start=0 and end=0 refers to the current day;
    • Daily period where start=1 and end=1 refers to the previous day.
  • The Date Range Time Step option (Figure 15) allows you to specify the date range in terms of time-steps. The number of time-steps included in the range is controlled by the X time-steps ago(start) and Y time-steps ago(end) fields where where end ≥ start. A value of zero refers to the current time-step. For example:
    • If start = 0 and end = 0, this refers to the current time-step;
    • If start = 1 and end = 1, this refers to the last time-step;
    • If start = 0 and end = 6, this refers to the last seven time-steps including the current time-step.
Figure 14. Function Editor (Date Range, Date range calendar)

Figure 15. Function Editor (Date Range, period)

Figure 16. Function Editor (Date Range, time-step)

For all three custom calendar options:

  • The Update Frequency popup menu offers a choice of OncePerTimeStep or OncePerIteration. The latter setting is only applicable to NetLP.
  • The Return set popup menu controls the granularity of the returned result:
    • If the range represents a single value, that value is returned regardless of this setting.
    • Table 13 summarises what is returned if the range represents more than one value.
Table 13. Function Editor, Date Ranges (Variables)
OptionSummaryResult
Simple SetReturns the set of observations without modification[1,2,3,4,5]
Set of Averages

Returns a set of the same size where each member is the average of all of the members of the set

[3,3,3,3,3]
Set of Progressive Averages

Returns a set of the same size where each member is the original value of that member averaged with the value of the first member.

[1,1.5,2,2.5,3]

Where: input is the series [1,2,3,4,5]

Info
iconfalse
Note: While the user interface uses the word set to refer to the concept of returning multiple values, because the values are both ordered and can be repeated, it is probably better to think of these as lists.

Example

As an example, you can used a function or expression at a Maximum Order Constraint node to limit the maximum orders for each time-step. Assume that a channel constraint of 80 ML/day is required to prevent flows going overbank, except during floods (defined as more than 2,000 ML/day) when up to 3,000 ML/day is permitted as an environmental flow.

Figure 16 shows a fragment of the river network. Downstream demands are represented by a supply point and water user node. In the Function Editor, you specify the internal orders and unregulated river gain of the model using modelled variables. Maximum orders are then defined using an expression.

Figure 17. Maximum Order Constraint node (example)

In this case, the following components will be assigned:

  • Storage 2: Requested flow rate - say, $Orders with a data range of Last time-step; and
  • Inflow 3: Inflow - $predictedInflow, with the same data range as Storage 2.

Note that both variables will have ML/day as designated units.

Then, the following expression will return a value of 3,000 ML/day if flows are above 2,000 ML/day but 80 ML/day otherwise.

If(($predictedinflow+$orders) > 2000, 3000, 80

The Metaparameter Explorer will be functional from v3.4.2 onwards.

Anchor
Metaparameter Explorer
Metaparameter Explorer
Metaparameter Explorer

The Metaparameter Explorer allows you to calibrate a variable using a function, where there is no Function manager available and can be accessed using Tools » MetaParameter Explorer. For example, if you want to calibrate a link variable, you can specify this in the Metaparameter Explorer, and then assign it a value using the Function manager.

Suppose you want to calibrate the storage routing exponent (m) on one of the reaches in a Source model. Initially, idenitfy which link in the model you want to place the expression in. Then, use the Metaparameter Explorer to allocate a parameter to the variable (steps outlined in Figure 15).

Figure 15. Calibration Wizard (Metaparameter Explorer)

Finally, to define the value of the variable, m in the Function manager, choose View » Expression List... to open the Expression List Viewer (Figure 16). Click on the hyperlink (circled in orange) to open the Function manager and set the value of m to 2.

Figure 16. Expression List Viewer (Metaparameter Explorer)