Skip to content

Commit

Permalink
fix(vtk): change in export_model when packages_names is None (#770)
Browse files Browse the repository at this point in the history
model packages extraction change from ml.packageslist to model.packageslist
  • Loading branch information
rodrperezi authored and langevin-usgs committed Dec 30, 2019
1 parent ec71e6c commit 73f7051
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 1 deletion.
34 changes: 34 additions & 0 deletions autotest/t069_test_vtkexportmodel.py
@@ -0,0 +1,34 @@
"""
Test vtk export_model function without packages_names definition
"""

import os
import flopy
from flopy.export import vtk

mf_exe_name = 'mf6'

def test_vtk_export_model_without_packages_names():

ws = os.path.join('.', 'temp', 't069')
name = 'mymodel'
sim = flopy.mf6.MFSimulation(sim_name=name, sim_ws=ws, exe_name='mf6')
tdis = flopy.mf6.ModflowTdis(sim)
ims = flopy.mf6.ModflowIms(sim)
gwf = flopy.mf6.ModflowGwf(sim, modelname=name, save_flows=True)
dis = flopy.mf6.ModflowGwfdis(gwf, nrow=10, ncol=10)
ic = flopy.mf6.ModflowGwfic(gwf)
npf = flopy.mf6.ModflowGwfnpf(gwf, save_specific_discharge=True)
chd = flopy.mf6.ModflowGwfchd(gwf, stress_period_data=[[(0, 0, 0), 1.],
[(0, 9, 9), 0.]])

# Export model without specifying packages_names parameter
vtk.export_model(sim.get_model(), ws)

# If the function executes without error then test was successful
assert True

if __name__ == '__main__':
test_vtk_export_model_without_packages_names()


2 changes: 1 addition & 1 deletion flopy/export/vtk.py
Expand Up @@ -1543,7 +1543,7 @@ def export_model(model, ot_folder, package_names=None, nanval=-1e+20,
if not isinstance(package_names, list):
package_names = [package_names]
else:
package_names = [pak.name[0] for pak in ml.packagelist]
package_names = [pak.name[0] for pak in model.packagelist]

if not os.path.exists(ot_folder):
os.mkdir(ot_folder)
Expand Down

0 comments on commit 73f7051

Please sign in to comment.