Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

D b D The goal of this exercise is to learn how to compute the x- and y-components of the electric field due to

 

D b D The goal of this exercise is to learn how to compute the x- and y-components of the electric field due to an arbitrary collection of point charges. Create a new Python program Import relevant packages import numpy as np import matplotlib.pyplot as plt import math Define charges and their positions. The data structure shown below is a list. You can add any number of new charges to this list, or remove some of the charges. The instructor will explain how to the elements of the list are indexed. charges = [(-1.0, [-1.0, 0.0]), (-1.0, [1.0, 0.0]), (1.0, (0.0, 1.0))] Define a function to calculate the x- and y-components of the E field. Try and understand what each line does and how the principle of superposition is coded. Ask the instructor for clarification if needed. def Ecomp(x,y): Ex=0.0 Ey-0.0 for C in charges: r=((x-C[1][0])**2+(y-C[1][1])**2)**(1/2) Ex-Ex+C[0]*(x-C[1][0])/r**3 Ey Ey+C[0]*(y-C[1][1])/r**3 return Ex, Ey Now you are ready to call this function. print (Ecomp(0,0)) Does the output make sense? Now let us make some plots Set up a double charge system on the y-axis : charge q=+0.5 at y=1.0 and charge q=+0.5 at y=1.0 Plot the electric field on the x-axis by using the code below x= np.linspace(-10.0, 10.0, 100) # Create 1-D array for x E1-Ecomp(x,0)[0] #x-comp of E field on x-axis E2-Ecomp(x,0) [1] #y-comp of E field on x-axis pit.figure() # create a new figure window pit.plot(x,E1, 'r') plt.figure() # create a new figure window plt.plot(y,E2, 'b') plt.show() Create titles and label axes on your plots M

Step by Step Solution

3.44 Rating (179 Votes )

There are 3 Steps involved in it

Step: 1

To calculate the x and y components of the electric field due to an arbitrary collection of point charges you can follow the steps outlined below 1 Im... blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Calculus With Applications

Authors: Margaret L. Lial

12th Edition

978-0135871348, 0135871344

More Books

Students also viewed these Programming questions

Question

Salary (if known)

Answered: 1 week ago