tral = 0.005 # Transverse vertical dispersivity ($m$) dmcoef = 1.34e-5 # Effective diffusion coefficient ($cm^2/sec$) perlen = 20.0 # Simulation time ($years$) # Additional model input k1 = 5e-4 / 100.0 * 86400 # m/d k2 = 1e-2 / 100.0 * 86400 # m/d k11 = k1 * np.ones((nlay, nrow, ncol), dtype=float) k11[11:19, :, 0:24] = k2 k11[11:19, :, 36:] = k2 laytyp = 6 * [1] + 21 * [0] # Setting starting head information f = open(os.path.join("..", "data", "ex-gwt-mt3dms-p08", "p08shead.dat")) strt = np.empty((nlay * ncol), dtype=float) strt = read1d(f, strt).reshape((nlay, nrow, ncol)) f.close() # Active model domain ibound = np.ones((nlay, nrow, ncol), dtype=int) ibound[5:, :, -1] = -1 ibound[strt < 0] = 0 idomain = 1 # Fow boundary condition rech = 10.0 / 100 / 365 # cm/yr -> m/d # Transport relate`xd trpt = 0.01 # Ratio of transverse to longitudinal dispersitivity trpv = 0.01 # Ratio of vertical to longitudinal dispersitivity dmcoef = 1.34e-5 / 100 / 100 * 86400 # cm^2/s -> m^2/d ath1 = al * trpt atv = al * trpv # Time variables
trpv = 0.2 # Ratio of vertical transverse dispersivity to longitudinal dispersivity rhob = 1.7 # Aquifer bulk density ($g/cm^3$) sp1 = 0.176 # Distribution coefficient ($cm^3/g$) perlen = 1000.0 # Simulation time ($days$) # Additional model input delr = ([2000, 1600, 800, 400, 200, 100] + 28 * [50] + [100, 200, 400, 800, 1600, 2000]) delc = ([2000, 2000, 2000, 1600, 800, 400, 200, 100] + 45 * [50] + [100, 200, 400, 800, 1600, 2000, 2000, 2000]) hk = [60.0, 60.0, 520.0, 520.0] laytyp = icelltype = 0 # Starting Heads: f = open(os.path.join("..", "data", "ex-gwt-mt3dms-p10", "p10shead.dat")) s0 = np.empty((nrow * ncol), dtype=np.float) s0 = read1d(f, s0).reshape((nrow, ncol)) f.close() strt = np.zeros((nlay, nrow, ncol), dtype=np.float) for k in range(nlay): strt[k] = s0 # Active model domain ibound = np.ones((nlay, nrow, ncol), dtype=np.int) ibound[:, :, 0] = -1 # left side ibound[:, :, -1] = -1 # right side ibound[:, 0, :] = -1 # top ibound[:, -1, :] = -1 # bottom icbund = idomain = 1 # Boundary conditions rech = 12.7 / 365 / 30.48 # cm/yr -> ft/day crch = 0.0
def get_disu(self, model, nper=1, perlen=1, nstp=1, tsmult=1, steady=True, itmuni=4, lenuni=2): # nodes, nlay, ivsd, itmuni, lenuni, idsymrd, laycbd fname = os.path.join(self.model_ws, 'qtg.nod') f = open(fname, 'r') line = f.readline() ll = line.strip().split() nodes = int(ll.pop(0)) f.close() nlay = self.dis.nlay ivsd = 0 idsymrd = 0 laycbd = 0 # Save nodes self.nodes = nodes # nodelay nodelay = np.empty((nlay), dtype=np.int) fname = os.path.join(self.model_ws, 'qtg.nodesperlay.dat') f = open(fname, 'r') nodelay = read1d(f, nodelay) f.close() # top top = [0] * nlay for k in range(nlay): fname = os.path.join(self.model_ws, 'quadtreegrid.top{}.dat'.format(k + 1)) f = open(fname, 'r') tpk = np.empty((nodelay[k]), dtype=np.float32) tpk = read1d(f, tpk) f.close() if tpk.min() == tpk.max(): tpk = tpk.min() else: tpk = Util2d(model, (1, nodelay[k]), np.float32, np.reshape(tpk, (1, nodelay[k])), name='top {}'.format(k + 1)) top[k] = tpk # bot bot = [0] * nlay for k in range(nlay): fname = os.path.join(self.model_ws, 'quadtreegrid.bot{}.dat'.format(k + 1)) f = open(fname, 'r') btk = np.empty((nodelay[k]), dtype=np.float32) btk = read1d(f, btk) f.close() if btk.min() == btk.max(): btk = btk.min() else: btk = Util2d(model, (1, nodelay[k]), np.float32, np.reshape(btk, (1, nodelay[k])), name='bot {}'.format(k + 1)) bot[k] = btk # area area = [0] * nlay fname = os.path.join(self.model_ws, 'qtg.area.dat') f = open(fname, 'r') anodes = np.empty((nodes), dtype=np.float32) anodes = read1d(f, anodes) f.close() istart = 0 for k in range(nlay): istop = istart + nodelay[k] ark = anodes[istart: istop] if ark.min() == ark.max(): ark = ark.min() else: ark = Util2d(model, (1, nodelay[k]), np.float32, np.reshape(ark, (1, nodelay[k])), name='area layer {}'.format(k + 1)) area[k] = ark istart = istop # iac iac = np.empty((nodes), dtype=np.int) fname = os.path.join(self.model_ws, 'qtg.iac.dat') f = open(fname, 'r') iac = read1d(f, iac) f.close() # Calculate njag and save as nja to self njag = iac.sum() self.nja = njag # ja ja = np.empty((njag), dtype=np.int) fname = os.path.join(self.model_ws, 'qtg.ja.dat') f = open(fname, 'r') ja = read1d(f, ja) f.close() # ivc ivc = np.empty((njag), dtype=np.int) fname = os.path.join(self.model_ws, 'qtg.fldr.dat') f = open(fname, 'r') ivc = read1d(f, ivc) f.close() cl1 = None cl2 = None # cl12 cl12 = np.empty((njag), dtype=np.float32) fname = os.path.join(self.model_ws, 'qtg.c1.dat') f = open(fname, 'r') cl12 = read1d(f, cl12) f.close() # fahl fahl = np.empty((njag), dtype=np.float32) fname = os.path.join(self.model_ws, 'qtg.fahl.dat') f = open(fname, 'r') fahl = read1d(f, fahl) f.close() # create dis object instance disu = ModflowDisU(model, nodes=nodes, nlay=nlay, njag=njag, ivsd=ivsd, nper=nper, itmuni=itmuni, lenuni=lenuni, idsymrd=idsymrd, laycbd=laycbd, nodelay=nodelay, top=top, bot=bot, area=area, iac=iac, ja=ja, ivc=ivc, cl1=cl1, cl2=cl2, cl12=cl12, fahl=fahl, perlen=perlen, nstp=nstp, tsmult=tsmult, steady=steady) # return dis object instance return disu
def p10mt3d(exe_name_mf, exe_name_mt, model_ws, mixelm, perlen=1000, isothm=1, sp2=0., ttsmult=1.2): nlay = 4 nrow = 61 ncol = 40 delr = [2000, 1600, 800, 400, 200, 100 ] + 28 * [50] + [100, 200, 400, 800, 1600, 2000] delc = [2000, 2000, 2000, 1600, 800, 400, 200, 100 ] + 45 * [50] + [100, 200, 400, 800, 1600, 2000, 2000, 2000] delv = 25. top = 780. botm = [top - delv * k for k in range(1, nlay + 1)] prsity = 0.3 al = 10. trpt = 0.2 trpv = 0.2 perlen_mf = perlen perlen_mt = perlen hk = [60., 60., 520., 520.] vka = .1 laytyp = 0 modelname_mf = 'p10_mf' mf = flopy.modflow.Modflow(modelname=modelname_mf, model_ws=model_ws, exe_name=exe_name_mf) dis = flopy.modflow.ModflowDis(mf, nlay=nlay, nrow=nrow, ncol=ncol, delr=delr, delc=delc, top=top, botm=botm, perlen=perlen_mf) ibound = np.ones((nlay, nrow, ncol), dtype=np.int) ibound[:, :, 0] = -1 ibound[:, :, -1] = -1 f = open(os.path.join(datadir, 'p10shead.dat')) s0 = np.empty((nrow * ncol), dtype=np.float) s0 = read1d(f, s0).reshape((nrow, ncol)) f.close() strt = np.zeros((nlay, nrow, ncol), dtype=np.float) for k in range(nlay): strt[k] = s0 bas = flopy.modflow.ModflowBas(mf, ibound=ibound, strt=strt) lpf = flopy.modflow.ModflowLpf(mf, hk=hk, layvka=1, vka=vka, laytyp=laytyp) welspd = [[3 - 1, 11 - 1, 29 - 1, -19230.00], [3 - 1, 19 - 1, 26 - 1, -19230.00], [3 - 1, 26 - 1, 23 - 1, -19230.00], [3 - 1, 33 - 1, 20 - 1, -19230.00], [3 - 1, 40 - 1, 17 - 1, -19230.00], [3 - 1, 48 - 1, 14 - 1, -19230.00], [3 - 1, 48 - 1, 9 - 1, -15384.00], [3 - 1, 52 - 1, 17 - 1, -17307.00]] wel = flopy.modflow.ModflowWel(mf, stress_period_data=welspd) rch = flopy.modflow.ModflowRch(mf, rech=1.14e-3) pcg = flopy.modflow.ModflowPcg(mf) lmt = flopy.modflow.ModflowLmt(mf) mf.write_input() fname = os.path.join(model_ws, 'MT3D001.UCN') if os.path.isfile(fname): os.remove(fname) mf.run_model(silent=True) modelname_mt = 'p10_mt' mt = flopy.mt3d.Mt3dms(modelname=modelname_mt, model_ws=model_ws, exe_name=exe_name_mt, modflowmodel=mf) f = open(os.path.join(datadir, 'p10cinit.dat')) c0 = np.empty((nrow * ncol), dtype=np.float) c0 = read1d(f, c0).reshape((nrow, ncol)) f.close() sconc = np.zeros((nlay, nrow, ncol), dtype=np.float) sconc[1] = 0.2 * c0 sconc[2] = c0 obs = [[3 - 1, 11 - 1, 29 - 1], [3 - 1, 19 - 1, 26 - 1], [3 - 1, 26 - 1, 23 - 1], [3 - 1, 33 - 1, 20 - 1], [3 - 1, 40 - 1, 17 - 1], [3 - 1, 48 - 1, 14 - 1], [3 - 1, 48 - 1, 9 - 1], [3 - 1, 52 - 1, 17 - 1]] btn = flopy.mt3d.Mt3dBtn(mt, icbund=1, prsity=prsity, sconc=sconc, timprs=[500, 750, 1000], dt0=2.25, ttsmult=ttsmult, obs=obs) dceps = 1.e-5 nplane = 0 npl = 0 nph = 16 npmin = 2 npmax = 32 dchmoc = 0.01 nlsink = nplane npsink = nph adv = flopy.mt3d.Mt3dAdv(mt, mixelm=mixelm, dceps=dceps, nplane=nplane, npl=npl, nph=nph, npmin=npmin, npmax=npmax, nlsink=nlsink, npsink=npsink, percel=1.0) dsp = flopy.mt3d.Mt3dDsp(mt, al=al, trpt=trpt, trpv=trpv) ssm = flopy.mt3d.Mt3dSsm(mt, crch=0.) rct = flopy.mt3d.Mt3dRct(mt, isothm=isothm, igetsc=0, rhob=1.7, sp1=0.176, sp2=sp2) mxiter = 1 if isothm == 4: mxiter = 50 gcg = flopy.mt3d.Mt3dGcg(mt, mxiter=mxiter, iter1=500) mt.write_input() fname = os.path.join(model_ws, 'MT3D001.UCN') if os.path.isfile(fname): os.remove(fname) mt.run_model(silent=True) fname = os.path.join(model_ws, 'MT3D001.UCN') ucnobj = flopy.utils.UcnFile(fname) times = ucnobj.get_times() conc = ucnobj.get_alldata() fname = os.path.join(model_ws, 'MT3D001.OBS') if os.path.isfile(fname): cvt = mt.load_obs(fname) else: cvt = None fname = os.path.join(model_ws, 'MT3D001.MAS') mvt = mt.load_mas(fname) return mf, mt, conc, cvt, mvt
def p08mt3d(exe_name_mf, exe_name_mt, model_ws, mixelm): nlay = 27 nrow = 1 ncol = 50 delr = 5 delc = 1 delv = 0.25 prsity = 0.35 al = 0.5 trpt = 0.01 trpv = 0.01 dmcoef = 1.34e-5 / 100 / 100 * 86400 rech = 0.1 / 365 # m/d perlen_mf = 1 perlen_mt = [5 * 365, 15 * 365] k1 = 5e-4 / 100. * 86400 # m/d k2 = 1e-2 / 100. * 86400 # m/d hk = k1 * np.ones((nlay, nrow, ncol), dtype=np.float) hk[11:19, :, 0:24] = k2 hk[11:19, :, 36:] = k2 laytyp = 6 * [1] + 21 * [0] modelname_mf = 'p08_mf' mf = flopy.modflow.Modflow(modelname=modelname_mf, model_ws=model_ws, exe_name=exe_name_mf) dis = flopy.modflow.ModflowDis(mf, nlay=nlay, nrow=nrow, ncol=ncol, delr=delr, delc=delc, top=6.75, botm=[6.75 - delv * k for k in range(1, nlay + 1)], perlen=perlen_mf) f = open(os.path.join(datadir, 'p08shead.dat')) strt = np.empty((nlay * ncol), dtype=np.float) strt = read1d(f, strt).reshape((nlay, nrow, ncol)) f.close() ibound = np.ones((nlay, nrow, ncol), dtype=np.int) ibound[5:, :, -1] = -1 ibound[strt < 0] = 0 bas = flopy.modflow.ModflowBas(mf, ibound=ibound, strt=strt) lpf = flopy.modflow.ModflowLpf(mf, hk=hk, vka=hk, laytyp=laytyp) rch = flopy.modflow.ModflowRch(mf, rech=rech) pcg = flopy.modflow.ModflowPcg(mf) lmt = flopy.modflow.ModflowLmt(mf) mf.write_input() mf.run_model(silent=True) modelname_mt = 'p08_mt' mt = flopy.mt3d.Mt3dms(modelname=modelname_mt, model_ws=model_ws, exe_name=exe_name_mt, modflowmodel=mf) btn = flopy.mt3d.Mt3dBtn(mt, icbund=1, prsity=prsity, sconc=0, nper=2, perlen=perlen_mt, timprs=[8 * 365, 12 * 365, 20 * 365]) percel = 1.0 itrack = 3 wd = 0.5 dceps = 1.e-5 nplane = 0 npl = 0 nph = 10 npmin = 2 npmax = 20 dchmoc=1.e-3 nlsink = nplane npsink = nph adv = flopy.mt3d.Mt3dAdv(mt, mixelm=mixelm, dceps=dceps, nplane=nplane, npl=npl, nph=nph, npmin=npmin, npmax=npmax, nlsink=nlsink, npsink=npsink, percel=percel, itrack=itrack, wd=wd) dsp = flopy.mt3d.Mt3dDsp(mt, al=al, trpt=trpt, trpv=trpv, dmcoef=dmcoef) crch1 = np.zeros((nrow, ncol), dtype=np.float) crch1[0, 9:18] = 1. cnc0 = [(0, 0, j, 1, -1) for j in range(8, 16)] cnc1 = [(0, 0, j, 0., -1) for j in range(8, 16)] ssmspd = {0: cnc0, 1:cnc1} ssm = flopy.mt3d.Mt3dSsm(mt, stress_period_data=ssmspd) gcg = flopy.mt3d.Mt3dGcg(mt) mt.write_input() fname = os.path.join(model_ws, 'MT3D001.UCN') if os.path.isfile(fname): os.remove(fname) mt.run_model(silent=True) fname = os.path.join(model_ws, 'MT3D001.UCN') ucnobj = flopy.utils.UcnFile(fname) times = ucnobj.get_times() conc = ucnobj.get_alldata() fname = os.path.join(model_ws, 'MT3D001.OBS') if os.path.isfile(fname): cvt = mt.load_obs(fname) else: cvt = None fname = os.path.join(model_ws, 'MT3D001.MAS') mvt = mt.load_mas(fname) return mf, mt, conc, cvt, mvt