Skip to content

Commit

Permalink
ruff'led
Browse files Browse the repository at this point in the history
  • Loading branch information
emorway-usgs committed Dec 3, 2024
1 parent 3bc1e7c commit 3df7bd3
Show file tree
Hide file tree
Showing 3 changed files with 69 additions and 101 deletions.
65 changes: 28 additions & 37 deletions autotest/test_gwe_drycell_cnd3.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,14 +152,14 @@ def add_gwf_model(sim, gwfname, newton=False):
modelname=gwfname,
newtonoptions="NEWTON",
save_flows=True,
model_nam_file="{}.nam".format(gwfname),
model_nam_file=f"{gwfname}.nam",
)
else:
gwf = flopy.mf6.ModflowGwf(
sim,
modelname=gwfname,
save_flows=True,
model_nam_file="{}.nam".format(gwfname),
model_nam_file=f"{gwfname}.nam",
)

# Instantiating MODFLOW 6 solver for flow model
Expand All @@ -176,7 +176,7 @@ def add_gwf_model(sim, gwfname, newton=False):
scaling_method="NONE",
reordering_method="NONE",
relaxation_factor=relax,
filename="{}.ims".format(gwfname),
filename=f"{gwfname}.ims",
)
sim.register_ims_package(imsgwf, [gwfname])

Expand All @@ -193,7 +193,7 @@ def add_gwf_model(sim, gwfname, newton=False):
botm=bot,
idomain=1,
pname="DIS",
filename="{}.dis".format(gwfname),
filename=f"{gwfname}.dis",
)

# Instantiating MODFLOW 6 storage package
Expand All @@ -205,7 +205,7 @@ def add_gwf_model(sim, gwfname, newton=False):
steady_state=steady,
transient=transient,
pname="STO",
filename="{}.sto".format(gwfname),
filename=f"{gwfname}.sto",
)

# Instantiating MODFLOW 6 node-property flow package
Expand All @@ -217,22 +217,22 @@ def add_gwf_model(sim, gwfname, newton=False):
k33=k33,
save_specific_discharge=True,
pname="NPF",
filename="{}.npf".format(gwfname),
filename=f"{gwfname}.npf",
)

# Instantiating MODFLOW 6 initial conditions package for flow model
flopy.mf6.ModflowGwfic(
gwf,
strt=strthd,
filename="{}.ic".format(gwfname),
filename=f"{gwfname}.ic",
)

# Instantiating MODFLOW 6 output control package for flow model
flopy.mf6.ModflowGwfoc(
gwf,
pname="OC",
head_filerecord="{}.hds".format(gwfname),
budget_filerecord="{}.cbc".format(gwfname),
head_filerecord=f"{gwfname}.hds",
budget_filerecord=f"{gwfname}.cbc",
headprintrecord=[("COLUMNS", 10, "WIDTH", 15, "DIGITS", 6, "GENERAL")],
saverecord=[("HEAD", "ALL"), ("BUDGET", "ALL")],
printrecord=[("HEAD", "ALL"), ("BUDGET", "ALL")],
Expand All @@ -259,7 +259,7 @@ def add_gwf_model(sim, gwfname, newton=False):
connectiondata=connectiondata,
perioddata=sfr_perioddata,
pname=pname,
filename="{}.sfr".format(gwfname),
filename=f"{gwfname}.sfr",
)
fname = f"{gwfname}.sfr.obs"
sfr_obs = {
Expand All @@ -274,9 +274,7 @@ def add_gwf_model(sim, gwfname, newton=False):


def add_gwe_model(sim, gwename):
gwe = flopy.mf6.ModflowGwe(
sim, modelname=gwename, model_nam_file="{}.nam".format(gwename)
)
gwe = flopy.mf6.ModflowGwe(sim, modelname=gwename, model_nam_file=f"{gwename}.nam")
gwe.name_file.save_flows = True

imsgwe = flopy.mf6.ModflowIms(
Expand All @@ -292,7 +290,7 @@ def add_gwe_model(sim, gwename):
scaling_method="NONE",
reordering_method="NONE",
relaxation_factor=relax,
filename="{}.ims".format(gwename),
filename=f"{gwename}.ims",
)
sim.register_ims_package(imsgwe, [gwe.name])

Expand All @@ -309,18 +307,14 @@ def add_gwe_model(sim, gwename):
botm=bot,
idomain=1,
pname="DIS",
filename="{}.dis".format(gwename),
filename=f"{gwename}.dis",
)

