imod.mf6.Modflow6Simulation.from_imod5_data#

classmethod Modflow6Simulation.from_imod5_data(imod5_data: dict[str, dict[str, DataArray | UgridDataArray]], period_data: dict[str, list[datetime]], times: list[datetime], allocation_options: SimulationAllocationOptions | None = None, distributing_options: SimulationDistributingOptions | None = None, regridder_types: dict[str, RegridMethodType] | None = None) Modflow6Simulation[source]#

Imports a GroundwaterFlowModel (GWF) from the data in an iMOD5 project file and puts it in a simulation. Quasi-3D iMOD5 models, i.e. models where there is only horizontal flow in aquifers and vertical flow in aquitards, are not supported.

This method adds all static and boundary condition packages from the projectfile to the simulation. Output Control (OC) must be added manually after importing. The imod.mf6.ims.SolutionPresetModerate() solver settings are added automatically under the “ims” key, but these can be overrided by the user after importing.

Parameters:
  • imod5_data (dict[str, dict[str, GridDataArray]]) – dictionary containing the arrays mentioned in the project file as xarray datasets, under the key of the package type to which it belongs.

  • period_data (dict[str, list[datetime]]) – dictionary containing the package names mapped to a list of repeated stress periods. These are set as repeat_stress.

  • times (list[datetime]) –

    time discretization of the model to be imported. This is used for the following:

    • Times of wells with associated timeseries are resampled to these times

    • Start and end times in the list are used to repeat the stresses of periodic data (e.g. river stages in iMOD5 for “summer”, “winter”)

    • The simulation is discretized to these times, using imod.mf6.Modflow6Simulation.create_time_discretization()

  • allocation_options (SimulationAllocationOptions, optional) – object containing the allocation options per package type. If you want a specific package to have a different allocation option, then it should be imported separately.

  • distributing_options (SimulationDistributingOptions, optional) – object containing the conductivity distribution options per package type. If you want a package to have a different allocation option, then it should be imported separately.

  • regridder_types (dict[str, RegridMethodType]) – the key is the package name. The value is the RegridMethodType object containing the settings for regridding the package with the specified key.

Returns:

Simulation prepared for MODFLOW6

Return type:

Modflow6Simulation

Examples

Open projectfile data first:

>>> from imod.formats.prj import open_projectfile_data
>>> imod5_data, period_data = open_projectfile_data("path/to/projectfile")

You can then import the simulation as follows:

>>> times = [np.datetime("2001-01-01"), np.datetime("2002-01-01"), np.datetime("2003-01-01")]
>>> mf6_sim = imod.mf6.Modflow6Simulation.from_imod5_data(imod5_data, period_data, times)

Allocate rivers differently:

>>> from imod.prepare.topsystem import SimulationAllocationOptions, ALLOCATION_OPTION
>>> allocation_options = SimulationAllocationOptions()
>>> allocation_options.riv = ALLOCATION_OPTION.at_elevation
>>> mf6_sim = imod.mf6.Modflow6Simulation.from_imod5_data(imod5_data, period_data, times, allocation_options)

You can override solver settings if needed after importing:

>>> mf6_sim["imported_model"]["ims"] = SolutionPresetComplex()