Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions docs/api/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ Fixed
and the model already contained a :class:`imod.mf6.ConstantHead` or
:class:`imod.mf6.ConstantConcentration`, both with timesteps, which were
unaligned.
- Fixed bug where :class:`imod.mf6.Lake` package did not pass ``budgetfile``,
``budgetcsvfile``, ``stagefile`` options to the written MODFLOW 6 package.

Changed
~~~~~~~
Expand Down
4 changes: 4 additions & 0 deletions imod/mf6/lak.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import pathlib
import textwrap
from collections import defaultdict
from pathlib import Path
from typing import Any, Dict

import jinja2
Expand Down Expand Up @@ -670,6 +671,9 @@ class Lake(BoundaryCondition):
DTypeSchema(np.floating),
DimsSchema("index", "time") | DimsSchema(),
],
"budgetcsvfile": [DTypeSchema(str) | DTypeSchema(Path)],
"stagefile": [DTypeSchema(str) | DTypeSchema(Path)],
"budgetfile": [DTypeSchema(str) | DTypeSchema(Path)],
}

_write_schemata = {
Expand Down
52 changes: 27 additions & 25 deletions imod/templates/mf6/gwf-lak.j2
Original file line number Diff line number Diff line change
@@ -1,31 +1,33 @@
begin options
{% if auxiliary is defined %} auxiliary{% for aux in auxiliary %} {{aux}}{% endfor %}
{% endif %}
{%- if boundnames is defined -%} boundnames
{% endif -%}
{%- if print_input is defined -%} print_input
{% endif -%}
{%- if print_stage is defined -%} print_stage
{% endif -%}
{%- if print_flows is defined -%} print_flows
{% endif -%}
{%- if save_flows is defined -%} save_flows
{% endif -%}
{%- if stage_filerecord is defined -%}stage fileout {{stagefile}}
{% endif -%}
{%- if budget_filerecord is defined -%} budget fileout {{budgetfile}}
{% endif -%}
{%- if ts_filerecord is defined -%} ts6 filein {{ts6_filename}}
{% endif -%}
{%- if obs_filerecord is defined -%} obs6 filein {{obs6_filename}}
{% endif -%}
{%- if mover is defined -%} mover
{% endif -%}
{%- if surfdep is defined -%} surfdep {{surfdep}}
{% endif -%}
{%- if time_conversion is defined -%} time_conversion {{time_conversion}}
{% endif -%}
{%- if length_conversion is defined -%} length_conversion {{length_conversion}}
{%- if boundnames is defined %} boundnames
{% endif %}
{%- if print_input is defined %} print_input
{% endif %}
{%- if print_stage is defined %} print_stage
{% endif %}
{%- if print_flows is defined %} print_flows
{% endif %}
{%- if save_flows is defined %} save_flows
{% endif %}
{%- if stagefile is defined %} stage fileout {{stagefile}}
{% endif %}
{%- if budgetfile is defined %} budget fileout {{budgetfile}}
{% endif %}
{%- if budgetcsvfile is defined %} budgetcsv fileout {{budgetcsvfile}}
{% endif %}
{%- if ts_filerecord is defined %} ts6 filein {{ts6_filename}}
{% endif %}
{%- if obs_filerecord is defined %} obs6 filein {{obs6_filename}}
{% endif %}
{%- if mover is defined%} mover
{% endif %}
{%- if surfdep is defined %} surfdep {{surfdep}}
{% endif %}
{%- if time_conversion is defined %} time_conversion {{time_conversion}}
{% endif %}
{%- if length_conversion is defined %} length_conversion {{length_conversion}}
{% endif -%}
end options

Expand Down
32 changes: 32 additions & 0 deletions imod/tests/test_mf6/test_mf6_lak.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import textwrap
from pathlib import Path

import numpy as np
import pandas as pd
Expand Down Expand Up @@ -48,6 +49,37 @@ def test_lake_render(lake_package):
assert actual == expected


def test_lake_render__options(lake_package):
lake_package.dataset["stagefile"] = Path("path/to/stagefile.bin")
lake_package.dataset["budgetfile"] = "path/to/budgetfile.bin"
lake_package.dataset["budgetcsvfile"] = "path/to/budgetcsvfile.bin"
lake_package._validate_init_schemata(
True
) # Verify that added options pass validation.
actual = lake_package._render(None, None, None, False)
expected = textwrap.dedent(
"""\
begin options
stage fileout path\\to\\stagefile.bin
budget fileout path/to/budgetfile.bin
budgetcsv fileout path/to/budgetcsvfile.bin
end options

begin dimensions
nlakes 2
noutlets 2
ntables 0
end dimensions

begin packagedata
1 11.0 3 Naardermeer
2 15.0 3 IJsselmeer
end packagedata
"""
)
assert actual == expected


def test_lake_connection_dataframe(lake_package):
df = lake_package._connection_dataframe()
assert isinstance(df, pd.DataFrame)
Expand Down