# Instantiating MODFLOW 6 transport initial concentrations
flopy.mf6.ModflowGweic(
gwe, strt=strt_temp, pname="IC", filename="{}.ic".format(gwename)
)
flopy.mf6.ModflowGweic(gwe, strt=strt_temp, pname="IC", filename=f"{gwename}.ic")

# Instantiating MODFLOW 6 transport advection package
flopy.mf6.ModflowGweadv(
gwe, scheme=scheme, pname="ADV", filename="{}.adv".format(gwename)
)
flopy.mf6.ModflowGweadv(gwe, scheme=scheme, pname="ADV", filename=f"{gwename}.adv")

# Instantiating MODFLOW 6 transport dispersion package
flopy.mf6.ModflowGwecnd(
Expand All @@ -331,10 +325,11 @@ def add_gwe_model(sim, gwename):
ktw=ktw * 86400,
kts=kts * 86400,
pname="CND",
filename="{}.cnd".format(gwename),
filename=f"{gwename}.cnd",
)

# Instantiating MODFLOW 6 transport mass storage package (formerly "reaction" package in MT3DMS)
# Instantiating MODFLOW 6 transport mass storage package
# (formerly "reaction" package in MT3DMS)
flopy.mf6.ModflowGweest(
gwe,
save_flows=True,
Expand All @@ -345,7 +340,7 @@ def add_gwe_model(sim, gwename):
heat_capacity_solid=cps,
density_solid=rhos,
pname="EST",
filename="{}.est".format(gwename),
filename=f"{gwename}.est",
)

# Instantiating MODFLOW 6 source/sink mixing package for dealing with
Expand All @@ -355,18 +350,16 @@ def add_gwe_model(sim, gwename):
gwe,
sources=sourcerecarray,
pname="SSM",
filename="{}.ssm".format(gwename),
filename=f"{gwename}.ssm",
)

# Instantiate MODFLOW 6 heat transport output control package
flopy.mf6.ModflowGweoc(
gwe,
pname="OC",
budget_filerecord="{}.cbc".format(gwename),
temperature_filerecord="{}.ucn".format(gwename),
temperatureprintrecord=[
("COLUMNS", 10, "WIDTH", 15, "DIGITS", 6, "GENERAL")
],
budget_filerecord=f"{gwename}.cbc",
temperature_filerecord=f"{gwename}.ucn",
temperatureprintrecord=[("COLUMNS", 10, "WIDTH", 15, "DIGITS", 6, "GENERAL")],
saverecord=[("TEMPERATURE", "ALL"), ("BUDGET", "ALL")],
printrecord=[("TEMPERATURE", "ALL"), ("BUDGET", "ALL")],
)
Expand All @@ -393,7 +386,7 @@ def add_gwe_model(sim, gwename):
reachperioddata=sfe_perioddata,
flow_package_name=flwpckname,
pname="SFE",
filename="{}.sfe".format(gwename),
filename=f"{gwename}.sfe",
)

return sim
Expand All @@ -404,7 +397,7 @@ def build_models(idx, test):
ws = test.workspace
name = cases[idx]

print("Building MF6 model...{}".format(name))
print(f"Building MF6 model...{name}")

# generate names for each model
gwfname1 = "gwf-" + name + "nwt1"
Expand All @@ -417,9 +410,7 @@ def build_models(idx, test):
)

# Instantiating MODFLOW 6 time discretization
flopy.mf6.ModflowTdis(
sim, nper=nper, perioddata=tdis_rc, time_units=time_units
)
flopy.mf6.ModflowTdis(sim, nper=nper, perioddata=tdis_rc, time_units=time_units)

# Build two flow models, one with NWT, one without
sim = add_gwf_model(sim, gwfname1, newton=True)
Expand All @@ -436,7 +427,7 @@ def build_models(idx, test):
exgmnamea=gwfname1,
exgmnameb=gwename1,
pname="GWFGWE1",
filename="{}.gwfgwe1".format(gwename1),
filename=f"{gwename1}.gwfgwe1",
)

