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: https://oss.deltares.nl/web/imod

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 https://gitlab.com/deltares/imod/imod-python and uses the iMOD RUNFILE batch function to create run files from project files.

iMODFLOW

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

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.

WOFOST

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.

iMODFLOW-MetaSWAP-WOFOST coupling

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.

iMODFLOW-MetaSWAP-WOFOST coupling

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

channels:
  - conda-forge
  - defaults

dependencies:
  - imod

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+https://gitlab.com/deltares/imod/imod-fews-adapter

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

Input

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).

RUNFILE_TEMPLATE.INI template

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.

FUNCTION=RUNFILE

PRJFILE_IN=
RUNFILE_OUT=

ISS=1

SDATE=
EDATE=

ITT=2
IDT=1
SAVESHD=-1
SAVERIV=-1
SAVERCH=1
SAVEDRN=1
SAVEWEL=-1
SAVEFLX=-1
WINDOW=165000.00, 390000.00, 200000.00, 424000.00
CELLSIZE=100.00

run_info.xml

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="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://www.wldelft.nl/fews/PI" xsi:schemaLocation="http://www.wldelft.nl/fews/PI http://fews.wldelft.nl/schemas/version1.0/pi-schemas/pi_run.xsd" version="1.5">
    <timeZone>1.0</timeZone>
    <startDateTime date="2020-09-09" time="00:00:00"/>
    <endDateTime date="2020-09-20" time="00:00:00"/>
    <time0 date="2020-09-09" time="00:00:00"/>
    <lastObservationDateTime date="2020-09-20" time="00:00:00"/>
    <workDir>Modules\Mipwa-Uitsnede</workDir>
    <inputStateDescriptionFile>Modules\Mipwa-Uitsnede\states\config_in\MetaSwap_States_in.xml</inputStateDescriptionFile>
    <inputStateDescriptionFile>Modules\Mipwa-Uitsnede\states\config_in\Modflow_States_in.xml</inputStateDescriptionFile>
    <inputNetcdfFile>Modules\Mipwa-Uitsnede\FromFewsToModel\evaporation.nc</inputNetcdfFile>
    <inputNetcdfFile>Modules\Mipwa-Uitsnede\FromFewsToModel\precipitation.nc</inputNetcdfFile>
    <outputDiagnosticFile>Modules\Mipwa-Uitsnede\Logs\dummy_Diagnostics.xml</outputDiagnosticFile>
    <outputStateDescriptionFile>Modules\Mipwa-Uitsnede\states\config_out\Modflow_States_out.xml</outputStateDescriptionFile>
    <outputStateDescriptionFile>Modules\Mipwa-Uitsnede\states\config_out\MetaSwap_States_out.xml</outputStateDescriptionFile>
    <outputNetcdfFile>Modules\Mipwa-Uitsnede\FromModelToFEWS\grid.nc</outputNetcdfFile>
    <properties>
        <string key="imod-executable" value="Modules\Mipwa-Uitsnede/bin/iMOD_V4_4_X64R.exe"/>
        <string key="model-executable" value="Modules\Mipwa-Uitsnede/bin/iMODFLOW_V4_4_METASWAP_SVN1233_X64R.exe"/>
        <string key="project-file" value="Modules\Mipwa-Uitsnede/Runfiles/mipwa30_transient.prj"/>
        <string key="input-grid-file" value="Modules\Mipwa-Uitsnede/FromFewsToModel/precipitation.nc"/>
        <string key="input-scalar-file" value="Modules\Mipwa-Uitsnede/FromFewsToModel/evaporation.nc"/>
        <string key="state-directory" value="Modules\Mipwa-Uitsnede/states"/>
        <string key="output-directory" value="Modules\Mipwa-Uitsnede/output"/>
        <string key="output-grid-file" value="Modules\Mipwa-Uitsnede/FromModelToFews\grid.nc"/>
    </properties>
</Run>

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:

Notes to users

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: MIPWA-Uitsnede.xml.