mbakker7 / ttim

MIT License
34 stars 23 forks source link

'tuple' object does not support item assignment #20

Closed btimani closed 5 years ago

btimani commented 5 years ago

I am getting the error ('tuple' object does not support item assignment) when I call the solver in the code. I am not sure why I am getting the error in the solve statement because I think that the code checks the validity of the inputs for the model and elements. Please, advise. If of any use, I am using Spyder 3.3.6, Python 3.6.6, Qt 5.9.6,PyQt5 5.9.2, and Darwin 18.7.0 on a Mac. Thank you.

import ttim as t import numpy as np import matplotlib.pyplot as plt import matplotlib as mpl import time

start_time = time.time()

mpl.rcParams['font.sans-serif'] = "Times New Roman" mpl.rcParams['font.family'] = "sans-serif"

mytime = np.linspace(0,500.,501)

dL = 26 #number of doublets to break length boundaries into dL2 = 9 #number of doublets to break width boundaries into width = 4500. #approximate width of aquifer in feet length = 65000. #approximate length of aquifer in feet (east of groundwater divide)+

xright = np.ones(dL)*width yright = np.linspace(0,length,dL) xyright = np.asarray(list(zip(xright,yright)))

xleft = np.ones(dL)*0 yleft = np.linspace(0,length,dL) xyleft = np.asarray(list(zip(xleft,yleft)))

xtop = np.linspace(0,width,dL2) ytop = np.ones(dL2)*length xytop = np.asarray(list(zip(xtop,ytop)))

fig=plt.figure()

crange=[0.0,10.,50.,100., 1000.] for i in range(len(crange)): ml = t.Model3D(kaq=[0.001,1000.],z=[300.,100.,0],Saq=[0.01,6.84E-6],kzoverkh=[0.1,0.1],phreatictop=True,tmin=1E-5,tmax=1E5,M=20) LakeS = t.HeadLineSinkString(ml,xy=[[0,0],[4500,0]],res=crange[i],wh='H',layers=[0,1],label=None) right = t.LeakyLineDoubletString(ml,xyright,res='imp',order = 2,layers=1) left = t.LeakyLineDoubletString(ml,xyleft,res='imp',order =2,layers=1) top = t.LeakyLineDoubletString(ml,xytop,res='imp',order = 2,layers=1)

Iglehart = t.Well(ml,xw=4000.,yw=4500.,rw=0.67,tsandQ=[(134.,313.2*2.514*192.5),(134.+ 90.,0.)],layers=1)

ml.solve()
irrwell = ml.head(4000.,4500.,mytime)
Rime = ml.head(3068.,1375.,mytime)
Ziegler = ml.head(3570.,3410.,mytime)

fig.add_subplot(4,2,2*i+1)
plt.plot(mytime,-1*irrwell[1],label='Iglehart Well')
plt.plot(mytime,-1*Rime[1],label='Rime')
plt.plot(mytime,-1*Ziegler[1],label='Ziegler')

plt.title('c = %s Days' %crange[i], fontsize = 10)
plt.xlabel('Time (day)',fontsize = 10)
plt.ylabel('Drawdown (feet)',fontsize = 10)
if i==0:
    leg = plt.legend(fontsize=8).set_draggable(True)
plt.grid()
plt.ylim(0,5.)
plt.show()

fig.add_subplot(4,2,2*i+2)
plt.xlabel('Time (day)',fontsize = 10)
plt.ylabel('$Q_{Lake}/Q_{Well}$',fontsize = 10)
plt.title('c = %s Days' %crange[i], fontsize = 10)
if i == 0:
        plt.legend(fontsize=8).set_draggable(True)
plt.grid()
plt.ylim(0,1.)
plt.show()

time_elapsed = time.time() - start_time time_elapsed = time.strftime('%H:%M:%S', time.gmtime(time_elapsed)) print("Solution found in ", time_elapsed, "(hh:mm:ss)")

dbrakenhoff commented 5 years ago

This error is caused by a typo in the last release. In the file linesink.py on line 77 there is a trailing comma that should not be there. If you remove that comma you should be good to go.

You can also install the latest version of ttim by cloning the repository and installing that version. After downloading and unzipping the repo, in a terminal navigate to the ttim directory and then type pip install .

btimani commented 5 years ago

Thank you.