flopy.mf6.ModflowGwfgwe(
Expand All @@ -445,7 +436,7 @@ def build_models(idx, test):
exgmnamea=gwfname2,
exgmnameb=gwename2,
pname="GWFGWE2",
filename="{}.gwfgwe2".format(gwename2),
filename=f"{gwename2}.gwfgwe2",
)

return sim, None
Expand Down
30 changes: 10 additions & 20 deletions autotest/test_gwf_sfrsft_gwdischrg.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,7 @@


def add_gwt_model(sim, gwtname):
gwt = flopy.mf6.ModflowGwt(
sim, modelname=gwtname, model_nam_file="{}.nam".format(gwtname)
)
gwt = flopy.mf6.ModflowGwt(sim, modelname=gwtname, model_nam_file=f"{gwtname}.nam")
gwt.name_file.save_flows = True

imsgwt = flopy.mf6.ModflowIms(
Expand All @@ -41,7 +39,7 @@ def add_gwt_model(sim, gwtname):
scaling_method="NONE",
reordering_method="NONE",
relaxation_factor=relax,
filename="{}.ims".format(gwtname),
filename=f"{gwtname}.ims",
)
sim.register_ims_package(imsgwt, [gwt.name])

Expand All @@ -65,7 +63,7 @@ def add_gwt_model(sim, gwtname):
gwt,
sources=sourcerecarray,
pname="SSM",
filename="{}.ssm".format(gwtname),
filename=f"{gwtname}.ssm",
)

# Instantiate Streamflow Transport package
Expand All @@ -90,16 +88,14 @@ def add_gwt_model(sim, gwtname):
reachperioddata=sft_perioddata,
flow_package_name=flwpckname,
pname="SFT",
filename="{}.sft".format(gwtname),
filename=f"{gwtname}.sft",
)

flopy.mf6.ModflowGwtoc(
gwt,
budget_filerecord=f"{gwtname}.cbc",
concentration_filerecord=f"{gwtname}.ucn",
concentrationprintrecord=[
("COLUMNS", 10, "WIDTH", 15, "DIGITS", 6, "GENERAL")
],
concentrationprintrecord=[("COLUMNS", 10, "WIDTH", 15, "DIGITS", 6, "GENERAL")],
saverecord=[("CONCENTRATION", "ALL"), ("BUDGET", "ALL")],
printrecord=[("CONCENTRATION", "ALL"), ("BUDGET", "ALL")],
)
Expand Down Expand Up @@ -150,10 +146,8 @@ def build_models(idx, test):
)

# sfr data
# <ifno> <cellid(ncelldim)> <rlen> <rwid> <rgrd> <rtp> <rbth> <rhk> <man> <ncon> <ustrf> <ndv>
package_data = [
(0, (0, 0, 0), delr, 1.0, 1e-3, 0.0, 1.0, 1.0, 0.001, 0, 0.0, 0)
]
# <ifno> <cellid> <rlen> <rwid> <rgrd> <rtp> <rbth> <rhk> <man> <ncon> <ustrf> <ndv>
package_data = [(0, (0, 0, 0), delr, 1.0, 1e-3, 0.0, 1.0, 1.0, 0.001, 0, 0.0, 0)]
connection_data = [(0)]

sfr_obs = {
Expand Down Expand Up @@ -191,7 +185,7 @@ def build_models(idx, test):
exgmnamea=name,
exgmnameb=gwtname,
pname="GWFGWT1",
filename="{}.gwfgwt1".format(gwtname),
filename=f"{gwtname}.gwfgwt1",
)

return sim, None
Expand Down Expand Up @@ -227,9 +221,7 @@ def check_output(idx, test):
)
sim_conc_sft = cobj.get_alldata()
except:
assert (
False
), f'could not load concentration data from "{sft_obs_fl}"'
assert False, f'could not load concentration data from "{sft_obs_fl}"'

gwt_sim_conc = pl.Path(f"{test.workspace}/{gwtname}.ucn")
try:
Expand All @@ -240,9 +232,7 @@ def check_output(idx, test):
)
conc_gw = cobj.get_alldata()
except:
assert (
False
), f'could not load temperature data from "{sft_obs_fl}"'
assert False, f'could not load temperature data from "{sft_obs_fl}"'

msg0 = "The simulation is not matching the established answer"
msg1 = (
Expand Down
Loading

0 comments on commit 3df7bd3

Please sign in to comment.