diff --git a/docs/api/changelog.rst b/docs/api/changelog.rst index c9df74458..407a57809 100644 --- a/docs/api/changelog.rst +++ b/docs/api/changelog.rst @@ -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 ~~~~~~~ diff --git a/imod/mf6/lak.py b/imod/mf6/lak.py index 5004c4dd1..bdc2b231b 100644 --- a/imod/mf6/lak.py +++ b/imod/mf6/lak.py @@ -8,6 +8,7 @@ import pathlib import textwrap from collections import defaultdict +from pathlib import Path from typing import Any, Dict import jinja2 @@ -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 = { diff --git a/imod/templates/mf6/gwf-lak.j2 b/imod/templates/mf6/gwf-lak.j2 index b0e08ba13..baefe9285 100644 --- a/imod/templates/mf6/gwf-lak.j2 +++ b/imod/templates/mf6/gwf-lak.j2 @@ -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 diff --git a/imod/tests/test_mf6/test_mf6_lak.py b/imod/tests/test_mf6/test_mf6_lak.py index 821d07995..cad368508 100644 --- a/imod/tests/test_mf6/test_mf6_lak.py +++ b/imod/tests/test_mf6/test_mf6_lak.py @@ -1,4 +1,5 @@ import textwrap +from pathlib import Path import numpy as np import pandas as pd @@ -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)