Implementation

This page is part of the Multi Agent System (MAS) documentation.
It contains a description of the technical implementation of the Multi Agent System (MAS).
For an overview of all MAS-related pages, see the MAS main page.

This section will give a brief summary of the agent code structure. This structure is largely based on the structure of the [wiki:doc/tec/particle Lagrangian Particle Model.
The entire MAS is modularized and can be found in the file SOURCE/multi_agent_system_mod.f90 (here).

Storage of agent data

Each agent is defined by its features, which are stored as components of a Fortran 95 derived data type (e.g., Metcalf et al., Chap.~2.9):

\begin{verbatim}
TYPE agent_type

   REAL :: x, y, radius, force_x, force_y,...

END TYPE agent_type
\end{verbatim}

Here, x, y, radius, etc. are some components of the derived data type of the intrinsic data type REAL. Several other components of all intrinsic data types (or even other derived data types) can be defined (e.g., location, velocity). Agents are stored in an allocatable array of the derived data type

\begin{verbatim}
TYPE(agent_type), DIMENSION(:), ALLOCATABLE ::  agents
\end{verbatim}

An element of agents defines a complete agent with all of its features. They can be accessed by the selector %, e.g., the position of the of the agent by

\begin{verbatim}
agents(n)%x
\end{verbatim}

and

\begin{verbatim}
agents(n)%y,
\end{verbatim}

respectively, where n is the index of a certain agent.

All agents are stored in an array-structure based on another derived data type named agent_grid_type, which contains, as a component, a 1-D array of the derived data type agent_type:

\begin{verbatim}
TYPE agent_grid_type

   TYPE(agent_type), DIMENSION(:), ALLOCATABLE ::  agents

END TYPE agent_grid_type
\end{verbatim}

Note that the individual agent features are still accessible as components of agents. An allocatable two-dimensional array of agent_grid_type is defined

\begin{verbatim}
TYPE(agent_grid_type), DIMENSION(:,:), ALLOCATABLE ::  agent_grid
\end{verbatim}

and allocated using the x- and y-dimensions that are used for a scalar of the LES model. In this way, all agents currently located in a certain LES grid volume are permanently stored in the agent array, assigned to this grid volume:

\begin{verbatim}
agent_grid(j,i)%agents(1:n_par)
\end{verbatim}

Here, n_par is the number of agents located in the grid volume defined by the indices j and i As an agent moves from one grid volume to another, its data has to be copied from the 1-D array of the previous grid volume to the 1-D array of the new volume, and finally deleted from the previous one.

References

  • Metcalf M, Reid JK, Cohen M. 2004. Fortran 95/2003 Explained. vol. 416. Oxford University Press. Oxford.
Last modified 5 years ago Last modified on Nov 19, 2018 2:35:32 PM