示例#1
0
文件: wncMF.py 项目: bbuzz31/ModSWMM
    def init_mf(self):
        """ Initialize MODFLOW object """
        NAME_mf = '{}'.format(self.params.get('name', 'MISSING'))
        MODEL = op.join(self.path, 'MF', NAME_mf)
        path_exe = self.params.get('path_exe',
                                   op.join('/', 'opt', 'local', 'bin'))

        if self.params['coupled']:
            self.mf = flomf.Modflow(MODEL,
                                    exe_name=op.join(path_exe, 'MF_BB'),
                                    version='mf2005',
                                    silent=False,
                                    verbose=False,
                                    external_path=op.join(
                                        self.path, 'MF', 'ext'))
        else:
            self.mf = flomf.Modflow(MODEL,
                                    exe_name=op.join(path_exe, 'mf2005'),
                                    version='mf2005',
                                    external_path=op.join(
                                        self.path, 'MF', 'ext'))

        if self.params['ss']:
            self.steady = [True] * self.kpers
        else:
            self.steady = [False] * self.kpers
            self.steady[0] = True
示例#2
0
文件: t006_test.py 项目: inowas/flopy
def test_mflist_reference():
    import os
    import numpy as np
    import shapefile
    import flopy.modflow as fmf

    # model_ws = os.path.join('..', 'data', 'freyberg')
    # ml = fmf.Modflow.load('freyberg.nam', model_ws=model_ws)
    # make the model
    ml = fmf.Modflow()
    assert isinstance(ml, fmf.Modflow)
    perlen = np.arange(1, 20, 1)
    nstp = np.flipud(perlen) + 3
    tsmult = 1.2
    nlay = 10
    nrow, ncol = 50, 40
    botm = np.arange(0, -100, -10)
    hk = np.random.random((nrow, ncol))
    dis = fmf.ModflowDis(ml,
                         delr=100.0,
                         delc=100.0,
                         nrow=nrow,
                         ncol=ncol,
                         nlay=nlay,
                         nper=perlen.shape[0],
                         perlen=perlen,
                         nstp=nstp,
                         tsmult=tsmult,
                         top=10,
                         botm=botm,
                         steady=False)
    assert isinstance(dis, fmf.ModflowDis)
    lpf = fmf.ModflowLpf(ml, hk=hk, vka=10.0, laytyp=1)
    assert isinstance(lpf, fmf.ModflowLpf)
    pcg = fmf.ModflowPcg(ml)
    assert isinstance(pcg, fmf.ModflowPcg)
    oc = fmf.ModflowOc(ml)
    assert isinstance(oc, fmf.ModflowOc)
    ibound = np.ones((nrow, ncol))
    ibound[:, 0] = -1
    ibound[25:30, 30:39] = 0
    bas = fmf.ModflowBas(ml, strt=5.0, ibound=ibound)
    assert isinstance(bas, fmf.ModflowBas)
    rch = fmf.ModflowRch(ml, rech={0: 0.00001, 5: 0.0001, 6: 0.0})
    assert isinstance(rch, fmf.ModflowRch)
    wel_dict = {}
    wel_data = [[9, 25, 20, -200], [0, 0, 0, -400], [5, 20, 32, 500]]
    wel_dict[0] = wel_data
    wel_data2 = [[45, 20, 200], [9, 49, 39, 400], [5, 20, 32, 500]]
    wel_dict[10] = wel_data2
    wel = fmf.ModflowWel(ml, stress_period_data={0: wel_data})
    assert isinstance(wel, fmf.ModflowWel)
    ghb_dict = {0: [1, 10, 10, 400, 300]}
    ghb = fmf.ModflowGhb(ml, stress_period_data=ghb_dict)
    assert isinstance(ghb, fmf.ModflowGhb)

    test = os.path.join('temp', 'test3.shp')
    ml.export(test, kper=0)
    shp = shapefile.Reader(test)
    assert shp.numRecords == nrow * ncol
    def setup_class(cls):
        """Make a modflow model."""
        print("setting up model...")
        t0 = time.time()
        size = 100
        nlay = 10
        nper = 10
        nsfr = int((size**2) / 5)

        cls.modelname = "junk"
        cls.model_ws = "temp/t064"
        external_path = "external/"

        if not os.path.isdir(cls.model_ws):
            os.makedirs(cls.model_ws)
        if not os.path.isdir(os.path.join(cls.model_ws, external_path)):
            os.makedirs(os.path.join(cls.model_ws, external_path))

        m = fm.Modflow(cls.modelname,
                       model_ws=cls.model_ws,
                       external_path=external_path)

        dis = fm.ModflowDis(
            m,
            nper=nper,
            nlay=nlay,
            nrow=size,
            ncol=size,
            top=nlay,
            botm=list(range(nlay)),
        )

        rch = fm.ModflowRch(
            m, rech={k: 0.001 - np.cos(k) * 0.001
                     for k in range(nper)})

        ra = fm.ModflowWel.get_empty(size**2)
        well_spd = {}
        for kper in range(nper):
            ra_per = ra.copy()
            ra_per["k"] = 1
            ra_per["i"] = ((np.ones((size, size)) *
                            np.arange(size)).transpose().ravel().astype(int))
            ra_per["j"] = list(range(size)) * size
            well_spd[kper] = ra
        wel = fm.ModflowWel(m, stress_period_data=well_spd)

        # SFR package
        rd = fm.ModflowSfr2.get_empty_reach_data(nsfr)
        rd["iseg"] = range(len(rd))
        rd["ireach"] = 1
        sd = fm.ModflowSfr2.get_empty_segment_data(nsfr)
        sd["nseg"] = range(len(sd))
        sfr = fm.ModflowSfr2(reach_data=rd, segment_data=sd, model=m)
        cls.init_time = time.time() - t0
        cls.m = m
