flopy.mf6.mfmodel module

mfmodel module. Contains the MFModel class

class MFModel(simulation, model_type='gwf6', modelname='model', model_nam_file=None, version='mf6', exe_name='mf6.exe', add_to_simulation=True, structure=None, model_rel_path='.', verbose=False, **kwargs)[source]

Bases: flopy.mf6.mfbase.PackageContainer, flopy.mbase.ModelInterface

MODFLOW Model Class. Represents a single model in a simulation.

Parameters:
  • simulation_data (MFSimulationData) – simulation data object
  • structure (MFModelStructure) – structure of this type of model
  • modelname (string) – name of the model
  • model_nam_file (string) – relative path to the model name file from model working folder
  • version (string) – version of modflow
  • exe_name (string) – model executable name
  • model_ws (string) – model working folder path
  • disfile (string) – relative path to dis file from model working folder
  • grid_type (string) – type of grid the model will use (structured, unstructured, vertices)
  • verbose (bool) – verbose setting for model operations (default False)
model_name

name of the model

Type:string
exe_name

model executable name

Type:string
packages

dictionary of model packages

Type:OrderedDict(MFPackage)
_name_file_io

name file

Type:MFNameFile
load : (simulation : MFSimulationData, model_name : string,

namfile : string, type : string, version : string, exe_name : string, model_ws : string, strict : boolean) : MFSimulation

a class method that loads a model from files
write()[source]

writes the simulation to files

remove_package : (package_name : string)

removes package from the model. package_name can be the package’s name, type, or package object to be removed from the model

set_model_relative_path : (path : string)

sets the file path to the model folder and updates all model file paths

is_valid : () : boolean

checks the validity of the model and all of its packages

rename_all_packages : (name : string)

renames all packages in the model

set_all_data_external : (check_data : boolean)

sets the model’s list and array data to be stored externally, check_data determines if data error checking is enabled during this process

Notes

Examples

check(f=None, verbose=True, level=1)[source]

Check model data for common errors.

Parameters:
  • f (str or file handle) – String defining file name or file handle for summary file of check method output. If a string is passed a file handle is created. If f is None, check method does not write results to a summary file. (default is None)
  • verbose (bool) – Boolean flag used to determine if check method results are written to the screen
  • level (int) – Check method analysis level. If level=0, summary checks are performed. If level=1, full checks are performed.
Returns:

Return type:

None

Examples

>>> import flopy
>>> m = flopy.modflow.Modflow.load('model.nam')
>>> m.check()
exename
export(f, **kwargs)[source]
get_grid_type()[source]

Return the type of grid used by model ‘model_name’ in simulation containing simulation data ‘simulation_data’.

Returns:grid type
Return type:DiscretizationType
get_ims_package()[source]
get_steadystate_list()[source]
hdry
hnoflo
is_valid()[source]

checks the validity of the model and all of its packages

Returns:valid
Return type:boolean

Examples

laycbd
laytyp
classmethod load_base(simulation, structure, modelname='NewModel', model_nam_file='modflowtest.nam', mtype='gwf', version='mf6', exe_name='mf6.exe', strict=True, model_rel_path='.', load_only=None)[source]

Load an existing model.

Parameters:
  • simulation (MFSimulation) – simulation object that this model is a part of
  • simulation_data (MFSimulationData) – simulation data object
  • structure (MFModelStructure) – structure of this type of model
  • model_name (string) – name of the model
  • model_nam_file (string) – relative path to the model name file from model working folder
  • version (string) – version of modflow
  • exe_name (string) – model executable name
  • model_ws (string) – model working folder relative to simulation working folder
  • strict (boolean) – strict mode when loading files
  • model_rel_path (string) – relative path of model folder to simulation folder
  • load_only (list) – list of package abbreviations or package names corresponding to packages that flopy will load. default is None, which loads all packages. the discretization packages will load regardless of this setting. subpackages, like time series and observations, will also load regardless of this setting. example list: [‘ic’, ‘maw’, ‘npf’, ‘oc’, ‘my_well_package_1’]
Returns:

model

Return type:

MFModel

Examples

load_package(ftype, fname, pname, strict, ref_path, dict_package_name=None, parent_package=None)[source]

loads a package from a file

Parameters:
  • ftype (string) – the file type
  • fname (string) – the name of the file containing the package input
  • pname (string) – the user-defined name for the package
  • strict (bool) – strict mode when loading the file
  • ref_path (string) – path to the file. uses local path if set to None
  • dict_package_name (string) – package name for dictionary lookup
  • parent_package (MFPackage) – parent package

Examples

model_ws
modeldiscrit
modelgrid
modeltime
namefile
nper
packagelist
plot(SelPackList=None, **kwargs)[source]

Plot 2-D, 3-D, transient 2-D, and stress period list (MfList) model input data from a model instance

Parameters:
  • model – Flopy model instance
  • SelPackList – (list) list of package names to plot, if none all packages will be plotted
  • **kwargs

    dict filename_base : str

    Base file name that will be used to automatically generate file names for output image files. Plots will be exported as image files if file_name_base is not None. (default is None)
    file_extension : str
    Valid matplotlib.pyplot file extension for savefig(). Only used if filename_base is not None. (default is ‘png’)
    mflay : int
    MODFLOW zero-based layer number to return. If None, then all all layers will be included. (default is None)
    kper : int
    MODFLOW zero-based stress period number to return. (default is zero)
    key : str
    MfList dictionary key. (default is None)
Returns:

list

Empty list is returned if filename_base is not None. Otherwise a list of matplotlib.pyplot.axis are returned.

Return type:

axes

register_package(package, add_to_package_list=True, set_package_name=True, set_package_filename=True)[source]

registers a package with the model

Parameters:
  • package (MFPackage) – package to register
  • add_to_package_list (bool) – add package to lookup list
  • set_package_name (bool) – produce a package name for this package
  • set_package_filename (bool) – produce a filename for this package
Returns:

(path

Return type:

tuple, package structure : MFPackageStructure)

Examples

remove_package(package_name)[source]

removes a package and all child packages from the model

Parameters:package_name (str) – package name, package type, or package object to be removed from the model

Examples

rename_all_packages(name)[source]
set_all_data_external(check_data=True)[source]
set_model_relative_path(model_ws)[source]

sets the file path to the model folder relative to the simulation folder and updates all model file paths, placing them in the model folder

Parameters:model_ws (string) – model working folder relative to simulation working folder

Examples

solver_tols
verbose
version
write(ext_file_action=<ExtFileAction.copy_relative_paths: 3>)[source]

write model to model files

Parameters:ext_file_action (ExtFileAction) – defines what to do with external files when the simulation path has changed. defaults to copy_relative_paths which copies only files with relative paths, leaving files defined by absolute paths fixed.

Examples