Question: Need help creating this code in VPython using the GlowScript IDE for Physics class. Your goal in this project is to use computational techniques to
Need help creating this code in VPython using the GlowScript IDE for Physics class.
Your goal in this project is to use computational techniques to model a 1-D gas and find how pressure and volume depend upon the kinetic energy of the particle. We will split this into two parts. Part 1 will simply be to examine the dependence of a 1-D gas. What is a 1-D gas? A 1-D gas is a gas in which the particles are only moving in 1 dimension, either left or right. This is a drastic simplification, but we can expand the results to 3-D. This will mirror what we did in the ideal gas tutorial. We want a particle moving in a particular direction, when it hits a wall, at some location, then it undergoes a momentum change: =. We are going to set =0.001 . You will want to figure out when the ball hits the wall, then determine the force. There have to be two walls and the ball will bounce back and forth between the two walls. We will be creating a force vs. time graph. We will also really care about the time average force exerted by the wall. This we will use to determine the walls pressure. For this assignment, we will only use a single ball with a single momentum. next assignment we will introduce more balls and vary the kinetic energy of the balls. As last time, create a ball which has a mass and a momentum property. Set the momentum to sum value.
O1 = sphere(pos=vec(0,0,0), radius = 0.5, mass = 1, momentum = vec(-5,0,0), charge = 2e-9,color = color.red) Create at least two walls: w1 = box(pos = vec(5, 0, 0), length=.5, height = 10, width = 10) w3 = box(pos = vec(-5, 0, 0), length=.5, height = 10, width = 10)
You will need to use an if statement for checking the location of the ball and if it has interacted with the wall. if O1.pos.x <= -5: O1.momentum.x = -1* O1.momentum.x # change direction of the object. F = 2*O1.momentum/dt elif O1.pos.x >= 5: O1.momentum.x = -1* O1.momentum.x F = 2*O1.momentum/dt Question, why is it twice the momentum? else: F = vec (0,0,0)
What this code does is calculate the average force over 0.001 seconds due to the change in momentum. If there is no interaction, there will be no force! We want to create a graph. At the top of your program add the following code:
f1=graph() f1a=gcurve(graph=f1, color=color.red)
Then in the while loop, add this code: f1a.plot(t,F.mag)
The F.mag means the magnitude of the force. Since we are doing a 1-D situation, this will be fine. Be certain to show the graph of force vs. time. Calculating the average force. We also want to calculate the average force. This means we have to track the interaction with the wall over time. An average is given by the sum over the force, divided by the total number of items. We are doing a time average. So, we want to sum up all the values of the force multiplied by dt, then divide by the total time. Or you can simply add up the force values through each iteration and then divide by the number of iterations. Your goal is to simulate the pressure by calculating the average force for several different conditions: 1. Spacing between the walls (which simulates volume). 2. Momentum. You will want to run enough trials to be able to create the following graphs using excel: 1. pressure vs. wall separation 2. pressure vs. momentum.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
