19  Integrating a submodel

Let us build the next module, ARID, over what we just implemented in the load-weather-data module.

19.1 Module variables

Besides the weather variables we have on our dataset, ARID requires several other variables related to soil properties and cover. We will make an exception to our code legibility rule and use the notation from the original implementation (Wallach et al. 2019).

19.2 Module parameters

We will use a randomised configuration of most of these patch variables using hyperparameters giving the envelope of variation. The Indus Village eventually escapes this initial solution by calculating these variables based on various datasets and submodels. We will, however, use it for the sake of simplicity. As Wallach et al. (2019), we will use two global variables as constants (MUF and WP) and create some extra procedures that will help us register and apply a default configuration of the hyperparameters (parameters-check and parameters-to-default).

19.3 Connector variables and procedures

In our previous implementation of set-day-weather-from-input-data, we must now add a new final step, where netSolarRadiation and ETr (reference evapotranspiration) are set for each patch. We also need to implement a procedure to estimate ETr based on an FAO standard (Allen et al. 1998).

Allen, Richard G., Luis S. Pereira, Dirk Raes, and Martin Smith. 1998. Crop Evapotranspiration - FAO Irrigation and Drainage Paper No. 56. Rome: FAO. http://www.fao.org/3/X0490E/x0490e00.htm.

19.4 Implementing the main algorithm

Next, we add update-WAT, which contains the calculations that finally outputs ARID.

19.5 Merging with spatial data module

Until this point, we are still lacking our spatial data. Let us implement the necessary code to be able to import the processed data we output from the flows module.

19.6 Visualisation

Before advancing, we can implement a display procedure expanding it also to be able to paint patches according to the new patch variables, using the “chooser” parameter display-mode:

19.7 Combining with flow accumulation algorithm

Last, we finalise this module by implementing a solution that uses flow_accumulation to modulate the variation in ARID, as a proxy of the effect of the regional hydrology on the local soil water balance. The solution use the patch variable ARID_modifier, set during setup according to the parameter ARID-decrease-per-flow-accumulation and the local relative flow accumulation (flow_accumulation / maxFlowAccumulation). It then modifies ARID each day as a simple scalar.

19.8 Test

Our solution to link flow_accumulation and ARID is undoubtedly arbitrary. Such solutions should always be temporary and prompt further research and coding excursions. For the tutorial, however, we are good enough to go forward.

Screenshot of the ‘ARID’ module (tick 100)
Screenshot of the ‘ARID’ module (tick 100)

Screenshot of the ‘ARID’ module (tick 150)
Screenshot of the ‘ARID’ module (tick 150)

Screenshot of the ‘ARID’ module (tick 200)
Screenshot of the ‘ARID’ module (tick 200)

See the fully implemented version of this module: BlockC_module3_ARID.nlogo.