[Errno2] No such file or directory

Completed

Hello everybody,

I'm trying to creat a simple groundwatermodel and I use the package flopy. 

Python should calculate some things and the results should represented as a figure.

import flopy
import numpy as np
import matplotlib.pyplot as plt
import flopy.utils.binaryfile as bf

# Assign name and create modflow model obj

filename = 'tutorial1'
mf = flopy.modflow.Modflow(filename, exe_name='mf2005')

# Model domain and grid definition
Lx = 1000
Ly = 1000
ztop = 0
zbot = -50
nlay = 1
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 fpr 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] = 10
strt[:, :, -1] = 0
bas = flopy.modflow.ModflowBas(mf, ibound=ibound, strt=strt)

# Layer-Property
lpf = flopy.modflow.ModflowLpf(mf, hk=10., vka=10., ipakcb=53)

# output
spd = {(0, 0): ['print head', 'print budget', 'save head', 'save budget']}
oc = flopy.modflow.ModflowOc(mf, stress_period_data=spd, compact=True)

# Gradient
pcg = flopy.modflow.ModflowPcg(mf)

mf.write_input()

# grafic
plt.subplot(1, 1, 1, aspect='equal')
hds = bf.HeadFile(filename+'.hds')
head = hds.get_data(totim=1.0)
levels = np.arange(1,10,1)
extent = (delr/2., Lx - delr/2., Ly - delc/2., delc/2.)
plt.contour(head[0, :, :], levels=levels, extent=extent)

Unfortunately after running the skript I get following message:

Traceback (most recent call last):
  File "C:/Users/Johannes/PycharmProjects/getting_started/tutorial1.py", line 50, in <module>
    hds = bf.HeadFile(filename+'.hds')
 

File "C:\Users\Johannes\PycharmProjects\getting_started\venv\lib\site-packages\flopy\utils\binaryfile.py", line 436, in __init__
    precision = get_headfile_precision(filename)

  File "C:\Users\Johannes\PycharmProjects\getting_started\venv\lib\site-packages\flopy\utils\binaryfile.py", line 202, in get_headfile_precision
    f = open(filename, 'rb')
FileNotFoundError: [Errno 2] No such file or directory: 'tutorial1.hds'

Process finished with exit code 1

 

Has anybody an idea or maybe a solution for this problem?

BTW: I didn't creat it by my own. Actually it is a simply tutorial. ;)

Thanks for your help

 

0
3 comments

Hi Physiker,

Thank you for contacting PyCharm support.

Have you tried to run this code outside of PyCharm?

Are you getting the same error?

Kind regards,

Sergey

 

0

Hello Sergey,

thanks for your answer.

Yes I did it. And it doesn't work too.

But in the meantime I have found my mistake. The exe-file 'mf2005' wasn't in the right directory path. So it work now. :)

Well, I'm just a beginner. :D

Thanks for your help.

0

Alright thanks for letting me know :)

Kind regards,

Sergey

0

Please sign in to leave a comment.