示例#4
0
def test_mflist_external():
    import flopy.modflow as fmf
    ml = fmf.Modflow("mflist_test", model_ws="temp", external_path="ref")
    dis = fmf.ModflowDis(ml, 1, 10, 10, nper=3, perlen=1.0)
    wel_data = {
        0: [[0, 0, 0, -1], [1, 1, 1, -1]],
        1: [[0, 0, 0, -2], [1, 1, 1, -1]]
    }
    wel = fmf.ModflowWel(ml, stress_period_data=wel_data)
    ml.write_input()

    ml1 = fmf.Modflow.load("mflist_test.nam",
                           model_ws=ml.model_ws,
                           verbose=True,
                           forgive=False)
    assert np.array_equal(ml.wel[0], ml1.wel[0])
    assert np.array_equal(ml.wel[1], ml1.wel[1])
示例#5
0
z1 = np.zeros((nlay, nrow, ncol), np.float)
z0[0, 0, 30:38] = np.arange(-2.5, -40, -5)
z0[0, 0, 38:] = -40
z1[0, 0, 22:30] = np.arange(-2.5, -40, -5)
z1[0, 0, 30:] = -40
z = []
z.append(z0)
z.append(z1)
ssz = 0.2
isource = np.ones((nrow, ncol), 'int')
isource[0, 0] = 2

# stratified model
modelname = 'swiex2_strat'
print('creating...', modelname)
ml = mf.Modflow(modelname, version='mf2005', exe_name=mf_name, model_ws=dirs[0])
discret = mf.ModflowDis(ml, nlay=1, ncol=ncol, nrow=nrow, delr=delr, delc=1, top=0, botm=[-40.0],
                        nper=nper, perlen=perlen, nstp=nstp)
bas = mf.ModflowBas(ml, ibound=ibound, strt=0.05)
bcf = mf.ModflowBcf(ml, laycon=0, tran=2 * 40)
swi = mf.ModflowSwi2(ml, nsrf=nsurf, istrat=1, toeslope=0.2, tipslope=0.2, nu=[0, 0.0125, 0.025],
                     zeta=z, ssz=ssz, isource=isource, nsolver=1)
oc = mf.ModflowOc88(ml, save_head_every=1000)
pcg = mf.ModflowPcg(ml)
ml.write_input()
# run stratified model
if not skipRuns:
    m = ml.run_model(silent=False)
