flopy.mfusg package

Submodules

Module contents

Initialize MfUsg.

class MfUsg(modelname='modflowusgtest', structured=True, model_ws: str | PathLike = '.', **kwargs)[source]

Bases: Modflow

MODFLOW-USG Model Class.

Parameters:
  • modelname (str or PathLike, default "modflowusgtest".) – Name of model. This string will be used to name the MODFLOW input that are created with write_model.

  • namefile_ext (str, default "nam") – Extension for the namefile.

  • exe_name (str, default "mfusg") – The name of the executable to use.

  • structured (bool, default True) – Specify if model grid is structured (default) or unstructured.

  • listunit (int, default 2) – Unit number for the list file.

  • model_ws (str, default ".") – Model workspace. Directory name to create model data sets. Default is the present working directory.

  • external_path (str, optional) – Location for external files.

  • verbose (bool, default False) – Print additional information to the screen.

Notes

Examples

>>> import flopy
>>> usg = flopy.mfusg.MfUsg()
classmethod load(f: str, version='mfusg', exe_name: str | PathLike = 'mfusg', verbose=False, model_ws: str | PathLike = '.', load_only=None, forgive=False, check=True)[source]

Load an existing MODFLOW-USG model.

Parameters:
  • f (str) – Name of MODFLOW name file to load.

  • version (str, default "mfusg") – MODFLOW version. Must be “mfusg”.

  • exe_name (str, default "mfusg") – MODFLOW executable name.

  • verbose (bool, default False) – Show messages that can be useful for debugging.

  • model_ws (str or PathLike, default ".") – Model workspace path. Default is the current directory.

  • load_only (list, str or None) – List of case insensitive packages to load, e.g. [“bas6”, “lpf”]. One package can also be specified, e.g. “rch”. Default is None, which attempts to load all files. An empty list [] will not load any additional packages than is necessary. At a minimum, “dis” or “disu” is always loaded.

  • forgive (bool, optional, default False) – Option to raise exceptions on package load failure, which can be useful for debugging. Default False.

  • check (boolean, optional) – Check model input for common errors. Default True.

Return type:

flopy.mfusg.MfUsg

Examples

>>> import flopy
>>> ml = flopy.mfusg.MfUsg.load('model.nam')
class MfUsgBcf(model, ipakcb=None, intercellt=0, laycon=3, trpy=1.0, hdry=-1e+30, iwdflg=0, wetfct=0.1, iwetit=1, ihdwet=0, ikvflag=0, ikcflag=0, tran=1.0, hy=1.0, vcont=1.0, kv=1.0, anglex=0.0, ksat=1.0, sf1=1e-05, sf2=0.15, wetdry=-0.01, extension='bcf', unitnumber=None, filenames=None, add_package=True)[source]

Bases: ModflowBcf

Block Centered Flow (BCF) Package Class for MODFLOW-USG.

Parameters:
  • model (model object) – The model object (of type flopy.modflow.Modflow) to which this package will be added.

  • ipakcb (int, optional) – Toggles whether cell-by-cell budget data should be saved. If None or zero, budget data will not be saved (default is None).

  • intercellt (int) – Intercell transmissivities, harmonic mean (0), arithmetic mean (1), logarithmic mean (2), combination (3). (default is 0)

  • laycon (int) – Layer type, confined (0), unconfined (1), constant T, variable S (2), variable T, variable S (default is 3)

  • trpy (float or array of floats (nlay)) – horizontal anisotropy ratio (default is 1.0)

  • hdry (float) – head assigned when cell is dry - used as indicator(default is -1E+30)

  • iwdflg (int) – flag to indicate if wetting is inactive (0) or not (non zero) (default is 0)

  • wetfct (float) – factor used when cell is converted from dry to wet (default is 0.1)

  • iwetit (int) – iteration interval in wetting/drying algorithm (default is 1)

  • ihdwet (int) – flag to indicate how initial head is computed for cells that become wet (default is 0)

  • ikvflag (int) – flag indicating if vertical hydraulic conductivity is input instead of leakance between two layers.

  • ikcflag (int) – flag indicating if hydraulic conductivity or transmissivity information is input for each of the nodes or whether this information is directly input for the nodal connections. The easiest input format is to provide the hydraulic conductivity or transmissivity values to the cells using a zero value for IKCFLAG.

  • anglex (float or array of floats (njag)) – is the angle (in radians) between the horizontal x-axis and the outward normal to the face between a node and its connecting nodes. The angle varies between zero and 6.283185 (two pi being 360 degrees).

  • tran (float or array of floats (nlay, nrow, ncol), optional) – transmissivity (only read if laycon is 0 or 2) (default is 1.0)

  • hy (float or array of floats (nlay, nrow, ncol)) – hydraulic conductivity (only read if laycon is 1 or 3) (default is 1.0)

  • vcont (float or array of floats (nlay-1, nrow, ncol)) – vertical leakance between layers (default is 1.0)

  • kv (float or array of floats (nlay, nrow, ncol)) – is the vertical hydraulic conductivity of the cell and the leakance is computed for each vertical connection.

  • sf1 (float or array of floats (nlay, nrow, ncol)) – specific storage (confined) or storage coefficient (unconfined), read when there is at least one transient stress period. (default is 1e-5)

  • sf2 (float or array of floats (nlay, nrow, ncol)) – specific yield, only read when laycon is 2 or 3 and there is at least one transient stress period (default is 0.15)

  • wetdry (float) – a combination of the wetting threshold and a flag to indicate which neighboring cells can cause a cell to become wet (default is -0.01)

  • ksat (float or array of floats (njag)) – inter-block saturated hydraulic conductivity or transmissivity (if IKCFLAG = 1) or the inter-block conductance (if IKCFLAG = - 1) of the connection between nodes n and m.

  • extension (string) – Filename extension (default is ‘bcf’)

  • unitnumber (int) – File unit number (default is None).

  • filenames (str or list of str) – Filenames to use for the package and the output files. If filenames=None the package name will be created using the model name and package extension and the cbc output name will be created using the model name and .cbc extension (for example, modflowtest.cbc), if ipakcb is a number greater than zero. If a single string is passed the package will be set to the string and cbc output name will be created using the model name and .cbc extension, if ipakcb is a number greater than zero. To define the names for all package files (input and output) the length of the list of strings should be 2. Default is None.

  • add_package (bool) – Flag to add the initialised package object to the parent model object. Default is True.

