D b D The goal of this exercise is to learn how to compute the x-...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
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 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
Expert Answer:
Answer rating: 100% (QA)
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... View the full answer
Related Book For
Posted Date:
Students also viewed these programming questions
-
The purpose of this exercise is to learn how to calculate stock returns for portfolio models using actual stock price data. Ten years worth of stock price data are included in the file StockReturns...
-
The YTM on a 4-year T-bond is 5.78%. If the coupon rate on this bond is 5.25%, with coupons paid SEMIANNUALLY, calculate the price of this bond today.
-
The purpose of this exercise is to give you an opportunity to create the tables for Bearcat Incorporated. The tables themselves are based on the relations that appear in the following figure. L1:...
-
Write a SET client SpellChecker that takes as a commandline argument the name of a file containing a dictionary of words, and then reads strings from standard input and prints any string that is not...
-
An annular fin of thickness t is used as a radiator to dissipate heat for a space power system. The fin is insulated on the bottom and may be exposed to solar irradiation GS. The fin is coated with a...
-
Row-reduce the matrix without the aid of a calculator, indicating the row operations you are using at each step using the notation of Definition RO. 1. 2. [21510 1-3-1 -2 4 -2 6 12 12-4
-
Each of the wires 1 to 3 in Figure P28.39 carries a current perpendicular to the page. The line integrals of the magnetic field around the three Amprian paths shown all have the same positive value....
-
Call Systems Company, a telephone service and supply company, has just completed its fourth year of operations. The direct write-off method of recording bad debt expense has been used during the...
-
4 16. The mean and variance of a binomial distribution area and respectively. If P(X = 1) = then P(X = 4 or 5) is equal to: 243 (a) 1/159 64 (b) $ 16 (c) 81 925 145 (d) 27 243 17. Let E1, E2, E3 be...
-
As the in-charge senior auditor on the audit engagement for JA Tire Manufacturing for the year ended December 31, 2019, you are responsible for performing risk assessment procedures related to the...
-
Find the real zeros of f and state the multiplicity for each zero. State whether the graph of f crosses or touches the x-axis at each zero. f(x)=-9(x-1)(x+7) The real zeros of f are x=1,-7 (Use a...
-
Business A and Business B are both engaged in retailing, but seem to take a different approach to this trade according to the information available. This information consists of a table of ratios,...
-
Bill Smithson runs a second-hand furniture business from a shop which he rents. He does not keep complete accounting records, but is able to provide you with the following information about his...
-
V. Fraga is a trader who sells all of his goods at 30% above cost. His books give the following information at 31 December 2013 You are required to: (a) Ascertain cost of goods sold. (b) Show the...
-
Fails business has a rate of inventory turnover of 10 times per year. Average inventory is 14,000. Mark-up is 40%. Expenses are 60% of gross profit. You are to calculate: (a) Cost of goods sold. (b)...
-
From the following information, calculate: (a) Earnings per share; (b) Price/earnings ratio; (c) Dividend yield; and (d) Dividend cover. (i) Net profit after interest and tax and preference dividends...
-
Discuss the product line and product mix strategy of Nintendo Switch and Switch Lite.
-
Write a program that initializes an array. It inputs a value from the user and searches the number in the array.
-
Using the definition of the derivative, find f(x). Then find f(-2), f(0), and f(3) when the derivative exists. (x) = 4x 3 - 3
-
In exercises, find an equation in slope-intercept form for each line. Through 1-2, 3/42 and 12/3, 5/22
-
Identify which geometric series converge. Give the sum of each convergent series. 1 + 0.8 + 0.64 + 0.512 +....
-
A laptop battery has an emf of 10.8 V. The laptop uses 0.70 A while running. a. How much charge moves through the battery each second? b. By how much does the electric potential energy of this charge...
-
When a current passes through the body, it is mainly carried by positively charged sodium ions (Na + ) with charge +e and negatively charged chloride ions (Cl - ) with charge -e. In a given electric...
-
Will the bulb in Figure Q22.2 light? Explain. + FIGURE Q22.2
Study smarter with the SolutionInn App