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)
Collepals.com Plagiarism Free Papers
Are you looking for custom essay writing service or even dissertation writing services? Just request for our write my paper service, and we'll match you with the best essay writer in your subject! With an exceptional team of professional academic experts in a wide range of subjects, we can guarantee you an unrivaled quality of custom-written papers.
Get ZERO PLAGIARISM, HUMAN WRITTEN ESSAYS
Why Hire Collepals.com writers to do your paper?
Quality- We are experienced and have access to ample research materials.
We write plagiarism Free Content
Confidential- We never share or sell your personal information to third parties.
Support-Chat with us today! We are always waiting to answer all your questions.