flopy basic question

244 views
Skip to first unread message

ashutosh singh

unread,
Jan 15, 2021, 9:25:03 AM1/15/21
to mod...@googlegroups.com
Hi,

I am learning flopy. I used a script for modflow2005 version and I started to modify the same script for modflow nwt. For modflow2005 it works. Although the files get created but then the run is not successful. The list file ends with

UPW1 -- UPSTREAM WEIGHTING FLOW PACKAGE, VERSION 1.2.0, 3/01/2020
         INPUT READ FROM UNIT 31

 # UPW package for  MODFLOW-NWT, generated by Flopy.
 No named parameters

-----------------------

#The used script is this:

import flopy
import os
import sys
import numpy as np

import glob
import shutil
## modflownwt model which is a trial
## still not working

# Assign name and create modflow model object
modelname = 'tutorial1'
#os.chdir('~/Desktop/flopy/mod01')
mf = flopy.modflow.Modflow(modelname, exe_name="modellering/flopymodels/flopymodels/MODFLOW-NWT_64.exe", maxiterout=150, linmeth=2, version="mfnwt")
#flopy.modflow.Modflow(modelname, exe_name=modellering/flopymodels/flopymodels/MODFLOW-NWT_64')

Lx = 2000.
Ly = 2000.
ztop = 1000.
zbot = 0.
nlay = 10
nrow = 10
ncol = 10
delr = Lx/ncol
delc = Ly/nrow
delv = (ztop - zbot) / nlay
botm = np.linspace(ztop, zbot, nlay + 1)
# Create the discretization object
dis = flopy.modflow.ModflowDis(mf, nlay, nrow, ncol, delr=delr, delc=delc,
                               top=ztop, botm=botm[1:])
# Variables for the BAS package
ibound = np.ones((nlay, nrow, ncol), dtype=np.int32)
ibound[:, :, 0] = -1
ibound[:, :, -1] = -1
strt = np.ones((nlay, nrow, ncol), dtype=np.float32)
strt[:, :, 0] = 110.
strt[:, :, -1] = 100.
bas = flopy.modflow.ModflowBas(mf, ibound=ibound, strt=strt)
#importing the fracman file first
#data=np.loadtxt('F2M.txt', dtype='float', comments='#', delimiter=None, converters=None, skiprows=1, usecols=[0,1,2,6,7,8], unpack=False, ndmin=0, encoding='bytes')
hk1=1E-6*(np.ones((nrow,ncol,nlay), dtype=np.float32)).transpose()#.transpose((2,0,1))
#hk1=np.array([data[:,3]]).reshape((nrow,ncol,nlay)).transpose()#.transpose((2,0,1))
# print(hk1)
#hani1=np.true_divide(data[:,3], data[:,4]).reshape((nrow,ncol,nlay)).transpose()
hani1=(np.ones((nrow,ncol,nlay), dtype=np.float32)).transpose()
vk1=1E-7*(np.ones((nrow,ncol,nlay), dtype=np.float32)).transpose()
ss1=1E-2*(np.ones((nrow,ncol,nlay), dtype=np.float32)).transpose() # plocka vertikal hydraulisk konduktivitet
porositat=0.35*(np.ones((nrow,ncol,nlay), dtype=np.float32)).transpose() # plocka vertikal hydraulisk konduktivitet
chani1=-1*np.ones(nlay) # required for creating anisotropy
#print(chani1)
# Add LPF package to the MODFLOW model
#print(hani1)
#lpf = flopy.modflow.ModflowLpf(mf, hk=hk1, chani=chani1, hani=hani1, vka=vk1, ipakcb=53)
upw = flopy.modflow.ModflowUpw(mf, laytyp = 1*np.ones(nlay), hk = hk1)

# Add OC package to the MODFLOW model
spd = {(0, 0): ['print head', 'print budget', 'save head', 'save budget']}
oc = flopy.modflow.ModflowOc(mf, stress_period_data=spd, compact=True)


# Adding constant head boundary condition

 shead = 110.0
 ehead = 110.0
 chd = []
 for l in range(nlay):
     for r in range(ncol):
         chd.append([l,r,0,shead,ehead])
 lrcd = {0:chd}
 chd = flopy.modflow.mfchd.ModflowChd(mf, stress_period_data=lrcd)




# lrcd={0: (([np.ones(10)+np.arange(10), np.ones(10)+np.arange(10), np.ones(10), 10.*np.ones(10), 10.*np.ones(10)]).reshape(5,10))}
# kk=np.ones(10).reshape(10,1);
# print(kk)
# lrcd = {0:[[np.ones(10).transpose(), (np.ones(10)+np.arange(10)).transpose(), (np.ones(10)+np.arange(10)).transpose(), (10.*np.ones(10)).transpose(), (10.*np.ones(10)).transpose()]]}

# Run the MODFLOW model
success, buff = mf.run_model()

Saul Montoya

unread,
Jan 15, 2021, 10:49:20 PM1/15/21
to mod...@googlegroups.com
Where is the mf.write_model ?

Pd. Be safe from Covid and software licences

--
You received this message because you are subscribed to the Google Groups "MODFLOW Users Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to modflow+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/modflow/CA%2BOP%2B8vs-de5Qrjr0qyFW6qKJaLCvrdtd3C0%2BFPfS1HqqjErZw%40mail.gmail.com.

Ashutosh

unread,
Jan 16, 2021, 10:47:45 AM1/16/21
to mod...@googlegroups.com
Hi,

I was deleting a lot of comments line from the code and unfortunately that got deleted as well. Its just before the success line.
I have it in my original code but the problem still exists. I know there is something really basic which I am missing here.

Thanks and Regards
Ashutosh

Sent from my iPhone

On 16 Jan 2021, at 04:49, Saul Montoya <saulm...@gidahatari.com> wrote:



Tariq Laattoe

unread,
Jan 17, 2021, 11:43:41 PM1/17/21
to MODFLOW Users Group
Hi,

Perhaps it is because you are setting all your layers to type 1: unconfined. My understanding is that only layer 1 can be unconfined and the rest have to be convertible or confined. Not 100% sure that is the problem though but it is the first thing I noticed reading through your script.

Tariq

ashutosh singh

unread,
Jan 18, 2021, 10:00:08 AM1/18/21
to mod...@googlegroups.com
Hi!

Confined and convertible are the only two options shown at the website https://water.usgs.gov/ogw/modflow-nwt/MODFLOW-NWT-Guide/index.html?upw_upstream_weighting_package.htm
I have used both 0 and -1 and nothing works.

//Ashutosh



Reply all
Reply to author
Forward
0 new messages