DivideFunction
The DivideFunction is a utility function that divides the value of its first child (the numerator) by the product of its subsequent children (the denominators).
Overview
The DivideFunction divides the value of the first child function by the product of all subsequent child functions (i.e. It starts from the first child function, recursively divide by the values of the subsequent child functions). If the numerator is zero, the function returns zero. If any denominator is zero, the function returns positive or negative infinity depending on the sign of the numerator. This is useful for safely performing division operations in plant growth models, such as calculating ratios or efficiencies, while handling division-by-zero scenarios.
Model Structure
This section describes how this model is positioned within the APSIM framework. It outlines the broader structural and computational components that define its role and interactions in the simulation system.
This model inherits structural and functional behaviour from the following core APSIM components:
Connections to Other Components
This section describes how the model interacts with other components in the APSIM Next Generation framework.
These connections allow the model to exchange information—such as environmental conditions, developmental stage, or physiological responses—with other parts of the simulation system. For a general overview of how model components are connected in APSIM, see the Connections Overview.
| Component | Connection Type | Description |
|---|---|---|
| Child Functions | IFunction | All child functions are used in the division operation; the first child is the numerator, and subsequent children are denominators. |
Model Variables
This section lists the key variables that describe or control the behaviour of this component. Some variables can be adjusted by the user to modify how the model behaves (configurable), while others are calculated internally and can be viewed as model outputs (reportable). For a general explanation of variable types and how they are used within the APSIM Next Generation framework, see the Model Variables Overview.
Configurable and Reportable Properties
No configurable properties are available for this function.
Read-Only Reportable Properties
| Property | Type | Description |
|---|---|---|
| Value | double | The sum of values from all child functions. |
Processes and Algorithms
This section describes the scientific processes and algorithms represented by this component. Each process corresponds to a biological, physical, or chemical mechanism simulated during a model time step. Where appropriate, equations or conceptual summaries are provided to explain how the process operates within the APSIM Next Generation framework.
Division Algorithm
The DivideFunction implements a sequential division algorithm with special handling for edge cases:
Starting with the first child function as the numerator, the algorithm recursively divides by each subsequent child function:
User Interface
DivideFunction can be added into the model tree by right-clicking on a parent node and selecting “Add Model…”, then searching for DivideFunction in the Filter Box. A symbol for the DivideFunction is displayed in the user interface to represent the function.
Practical Example
Suppose you want to calculate the water use efficiency (WUE) of a crop, which is the ratio of yield to water used:
\[ WUE = \frac{Yield}{WaterUsed} \]
The DivideFunction can be used to divide the Yield by WaterUsed. If WaterUsed is zero, the function will return positive infinity to indicate an undefined or infinite result.
See Also
- Source code: DivideFunction.cs on GitHub