Notes

Examples

>>> import flopy
>>> ml = flopy.mfusg.MfUsg()
>>> disu = flopy.mfusg.MfUsgDisU(model=ml, nlay=1, nodes=1,
             iac=[1], njag=1,ja=np.array([0]), fahl=[1.0], cl12=[1.0])
>>> bcf = flopy.mfusg.MfUsgBcf(ml)
classmethod load(f, model, ext_unit_dict=None)[source]

Load an existing package.

Parameters:
  • f (filename or file handle) – File to load.

  • model (model object) – The model object (of type flopy.modflow.mf.Modflow) to which this package will be added.

  • ext_unit_dict (dictionary, optional) – If the arrays in the file are specified using EXTERNAL, or older style array control records, then f should be a file handle. In this case ext_unit_dict is required, which can be constructed using the function flopy.utils.mfreadnam.parsenamefile.

Returns:

bcf

Return type:

MfUsgBcf object

Examples

>>> import flopy
>>> m = flopy.mfusg.MfUsg()
>>> disu = flopy.mfusg.MfUsgDisU(
    model=m, nlay=1, nodes=1, iac=[1], njag=1,ja=np.array([0]), fahl=[1.0], cl12=[1.0])
>>> bcf = flopy.mfusg.MfUsgBcf.load('test.bcf', m)
write_file(f=None)[source]

Write the BCF package file.

Parameters:

f (open file object.) – Default is None, which will result in MfUsg.fn_path being opened for writing.

class MfUsgCln(model, ncln=None, iclnnds=None, nndcln=None, clncon=None, nja_cln=None, iac_cln=None, ja_cln=None, node_prop=None, nclngwc=None, cln_gwc=None, nconduityp=1, cln_circ=None, ibound=1, strt=1.0, transient=False, printiaja=False, nrectyp=0, cln_rect=None, bhe=False, grav=None, visk=None, extension=('cln', 'clncb', 'clnhd', 'clndd', 'clnib', 'clncn', 'clnmb'), unitnumber=None, filenames=None)[source]

Bases: Package

Connected Linear Network (CLN) Package class for MODFLOW-USG.

Parameters:
  • model (model object) – The model object (of type flopy.modflowusg.mf.Modflow) to which this package will be added.

  • ncln (int) – is a flag or the number of CLN segments. If NCLN = 0, this flag indicates that the CLN domain connectivity is input in a general IA-JA manner as is used for the GWF Process.If NCLN > 0, linear CLN segments (for instance multi-aquifer wells) or simple CLN networks are simulated and NCLN is the total number of CLN segments in the domain.

  • iclnnds (int) – is a flag or number of CLN-nodes simulated in the model. Multiple CLN-nodes constitute a segment.If ICLNNDS < 0, the CLN-nodes are ordered in a sequential manner from the first CLN node to the last CLN node. Therefore, only linear CLN segments are simulated since a CLN segment does not share any of its nodes with another CLN segment. If ICLNNDS > 0, CLN networks can be simulated and ICLNNDS is the total number of CLN-nodes simulated by the model (NCLNNDS). CLN nodes can be shared among CLN segments and therefore, the CLN-nodal connectivity for the network is also required as input.

  • nndcln (list of int) – is the number of CLN-nodes that are associated with each CLN segment. Only read if NCLN > 0. If ICLNNDS < 0, sum of nndcln is the total number of CLN-nodes (NCLNNDS)

  • clncon (list of list) – are the CLN-node numbers associated with each CLN segment. Only read if NCLN > 0 and ICLNNDS > 0. It is read NCLN times, once for each CLN segment. The number of entries for each sublist is the number of CLN cells (NNDCLN) associated with each CLN segment

  • nja_cln (int) – is the total number of connections of the CLN domain. NJA_CLN is used to dimension the sparse matrix in a compressed row storage format.

  • iac_cln (list of int) – is a matrix indicating the number of connections plus 1 for each CLN node to another CLN node. Note that the IAC_CLN array is only supplied for the CLN cells; the IAC_CLN array is internally expanded to include other domains if present in a simulation. sum(IAC)=NJAG

  • ja_cln (list of list) – is a list of CLN cell number (n) followed by its connecting CLN cell numbers (m) for each of the m CLN cells connected to CLN cell n. This list is sequentially provided for the first to the last CLN cell. Note that the cell and its connections are only supplied for the CLN cells and their connections to the other CLN cells using the local CLN cell numbers.

  • node_prop (matrix) – [IFNO IFTYP IFDIR FLENG FELEV FANGLE IFLIN ICCWADI X1 Y1 Z1 X2 Y2 Z2] is a table of the node properties. Total rows equal the total number of CLN-nodes (NCLNNDS). The first 6 fields is required for running model. Rest of fields have default value of 0.

  • nclngwc (int) – is the number of CLN to porous-medium grid-block connections present in the model. A CLN node need not be connected to any groundwater node. Conversely, a CLN node may be connected to multiple groundwater nodes, or multiple CLN nodes may be connected to the same porous medium mode.

  • cln_gwc (matrix) –

    unstructured: [IFNOD IGWNOD IFCON FSKIN FLENGW FANISO ICGWADI] structured: [IFNOD IGWLAY IGWROW IGWFCOL IFCON FSKIN FLENGW FANISO

    ICGWADI]

    is a table define connections between CLN nodes and groundwater cells. Total rows of the table equals nclngwc.

  • nconduityp (int) – is the number of circular conduit-geometry types.

  • cln_circ – [ICONDUITYP FRAD CONDUITK TCOND TTHK TCFLUID TCONV] is a table define the circular conduit properties. Total rows of the table equals nconduityp. Last 4 fields only needed for heat transport simulation.

  • ibound (1-D array) – is the boundary array for CLN-nodes. Length equal NCLNNDS

  • strt (1-D array) – is initial head at the beginning of the simulation in CLN nodes. Length equal NCLNNDS

  • transient (bool) – if there is transient IBOUND for each stress period

  • printiaja (bool) – whether to print IA_CLN and JA_CLN to listing file

  • nrectyp (int) – is the number of rectangular conduit-geometry types.

  • cln_rect (rectangular fracture properties) – [IRECTYP FLENGTH FHEIGHT CONDUITK TCOND TTHK TCFLUID TCONV] is read for each rectangular conduit. Total rows of the table equals nrectyp. Last 4 fields only needed for heat transport simulation.

  • bhe (bool) – is a flag indicating that bhe details are also included in a heat transport model. Specifically, the thermal conductance and bhe tube thickness are included in transfer of heat between groundwater and CLN cells along with the heat conductivity of the bhe fluid and the convective heat transfer coefficient.

  • grav (float) – is the gravitational acceleration constant in model simulation units. The value of the constant follows the keyword GRAVITY. Note that the constant value is 9.81 m/s2 in SI units; 32.2 ft/s2 in fps units.

  • visk (float) – is the kinematic viscosity of water in model simulation units [L2/T]. The value of kinematic viscosity follows the keyword VISCOSITY. Note that the constant value is 1.787 x 10-6 m2/s in SI units; 1.924 x 10-5 ft2/s in fps units.

  • extension (list of strings) – (default is [‘cln’,’clncb’,’clnhd’,’clndd’,’clnib’,’clncn’,’clnmb’]).

  • unitnumber (list of int) – File unit number for the package and the output files. (default is [71, 0, 0, 0, 0, 0, 0] ).

  • filenames (list of str) – Filenames to use for the package and the output files. If filenames = None the package name will be created using the model name and package extensions.

