Question
I NEED HELP ON THIS ASSIGNMNET i DONT KNOW HOW TO PUT THEM IN CODE PYTON Exercise 2. Explore the dipole. That is, place a
I NEED HELP ON THIS ASSIGNMNET i DONT KNOW HOW TO PUT THEM IN CODE PYTON Exercise 2. Explore the dipole. That is, place a positive charge at (1,0) and an equal but opposite charge at (-1,0) plot the resulting force vector at the (positively charged) target locations (-2,1), (-1,1), (0,1), (1,1), (2,1), (-2,0), (0,0), (2,0), (-2,-1), (-1,-1), (0,-1), (1,-1), (2,-1) - all on the same plot. Code this in the cell below.
CODE BELOW:
# find and plot the force of three (+) source charges on one (+) target charge
x_s = [-1, 0, 1] # x-coordinates of sources y_s = [0, 0, 0] # y-coordinates of sources
x_t, y_t = [-1, 1] # target coordinates
# let's assume all charges are single protons and # ignore the common factor k_e*q_t*q_s
for n in range(3): # place red o at each source plt.plot(x_s[n], y_s[n], 'ro', markersize=12)
plt.plot(x_t, y_t, 'ko', markersize=12) # place black o at target
Fvec = np.zeros(2,) # initialize the Force vector (Fvec)
for n in range(3): # build the Fvec, one charge at a time r = np.array([x_t-x_s[n], y_t-y_s[n]]) # r = r_t - r_s Fvec = Fvec + r/np.linalg.norm(r)**3 # Coulomb's Law Fvec = Fvec / np.linalg.norm(Fvec) # normalize for plotting purposes
plt.arrow(x_t,y_t,Fvec[0],Fvec[1],width = 0.06, length_includes_head = True)
plt.title('Figure 2',fontsize=18) plt.grid('on') plt.xlim([-2,2]) # extend axes to see arrow plt.ylim([-1, 2]);
The electrical force between two charged particles takes the exact same form as the gravitational force between two masses.
We suppose a source of charge (in coulombs, C) at position =(,) (in meters, m) and a target of charge (in coulombs, C) at position =(,) (in meters, m).
The force that the source charge imparts to the target charge is directed along the line through the two charges. The source will repell the target if they have the same sign and will attract the target if they have opposite sign. We use python to visualize the scene, and the arrowhead implies that repells .
BELOW IS MORE CODE
# plot the force vector between a pair of charges
import numpy as np # math helper routines import matplotlib.pyplot as plt # graphics helper routines
x_s, y_s = [1,1] # source coordinates x_t, y_t = [3,3] # target coordinates
plt.plot(x_s, y_s, 'ro', markersize=12) plt.text(x_s-.2, y_s+.1,'$q_s$',fontsize=16)
plt.plot(x_t, y_t, 'gs', markersize=12) plt.text(x_t+.1, y_t-.1,'$q_t$',fontsize=16)
plt.arrow(x_s,y_s,x_t-x_s,y_t-y_s,width = 0.06, length_includes_head = True) plt.text(2.1,1.75,'$\\vec F(s,t)$',fontsize=16)
plt.title('Figure 1',fontsize=18) plt.grid('on') plt.xlabel('x (m)', fontsize=12) plt.ylabel('y (m)', fontsize=12) plt.axis('equal');
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started