Run 10-1000 iterations, and note when convergence occurs.

timer Asked: Jan 22nd, 2021

Question Description

I'm working on a python question and need support to help me learn.

# Solve Laplace's eqtn, 3D matplot, close shell to quit

import matplotlib.pylab as p;

from mpl_toolkits.mplot3d import Axes3D

from numpy import *;

import numpy;


Nmax = 100; Niter = 70; V = zeros((Nmax, Nmax), float)

print ("Working hard, wait for the figure while I count to 60")

for k in range(0, Nmax-1): V[k,0] = 100.0 # Line at 100V

for iter in range(Niter):

if iter%10 == 0: print(iter)

for i in range(1, Nmax-2):

for j in range(1,Nmax-2):

V[i,j] = 0.25*(V[i+1,j]+V[i-1,j]+V[i,j+1]+V[i,j-1])

x = range(0, Nmax-1, 2); y = range(0, 50, 2)

X, Y = p.meshgrid(x,y)

def functz(V): # V(x, y)

z = V[X,Y]

return z

Z = functz(V)

fig = p.figure() # Create figure

ax = Axes3D(fig) # Plot axes

ax.plot_wireframe(X, Y, Z, color = 'r') # Red wireframe



ax.set_zlabel('Potential') # Show fig

Student has agreed that all tutoring, explanations, and answers provided by the tutor will be used to help in the learning process and in accordance with Studypool's honor code & terms of service.

This question has not been answered.

Create a free account to get help with this and any other question!

Brown University

1271 Tutors

California Institute of Technology

2131 Tutors

Carnegie Mellon University

982 Tutors

Columbia University

1256 Tutors

Dartmouth University

2113 Tutors

Emory University

2279 Tutors

Harvard University

599 Tutors

Massachusetts Institute of Technology

2319 Tutors

New York University

1645 Tutors

Notre Dam University

1911 Tutors

Oklahoma University

2122 Tutors

Pennsylvania State University

932 Tutors

Princeton University

1211 Tutors

Stanford University

983 Tutors

University of California

1282 Tutors

Oxford University

123 Tutors

Yale University

2325 Tutors