Notes

Examples

>>> import flopy
>>> ml = flopy.mfusg.MfUsg()
>>> node_prop = [[1,1,0,10.0,-110.0,1.57,0,0],[2,1,0,10.0,-130.0,1.57,0,0]]
>>> cln_gwc = [[1,1,50,50,0,0,10.0,1.0,0],[2,2,50,50,0,0,10.0,1.0,0]]
>>> cln = flopy.mfusg.MfUsgCln(ml, ncln=1, iclnnds=-1, nndcln=2,
        nclngwc = 2, node_prop =node_prop, cln_gwc =cln_gwc)
property cln_nodes

Returns the total number of CLN nodes.

classmethod load(f, model, pak_type='cln', ext_unit_dict=None, **kwargs)[source]

Load an existing package.

Parameters:
  • f (filename or file handle) – File to load.

  • model (model object) – The model object (of type flopy.modflow.mf.Modflow) to which this package will be added.

  • ext_unit_dict (dictionary, optional) – If the arrays in the file are specified using EXTERNAL, or older style array control records, then f should be a file handle. In this case ext_unit_dict is required, which can be constructed using the function flopy.utils.mfreadnam.parsenamefile.

Returns:

cln

Return type:

MfUsgCln object

Examples

>>> import flopy
>>> m = flopy.modflow.Modflow()
>>> cln = flopy.mfusg.MfUsgCln.load('test.cln', m)
write_file(f=None, check=False)[source]

Write the package file.

Parameters:

f (filename or file handle) – File to write to.

Return type:

None

class MfUsgClnDtypes[source]

Bases: object

Defines MfUsgCln dtypes for various CLN geometries.

static get_clncirc_dtype(bhe=False)[source]

Dtype of CLN node circular conduit type properties.

Parameters:

bhe (borehole heat exchanger (bhe)) –

Return type:

dtype

static get_clnnode_dtype()[source]

Define dtype of CLN node properties.

Return type:

dtype

static get_clnrect_dtype(bhe=False)[source]

Returns the dtype of CLN node rectangular conduit type properties.

Parameters:

bhe (borehole heat exchanger (bhe)) –

Return type:

dtype

static get_gwconn_dtype(structured=True)[source]

Dtype of CLN node - GW node connection properties.

Parameters:

structured (True = structured grid) –

Return type:

dtype

class MfUsgDisU(model, nodes=2, nlay=1, njag=None, ivsd=0, nper=1, itmuni=4, lenuni=2, idsymrd=0, laycbd=0, nodelay=None, top=1, bot=0, area=1.0, iac=None, ja=None, ivc=None, cl1=None, cl2=None, cl12=None, fahl=None, perlen=1, nstp=1, tsmult=1, steady=True, extension='disu', unitnumber=None, filenames=None, start_datetime=None)[source]

Bases: Package

MODFLOW Unstructured Discretization Package Class.

