Page tree
Skip to end of metadata
Go to start of metadata

iMOD Adapter

This page describes the iMOD module adapter, its functions, and provides an example for configuring an iMOD run in Delft-FEWS.

iMOD is an easy-to-use Graphical User Interface with Deltares' innovative version of MODFLOW (called iMODFLOW). Both iMOD and iMODFLOW are freely available here:

The iMOD Adapter is a Python script designed to make running iMODFLOW models from Delft-FEWS as easy as possible. This includes not only iMODFLOW, but also the coupled MetaSWAP and WOFOST models, as described below. It builds on the iMOD Python package found at and uses the iMOD RUNFILE batch function to create run files from project files.


MODFLOW is a popular open-source groundwater flow model distributed by the U.S. Geological Survey. iMODFLOW is characterized by fast, flexible and consistent high resolution and sub-domain modelling techniques. It enables very large, high resolution groundwater modelling. Results include the groundwater heads of the various aquifers.


MetaSWAP can model both shallow and deep groundwater levels; it is intended for regions with an undulating topography and unconsolidated sediments. Its strength lies in modelling the unsaturated zone and shallow subsurface. MetaSWAP covers plant-atmosphere interactions and groundwater. Results include the fluxes to and from the unsaturated zone.


WOrld FOod STudies (WOFOST) is a crop growth model for the quantitative analysis of the growth and production of annual field crops. WOFOST can be used to calculate attainable crop production, biomass, water use, etc. for a given location. Calculations are made based on local soil type, crop type, weather data, and crop management factors (e.g. sowing date). Results include the root zone depth, leaf area index, and water demand.


The coupled iMODFLOW-MetaSWAP-WOFOST model benefits from the strengths of each model: iMODFLOW for the groundwater flow, MetaSWAP for the unsaturated zone, and WOFOST for the crop growth aspect. A schema of the fluxes between the models is provided in Figure 1.


Figure 1. iMODFLOW-MetaSWAP-WOFOST coupling.

Adapter installation instructions

The iMOD Adapter is a Python package and requires Python 3.6 or higher. A number of packages need to be installed prior to installing the adapter. This can be done by using a file called "environment.yml" such as the one below:

name: fews

  - conda-forge
  - defaults

  - python=3.6
  - numpy
  - xarray
  - numba
  - pandas
  - geopandas
  - dask
  - rasterio
  - git
  - git-lfs
  - jupyterlab
  - spyder
  - jinja2
  - cookiecutter
  - matplotlib
  - pytest
  - cftime
  - netcdf4
  - black

This file can be installed as follows:

conda env create -f environment.yml

Once Python and the required packages are installed and the package manager pip is available on the Path, the adapter can be installed as follows:

pip install git+

To test if the installation was successful, try starting the Python interpreter and type "import imodfews".


Project file

An iMOD project file (*.PRJ) that describes the model and provides links to the input files needs to be available to the adapter. This project file needs to cover at least the time period that you intend to run. If you only have a runfile (*.RUN), a corresponding project file can be created in iMOD (refer to the iMOD user manual).


The iMOD Adapter creates a runfile using iMOD batch functionality. For this batch function, a RUNFILE_TEMPLATE.INI file is needed with, among other things, the start and end time of the desired runfile. The highlighted fields below can be left blank and are filled in by the adapter before calling the iMOD batch function.





WINDOW=165000.00, 390000.00, 200000.00, 424000.00


A run_info.xml file can be exported from Delft-FEWS using the exportRunFileActivity. This file gives the iMOD Adapter the required start and end time of the simulation, as well as the location of the state files and other custom properties needed for the adapter, as seen below.

<?xml version="1.0" encoding="UTF-8"?>
<Run xmlns:xsi="" xmlns="" xsi:schemaLocation="" version="1.5">
    <startDateTime date="2016-01-28" time="00:00:00"/>
    <endDateTime date="2016-01-30" time="00:00:00"/>
    <time0 date="2016-01-30" time="00:00:00"/>
    <lastObservationDateTime date="2016-01-30" time="00:00:00"/>
        <string key="imod-executable" value="D:\Delft-FEWS\FEWS_FARMERS_APP\Modules\fews_aaenmaas/bin/iMOD_V4_2_1_X64R.exe"/>
        <string key="model-executable" value="D:\Delft-FEWS\FEWS_FARMERS_APP\Modules\fews_aaenmaas/bin/Driver_MetaSWAP_SVN1361_iMOD43_SVN2240.exe"/>
        <string key="project-file" value="D:\Delft-FEWS\FEWS_FARMERS_APP\Modules\fews_aaenmaas/Runfiles/AaenMaas.PRJ"/>
        <string key="state-directory" value="D:\Delft-FEWS\FEWS_FARMERS_APP\Modules\fews_aaenmaas/states"/>
        <string key="output-directory" value="D:\Delft-FEWS\FEWS_FARMERS_APP\Modules\fews_aaenmaas/output"/>

Folder organization

The exported data from Delft-FEWS, including run_info.xml, are expected in a folder called FromFewsToModel. The state directory can be specified in the run_info.xml properties; the following sub-directories are expected in the state directory:

  • config_in
  • config_out
  • files_in
  • files_out

Notes to users

  • For all files that are written by this adapter, if the file to be written already exists, it will be overwritten.
  • This adapter only handles soil moisture retention curves (pF curves) as input for the init_svat.inp file (MetaSWAP), not "MeteoInputP" as input.

Example configuration files

A sample configuration file exporting necessary input data from Delft-FEWS to the model an running the adapter can be found here: Template_ExportToMMW_historical.xml.