Changes between Initial Version and Version 1 of doc/tec/mas/implementation


Ignore:
Timestamp:
Sep 10, 2018 11:53:28 AM (6 years ago)
Author:
sward
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • doc/tec/mas/implementation

    v1 v1  
     1[[NoteBox(note,This page contains a description of the technical implementation of the Multi Agent System (MAS). \\ For an overview of all MAS-related pages\, see the [wiki:doc/tec/mas MAS main page].)]]
     2
     3= Agent code structure =
     4
     5This 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].
     6
     7Each agent is defined by its features, which are stored as components of a Fortran 95 derived data type (e.g., [#metcalf2004 Metcalf et al.], Chap.~2.9):
     8{{{
     9#!Latex
     10\begin{verbatim}
     11TYPE agent_type
     12
     13   REAL :: x, y, radius, force_x, force_y,...
     14
     15END TYPE agent_type
     16\end{verbatim}
     17}}}
     18Here, '''''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
     19{{{
     20#!Latex
     21\begin{verbatim}
     22TYPE(agent_type), DIMENSION(:), ALLOCATABLE ::  agents
     23\end{verbatim}
     24}}}
     25An element of '''''agents''''' defines a complete agent with its entire features, which can be accessed by the selector '''''%''''', e.g., the position of the of the agent by
     26{{{
     27#!Latex
     28\begin{verbatim}
     29agents(n)%x
     30\end{verbatim}
     31}}}
     32and
     33{{{
     34#!Latex
     35\begin{verbatim}
     36agents(n)%y,
     37\end{verbatim}
     38}}}
     39respectively, where '''''n''''' is the index of a certain agent.
     40
     41All 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''''':
     42{{{
     43#!Latex
     44\begin{verbatim}
     45TYPE agent_grid_type
     46
     47   TYPE(agent_type), DIMENSION(:),       &
     48      ALLOCATABLE ::  agents
     49
     50END TYPE agent_grid_type
     51\end{verbatim}
     52}}}
     53Note that the individual agent features are still accessible as components of '''''agents'''''. An allocatable two-dimensional array of '''''agent_grid_type''''' is defined
     54{{{
     55#!Latex
     56\begin{verbatim}
     57TYPE(agent_grid_type), DIMENSION(:,:), &
     58   ALLOCATABLE ::  agent_grid
     59\end{verbatim}
     60}}}
     61and 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
     62LES grid volume are permanently stored in the agent array, assigned to this grid volume:
     63{{{
     64#!Latex
     65\begin{verbatim}
     66agent_grid(j,i)%agents(1:n_par)
     67\end{verbatim}
     68}}}
     69Here, '''''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. \\\\
     70
     71
     72
     73== References ==
     74
     75* [=#metcalf2004] '''Metcalf M, Reid JK, Cohen M.''' 2004. Fortran 95/2003 Explained. vol. 416. Oxford University Press. Oxford.