flopy.mf6.mfmodel module
- class MFModel(simulation, model_type='gwf6', modelname='model', model_nam_file=None, version='mf6', exe_name='mf6', add_to_simulation=True, structure=None, model_rel_path='.', verbose=False, **kwargs)[source]
Bases:
PackageContainer
,ModelInterface
MODFLOW-6 model base class. Represents a single model in a simulation.
- Parameters:
simulation_data (MFSimulationData) – Simulation data object of the simulation this model will belong to
structure (MFModelStructure) – Structure of this type of model
modelname (str) – Name of the model
model_nam_file (str) – Relative path to the model name file from model working folder
version (str) – Version of modflow
exe_name (str) – Model executable name
model_ws (str) – Model working folder path
disfile (str) – Relative path to dis file from model working folder
grid_type (str) – Type of grid the model will use (structured, unstructured, vertices)
verbose (bool) – Verbose setting for model operations (default False)
- 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:
success
- Return type:
Examples
>>> import flopy >>> m = flopy.modflow.Modflow.load('model.nam') >>> m.check()
- property exename
MODFLOW executable name
- export(f, **kwargs)[source]
Method to export a model to a shapefile or netcdf file
- Parameters:
f (str) – File name (“.nc” for netcdf or “.shp” for shapefile) or dictionary of ….
**kwargs (keyword arguments) –
- modelgrid: flopy.discretization.Grid
User supplied modelgrid object which will supercede the built in modelgrid object
- epsgint
EPSG projection code
- prjstr
The prj file name
if fmt is set to ‘vtk’, parameters of vtk.export_model
- 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:
- get_ims_package()[source]
Get the IMS package associated with this model.
- Returns:
IMS package
- Return type:
- get_steadystate_list()[source]
Returns a list of stress periods that are steady state.
- Returns:
steady state list
- Return type:
- property hdry
Dry cell value
- property hnoflo
No-flow cell value
- inspect_cells(cell_list, stress_period=None, output_file_path=None, inspect_budget=True, inspect_dependent_var=True)[source]
Inspect model cells. Returns model data associated with cells.
- Parameters:
cell_list (list of tuples) – List of model cells. Each model cell is a tuple of integers. ex: [(1,1,1), (2,4,3)]
stress_period (int) – For transient data qnly return data from this stress period. If not specified or None, all stress period data will be returned.
output_file_path (str) – Path to output file that will contain the inspection results
inspect_budget (bool) – Inspect budget file
inspect_dependent_var (bool) – Inspect head file
- Returns:
output – Dictionary containing inspection results
- Return type:
Examples
>>> import flopy >>> sim = flopy.mf6.MFSimulation.load("name", "mf6", "mf6", ".") >>> model = sim.get_model() >>> inspect_list = [(2, 3, 2), (0, 4, 2), (0, 2, 4)] >>> out_file = os.path.join("temp", "inspect_AdvGW_tidal.csv") >>> model.inspect_cells(inspect_list, output_file_path=out_file)
- is_valid()[source]
Checks the validity of the model and all of its packages
- Returns:
valid
- Return type:
- property laycbd
Quasi-3D confining bed. Not supported in MODFLOW-6.
- Returns:
None
- Return type:
None
- property laytyp
Layering type
- classmethod load_base(simulation, structure, modelname='NewModel', model_nam_file='modflowtest.nam', mtype='gwf', version='mf6', exe_name: str | PathLike = 'mf6', strict=True, model_rel_path='.', load_only=None)[source]
Class method that loads 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 (str) – name of the model
model_nam_file (str) – relative path to the model name file from model working folder
version (str) – version of modflow
exe_name (str or PathLike) – model executable name or path
strict (bool) – strict mode when loading files
model_rel_path (str) – 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:
Examples
- load_package(ftype, fname, pname, strict, ref_path, dict_package_name=None, parent_package=None)[source]
Loads a package from a file. This method is used internally by FloPy and is not intended for the end user.
- Parameters:
ftype (str) – the file type
fname (str) – the name of the file containing the package input
pname (str) – the user-defined name for the package
strict (bool) – strict mode when loading the file
ref_path (str) – path to the file. uses local path if set to None
dict_package_name (str) – package name for dictionary lookup
parent_package (MFPackage) – parent package
Examples
- property model_ws
Model file path.
- property modeldiscrit
Basic model spatial discretization information. This is used internally prior to model spatial discretization information being fully loaded.
- Returns:
model grid – FloPy object containing basic spatial discretization information for the model.
- Return type:
Grid subclass
- property modelgrid
Model spatial discretization information.
- Returns:
model grid – FloPy object containing spatial discretization information for the model.
- Return type:
Grid subclass
- property modeltime
Model time discretization information.
- Returns:
modeltime – FloPy object containing time discretization information for the simulation.
- Return type:
- property namefile
Model namefile object.
- property nper
Number of stress periods.
- Returns:
nper – Number of stress periods in the simulation.
- Return type:
- property output
- property packagelist
List of model packages.
- 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_extensionstr
Valid matplotlib.pyplot file extension for savefig(). Only used if filename_base is not None. (default is ‘png’)
- mflayint
MODFLOW zero-based layer number to return. If None, then all all layers will be included. (default is None)
- kperint
MODFLOW zero-based stress period number to return. (default is zero)
- keystr
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. This method is used internally by FloPy and is not intended for use by the end user.
- Parameters:
- Returns:
path, package structure
- Return type:
tuple, MFPackageStructure
- remove_package(package_name)[source]
Removes package and all child packages from the model. package_name can be the package’s name, type, or package object to be removed from the model.
- Parameters:
package_name (str) – Package name, package type, or package object to be removed from the model.
- rename_all_packages(name)[source]
Renames all package files in the model.
- Parameters:
name (str) – Prefix of package names. Packages files will be named <name>.<package ext>.
- set_all_data_external(check_data=True, external_data_folder=None)[source]
Sets the model’s list and array data to be stored externally.
- Parameters:
check_data (bool) – Determines if data error checking is enabled during this process.
external_data_folder – Folder, relative to the simulation path or model relative path (see use_model_relative_path parameter), where external data will be stored
- set_all_data_internal(check_data=True)[source]
Sets the model’s list and array data to be stored externally.
- Parameters:
check_data (bool) – Determines if data error checking is enabled during this process.
- 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 (str) – Model working folder relative to simulation working folder
- property solver_tols
Returns the solver inner hclose and rclose values.
- update_package_filename(package, new_name)[source]
Updates the filename for a package. For internal flopy use only.
- property verbose
Verbose setting for model operations (True/False)
- property version
Version of MODFLOW
- write(ext_file_action=ExtFileAction.copy_relative_paths)[source]
Writes out model’s package 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.