Nov-21-2022, 07:03 PM
This returns the same error.
But I don't see where this is happening in your code. I did this as a quick check.
import numpy as np x = np.array((1, 2, 3)) y = x[1] z = y[1]
Error: File "test.py", line 4, in <module>
z = y[1]
IndexError: invalid index to scalar variable.
This indicates that something that is not indexable is being indexed. In particular it means a numpy scalar is being indexed because you get a different error message if you index an int or a float.But I don't see where this is happening in your code. I did this as a quick check.
import numpy as np iteration = 40 Ltotal = np.linspace(1,20000,iteration) #m m = np.linspace(1,40,iteration) #number of passes ktube = np.array([400,48,160,16]) #copper,mild steel, aluminum, stainless steel Cptube = np.array([376.8,510.8,921.1,460.5]) ptube = np.array([894,785,270,800] ) tfin = np.linspace(0.1/1000,1/1000,iteration) #m tspace = np.linspace(1/1000,1/100,iteration) #m ODtube = np.linspace(0.0001,1,iteration) #m unitcost = np.array([7.50,0.34,1.87,1.98]) #$/kg i = 0 j = 0 print(Ltotal[i],m[i],ktube[j],Cptube[j],ptube[j],tfin[i],tspace[i],ODtube[i],unitcost[j])That ran with no problems, leaving this:
values(Ltotal[i],m[i],ktube[j],Cptube[j],ptube[j],tfin[i],tspace[i],ODtube[i],unitcost[j])What is values()?