Demo for new kwargs-based ncomp


In [1]:
import numpy as np
import flopy
reload(flopy)
from flopy.modflow import *
from flopy.mt3d import *

In [2]:
nlay, nrow, ncol = 3, 10, 10
ml = Modflow("test")
dis = ModflowDis(ml,nlay=nlay, nrow=nrow, ncol=ncol)

for btn, sconc is passed as a normal util_3d-compatible argument, no need for the list anymore


In [3]:
mt = Mt3dms(modflowmodel=ml)
btn = Mt3dBtn(mt, sconc=1.0,ncomp=2)


BTN: setting sconc for component 2 to zero, kwarg name sconc2
/Users/langevin/langevin/dev/flopy3.git/flopy/mt3d/mtbtn.py:372: UserWarning: BTN warning. Laycon has not been set.  A modflow model with a  BCF or LPF package does not exist and laycon was not passed  to the BTN constructor.  Setting laycon to 1 (convertible).
  warnings.warn(s)

or we pass in the sconc2 kwarg explicitly


In [4]:
mt = Mt3dms(modflowmodel=ml)
btn = Mt3dBtn(mt,sconc=1.0,ncomp=2,sconc2=1.5)
print btn.sconc[1].name_base


['sconc2 Layer ', 'sconc2 Layer ', 'sconc2 Layer ']

error raised for unrecognized kwargs


In [5]:
mt = Mt3dms(modflowmodel=ml)
btn = Mt3dBtn(mt,sconc=1.0,ncomp=2,sconc3=1.5)


BTN: setting sconc for component 2 to zero, kwarg name sconc2
---------------------------------------------------------------------------
Exception                                 Traceback (most recent call last)
<ipython-input-5-3f8a6a5d9f52> in <module>()
      1 mt = Mt3dms(modflowmodel=ml)
----> 2 btn = Mt3dBtn(mt,sconc=1.0,ncomp=2,sconc3=1.5)

/Users/langevin/langevin/dev/flopy3.git/flopy/mt3d/mtbtn.pyc in __init__(self, model, nlay, nrow, ncol, nper, ncomp, mcomp, tunit, lunit, munit, laycon, delr, delc, htop, dz, prsity, icbund, sconc, cinact, thkmin, ifmtcn, ifmtnp, ifmtrf, ifmtdp, savucn, nprs, timprs, obs, nprobs, chkmas, nprmas, perlen, nstp, tsmult, ssflag, dt0, mxstrn, ttsmult, ttsmax, species_names, extension, **kwargs)
    222         if len(list(kwargs.keys())) > 0:
    223             raise Exception("BTN error: unrecognized kwargs: " +
--> 224                             ' '.join(list(kwargs.keys())))
    225 
    226         # Finally add self to parent's package list and return

Exception: BTN error: unrecognized kwargs: sconc3

same behavior for SSM


In [6]:
mt = Mt3dms(modflowmodel=ml)
btn = Mt3dBtn(mt,sconc=1.0,ncomp=2, mcomp=2, sconc2=1.5)
ssm = Mt3dSsm(mt,crch=1.0,crch2=1.0,cevt=0.5,cevt2=1.5)
print ssm.crch,ssm.cevt


[<flopy.utils.util_array.transient_2d object at 0x107c61810>, <flopy.utils.util_array.transient_2d object at 0x107d60c10>] [<flopy.utils.util_array.transient_2d object at 0x107d60bd0>, <flopy.utils.util_array.transient_2d object at 0x107d60d10>]

DSP does not need multDiff flag for multi species. But in this case, arrays are by layer, not by layer, row, column.


In [7]:
dsp = Mt3dDsp(mt,dmcoef2=1.0)

If we set multiDiff to True, then there will be mcomp (not ncomp, according to mt3d supplemental guide) number of 3d dmcoef arrays.


In [8]:
dsp = Mt3dDsp(mt,dmcoef2=1.0,multiDiff=True)
print dsp.dmcoef


****Warning -- two packages of the same type:  <class 'flopy.mt3d.mtdsp.Mt3dDsp'> <class 'flopy.mt3d.mtdsp.Mt3dDsp'>
replacing existing Package...
[<flopy.utils.util_array.util_3d object at 0x107d33d50>, <flopy.utils.util_array.util_3d object at 0x107d60dd0>]

In [ ]: