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, DataclassType] | None = None, target_grid: DataArray | UgridDataArray | None = None, name: str = 'imported') 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.
target_grid (GridDataArray, optional) – the target grid to which the data should be regridded. If not provided, the first grid of the BND package is used as target grid.
name (str, optional) – name that will be used as a prefix for the simulation and model names. Default is “imported”.
- Returns:
Simulation prepared for MODFLOW6
- Return type:
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)
You can override solver settings if needed after importing:
>>> mf6_sim["imported_model"]["ims"] = SolutionPresetSimple()
To allocate rivers to model layers differently than the default, you can set the allocation options for the river package before importing. For more information on topsystem allocation see the user guide.
>>> 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=allocation_options >>> )
To regrid the model to a specific grid upon import:
>>> target_grid = imod.util.empty_2d( >>> dx=100.0, xmin=195000.0, xmax=199000.0, dy=100.0, ymin=361000.0, ymax=365000.0 >>> ) >>> mf6_sim = imod.mf6.Modflow6Simulation.from_imod5_data( >>> imod5_data, period_data, times, target_grid=target_grid >>> )
To set regridding methods for specific packages upon import:
>>> from imod.util.regrid import RegridderType >>> from imod.mf6.regrid import NodePropertyFlowRegridMethod >>> regridder_types = { >>> "npf": NodePropertyFlowRegridMethod(k=(RegridderType.OVERLAP, "mean")), >>> } >>> mf6_sim = imod.mf6.Modflow6Simulation.from_imod5_data( >>> imod5_data, period_data, times, regridder_types=regridder_types, target_grid=target_grid >>> )
Provide custom name to the simulation and model:
>>> mf6_sim = imod.mf6.Modflow6Simulation.from_imod5_data( >>> imod5_data, period_data, times, name="custom" >>> ) >>> print(mf6_sim.name) # prints "custom_simulation" >>> gwf_model = mf6_sim["custom_model"]