Parameters:
  • model (model object) – The model object (of type flopy.mfusg.MfUsg) to which this package will be added.

  • nodes (int) – Number of nodes in the model grid (default is 2).

  • nlay (int) – Number of layers in the model grid (default is 1).

  • njag (int) – Total number of connections of an unstructured grid. njag is used to dimension the sparse matrix in a compressed row storage format. For symmetric arrays, only the upper triangle of the matrix may be entered. For that case, the symmetric portion (minus the diagonal terms) is dimensioned as njags = (njag - nodes) / 2. (default is None).

  • ivsd (int) – is the vertical sub-discretization index. For purposes of this flag, vertical sub-discretization is defined to occur when all layers are not a stacked representation of each other. If IVSD = 0 there is no sub-discretization of layers within the model domain. That is, grids are not nested in the vertical direction. However, one layer may have a different grid structure from the next due to different sub-gridding structures within each layer. If IVSD = 1 there could be sub-discretization of layers with vertically nested grids (as shown in Figure 5c in the MODFLOW-USG document) within the domain. For this case, the vertical connection index IVC is required to determine the vertical connections of every node. Otherwise, the vertical connections are internally computed and IVC is not read. If IVSD = -1 there is no vertical sub-discretization of layers, and further, the horizontal discretization of all layers is the same. For this case, the cell areas (AREA) are read only for one layer and are computed to be the same for all the stacked layers. A structured finite-difference grid is an example of this condition. (default is 0).

  • nper (int) – Number of model stress periods (the default is 1).

  • itmuni (int) – Time units, default is days (4)

  • lenuni (int) – Length units, default is meters (2)

  • idsymrd (int) – A flag indicating if the finite-volume connectivity information of an unstructured grid is input as a full matrix or as a symmetric matrix in the input file. If idsymrd is 0 the finite-volume connectivity information is provided for the full matrix of the porous matrix grid-block connections of an unstructured grid. The code internally stores only the symmetric portion of this information. This input structure (IDSYMRD=0) is easy to organize but contains unwanted information which is parsed out when the information is stored. If idsymrd is 1 then finite-volume connectivity information is provided only for the upper triangular portion of the porous matrix grid-block connections within the unstructured grid. This input structure (IDSYMRD=1) is compact but is slightly more complicated to organize. Only the non-zero upper triangular items of each row are read in sequence for all symmetric matrices. (default is 0).

  • laycbd (int or array of ints (nlay), optional) – An array of flags indicating whether or not a layer has a Quasi-3D confining bed below it. 0 indicates no confining bed, and not zero indicates a confining bed. LAYCBD for the bottom layer must be 0. (the default is 0)

  • nodelay (int or array of ints (nlay)) – The number of cells in each layer. (the default is None, which means the number of cells in a layer is equal to nodes / nlay).

  • top (float or array of floats (nodes), optional) – An array of the top elevation for every cell. For the situation in which the top layer represents a water-table aquifer, it may be reasonable to set Top equal to land-surface elevation (the default is 1.0)

  • bot (float or array of floats (nodes), optional) – An array of the bottom elevation for each model cell (the default is 0.)

  • area (float or array of floats) – Surface area for model cells. Area is for only one layer if IVSD = -1 to indicate that the grid is vertically stacked. Otherwise, area is required for each layer in the model grid. Note that there may be different number of nodes per layer (ndslay) for an unstructured grid. (default is 1.0)

  • iac (array of integers) – is a vector indicating the number of connections plus 1 for each node. Note that the IAC array is only supplied for the GWF cells; the IAC array is internally expanded to include CLN or GNC nodes if they are present in a simulation. (default is None. iac must be provided).

  • ja (array of integers) – is a list of cell number (n) followed by its connecting cell numbers (m) for each of the m cells connected to cell n. This list is sequentially provided for the first to the last GWF cell. Note that the cell and its connections are only supplied for the GWF cells and their connections to the other GWF cells. This connectivity is internally expanded if CLN or GNC nodes are present in a simulation. Also note that the JA list input may be chopped up to have every node number and its connectivity list on a separate line for ease in readability of the file. To further ease readability of the file, the node number of the cell whose connectivity is subsequently listed, may be expressed as a negative number the sign of which is subsequently corrected by the code. (default is None. ja must be provided).

  • ivc (int or array of integers) – is an index array indicating the direction between a node n and all its m connections. IVC = 0 if the connection between n and m is horizontal. IVC = 1 if the connecting node m is vertically oriented to node n. Note that if the CLN Process is active, the connection between two CLN cells has IVC = 2 and the connection between a CLN cell and a GWF cell has IVC = 3. (default is None. ivc must be provided if ivsd = 1)

  • cl1 (float or array of floats) – is the perpendicular length between the center of a node (node 1) and the interface between the node and its adjoining node (node 2). (default is None. cl1 and cl2 must be specified, or cl12 must be specified)

  • cl2 (float or array of floats) – is the perpendicular length between node 2 and the interface between nodes 1 and 2, and is at the symmetric location of CL1. (default is None. cl1 and cl2 must be specified, or cl12 must be specified)

  • cl12 (float or array of floats) – is the array containing CL1 and CL2 lengths, where CL1 is the perpendicular length between the center of a node (node 1) and the interface between the node and its adjoining node (node 2). CL2, which is the perpendicular length between node 2 and the interface between nodes 1 and 2 is at the symmetric location of CL1. The array CL12 reads both CL1 and CL2 in the upper and lower triangular portions of the matrix respectively. Note that the CL1 and CL2 arrays are only supplied for the GWF cell connections and are internally expanded if CLN or GNC nodes exist in a simulation. (default is None. cl1 and cl2 must be specified, or cl12 must be specified)

  • fahl (float or array of floats) – Area of the interface Anm between nodes n and m. (default is None. fahl must be specified.)

  • perlen (float or array of floats (nper)) – An array of the stress period lengths.

  • nstp (int or array of ints (nper)) – Number of time steps in each stress period (default is 1).

  • tsmult (float or array of floats (nper)) – Time step multiplier (default is 1.0).

  • steady (bool or array of bool (nper)) – True or False indicating whether or not stress period is steady state (default is True).

  • extension (string) – Filename extension (default is ‘dis’)

  • unitnumber (int) – File unit number (default is None).

  • filenames (str or list of str) – Filenames to use for the package. If filenames=None the package name will be created using the model name and package extension. If a single string is passed the package will be set to the string. Default is None.

heading

Text string written to top of package input file.

Type:

str

Notes

Now works for multi-layer USG models since u3d was modified to handle multiple u2d instances of different size.

Examples

>>> import flopy
>>> m = flopy.mfusg.MfUsg()
>>> disu = flopy.mfusg.MfUsgDisU(m)
checklayerthickness()[source]

Check layer thickness.

get_cell_volumes()[source]

Get an array of cell volumes.

Returns:

vol

Return type:

array of floats (nodes)

classmethod load(f, model, ext_unit_dict=None, check=True)[source]

Load an existing package.

Parameters:
  • f (filename or file handle) – File to load.

  • model (model object) – The model object (of type flopy.mfusg.MfUsg) to which this package will be added.

  • ext_unit_dict (dictionary, optional) – If the arrays in the file are specified using EXTERNAL, or older style array control records, then f should be a file handle. In this case ext_unit_dict is required, which can be constructed using the function flopy.utils.mfreadnam.parsenamefile.

  • check (bool) – Check package data for common errors. (default False; not setup yet)

Returns:

dis – MfUsgDisU object.

Return type:

MfUsgDisU object

Examples

>>> import flopy
>>> m = flopy.mfusg.MfUsg()
>>> disu = flopy.mfusg.MfUsgDisU.load('test.disu', m)
property ncpl
write_file()[source]

Write the package file.

Return type:

None

property zcentroids

Return an array of size nodes that contains the vertical cell center elevation.

class MfUsgGnc(model, numgnc=0, numalphaj=1, i2kn=0, isymgncn=0, iflalphan=0, gncdata=None, extension='gnc', options=None, unitnumber=None, filenames=None)[source]

Bases: Package

MODFLOW USG Ghost Node Correction (GNC) Package Class.

