def build_model(idx, dir): # grid properties nlay = 3 nrow = 6 ncol = 6 delr = 100.0 delc = 100.0 top = 300.0 botm = [200.0, 100.0, 0.0] # hydraulic properties hk = 1.0 vk = 1.0 # Set the idomain of the parent model in order to # define where the child model will be located idomain = np.ones((nlay, nrow, ncol), dtype=int) idomain[:, 2:4, 2:4] = 0 ncpp = 1 ncppl = [1, 1, 1] lgr = Lgr(nlay, nrow, ncol, delr, delc, top, botm, idomain, ncpp, ncppl) name = ex[idx] # build MODFLOW 6 files # create simulation sim = flopy.mf6.MFSimulation(sim_name=name, version="mf6", exe_name="mf6", sim_ws=dir) # create tdis package tdis = flopy.mf6.ModflowTdis(sim, nper=2, perioddata=[(1.0, 1, 1.0), (1.0, 1, 1.0)]) # create gwf model gwf = flopy.mf6.ModflowGwf(sim, modelname=namea, save_flows=True) # create iterative model solution and register the gwf model with it ims = flopy.mf6.ModflowIms(sim, outer_dvclose=1e-9, inner_dvclose=1.0e-9) # dis dis = flopy.mf6.ModflowGwfdis( gwf, nlay=nlay, nrow=nrow, ncol=ncol, delr=delr, delc=delc, top=top, botm=botm, idomain=idomain, ) # initial conditions ic = flopy.mf6.ModflowGwfic(gwf, pname="ic", strt=top) # node property flow npf = flopy.mf6.ModflowGwfnpf(gwf, save_specific_discharge=True, icelltype=0, k=hk, k33=vk) # chd chdspd = [] for k in range(nlay): for i in range(nrow): chdspd.append([(k, i, 0), 1.0]) chdspd.append([(k, i, ncol - 1), 6.0]) chd = flopy.mf6.ModflowGwfchd(gwf, stress_period_data=chdspd) # output control oc = flopy.mf6.ModflowGwfoc( gwf, pname="oc", budget_filerecord="{}.cbc".format(namea), head_filerecord="{}.hds".format(namea), headprintrecord=[("COLUMNS", 10, "WIDTH", 15, "DIGITS", 6, "GENERAL")], saverecord=[("HEAD", "ALL"), ("BUDGET", "ALL")], printrecord=[("HEAD", "ALL"), ("BUDGET", "ALL")], ) # create child gwf model cgwf = flopy.mf6.ModflowGwf(sim, modelname=nameb, save_flows=True) cnlay, cnrow, cncol = lgr.get_shape() cdelr, cdelc = lgr.get_delr_delc() ctop, cbotm = lgr.get_top_botm() xorigin, yorigin = lgr.get_lower_left() cidomain = lgr.get_idomain() cdis = flopy.mf6.ModflowGwfdis( cgwf, nlay=cnlay, nrow=cnrow, ncol=cncol, delr=cdelr, delc=cdelc, top=ctop, botm=cbotm, idomain=cidomain, xorigin=xorigin, yorigin=yorigin, ) cic = flopy.mf6.ModflowGwfic(cgwf, pname="ic", strt=top) cnpf = flopy.mf6.ModflowGwfnpf(cgwf, save_specific_discharge=True, icelltype=0, k=hk, k33=vk) oc = flopy.mf6.ModflowGwfoc( cgwf, pname="oc", budget_filerecord="{}.cbc".format(nameb), head_filerecord="{}.hds".format(nameb), headprintrecord=[("COLUMNS", 10, "WIDTH", 15, "DIGITS", 6, "GENERAL")], saverecord=[("HEAD", "ALL"), ("BUDGET", "ALL")], printrecord=[("HEAD", "ALL"), ("BUDGET", "ALL")], ) # exchange information exchangedata = lgr.get_exchange_data(angldegx=True, cdist=True) nexg = len(exchangedata) gwfe = flopy.mf6.ModflowGwfgwf( sim, exgtype="gwf6-gwf6", exgmnamea="a", exgmnameb="b", nexg=nexg, auxiliary=[("angldegx", "cdist")], exchangedata=exchangedata, ) return sim, None
def get_model(idx, dir): # grid properties nlay = 3 nrow = 6 ncol = 6 delr = 100. delc = 100. top = 300. botm = [200., 100., 0.] # hydraulic properties hk = 1. vk = 1. # Set the idomain of the parent model in order to # define where the child model will be located idomain = np.ones((nlay, nrow, ncol), dtype=int) idomain[:, 2:4, 2:4] = 0 ncpp = 1 ncppl = [1, 1, 1] lgr = Lgr(nlay, nrow, ncol, delr, delc, top, botm, idomain, ncpp, ncppl) name = ex[idx] # build MODFLOW 6 files # create simulation sim = flopy.mf6.MFSimulation(sim_name=name, version='mf6', exe_name='mf6', sim_ws=dir) # create tdis package tdis = flopy.mf6.ModflowTdis(sim) # create gwf model gwf = flopy.mf6.ModflowGwf(sim, modelname=namea, save_flows=True) # create iterative model solution and register the gwf model with it ims = flopy.mf6.ModflowIms(sim, outer_hclose=1e-9, inner_hclose=1.e-9) # dis dis = flopy.mf6.ModflowGwfdis(gwf, nlay=nlay, nrow=nrow, ncol=ncol, delr=delr, delc=delc, top=top, botm=botm, idomain=idomain) # initial conditions ic = flopy.mf6.ModflowGwfic(gwf, pname='ic', strt=top) # node property flow npf = flopy.mf6.ModflowGwfnpf(gwf, save_specific_discharge=True, icelltype=0, k=hk, k33=vk) # chd chdspd = [] for k in range(nlay): for i in range(nrow): chdspd.append([(k, i, 0), 1.]) chdspd.append([(k, i, ncol - 1), 6.]) chd = flopy.mf6.ModflowGwfchd(gwf, stress_period_data=chdspd) # output control oc = flopy.mf6.ModflowGwfoc(gwf, pname='oc', budget_filerecord='{}.cbc'.format(namea), head_filerecord='{}.hds'.format(namea), headprintrecord=[('COLUMNS', 10, 'WIDTH', 15, 'DIGITS', 6, 'GENERAL')], saverecord=[('HEAD', 'ALL'), ('BUDGET', 'ALL')], printrecord=[('HEAD', 'ALL'), ('BUDGET', 'ALL')]) # create child gwf model cgwf = flopy.mf6.ModflowGwf(sim, modelname=nameb, save_flows=True) cnlay, cnrow, cncol = lgr.get_shape() cdelr, cdelc = lgr.get_delr_delc() ctop, cbotm = lgr.get_top_botm() xorigin, yorigin = lgr.get_lower_left() cidomain = lgr.get_idomain() cdis = flopy.mf6.ModflowGwfdis(cgwf, nlay=cnlay, nrow=cnrow, ncol=cncol, delr=cdelr, delc=cdelc, top=ctop, botm=cbotm, idomain=cidomain, xorigin=xorigin, yorigin=yorigin) cic = flopy.mf6.ModflowGwfic(cgwf, pname='ic', strt=top) cnpf = flopy.mf6.ModflowGwfnpf(cgwf, save_specific_discharge=True, icelltype=0, k=hk, k33=vk) oc = flopy.mf6.ModflowGwfoc(cgwf, pname='oc', budget_filerecord='{}.cbc'.format(nameb), head_filerecord='{}.hds'.format(nameb), headprintrecord=[('COLUMNS', 10, 'WIDTH', 15, 'DIGITS', 6, 'GENERAL')], saverecord=[('HEAD', 'ALL'), ('BUDGET', 'ALL')], printrecord=[('HEAD', 'ALL'), ('BUDGET', 'ALL')]) # exchange information exchangedata = lgr.get_exchange_data(angldegx=True, cdist=True) nexg = len(exchangedata) gwfe = flopy.mf6.ModflowGwfgwf(sim, exgtype='gwf6-gwf6', exgmnamea='a', exgmnameb='b', nexg=nexg, auxiliary=[('angldegx', 'cdist')], exchangedata=exchangedata) return sim