# read stratified results
zetafile = os.path.join(dirs[0], '{}.zta'.format(modelname))
zobj = fu.CellBudgetFile(zetafile)
示例#6
0
def main():
    '''
    This is the main function.
    '''

    # Package all the required file paths into the Paths object
    mfPaths = Paths()

    # Package all the required framework specifications into the mfFrame object
    mfFrame = Frame(Paths=mfPaths, dx_dy=dx_dy)

    if build_from_gis:

        # Build the model framework ASCII files from the GIS layers. Note that this
        # requires a GDAL installation.  If you don't want to get into that you
        # can skip this step and simply build the model from the ASCII files that I've
        # already created.
        mfFrame.build_frame(Paths=mfPaths)
    # ---------------------------------------------
    # ---------------------------------------------
    # Now use Flopy to build the MODFLOW model packages
    # ---------------------------------------------
    # ---------------------------------------------

    start_dir = os.getcwd()
    os.chdir(mfPaths.modflow_dir
             )  # This is simplest if done inside the MODFLOW directory

    # Initialize a Flopy model object. This is the base class around which the model
    # packages are built.
    Modflow = mf.Modflow(mfFrame.model_name,
                         external_path='./',
                         version=mfPaths.mf_version)

    # The .oc ('output control') package specifies how the model output is written.
    # This model includes a single steady state stress period. Save the
    # distribution of heads as well as the flow budget/mass balance to binaries.
    # These can be plotted or converted to rasters (the current version of the script
    # doesn't do any post-processing.)
    oc = mf.ModflowOc(Modflow,
                      stress_period_data={
                          (0, 0): ['SAVE HEAD', 'SAVE BUDGET']
                      })

    # The .dis and .bas packages define the model framework. I've already defined
    # the framework attributes using the mfFrame object and simply pass those
    # attributes to the constructor.
    dis = mf.ModflowDis(Modflow,mfFrame.nlay,mfFrame.nrow,mfFrame.ncol,\
                         delr=mfFrame.delr,delc=mfFrame.delc,\
                         top=mfFrame.top,botm=mfFrame.bottom)

    bas = mf.ModflowBas(Modflow,
                        ibound=mfFrame.ibound,
                        strt=mfFrame.top,
                        hnoflo=mfFrame.hnoflo)

    # The .upw package describes the system properties (e.g., transmissivity/conductivity).
    # For this model I simply give it a constant hydraulic conductivity field. This model
    # converges but I have no idea how physically realistic it is. If you would
    # like to make it more physically realistic (e.g., try to fit head or discharge
    # data) you would need to estimate the hydraulic conductivity field via
    # calibration/inverse modeling
    hk = np.ones(np.shape(mfFrame.ibound))
    upw = mf.ModflowUpw(Modflow, laytyp=mfFrame.laytyp, hk=hk, ipakcb=53)

    # The .nwt package defines the solver specs. Just use the defaults.
    nwt = mf.ModflowNwt(Modflow)

    # RECHARGE INPUTS TO THE SYSTEM
    # -----------------------------
    # The .rch packages specifies recharge/precipitation inputs to the water table.
    # Remember that I have already generated an array from the GIS layer and attached
    # it to the mfFrame object.
    rch = mf.ModflowRch(Modflow, nrchop=3, rech={0: mfFrame.rch}, ipakcb=53)

    # BASEFLOW DISCHARGE FROM THE SYSTEM
    # ----------------------------------
    # The .drn package is one method of simulating the discharge of groundwater as
    # base-flow in streams in rivers.  Define every landsurface cell as a drain
    # in order to allow the discharge network to emerge from topography.
    drn_stages = mfFrame.top
    drn_stages[mfFrame.ibound.squeeze() <= 0] = np.nan
    drn_input = build_drain_input(mfFrame=mfFrame, stages=drn_stages)

    drn = mf.ModflowDrn(Modflow, stress_period_data=drn_input, ipakcb=53)

    # Now write the files.  Flopy can also run the model if you tell it where the
    # binary is, but if I understood your method correctly you will be invoking something
    # from hydroshare. For convenience I am writing a windows .bat file that
    # can be used to run the model.
    Modflow.write_input()
    os.chdir(start_dir)

    with open(mfPaths.mf_bat_file, 'w') as fout:
        fout.write('%s %s' % (binary_path, os.path.basename(mfPaths.nam_file)))

    folder = mfPaths.scratch_dir
    for the_file in os.listdir(folder):
        file_path = os.path.join(folder, the_file)
        try:
            if os.path.isfile(file_path):
                os.unlink(file_path)
        except Exception as e:
            print(e)

    folder = mfPaths.model_frame_dir
    for the_file in os.listdir(folder):
        file_path = os.path.join(folder, the_file)
        try:
            if os.path.isfile(file_path):
                os.unlink(file_path)
        except Exception as e:
            print(e)

    folder = mfPaths.data_dir
    for the_file in os.listdir(folder):
        file_path = os.path.join(folder, the_file)
        try:
            if os.path.isfile(file_path):
                os.unlink(file_path)
        except Exception as e:
            print(e)

    return
 def get_package(self):
     content = self.merge()
     return mf.Modflow(**content)
