I have a while
loop in my python code which contains a nested for
loop that loops over a 2D array.
The variable T
needs to get updated at end of the while
loop.
However I'm seeing that the variable is getting updated within the for
loop itself.
What am I doing incorrectly here and how to modify this?
error = 1
tolerance = 1e-6
T = T_new
itr = 0
while error>tolerance:
itr = itr+1
for i in range(1,imax-1):
for j in range(1,jmax-1):
T_new[i,j]=0.25*(T[i-1,j]+T[i+1,j]+T[i,j-1]+T[i,j+1])
error = np.max(np.abs(T_new-T))
T = T_new