Project 4
Project 4A: Better Thundercloud Model
The storms over Lakeview have gotten worse, with an almost permanent pitch black cloud system hovering overhead. A new model for the thundercloud needs to be produced to obtain a better understansding of how it is functioning. While they greatly appreciated the model you created last week for the Mapping N$\vec{E}$twork Sensory Array (MNSA), the data they are collecting from the sensors are simply not matching the model's predictions. They have concluded that modeling storm clouds as point charges was, in fact, problematic. Based on some research from the National Weather Service, it looks like a better model for clouds would be two flat sheets of charge since the negative charges in the cloud collect on the bottom of the cloud and the positive charges collect near the top.
Given that the negative charge is much closer to the ground (and headquarters), the Lakeviewians want to prioritize what the Mapping N$\vec{E}$twork Sensory Array (MNSA) around HQ will show based on the bottom of the cloud. (If you have time though, they'd be interested in whether the top of the cloud has any effect.) They have shared their model of the bottom of the most recent storm cloud (which is thankfully fully functioning, well-commented code), but they are having trouble getting the electric field on the ground. The Lakeviewians have asked your team for your help completing the code.
#Set up of the objects ground = box(pos = vec(0,0,0), width=5000, length=5000, height=0.1, color=color.green) mountains = [cone(pos=vec(-1800,0,0), axis=vec(0,1000,0), radius=700, color=vec(1,0.7,0.2)), cone(pos=vec(-1800,0,-1600), axis=vec(0,1000,0), radius=700, color=vec(1,0.7,0.2)), cone(pos=vec(-1800,0,1600), axis=vec(0,1000,0), radius=700, color=vec(1,0.7,0.2))] HQ = box(pos = vec(-100,100,0), width = 15, length = 15, height= 200, color = color.blue) cloud = box(pos = vector(0,1000,0), size = vector(500, 1, 500), color = color.white) #Lines 13-48 create a grid of spheres to represent the bottom of the cloud (this part of the code doesn't need be modified): #Define how many chunks to split the cloud in the x direction (define x size of the cloud grid) nx = 10 #Define how many chunks to split the cloud in the z direction (define z size of the cloud grid) nz = 10 #Define where the cloud should start/stop in the x direction startx = -250 endx = 250 #Define the spacing between each chunk in the x, based on where the cloud start/stops and how many chunks there are stepx = (endx - startx)/nx #Define where the cloud should start/stop in the z direction startz = -250 endz = 250 #Define the spacing between each chunk in the z, based on where the cloud start/stops and how many chunks there are stepz = (endz - startz)/nz #Create an empty list to store each cloud chunk listOfCloudChunks = [] #For each cloud chunk in the x-direction for i in range(0,nx): #Define the x-location of the cloud chunk xloc = startx + i*stepx #For each cloud chunk in the z-direction for j in range(0,nz): #Define the z-location of the cloud chunk zloc = startz + j*stepz #Make a sphere at that x-z location cloudChunk = sphere(pos = vector(xloc,1000,zloc), radius = 50, color = color.red) #Add the sphere to the list of cloud chunks (so we can use it later) listOfCloudChunks.append(cloudChunk) #This part needs to be fixed and commented... obsLocation = vector(0,0,0) Enet = vector(0,0,0) Q = -15 dQ = Q/(nx*nz) k = 9e9 for chunk in listOfCloudChunks: Enet = vector(0,0,0)
Learning Goals
- Visualize the electric field from a 2D plane of charge
- Use multiple loops to create many observation points from many charges
- Identify patterns in the electric fields between 1D, 2D, and 3D charge distributions
- Compare/contrast process for a 2D charge distribution with a 1D charge distribution
Project 4B: Mini-Particle Accelerator
S.P.A.R.T.A.N force, still trapped in the town of Lakeview, has been sent as part of a larger governmental team to work on developing a micro-particle accelerator on the outskirts of town. Why does a town the size of Lakeview need a micro-particle accelerator? You are not at liberty to say. Your team is tasked with modeling the initial part of the accelerator, which uses a constant electric field to accelerate the charges. The concept is that the particles will enter a tube that is encapsulated by rings of charge. Your team needs to demonstrate that this concept will produce a constant electric field.
Part 1:
The first bit of code that you have received is from the previous team who were able to construct a single ring of charge and show the electric field due to that ring at some point. Your team should construct the electric field vectors for a circle inside the accelerator (smaller than the ring) at a distance of a few centimeters from the ring face.
GlowScript 2.7 VPython #Set up constants R = 0.02 r_obs = 0.05 Q = 1e-9 N = 20 dq = Q/N scale=1e-4 oofpez = 9e9 #1/(4pi epsilon_0) in N m^2/C^2 #Defining a ring at the origin myring = ring(pos = vector(0,0,0), radius = R, axis = vector(0,0,1), color = color.blue, thickness = 0.02*R) #Create an empty list for the charges ChargeList=[] #Set up the step size and angle for creating the charges dtheta = 2*pi/N theta = dtheta/2 #Create charges in a circle and add them to the ChargeList while theta < 2*pi: rpiece = R*vector(cos(theta),sin(theta),0) #location of piece particle = sphere(pos = rpiece, radius = R/20, color = color.yellow) ChargeList.append(particle) theta = theta + dtheta #Create an empty list for the observation points ObsList = [] #Set up the step size and angle for creating the observation points phi = 0 dphi = pi/4 #Create charges in a circle and add them to the ObsList while phi < 2*pi: r_obs_piece = r_obs*vector(cos(phi),sin(phi),1) #location of piece obs_particle = sphere(pos = r_obs_piece, radius = R/20, color = color.red) ObsList.append(obs_particle) phi = phi + dphi #Find the electric field at each observation point for obs_point in ObsList: for charge in ChargeList: Enet=vec(0,0,0)
Part 2
After you got this initial code working, your team was able to construct a model of a tube consisting of multiple rings, all with the same charge. But, the field doesn't look quite right - it's not constant as expected. Your bosses seem to think the field can be made constant in the tube, so it's up to you to figure out how.
num_points = 10 num_rings = 11 N = 11 spacing = 0.02 # Set some constants and stuff R=0.02 #radius of ring in m ax = vector(0,0,1) # simplify things Q=1e-9 #charge of ring in C oofpez=9e9 #1/(4pi epsilon_0) in N m^2/C^2 #draw axis zaxis=cylinder(pos=-2*R*ax, radius=0.015*R, axis=4*R*ax, color=color.black) #draw points points = [] for i in range(num_points): xr = 0.01*sin(i*2*pi/num_points) yr = 0.01*cos(i*2*pi/num_points) points.append(sphere(pos=vector(xr,yr,0.01), color=color.red, radius=5*zaxis.radius)) #make and draw rings rings = [] ring_charge = [Q,Q,Q,Q,Q,Q,Q,Q,Q,Q,Q] for i in range(num_rings): loc = i - (num_rings)//2 rings.append(ring(pos=vector(0,0,spacing*loc), radius=R, axis=ax, color=color.blue, thickness=0.02*R)) # Find net field for apoint in points: Enet = vector(0,0,0) for i in range(len(rings)): aring = rings[i] # look at one ring dq = ring_charge[i]/N #charge of a piece dtheta = 2*pi/N #theta increment for our loop theta=dtheta/2 #initial theta for first piece of loop Ering = vector(0,0,0) #net electric field for single ring rpoint = apoint.pos scale=1.2*mag(rpoint)/8000 #used to scale the arrows representing E-field while theta<2*pi: rpiece = R*vector(cos(theta),sin(theta),aring.pos.z/R) #location of piece r = rpoint-rpiece #vector from piece to point in space rmag = mag(r) #magnitude of r rhat = norm(r) #unit vector for r dE = oofpez * dq / rmag / rmag * rhat # Electric field of peice of ring Enet = Enet + dE particle=sphere(pos=rpiece, radius=apoint.radius, color=color.yellow) #draw a particlee theta=theta+dtheta Evector=arrow(pos=rpoint, axis=scale*Enet, color=color.orange, shaftwidth=apoint.radius/2)