Parameters:
  • numgnc (integer) – numgnc (integer) is the number of GNC entries.

  • numalphaj (integer) – numalphaj (integer) is the number of contributing factors.

  • i2kn (integer) – 0 : second-order correction not applied to unconfined transmissivity. 1 : second-order correction applied to unconfined transmissivity.

  • isymgncn (integer) – 0 : implicit update on left-hand side matrix for asymmetric systems. 1 : explicit update on right-hand side vector for symmetric systems.

  • iflalphan (integer) –

    0 : AlphaJ is contributing factors from all adjacent contributing nodes. 1 : AlphaJ represent the saturated conductances between the ghost node

    location and node j, and the contributing factors are computed internally using the equations for the unconfined conductances.

  • gncdata ([cellidn, cellidm, cellidsj, alphasj]) –

    • cellidn ((integer, …)) is the cellid of the cell in which the ghost node is located.

    • cellidm ((integer, …)) is the cellid of the connecting cell

    • cellidsj ((integer, …)) is the array of CELLIDS for the contributing j cells. This Item is repeated for each of the numalphaj adjacent contributing cells of the ghost node.

    • alphasj (double) is the contributing factors for each contributing node in CELLIDSJ. This Item is repeated for each of the numalphaj adjacent contributing cells of the ghost node.

  • model (model object) – The model object (of type flopy.modflow.mf.Modflow) to which this package will be added.

  • extension (str, optional) – File extension (default is ‘gnc’.

  • unitnumber (int, optional) – FORTRAN unit number for this package (default is None).

  • filenames (str or list of str) – Filenames to use for the package. If filenames=None the package name will be created using the model name and package extension. If a single string is passed the package will be set to the string. Default is None.

Notes

Examples

>>> import flopy
>>> m = flopy.modflow.Modflow()
>>> gnc = flopy.mfusg.MfUsgGnc(m)
static get_default_dtype(numalphaj, iflalphan)[source]

Returns default GNC dtypes.

static get_empty(numgnc=0, numalphaj=1, iflalphan=0)[source]

Returns empty GNC recarray of default dtype.

classmethod load(f, model, pak_type='gnc', ext_unit_dict=None, **kwargs)[source]

Load an existing package.

Parameters:
  • f (filename or file handle) – File to load.

  • model (model object) – The model object (of type flopy.modflow.mf.Modflow) to which this package will be added.

  • ext_unit_dict (dictionary, optional) – If the arrays in the file are specified using EXTERNAL, or older style array control records, then f should be a file handle. In this case ext_unit_dict is required, which can be constructed using the function flopy.utils.mfreadnam.parsenamefile.

Returns:

gnc

Return type:

MfUsgGnc object

Examples

>>> import flopy
>>> m = flopy.modflow.Modflow()
>>> gnc = flopy.modflow.ModflowGnc.load('test.gnc', m)
write_file(f=None, check=False)[source]

Write the package file.

Parameters:

f (filename or file handle) – File to write to.

Return type:

None

class MfUsgLpf(model, laytyp=0, layavg=0, chani=1.0, layvka=0, laywet=0, ipakcb=None, hdry=-1e+30, iwdflg=0, wetfct=0.1, iwetit=1, ihdwet=0, ikcflag=0, anglex=0, hk=1.0, hani=1.0, vka=1.0, ss=1e-05, sy=0.15, vkcb=0.0, wetdry=-0.01, ksat=1.0, storagecoefficient=False, constantcv=False, thickstrt=False, nocvcorrection=False, novfc=False, extension='lpf', unitnumber=None, filenames=None, add_package=True)[source]

Bases: ModflowLpf

MODFLOW Layer Property Flow Package Class.

Parameters:
  • model (model object) – The model object (of type flopy.modflowusg.mfusg.MfUsg) to which this package will be added.

  • ipakcb (int, optional) – Toggles whether cell-by-cell budget data should be saved. If None or zero, budget data will not be saved (default is None).

  • hdry (float) – Is the head that is assigned to cells that are converted to dry during a simulation. Although this value plays no role in the model calculations, it is useful as an indicator when looking at the resulting heads that are output from the model. HDRY is thus similar to HNOFLO in the Basic Package, which is the value assigned to cells that are no-flow cells at the start of a model simulation. (default is -1.e30).

  • laytyp (int or array of ints (nlay)) – Layer type, contains a flag for each layer that specifies the layer type. 0 confined >0 convertible <0 convertible unless the THICKSTRT option is in effect. (default is 0).

  • layavg (int or array of ints (nlay)) – Layer average 0 is harmonic mean 1 is logarithmic mean 2 is arithmetic mean of saturated thickness and logarithmic mean of of hydraulic conductivity (default is 0).

  • chani (float or array of floats (nlay)) – contains a value for each layer that is a flag or the horizontal anisotropy. If CHANI is less than or equal to 0, then variable HANI defines horizontal anisotropy. If CHANI is greater than 0, then CHANI is the horizontal anisotropy for the entire layer, and HANI is not read. If any HANI parameters are used, CHANI for all layers must be less than or equal to 0. Use as many records as needed to enter a value of CHANI for each layer. The horizontal anisotropy is the ratio of the hydraulic conductivity along columns (the Y direction) to the hydraulic conductivity along rows (the X direction). (default is 1).

  • layvka (int or array of ints (nlay)) – a flag for each layer that indicates whether variable VKA is vertical hydraulic conductivity or the ratio of horizontal to vertical hydraulic conductivity. 0: VKA is vertical hydraulic conductivity not 0: VKA is the ratio of horizontal to vertical hydraulic conductivity (default is 0).

  • laywet (int or array of ints (nlay)) – contains a flag for each layer that indicates if wetting is active. 0 wetting is inactive not 0 wetting is active (default is 0).

  • wetfct (float) – is a factor that is included in the calculation of the head that is initially established at a cell when it is converted from dry to wet. (default is 0.1).

  • iwetit (int) – is the iteration interval for attempting to wet cells. Wetting is attempted every IWETIT iteration. If using the PCG solver (Hill, 1990), this applies to outer iterations, not inner iterations. If IWETIT less than or equal to 0, it is changed to 1. (default is 1).

  • ihdwet (int) – is a flag that determines which equation is used to define the initial head at cells that become wet. (default is 0)

  • ikcflag (int) – flag indicating if hydraulic conductivity or transmissivity information is input for each of the nodes or whether this information is directly input for the nodal connections. The easiest input format is to provide the hydraulic conductivity or transmissivity values to the cells using a zero value for IKCFLAG.

  • anglex (float or array of floats (njag)) – is the angle (in radians) between the horizontal x-axis and the outward normal to the face between a node and its connecting nodes. The angle varies between zero and 6.283185 (two pi being 360 degrees).

  • hk (float or array of floats (nlay, nrow, ncol)) – is the hydraulic conductivity along rows. HK is multiplied by horizontal anisotropy (see CHANI and HANI) to obtain hydraulic conductivity along columns. (default is 1.0).

  • hani (float or array of floats (nlay, nrow, ncol)) – is the ratio of hydraulic conductivity along columns to hydraulic conductivity along rows, where HK of item 10 specifies the hydraulic conductivity along rows. Thus, the hydraulic conductivity along columns is the product of the values in HK and HANI. (default is 1.0).

  • vka (float or array of floats (nlay, nrow, ncol)) – is either vertical hydraulic conductivity or the ratio of horizontal to vertical hydraulic conductivity depending on the value of LAYVKA. (default is 1.0).

  • ss (float or array of floats (nlay, nrow, ncol)) – is specific storage unless the STORAGECOEFFICIENT option is used. When STORAGECOEFFICIENT is used, Ss is confined storage coefficient. (default is 1.e-5).

  • sy (float or array of floats (nlay, nrow, ncol)) – is specific yield. (default is 0.15).

  • vkcb (float or array of floats (nlay, nrow, ncol)) – is the vertical hydraulic conductivity of a Quasi-three-dimensional confining bed below a layer. (default is 0.0). Note that if an array is passed for vkcb it must be of size (nlay, nrow, ncol) even though the information for the bottom layer is not needed.

  • wetdry (float or array of floats (nlay, nrow, ncol)) – is a combination of the wetting threshold and a flag to indicate which neighboring cells can cause a cell to become wet. (default is -0.01).

  • ksat (float or array of floats (njag)) – inter-block saturated hydraulic conductivity or transmissivity (if IKCFLAG = 1) or the inter-block conductance (if IKCFLAG = - 1) of the connection between nodes n and m.

  • storagecoefficient (boolean) – indicates that variable Ss and SS parameters are read as storage coefficient rather than specific storage. (default is False).

  • constantcv (boolean) – indicates that vertical conductance for an unconfined cell is computed from the cell thickness rather than the saturated thickness. The CONSTANTCV option automatically invokes the NOCVCORRECTION option. (default is False).

  • thickstrt (boolean) – indicates that layers having a negative LAYTYP are confined, and their cell thickness for conductance calculations will be computed as STRT-BOT rather than TOP-BOT. (default is False).

  • nocvcorrection (boolean) – indicates that vertical conductance is not corrected when the vertical flow correction is applied. (default is False).

  • novfc (boolean) – turns off the vertical flow correction under dewatered conditions. This option turns off the vertical flow calculation described on p. 5-8 of USGS Techniques and Methods Report 6-A16 and the vertical conductance correction described on p. 5-18 of that report. (default is False).

  • extension (string) – Filename extension (default is ‘lpf’)

  • unitnumber (int) – File unit number (default is None).

  • filenames (str or list of str) – Filenames to use for the package and the output files. If filenames=None the package name will be created using the model name and package extension and the cbc output name will be created using the model name and .cbc extension (for example, modflowtest.cbc), if ipakcb is a number greater than zero. If a single string is passed the package will be set to the string and cbc output name will be created using the model name and .cbc extension, if ipakcb is a number greater than zero. To define the names for all package files (input and output) the length of the list of strings should be 2. Default is None.

  • add_package (bool) – Flag to add the initialised package object to the parent model object. Default is True.

Notes

Examples

>>> import flopy
>>> m = flopy.mfusg.MfUsg()
>>> disu = flopy.mfusg.MfUsgDisU(
    model=m, nlay=1, nodes=1, iac=[1], njag=1,ja=np.array([0]), fahl=[1.0], cl12=[1.0])
>>> lpf = flopy.mfusg.MfUsgLpf(m)
classmethod load(f, model, ext_unit_dict=None, check=True)[source]

Load an existing package.

Parameters:
  • f (filename or file handle) – File to load.

  • model (model object) – The model object (of type flopy.mfusg.MfUsg) to which this package will be added.

  • ext_unit_dict (dictionary, optional) – If the arrays in the file are specified using EXTERNAL, or older style array control records, then f should be a file handle. In this case ext_unit_dict is required, which can be constructed using the function flopy.utils.mfreadnam.parsenamefile.

  • check (boolean) – Check package data for common errors. (default True)

Returns:

lpf – MfUsgLpf object.

Return type:

MfUsgLpf object

Examples

>>> import flopy
>>> m = flopy.mfusg.MfUsg()
>>> disu = flopy.mfusg.MfUsgDisU(
    model=m, nlay=1, nodes=1, iac=[1], njag=1,ja=np.array([0]), fahl=[1.0], cl12=[1.0])
>>> lpf = flopy.mfusg.MfUsgLpf.load('test.lpf', m)
write_file(check=True, f=None)[source]

Write the package file.

Parameters:

check (boolean) – Check package data for common errors. (default True)

Return type:

None

class MfUsgSms(model, hclose=0.0001, hiclose=0.0001, mxiter=100, iter1=20, iprsms=2, nonlinmeth=0, linmeth=2, theta=0.7, akappa=0.1, gamma=0.2, amomentum=0.001, numtrack=20, btol=10000.0, breduc=0.2, reslim=100.0, iacl=2, norder=0, level=7, north=2, iredsys=0, rrctol=0.0, idroptol=0, epsrn=0.001, clin='bcgs', ipc=3, iscl=0, iord=0, rclosepcgu=0.1, relaxpcgu=1.0, extension='sms', options=None, unitnumber=None, filenames=None)[source]

Bases: Package

MODFLOW Sms Package Class.

Parameters:
  • model (model object) – The model object (of type flopy.modflow.mf.Modflow) to which this package will be added.

  • hclose (float) – is the head change criterion for convergence of the outer (nonlinear) iterations, in units of length. When the maximum absolute value of the head change at all nodes during an iteration is less than or equal to HCLOSE, iteration stops. Commonly, HCLOSE equals 0.01.

  • hiclose (float) – is the head change criterion for convergence of the inner (linear) iterations, in units of length. When the maximum absolute value of the head change at all nodes during an iteration is less than or equal to HICLOSE, the matrix solver assumes convergence. Commonly, HICLOSE is set an order of magnitude less than HCLOSE.

  • mxiter (int) – is the maximum number of outer (nonlinear) iterations – that is, calls to the solution routine. For a linear problem MXITER should be 1.

  • iter1 (int) – is the maximum number of inner (linear) iterations. The number typically depends on the characteristics of the matrix solution scheme being used. For nonlinear problems, ITER1 usually ranges from 60 to 600; a value of 100 will be sufficient for most linear problems.

  • iprsms (int) – is a flag that controls printing of convergence information from the solver: 0 is print nothing; 1 is print only the total number of iterations and nonlinear residual reduction summaries; 2 is print matrix solver information in addition to above.

  • nonlinmeth (int) – is a flag that controls the nonlinear solution method and under- relaxation schemes. 0 is Picard iteration scheme is used without any under-relaxation schemes involved. > 0 is Newton-Raphson iteration scheme is used with under-relaxation. Note that the Newton-Raphson linearization scheme is available only for the upstream weighted solution scheme of the BCF and LPF packages. < 0 is Picard iteration scheme is used with under-relaxation. The absolute value of NONLINMETH determines the underrelaxation scheme used. 1 or -1, then Delta-Bar-Delta under-relaxation is used. 2 or -2 then Cooley under-relaxation scheme is used. Note that the under-relaxation schemes are used in conjunction with gradient based methods, however, experience has indicated that the Cooley under-relaxation and damping work well also for the Picard scheme with the wet/dry options of MODFLOW.

  • linmeth (int) – is a flag that controls the matrix solution method. 1 is the XMD solver of Ibaraki (2005). 2 is the unstructured pre-conditioned conjugate gradient solver of White and Hughes (2011).

  • theta (float) – is the reduction factor for the learning rate (under-relaxation term) of the delta-bar-delta algorithm. The value of THETA is between zero and one. If the change in the variable (head) is of opposite sign to that of the previous iteration, the under-relaxation term is reduced by a factor of THETA. The value usually ranges from 0.3 to 0.9; a value of 0.7 works well for most problems.

  • akappa (float) – is the increment for the learning rate (under-relaxation term) of the delta-bar-delta algorithm. The value of AKAPPA is between zero and one. If the change in the variable (head) is of the same sign to that of the previous iteration, the under-relaxation term is increased by an increment of AKAPPA. The value usually ranges from 0.03 to 0.3; a value of 0.1 works well for most problems.

  • gamma (float) – is the history or memory term factor of the delta-bar-delta algorithm. Gamma is between zero and 1 but cannot be equal to one. When GAMMA is zero, only the most recent history (previous iteration value) is maintained. As GAMMA is increased, past history of iteration changes has greater influence on the memory term. The memory term is maintained as an exponential average of past changes. Retaining some past history can overcome granular behavior in the calculated function surface and therefore helps to overcome cyclic patterns of non-convergence. The value usually ranges from 0.1 to 0.3; a value of 0.2 works well for most problems.

  • amomentum (float) – is the fraction of past history changes that is added as a momentum term to the step change for a nonlinear iteration. The value of AMOMENTUM is between zero and one. A large momentum term should only be used when small learning rates are expected. Small amounts of the momentum term help convergence. The value usually ranges from 0.0001 to 0.1; a value of 0.001 works well for most problems.

  • numtrack (int) – is the maximum number of backtracking iterations allowed for residual reduction computations. If NUMTRACK = 0 then the backtracking iterations are omitted. The value usually ranges from 2 to 20; a value of 10 works well for most problems.

  • numtrack – is the maximum number of backtracking iterations allowed for residual reduction computations. If NUMTRACK = 0 then the backtracking iterations are omitted. The value usually ranges from 2 to 20; a value of 10 works well for most problems.

  • btol (float) – is the tolerance for residual change that is allowed for residual reduction computations. BTOL should not be less than one to avoid getting stuck in local minima. A large value serves to check for extreme residual increases, while a low value serves to control step size more severely. The value usually ranges from 1.0 to 1e6 ; a value of 1e4 works well for most problems but lower values like 1.1 may be required for harder problems.

  • breduce (float) – is the reduction in step size used for residual reduction computations. The value of BREDUC is between zero and one. The value usually ranges from 0.1 to 0.3; a value of 0.2 works well for most problems.

  • reslim (float) – is the limit to which the residual is reduced with backtracking. If the residual is smaller than RESLIM, then further backtracking is not performed. A value of 100 is suitable for large problems and residual reduction to smaller values may only slow down computations.

  • iacl (int) – is the flag for choosing the acceleration method. 0 is Conjugate Gradient; select this option if the matrix is symmetric. 1 is ORTHOMIN. 2 is BiCGSTAB.

  • norder (int) – is the flag for choosing the ordering scheme. 0 is original ordering 1 is reverse Cuthill McKee ordering 2 is Minimum degree ordering

  • level (int) – is the level of fill for ILU decomposition. Higher levels of fill provide more robustness but also require more memory. For optimal performance, it is suggested that a large level of fill be applied (7 or 8) with use of drop tolerance.

  • north (int) – is the number of orthogonalizations for the ORTHOMIN acceleration scheme. A number between 4 and 10 is appropriate. Small values require less storage but more iteration may be required. This number should equal 2 for the other acceleration methods.

  • iredsys (int) – is the index for creating a reduced system of equations using the red-black ordering scheme. 0 is do not create reduced system 1 is create reduced system using red-black ordering

  • rrctol (float) – is a residual tolerance criterion for convergence. The root mean squared residual of the matrix solution is evaluated against this number to determine convergence. The solver assumes convergence if either HICLOSE (the absolute head tolerance value for the solver) or RRCTOL is achieved. Note that a value of zero ignores residual tolerance in favor of the absolute tolerance (HICLOSE) for closure of the matrix solver.

  • idroptol (int) – is the flag to perform drop tolerance. 0 is do not perform drop tolerance 1 is perform drop tolerance

  • epsrn (float) – is the drop tolerance value. A value of 1e-3 works well for most problems.

  • clin (string) – an option keyword that defines the linear acceleration method used by the PCGU solver. CLIN is “CG”, then preconditioned conjugate gradient method. CLIN is “BCGS”, then preconditioned bi-conjugate gradient stabilized method.

  • ipc (int) – an integer value that defines the preconditioner. IPC = 0, No preconditioning. IPC = 1, Jacobi preconditioning. IPC = 2, ILU(0) preconditioning. IPC = 3, MILU(0) preconditioning (default).

  • iscl (int) – is the flag for choosing the matrix scaling approach used. 0 is no matrix scaling applied 1 is symmetric matrix scaling using the scaling method by the POLCG preconditioner in Hill (1992). 2 is symmetric matrix scaling using the l2 norm of each row of A (DR) and the l2 norm of each row of DRA.

  • iord (int) – is the flag for choosing the matrix reordering approach used. 0 = original ordering 1 = reverse Cuthill McKee ordering 2 = minimum degree ordering

  • rclosepcgu (float) – a real value that defines the flow residual tolerance for convergence of the PCGU linear solver. This value represents the maximum allowable residual at any single node. Value is in units of length cubed per time, and must be consistent with MODFLOW-USG length and time units. Usually a value of 1.0x10-1 is sufficient for the flow-residual criteria when meters and seconds are the defined MODFLOW-USG length and time.

  • relaxpcgu (float) – a real value that defines the relaxation factor used by the MILU(0) preconditioner. RELAXPCGU is unitless and should be greater than or equal to 0.0 and less than or equal to 1.0. RELAXPCGU values of about 1.0 are commonly used, and experience suggests that convergence can be optimized in some cases with RELAXPCGU values of 0.97. A RELAXPCGU value of 0.0 will result in ILU(0) preconditioning. RELAXPCGU is only specified if IPC=3. If RELAXPCGU is not specified and IPC=3, then a default value of 0.97 will be assigned to RELAXPCGU.

  • extension (str, optional) – File extension (default is ‘sms’.

  • unitnumber (int, optional) – FORTRAN unit number for this package (default is None).

  • filenames (str or list of str) – Filenames to use for the package. If filenames=None the package name will be created using the model name and package extension. If a single string is passed the package will be set to the string. Default is None.

Notes

Examples

>>> import flopy
>>> m = flopy.modflow.Modflow()
>>> sms = flopy.mfusg.MfUsgSms(m)
classmethod load(f, model, ext_unit_dict=None)[source]

Load an existing package.

Parameters:
  • f (filename or file handle) – File to load.

  • model (model object) – The model object (of type flopy.modflow.mf.Modflow) to which this package will be added.

  • ext_unit_dict (dictionary, optional) – If the arrays in the file are specified using EXTERNAL, or older style array control records, then f should be a file handle. In this case ext_unit_dict is required, which can be constructed using the function flopy.utils.mfreadnam.parsenamefile.

Returns:

sms

Return type:

MfUsgSms object

Examples

>>> import flopy
>>> m = flopy.modflow.Modflow()
>>> sms = flopy.modflow.ModflowPcg.load('test.sms', m)
write_file()[source]

Write the package file.

Return type:

None

class MfUsgWel(model, ipakcb=None, stress_period_data=None, cln_stress_period_data=None, dtype=None, cln_dtype=None, extension='wel', options=None, binary=False, unitnumber=None, filenames=None, add_package=True)[source]

Bases: ModflowWel

MODFLOW-USG Well Package Class.

Parameters:
  • model (model object) – The model object (of type flopy.modflow.mf.Modflow) to which this package will be added.

  • ipakcb (int, optional) – Toggles whether cell-by-cell budget data should be saved. If None or zero, budget data will not be saved (default is None).

  • stress_period_data (list of boundaries, or recarray of boundaries, or) –

    dictionary of boundaries For structured grid, each well is defined through definition of layer (int), row (int), column (int), flux (float). The simplest form is a dictionary with a lists of boundaries for each stress period, where each list of boundaries itself is a list of boundaries. Indices of the dictionary are the numbers of the stress period. This gives the form of:

    stress_period_data = {0: [

    [lay, row, col, flux], [lay, row, col, flux], [lay, row, col, flux] ],

    1: [

    [lay, row, col, flux], [lay, row, col, flux], [lay, row, col, flux] ], …

    kper:

    [ [lay, row, col, flux], [lay, row, col, flux], [lay, row, col, flux] ]

    }

    For unstructured grid,

    stress_period_data = {0: [

    [node, flux], [node, flux], [node, flux] ],

    1: [

    [node, flux], [node, flux], [node, flux] ], …

    kper:

    [ [node, flux], [node, flux], [node, flux] ]

    }

    Note that if the number of lists is smaller than the number of stress periods, then the last list of wells will apply until the end of the simulation. Full details of all options to specify stress_period_data can be found in the flopy3 boundaries Notebook in the basic subdirectory of the examples directory

  • cln_stress_period_data (list of boundaries, or recarray of boundaries, or) –

    dictionary of boundaries Stress period data of wells simulated as Connected Linear Network (CLN) The simplest form is a dictionary with a lists of boundaries for each stress period, where each list of boundaries itself is a list of boundaries. Indices of the dictionary are the numbers of the stress period. This gives the form of:

    cln_stress_period_data = {0: [

    [iclnnode, flux], [iclnnode, flux], [iclnnode, flux] ],

    1: [

    [iclnnode, flux], [iclnnode, flux], [iclnnode, flux] ], …

    kper:

    [ [iclnnode, flux], [iclnnode, flux], [iclnnode, flux] ]

    }

  • dtype (custom datatype of stress_period_data.) – If None the default well datatype will be applied (default is None).

  • cln_dtype (custom datatype of cln_stress_period_data.) – If None the default well datatype will be applied (default is None).

  • extension (string) – Filename extension (default is ‘wel’)

  • options (list of strings) – Package options (default is None).

  • unitnumber (int) – File unit number (default is None).

  • filenames (str or list of str) – Filenames to use for the package and the output files. If filenames=None the package name will be created using the model name and package extension and the cbc output name will be created using the model name and .cbc extension (for example, modflowtest.cbc), if ipakcb is a number greater than zero. If a single string is passed the package will be set to the string and cbc output names will be created using the model name and .cbc extension, if ipakcb is a number greater than zero. To define the names for all package files (input and output) the length of the list of strings should be 2. Default is None.

  • add_package (bool) – Flag to add the initialised package object to the parent model object. Default is True.

mxactw

Maximum number of wells for a stress period. This is calculated automatically by FloPy based on the information in stress_period_data.

Type:

int

Notes

Parameters are not supported in FloPy.

Examples

>>> import flopy
>>> m = flopy.mfusg.MfUsg()
>>> lrcq = {0:[[2, 3, 4, -100.]], 1:[[2, 3, 4, -100.]]}
>>> wel = flopy.mfusg.MfUsgWel(m, stress_period_data=lrcq)
write_file(f=None)[source]

Write the package file.

Parameters:

f: (str) optional file name

rtype:

None