示例#8
0
# conductivity `Kh`
name = 'lake_example'
h1 = 100
h2 = 90
Nlay = 10
N = 101
L = 400.0
H = 50.0
Kh = 1.0

# Create a MODFLOW model and store it (in this case in the variable `ml`, but you can call it
# whatever you want). The modelname will be the name given to all MODFLOW files (input and output).
# The exe_name should be the full path to your MODFLOW executable. The version is either 'mf2k'
# for MODFLOW2000 or 'mf2005'for MODFLOW2005.
ml = mf.Modflow(modelname=name,
                exe_name='mf2005',
                version='mf2005',
                external_path='./')

# Define the discretization of the model. All layers are given equal thickness. The `bot` array
# is build from the `Hlay` values to indicate top and bottom of each layer, and `delrow` and
# `delcol` are computed from model size `L` and number of cells `N`. Once these are all computed,
# the Discretization file is built.
bot = np.linspace(-H / Nlay, -H, Nlay)
delrow = delcol = L / (N - 1)
dis = mf.ModflowDis(ml,
                    nlay=Nlay,
                    nrow=N,
                    ncol=N,
                    delr=delrow,
                    delc=delcol,
                    top=0.0,
示例#9
0
# and columns `N`, lengths of the sides of the model `L`, aquifer thickness `H`, hydraulic
# conductivity `Kh`
name = 'lake_example'
h1 = 100
h2 = 90
Nlay = 10
N = 101
L = 400.0
H = 50.0
Kh = 1.0

# Create a MODFLOW model and store it (in this case in the variable `ml`, but you can call it
# whatever you want). The modelname will be the name given to all MODFLOW files (input and output).
# The exe_name should be the full path to your MODFLOW executable. The version is either 'mf2k'
# for MODFLOW2000 or 'mf2005'for MODFLOW2005.
ml = mf.Modflow(modelname=name, exe_name='mf2005', version='mf2005')

# Define the discretization of the model. All layers are given equal thickness. The `bot` array
# is build from the `Hlay` values to indicate top and bottom of each layer, and `delrow` and
# `delcol` are computed from model size `L` and number of cells `N`. Once these are all computed,
# the Discretization file is built.
bot = np.linspace(-H / Nlay, -H, Nlay)
delrow = delcol = L / (N - 1)
dis = mf.ModflowDis(ml,
                    nlay=Nlay,
                    nrow=N,
                    ncol=N,
                    delr=delrow,
                    delc=delcol,
                    top=0.0,
                    botm=bot,
示例#10
0
def calculate_model(z1_hk, z2_hk, z3_hk):
    # Z1_hk = 15  # 3<Z1_hk<15
    # Z2_hk = 15  # 3<Z2_hk<15
    # Z3_hk = 3  # 3<Z3_hk<15

    hobs = [
        [0, 20, 10, 69.52],
        [0, 40, 10, 71.44],
        [0, 60, 10, 72.99],
        [0, 80, 10, 73.86],
        [0, 20, 45, 58.73],
        [0, 40, 45, 50.57],
        [0, 60, 45, 54.31],
        [0, 80, 45, 58.06],
        [0, 20, 80, 56.31],
        [0, 40, 80, 52.32],
        [0, 60, 80, 46.35],
        [0, 80, 80, 29.01],
        [0, 20, 100, 57.24],
        [0, 40, 100, 54.24],
        [0, 60, 100, 39.48],
        [0, 80, 100, 48.47],
    ]

    model_path = os.path.join('_model')

    if os.path.exists(model_path):
        shutil.rmtree(model_path)

    modelname = 'parEstMod'

    version = 'mf2005'
    exe_name = 'mf2005'
    if platform.system() == 'Windows':
        exe_name = 'mf2005.exe'

    ml = mf.Modflow(modelname=modelname,
                    exe_name=exe_name,
                    version=version,
                    model_ws=model_path)

    nlay = 1
    nrow = 90
    ncol = 120

    area_width_y = 9000
    area_width_x = 12000

    delc = area_width_x / ncol
    delr = area_width_y / nrow

    nper = 1

    top = 100
    botm = 0

    dis = mf.ModflowDis(ml,
                        nlay=nlay,
                        nrow=nrow,
                        ncol=ncol,
                        delr=delr,
                        delc=delc,
                        top=top,
                        botm=botm,
                        nper=nper,
                        steady=True)

    ibound = 1
    strt = 100
    bas = mf.ModflowBas(ml, ibound=ibound, strt=strt)

    mask_arr = np.zeros((nlay, nrow, ncol))
    mask_arr[:, :, 0] = 80
    mask_arr[:, :, -1] = 60

    ghb_spd = {0: []}
    for layer_id in range(nlay):
        for row_id in range(nrow):
            for col_id in range(ncol):
                if mask_arr[layer_id][row_id][col_id] > 0:
                    ghb_spd[0].append([
                        layer_id, row_id, col_id,
                        mask_arr[layer_id][row_id][col_id], 200
                    ])

    ghb = mf.ModflowGhb(ml, stress_period_data=ghb_spd)

    rch = 0.0002
    rech = {}
    rech[0] = rch
    rch = mf.ModflowRch(ml, rech=rech, nrchop=3)

    welSp = {}
    welSp[0] = [
        [0, 20, 20, -20000],
        [0, 40, 40, -20000],
        [0, 60, 60, -20000],
        [0, 80, 80, -20000],
        [0, 60, 100, -20000],
    ]

    wel = mf.ModflowWel(ml, stress_period_data=welSp)

    hk = np.zeros((nlay, nrow, ncol))
    hk[:, :, 0:40] = z1_hk
    hk[:, :, 40:80] = z2_hk
    hk[:, :, 80:120] = z3_hk

    lpf = mf.ModflowLpf(ml, hk=hk, layavg=0, layvka=0, sy=0.3, ipakcb=53)

    pcg = mf.ModflowPcg(ml, rclose=1e-1)
    oc = mf.ModflowOc(ml)

    ml.write_input()
    ml.run_model(silent=True)
    hds = fu.HeadFile(os.path.join(model_path, modelname + '.hds'))
    times = hds.get_times()

    response = []

    for hob in hobs:
        observed = hob[3]
        calculated = hds.get_data(totim=times[-1])[hob[0]][hob[1]][hob[2]]
        response.append(observed - calculated)

    return json.dumps(response)
示例#11
0
z = np.array([[z1, z1]])
iso = np.zeros((nlay, nrow, ncol), np.int)
iso[0, :, :][index == 0] = 1
iso[0, :, :][index == 1] = -2
iso[1, 30, 35] = 2
ssz = 0.2
#--swi2 observations
obsnam = ['layer1_', 'layer2_']
obslrc = [[1, 31, 36], [2, 31, 36]]
nobs = len(obsnam)
iswiobs = 1051

modelname = 'swiex4_s1'
if not skipRuns:
    ml = mf.Modflow(modelname,
                    version='mf2005',
                    exe_name=exe_name,
                    model_ws=workspace)

    discret = mf.ModflowDis(ml,
                            nlay=nlay,
                            nrow=nrow,
                            ncol=ncol,
                            laycbd=0,
                            delr=delr,
                            delc=delc,
                            top=botm[0],
                            botm=botm[1:],
                            nper=nper,
                            perlen=perlen,
                            nstp=nstp,
                            steady=steady)
示例#12
0
文件: GGOR.py 项目: jonathanqv/GGOR
    isp: [[iLay, ir, 0, hL[isp], dz[iLay] / w[iLay] * dy[ir]]
          for iLay in range(Nlay) for ir in range(Ny)]
    for isp in range(NPER)
}
WEL = {isp: [*idW, Q[isp]] for isp in range(NPER)}
RECH = {isp: rech[isp] for isp in range(NPER)}
EVTR = {isp: evtr[isp] for isp in range(NPER)}
OC = {
    (0, 0): [
        'save head', 'save drawdown', 'save budget', 'print head',
        'print budget'
    ]
}

#%% MODEL AND packages ADDED TO IT
mf = fm.Modflow(modelname, exe_name=exe_name)

dis = fm.ModflowDis(mf,
                    Nlay,
                    Ny,
                    Nx,
                    delr=dx,
                    delc=dy,
                    top=zTop,
                    botm=zBot,
                    laycbd=LAYCBD,
                    nper=NPER,
                    perlen=PERLEN,
                    nstp=NSTP,
                    steady=STEADY)
bas = fm.ModflowBas(mf, ibound=IBOUND, strt=STRTHD)
示例#13
0
    shutil.rmtree(workspace)

if os.path.exists(output):
    shutil.rmtree(output)

if not os.path.exists(workspace):
    os.makedirs(workspace)

if not os.path.exists(output):
    os.makedirs(output)

print(workspace)

# flopy objects
modelname = 'obleo'
m = mf.Modflow(modelname=modelname, exe_name='mf2005', model_ws=workspace, version="mf2005")

# model domain and grid definition
ztop = 100.  # top of layer (m rel to msl) !!! mls=mean sea level ???
botm = -900.  # bottom of layer (m rel to msl) !!! mls=mean sea level ???
nlay = 1  # number of layers (z)
nrow = 11  # number of rows (y)
ncol = 13  # number of columns (x)
Lx = 13e+5 # length of x model domain, in m
Ly = 11e+5 # length of y model domain, in m
delr = Lx / ncol  # row width of cell, in m
delc = Ly / nrow  # column width of cell, in m

print(delr)
print(delc)
import numpy as np
import flopy.modflow as fpm
import flopy.utils as fpu

#2. Create a MODFLOW model object. Here, the MODFLOW
#model object is stored in a Python variable
#called model, but this can be an arbitrary name.
#This object name is important as it will be used as
#a reference to the model in the remainder of the
#FloPy script. In addition, a modelname is specified
#when the MODFLOW model object is created. This
#modelname is used for all the files that are created
#by FloPy for this model.

path_to_mf2005 = 'C:/Users/Sam/Dropbox/Work/Models/MODFLOW/MF2005.1_12/bin/mf2005.exe'  #SCZ
model = fpm.Modflow(modelname='gwexample', exe_name=path_to_mf2005)  #SCZ
#model = fpm.Modflow(modelname = 'gwexample')

#3. The discretization of the model is specified with the
#discretization file (DIS) of MODFLOW. The aquifer
#is divided into 201 cells of length 10m and width 1 m.
#The first input of the discretization package is the name
#of the model object. All other input arguments are self
#explanatory.

fpm.ModflowDis(model,
               nlay=1,
               nrow=1,
               ncol=201,
               delr=10,
               delc=1,
示例#15
0
import shutil
import sys
from datetime import datetime

workspace = os.path.join('ascii')

# delete directories if existing
if os.path.exists(workspace):
    shutil.rmtree(workspace)

if not os.path.exists(workspace):
    os.makedirs(workspace)

# flopy objects
modelname = 'performance_test'
m = mf.Modflow(modelname=modelname, exe_name='mf2005', model_ws=workspace)

# model domain and grid definition
ztop = 100.  # top of layer (m rel to msl) !!! mls=mean sea level ???
botm = -900.  # bottom of layer (m rel to msl) !!! mls=mean sea level ???
nlay = 1  # number of layers (z)
nrow = 11  # number of rows (y)
ncol = 13  # number of columns (x)
Lx = 13e+5  # length of x model domain, in m
Ly = 11e+5  # length of y model domain, in m
delr = Lx / ncol  # row width of cell, in m
delc = Ly / nrow  # column width of cell, in m

# define the stress periods
nper = 2
ts = 1  # length of time step, in years
示例#16
0
    def create_package(self, name, content):
        if name == 'mf':
            model_ws = os.path.realpath(os.path.join(self._data_folder, self._model_id, content['model_ws']))
            if not os.path.exists(model_ws):
                os.makedirs(model_ws)

            self._mf = mf.Modflow(
                modelname=content['modelname'],
                exe_name=content['exe_name'],
                version=content['version'],
                model_ws=model_ws
            )
        if name == 'dis':
            mf.ModflowDis(
                self._mf,
                nlay=content['nlay'],
                nrow=content['nrow'],
                ncol=content['ncol'],
                nper=content['nper'],
                delr=content['delr'],
                delc=content['delc'],
                laycbd=content['laycbd'],
                top=content['top'],
                botm=content['botm'],
                perlen=content['perlen'],
                nstp=content['nstp'],
                tsmult=content['tsmult'],
                steady=content['steady'],
                itmuni=content['itmuni'],
                lenuni=content['lenuni'],
                extension=content['extension'],
                unitnumber=content['unitnumber'],
                xul=content['xul'],
                yul=content['yul'],
                rotation=content['rotation'],
                proj4_str=content['proj4_str'],
                start_datetime=content['start_datetime']
            )
        if name == 'bas':
            mf.ModflowBas(
                self._mf,
                ibound=content['ibound'],
                strt=content['strt'],
                ifrefm=content['ifrefm'],
                ixsec=content['ixsec'],
                ichflg=content['ichflg'],
                stoper=content['stoper'],
                hnoflo=content['hnoflo'],
                extension=content['extension'],
                unitnumber=content['unitnumber']
            )
        if name == 'lpf':
            mf.ModflowLpf(
                self._mf,
                laytyp=content['laytyp'],
                layavg=content['layavg'],
                chani=content['chani'],
                layvka=content['layvka'],
                laywet=content['laywet'],
                ipakcb=content['ipakcb'],
                hdry=content['hdry'],
                iwdflg=content['iwdflg'],
                wetfct=content['wetfct'],
                iwetit=content['iwetit'],
                ihdwet=content['ihdwet'],
                hk=content['hk'],
                hani=content['hani'],
                vka=content['vka'],
                ss=content['ss'],
                sy=content['sy'],
                vkcb=content['vkcb'],
                wetdry=content['wetdry'],
                storagecoefficient=content['storagecoefficient'],
                constantcv=content['constantcv'],
                thickstrt=content['thickstrt'],
                nocvcorrection=content['nocvcorrection'],
                novfc=content['novfc'],
                extension=content['extension'],
                unitnumber=content['unitnumber']
            )
        if name == 'pcg':
            mf.ModflowPcg(
                self._mf,
                mxiter=content['mxiter'],
                iter1=content['iter1'],
                npcond=content['npcond'],
                hclose=content['hclose'],
                rclose=content['rclose'],
                relax=content['relax'],
                nbpol=content['nbpol'],
                iprpcg=content['iprpcg'],
                mutpcg=content['mutpcg'],
                damp=content['damp'],
                dampt=content['dampt'],
                ihcofadd=content['ihcofadd'],
                extension=content['extension'],
                unitnumber=content['unitnumber']
            )
        if name == 'oc':
            mf.ModflowOc(
                self._mf,
                ihedfm=content['ihedfm'],
                iddnfm=content['iddnfm'],
                chedfm=content['chedfm'],
                cddnfm=content['cddnfm'],
                cboufm=content['cboufm'],
                compact=content['compact'],
                stress_period_data=self.get_stress_period_data(content['stress_period_data']),
                extension=content['extension'],
                unitnumber=content['unitnumber']
            )
        if name == 'risdlkfjlv':
            mf.ModflowRiv(
                self._mf,
                ipakcb=content['ipakcb'],
                stress_period_data=content['stress_period_data'],
                dtype=content['dtype'],
                extension=content['extension'],
                unitnumber=content['unitnumber'],
                options=content['options'],
                naux=content['naux']
            )
        if name == 'wel':
            mf.ModflowWel(
                self._mf,
                ipakcb=content['ipakcb'],
                stress_period_data=content['stress_period_data'],
                dtype=content['dtype'],
                extension=content['extension'],
                unitnumber=content['unitnumber'],
                options=content['options']
            )
        if name == 'rch':
            mf.ModflowRch(
                self._mf,
                ipakcb=content['ipakcb'],
                nrchop=content['nrchop'],
                rech=content['rech'],
                extension=content['extension'],
                unitnumber=content['unitnumber']
            )
        if name == 'chd':
            mf.ModflowChd(
                self._mf,
                stress_period_data=content['stress_period_data'],
                dtype=content['dtype'],
                options=content['options'],
                extension=content['extension'],
                unitnumber=content['unitnumber']
            )

        if name == 'ghb':
            mf.ModflowGhb(
                self._mf,
                ipakcb=content['ipakcb'],
                stress_period_data=content['stress_period_data'],
                dtype=content['dtype'],
                options=content['options'],
                extension=content['extension'],
                unitnumber=content['unitnumber']
            )
示例#17
0
# #         converged = True
# #     ni += 1
# print 'Number of iterations = ', ni-1
# print h

name = 'lake_example'
h1 = 100
h2 = 90
Nlay = 10
N = 101
L = 400.0
H = 50.0
k = 1.0

ml = fmf.Modflow(modelname=name,
                 exe_name='/usr/local/src/mf2005/Unix/src/mf2005',
                 version='mf2005',
                 model_ws='mf_files/')

bot = np.linspace(-H / Nlay, -H, Nlay)
delrow = delcol = L / (N - 1)
dis = fmf.ModflowDis(ml,
                     nlay=Nlay,
                     nrow=N,
                     ncol=N,
                     delr=delrow,
                     delc=delcol,
                     top=0.0,
                     botm=bot,
                     laycbd=0)

Nhalf = (N - 1) / 2
示例#18
0
Nlay = 10

# Number of columns and rows
# we are assuming that NCol = NRow
N = 101

# The length and with of the model
L = 400.0

# The height of the model
H = 50.0
k = 1.0

# Intstantiating the Modflow-Object, ml is here an invented name
ml = mf.Modflow(modelname=name,
                exe_name='mf2005',
                version='mf2005',
                model_ws=workspace)
chb = mf.ModflowRch

# Calculation of the bottom-height of each layer
# more information: http://docs.scipy.org/doc/numpy-1.10.0/reference/generated/numpy.linspace.html
bot = np.linspace(-H / Nlay, -H, Nlay)
# result is:
# array([ -5., -10., -15., -20., -25., -30., -35., -40., -45., -50.])

# calculation of row-width and col-width
delrow = delcol = L / (N - 1)
# result is:
# 4

# instantiante the discretization object
示例#19
0
# what version of modflow to use?
modflow_v = 'mfnwt'  # 'mfnwt' or 'mf2005'

# where is your MODFLOW executable?
if (modflow_v == 'mf2005'):
    if platform.system() == 'Windows':
        path2mf = 'C:/Users/Sam/Dropbox/Work/Models/MODFLOW/MF2005.1_12/bin/mf2005.exe'
    else:
        path2mf = modflow_v
elif (modflow_v == 'mfnwt'):
    if platform.system() == 'Windows':
        path2mf = 'C:/Users/Sam/Dropbox/Work/Models/MODFLOW/MODFLOW-NWT_1.1.4/bin/MODFLOW-NWT.exe'
    else:
        path2mf = modflow_v

# set up super simple model
ml = mf.Modflow(modelname="testmodel", exe_name=path2mf, version=modflow_v)
dis = mf.ModflowDis(ml)
bas = mf.ModflowBas(ml)
oc = mf.ModflowOc(ml)

# choose solver package depending on modflow version
if (modflow_v == 'mf2005'):
    lpf = mf.ModflowLpf(ml)
    pcg = mf.ModflowPcg(ml)
elif (modflow_v == 'mfnwt'):
    upw = mf.ModflowUpw(ml)
    nwt = mf.ModflowNwt(ml)

ml.write_input()
ml.run_model()