25 Apr I have the code already developed. Can anyone
I have the code already developed. Can anyone add the code for taking inputs from user
for any values in the code .
Also, Can you please describe about the code written in details (You can add comments )
This is using vpython and numpy only.
# project using vpython which simulates 3-dimensional plot of an electric field vector # produced by the two charges. There will be two charges positive and negative # and the arrow showing the field will be changed based on the magnitude. (Dim for low and dark for higher) from vpython import * #for a smooth run scene = canvas() #constant values for below parameters scale = 4e-14 / 1e17 electronCharge = 1.6e-19 CoulombConstant = 9e9 scene.range = 2e-13 #texts wtext(text='red sphere = +ve and blue sphere = -ven') wtext(text='click on the space inorder to see the directionn') wtext(text="ctrl and Click to rotate inorder to view from different anglen") #parameter pos=vector() used for position of the sphere #x,y,z positions of an object in 3D space # size * vector() determines the size of the spehere charges = [sphere(pos=vector(-1e-13, 0, 0), Q=electronCharge, color=color.red, size=1.3e-14 * vector(2, 2, 2)), sphere(pos=vector(1e-13, 0, 0), Q=-electronCharge, color=color.blue, size=1.3e-14 * vector(2, 2, 2))] #get function create to get the field def getfield(p): f = vec(0, 0, 0) for c in charges: f = f + (p – c.pos) * CoulombConstant * c.Q / mag(p – c.pos) ** 3 return f #in progress to add the slider for altering the inputs # def Pos_x(x): # charges.x = x.value # scene.append_to_caption('input for X: ') # slider( bind=Pos_x, min=-1, max=1, step=0.001, value=0) # scene.append_to_caption('nn') def mouse_to_field(a): #mouse click of pos (position of sphere) p = scene.mouse.pos f = getfield(p) ma = mag(f) red = max(1 – 1e17 / ma, 0) blue = min(1e17 / ma, 1) if red >= blue: blue = blue / red red = 1.0 else: red = red / blue blue = 1.0 a.pos = p a.axis = scale * f a.color = vector(red, 0, blue) #we can turn off and on the visibility of the arrow a.visible = True def Checkbox(c): a.visible = not c.checked # alternates checkbox(bind=Checkbox, text='Turn off Arrow visibility') # text to right of checkbox drag = False a = None #mouse events #pressing down mouse event def down(ev): global a, drag a = arrow(shaftwidth=6e-15, visible=False) mouse_to_field(a) drag = True #mouse moving event def move(ev): global a, drag if not drag: return mouse_to_field(a) #mouse up event def up(ev): global a, drag mouse_to_field(a) drag = False # scene.bind register that want to be called back any time there is a click event #bind more than one event in function scene.bind("mousedown", down) scene.bind("mousemove", move) scene.bind("mouseup", up)
,
Can you please modify the code with below requirement: a. user should be able to change the distance between sphere using slider b. there should be atleast two inputs from user (you can pick any two variable from code or add any variable you think is applicable for electric field vector produced by two charge. c. Can you please write the comments for the code in detail (what the code will do and what happen when we change the values etc…) note : only use vpython and numpy (other libraries are not allowed)
Our website has a team of professional writers who can help you write any of your homework. They will write your papers from scratch. We also have a team of editors just to make sure all papers are of HIGH QUALITY & PLAGIARISM FREE. To make an Order you only need to click Ask A Question and we will direct you to our Order Page at WriteDemy. Then fill Our Order Form with all your assignment instructions. Select your deadline and pay for your paper. You will get it few hours before your set deadline.
Fill in all the assignment paper details that are required in the order form with the standard information being the page count, deadline, academic level and type of paper. It is advisable to have this information at hand so that you can quickly fill in the necessary information needed in the form for the essay writer to be immediately assigned to your writing project. Make payment for the custom essay order to enable us to assign a suitable writer to your order. Payments are made through Paypal on a secured billing page. Finally, sit back and relax.