Skip to content

Commit

Permalink
feat(solvers): support for multiple solver types (#1706) (#1709)
Browse files Browse the repository at this point in the history
* fix(exe path): FloPy now correctly resolves relative paths to mf6 executable (#1633)

* feat(solvers): support for multiple solver types #1706

* Revert "fix(exe path): FloPy now correctly resolves relative paths to mf6 executable (#1633)"

This reverts commit 14335cf.

* Update mfsimulation.py

feat(solver support): rolling back ims deprecation warning

---------

Co-authored-by: scottrp <[email protected]>
  • Loading branch information
spaulins-usgs and scottrp authored Feb 15, 2023
1 parent 82a1c0c commit ea04e83
Show file tree
Hide file tree
Showing 8 changed files with 246 additions and 121 deletions.
8 changes: 4 additions & 4 deletions autotest/regression/test_mf6.py
Original file line number Diff line number Diff line change
Expand Up @@ -1697,7 +1697,7 @@ def test005_create_tests_advgw_tidal(function_tmpdir, example_data_path):
assert filename == f"all_files_same_name.{package.package_type}"
package_type_dict[package.package_type] = 1
assert sim._tdis_file.filename == "all_files_same_name.tdis"
for ims_file in sim._ims_files.values():
for ims_file in sim._solution_files.values():
assert ims_file.filename == "all_files_same_name.ims"
sim.write_simulation()
name_file = str(function_tmpdir / "all_files_same_name.nam")
Expand Down Expand Up @@ -3929,12 +3929,12 @@ def test006_2models_mvr(function_tmpdir, example_data_path):
for name in names:
assert name in model_names
model = sim.get_model(name)
assert model.model_type == "gwf"
assert model.model_type == "gwf6"
models = sim.gwf
assert len(models) == 2
for model in models:
assert model.name in model_names
assert model.model_type == "gwf"
assert model.model_type == "gwf6"

# change some settings
parent_model = sim.get_model(model_names[0])
Expand Down Expand Up @@ -4021,7 +4021,7 @@ def test006_2models_mvr(function_tmpdir, example_data_path):
assert (len(sim._exchange_files) > 0) == (
"gwf6-gwf6" in load_only or "gwf-gwf" in load_only
)
assert (len(sim._ims_files) > 0) == (
assert (len(sim._solution_files) > 0) == (
"ims6" in load_only or "ims" in load_only
)

Expand Down
1 change: 1 addition & 0 deletions flopy/mf6/data/dfn/sln-ims.dfn
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# --------------------- sln ims options ---------------------
# flopy solution_package ims *

block options
name print_option
Expand Down
29 changes: 28 additions & 1 deletion flopy/mf6/data/mfstructure.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import ast
import keyword
import os
import warnings
from enum import Enum
from textwrap import TextWrapper

Expand Down Expand Up @@ -2473,6 +2474,9 @@ def __load_structure(self):
# set up structure classes
self.sim_struct = MFSimulationStructure()

# initialize flopy dict keys
MFStructure().flopy_dict["solution_packages"] = {}

if self.load_from_dfn_files:
mf_dfn = Dfn()
dfn_files = mf_dfn.get_file_list()
Expand Down Expand Up @@ -2503,14 +2507,37 @@ def __load_structure(self):
"parameter_name": line_lst[6],
}
MFStructure().flopy_dict[line_lst[3]] = sp_dict

elif line_lst[2] == "solution_package":
MFStructure().flopy_dict["solution_packages"][
line_lst[3]
] = line_lst[4:]
if len(MFStructure().flopy_dict["solution_packages"]) == 0:
MFStructure().flopy_dict["solution_packages"]["ims"] = ["*"]
warnings.warn(
"Package definition files (dfn) do not define a solution "
"package. This can happen if your dfn files are out of "
"sync. Auto-loaded default IMS solution package metadata."
" In the future auto-loading default metadata will be "
"deprecated.",
DeprecationWarning,
)
# process each file
for file in dfn_files:
self.sim_struct.process_dfn(DfnFile(file))
self.sim_struct.tag_read_as_arrays()
else:
package_list = PackageContainer.package_list()
for package in package_list:
# process header
for entry in package.dfn[0][1:]:
if (
isinstance(entry, list)
and entry[0] == "solution_package"
):
MFStructure().flopy_dict["solution_packages"][
package.package_abbr
] = entry[1:]
# process each package
self.sim_struct.process_dfn(DfnPackage(package))
self.sim_struct.tag_read_as_arrays()

Expand Down
4 changes: 2 additions & 2 deletions flopy/mf6/modflow/mfgwf.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# DO NOT MODIFY THIS FILE DIRECTLY. THIS FILE MUST BE CREATED BY
# mf6/utils/createpackages.py
# FILE created on December 15, 2022 12:49:36 UTC
# FILE created on January 27, 2023 18:36:16 UTC
from .. import mfmodel
from ..data.mfdatautil import ArrayTemplateGenerator, ListTemplateGenerator

Expand Down Expand Up @@ -129,7 +129,7 @@ def load(
structure,
modelname,
model_nam_file,
"gwf",
"gwf6",
version,
exe_name,
strict,
Expand Down
4 changes: 2 additions & 2 deletions flopy/mf6/modflow/mfgwt.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# DO NOT MODIFY THIS FILE DIRECTLY. THIS FILE MUST BE CREATED BY
# mf6/utils/createpackages.py
# FILE created on December 15, 2022 12:49:36 UTC
# FILE created on January 27, 2023 18:36:16 UTC
from .. import mfmodel
from ..data.mfdatautil import ArrayTemplateGenerator, ListTemplateGenerator

Expand Down Expand Up @@ -122,7 +122,7 @@ def load(
structure,
modelname,
model_nam_file,
"gwt",
"gwt6",
version,
exe_name,
strict,
Expand Down
3 changes: 2 additions & 1 deletion flopy/mf6/modflow/mfims.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# DO NOT MODIFY THIS FILE DIRECTLY. THIS FILE MUST BE CREATED BY
# mf6/utils/createpackages.py
# FILE created on December 15, 2022 12:49:36 UTC
# FILE created on January 27, 2023 18:36:16 UTC
from .. import mfpackage
from ..data.mfdatautil import ListTemplateGenerator

Expand Down Expand Up @@ -381,6 +381,7 @@ class ModflowIms(mfpackage.MFPackage):
dfn = [
[
"header",
["solution_package", "*"],
],
[
"block options",
Expand Down
Loading

0 comments on commit ea04e83

Please sign in to comment.