AddFunction
The AddFunction is a utility function that returns the sum of values from all of its child functions.
Overview
The AddFunction is used to sum up multiple values for a mathematical equation. It summarises values of all children functions (i.e. IFunction) and returns the total sum. This is useful when you need to combine multiple traits or parameters into a single value for further calculations in plant growth models.
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 whose values are summed together. |
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. |
Events
This section describes the events associated with this component. Events are signals or notifications that indicate when a particular process occurs within the simulation, or when a component needs to respond to a change in another part of the system. Some events are listened for by this component to trigger its processes, while others are raised to inform other components about changes. For a general overview of how APSIM Next Generation uses events to coordinate processes between components, see the Events Overview.
No events are listened or raisedby this function.
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.
The AddFunction implements a simple summation algorithm that iterates through all child functions and accumulates their values:
\[ V_{\text{total}} = \sum_{i=1}^{n} V_i \]
where \(V_{\text{total}}\) is the total sum, \(V_i\) is the value of the \(i\)-th child function, and \(n\) is the number of child functions.
The algorithm:
- Locates all child functions that implement the IFunction interface
- Iterates through each child function
- Calls the Value method on each child function
- Accumulates the returned values
- Returns the total sum
This allows for flexible composition of complex calculations by combining multiple simpler functions hierarchically.
This allows for flexible composition of complex calculations by combining multiple simpler functions hierarchically.
User Interface
AddFunction can be added into the model tree by right-clicking on a parent node and selecting “Add Model…”, and then search AddFunction in the Filter Box. A symbol for the AddFunction is displayed in the user interface to represent the function.

Practical Example
The target thermal time from germination to emergence in the wheat model is determined by ShootLag (\(ShootLag\)), Sowing Depth (\(SowingDepth\)), and Shoot Rate (\(ShootRate\)).
\[ TT = ShootLag + (SowingDepth \times ShootRate) \]
The AddFunction is used to sum these two values to get the total target thermal time in the equation above.
See Also
- Source code: AddFunction.cs on GitHub