I'm working on setting some boundary conditions for a water table model, and I am able to set the entire first row to a constant value, but not the entire first column. I am using np.zeros((11, 1001))
to make an empty matrix. Does anyone know why I am successful at defining the first row, but not the first column? I have noted the line in question below.
import numpy as np
x = range(0, 110, 10)
time = range(0, 5005, 5)
xSize = len(x)
timeSize = len(time)
dx = 10
dt = 5
Sy = 0.1
k = 0.002
head = np.zeros((11, 1001))
head[0:][0] = 16 # sets the first row to 16
head[0][0:] = 16 # DOESN'T set the first column to 16
for t in time:
for i in x[1:len(x)-1]:
head[t+1][i] = head[t][i] + ((dt*k)/(2*Sy)) * (((head[t][i-1]**2) - (2*head[t][i]**2) + (head[t][i+1]**2)) / (dx**2))
All you have to do is to change
to
If you want to change the first row you can just do:
EDIT:
Just in case you also wonder how you can change an arbitrary amount of values in an arbitrary row/column:
Now we set in row 2 3 values to 16:
The same works for columns:
And if you then also want to change certain values in e.g. two different rows at the same time you can do it like this: