Personal tools

Module Interface

From MohidWiki

Jump to: navigation, search


One way to accomplish the coupling of a biogeochemical pelagic module with different eulerian transport models is to build a biochemical module that computes the reactions for one control volume. Consequently, the biochemical subroutines have to be called inside the loops, a method proved to be computational time consuming. The alternative is to build a module that solves the biochemical processes for a 1D array of control volumes. Module Interface, responsible for transferring information (forcing conditions and state variables) from 1D, 2D or 3D structured grids to a 1D array and for calling the 0D biochemical module subroutines. This interface is a class (or module) currently used to transfer information from the module responsible for the transport processes in the water column to the module responsible for the biochemical process in the sediment. The same happens between the sediment transport module and sediment biochemical processes modules. In this way, for example, Module WaterQuality is a zero-dimensional ecological model, which can be used by the eulerian or lagrangian transport modules.


The interface construction phase consists on the memory allocation and options consistency to couple the transport model to the biochemical model. Thus, the variables needed to initialize the interface are:

  • Name of the biochemical model to be executed;
  • An array with the names of the state variables (properties) being modeled by the transport model, which have been defined to have sinks and sources terms using the defined biochemical equations; this is important, so that properties are defined coherently in both models and the properties indexing task can be performed straightforwardly;
  • A mapping matrix (WaterPointsxD, being x the number of dimensions) that takes the value of 0 for land points and 1 for water points; this is used to define the size of the 1D arrays where most information will be stored and then given to the biochemical module.
  • A size variable (SizexD, being x the number of dimensions), used to translate (loop through) 2D and 3D matrixes to 1D arrays.

Interfacing during the run

ModuleInterface first task is to gather information on state variables needed by the biochemical models. So, the transport model must loop through all properties, sending its concentration as an argument. Optionally, other variables can also be sent, like radiation at the top of the control volume, control volume thickness and the light extinction coefficient field. Mapping arrays (WaterPointsxD and OpenPointsxD) must be given so that biochemical processes can be computed, if desired, for example, only in covered cells. OpenPointsxD is a variable, which takes the value of 0 if the cell is uncovered and 1 if it is covered with water. State variables information (i.e. concentration of properties which have sinks and sources defined by the biochemical module) is stored in a bi-dimensional array with size equal to the number of properties versus the number of control volumes, with each property properly indexed in this array. The indexing is done in the constructing phase in agreement with the two models. On the other hand, properties like temperature and salinity as well as light and mapping variables, are stored in specific 1D arrays. The loop through all the properties continues until all information is gathered. This is achieved by creating a logical array with the indexed properties, defining the ones that have already been added to the state variables array. When everything is ready, the biochemical model is then called, looping through the number of control volumes, changing the state variables values. The biochemical model time step can be, and often is, different from the transport model time step. The latter needs, due to numerical reasons, smaller time steps than the biochemical models. Thus, in each biochemical time step the state variables values are previously stored in another array, allowing to compute the concentration variation during this time step. This flux is then available to the transport model to actualize the properties concentration in its own time step.