<jupyter_start><jupyter_text>Determine the potential of a pair of equal and opposite charges $\pm 2$ esu located at the 3-dimentional positions (4,5,0) and (6,5,0) and plot equipotential contours for 60 values of the potential varying between -1.50 and +1.50 esu/cm shown in the $x$-$y$ plane with $z=1$.<jupyter_code>import numpy as np
import matplotlib.pyplot as plt
# specify size of region:
Lx=10.0
Ly=10.0
# introduce two point charges:
x1=2; y1=3; z1= 3; q1= 2 #position of charge #1
x2=3; y2=2; z2= -1; q2=-2 #position of charge #2
x3=6; y3=8; z3= 2; q3= 0.5

# create a 2D array in NumPy for the potential with N elements in each 
# direction and set its elements initially to zero
Nx = 101 #nunber of points on our x-axis.
Ny = 1010 #nunber of points on our y-axis.
phia = np.zeros((Ny,Nx))
phi2 = np.zeros((Ny,Nx))
phi3 = np.zeros((Ny,Nx))
X   = np.zeros(Nx)
Y   = np.zeros(Ny)
Dx=Lx/(Nx-1); Dy=Ly/(Ny-1) # find spacing between the points in x and y
z=1 # choose to work at fixed z=1
for nx in range (0,Nx):
    X[nx]= Dx*nx
    for ny in range (0,Ny):
        Y[ny]= Dy*ny
        phia[ny,nx]= q1/((Dx*nx-x1)**2+(Dy*ny-y1)**2+(z-z1)**2)**0.5
        phi2[ny,nx]= phia[ny,nx] + q2/((Dx*nx-x2)**2+(Dy*ny-y2)**2+(z-z2)**2)**0.5 
        phi3[ny,nx]= phi2[ny,nx] + q3/((Dx*nx-x3)**2+(Dy*ny-y3)**2+(z-z3)**2)**0.5 
        
Nl = 30 # the number of contour levels to be plotted.
clevel = np.zeros(Nl)
for n in range(0,Nl):
    clevel[n]=0.02*n; # select the values of phi for which
                      # equipotential lines will be plotted
fig = plt.figure(figsize=(10,10))
ax = fig.add_subplot(1,1,1)
ax.contour(X,Y,phi3,levels=clevel, colors='b', linewidths=1)
ax.contour(X,Y,-phi3,levels=clevel, colors='b', linewidths=1, linestyles='dashed')
plt.show()<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.1701059676519799, 'fraction_numerical': 0.0630228667038483, 'mean_word_length': 3.8225806451612905, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '579807', 'license': 'Apache-2.0', 'n_tokens_mistral': 813, 'n_tokens_neox': 766, 'n_words': 216, 'path': 'PythonForAcceleratedPhysics/HW14-Electric Potential/ErinAhernHw14Python.ipynb', 'repo_name': 'ecahern16/AcademicCode', 'size': '1793'}