Ball on a Ramp

Activity Information

Learning Goals

  • Analyze data to support the claim that Newton's second law of motion describes the mathematical relationship among the net force on a macroscopic object, its mass, and its acceleration ( HS-PS2-1)
    • Students will develop and use models to verify mathematical computations
    • Use mathematics and computational thinking to quantify variables (velocity, acceleration, force, mass, gravity)
  • Use mathematical representations to support the claim that the total momentum of a system of objects is conserved when there is no net force on the system ( HS-PS2-2)
  • Developing an using models, communicating information, asking questions, defining problems and solutions

Prior Knowledge Required

  • Kinematic formulae
    • speed, velocity, acceleration
  • Basic coding commands and coding logic
  • Force of gravity (constant acceleration)

Code Manipulation

  • Manipulating variables and code
  • Generating code based on physics knowledge
  • While loops

—-

Activity

Handout

Ball on a Ramp

Provided below is some code that is supposed to model the behavior of a ball rolling down an inclined plane. Run the code.

Exploration Instructions

Find the variables below and record their abbreviations. Change them, one at a time, to see how they impact the code performance. Discuss what changes and what remains consistent:

  • Ramp length
  • Ball speed
  • Time interval
  • Number of books in the stack
  • Acceleration

Reset variables to the following:

  • Ramp length = 100
  • Time interval = 10
  • Number of books in the stack = 1
  • Acceleration = 0

Now run this code. Describe the motion of the ball. Does this represent real world physics? Why or why not? What would need to change?

Coding Instructions
  1. Make the ball follow the ramp instead of straight across the screen
    1. (Hint: see what code makes the ball move to the right to help determine how to make the ball move up or down)
  2. Add code to make the ball stop at the end of the ramp regardless of the angle or height of the ramp
  3. Use the data given to your group to calculate the acceleration for your ramp. Change the acceleration in the code to match this value
    1. (Note: different values may be provided to different students/groups, but for the sake of consistency, we will use the following values:)
      • Ramp length = 100
      • Ball speed = 1
      • Time interval = 100
      • Number of books in the stack = 8
  4. If necessary, change the code to make the motion of the ball to reflect the true motion of a ball held at the top of a ramp and let go from an initial velocity of zero
Evaluation Questions
  1. How did increasing the height of the ramp (by adding more books) change the final speed of the ball? Explain.
  2. How could increasing the length of the ramp (but keeping the height the same) impact the speed of the ball? Explain.
  3. Does your simulation truly represent the change in speed of a ball rolling down a ramp? Why or why not?
  4. What could be changed about the ramp itself (besides its height or length) in the real world to make the ball either have more or less speed at the bottom of the ramp? Explain.
  5. How could you change your code to reflect of of the changes listed in the previous question?
  6. What calculations did you need to do to determine the stop point for the ball?
  7. In the following code, “pos” tells us position. What does “axis” tell us?
      1. ramp1 = cylinder(pos = vector(R1s, R1h, 0), axis = vec(R1X, -R1Y, 0), radius = Bh, color = color.white)

Code

Link

  1. GlowScript 2.7 VPython
  2.  
  3. # Window setup########################
  4. scene.width = 800 #The width of your view window
  5. scene.height = 400 #The height of your view window
  6.  
  7. ######################################
  8.  
  9. # Parameters and Initial Conditions###
  10. BaR = 10 #Radius of the ball
  11. BaS = 1 #Scalar to change ball speed
  12. Bh = 5 #Height of books in first stack of books
  13. Bw = 30 #Width of books in first stack of books
  14. Bs = -100 #X-value offset of the center of the first book stack
  15. Tt = 0 #reference point for drawing the books (not used in any real math)
  16. Bc = 1 #condition for beginning to draw books (checked against time)
  17. R1L = 100 #Length of first ramp
  18. nB = 5 #The number of books in the first stack
  19. A1 = 0 #Acceleration of ramp 1
  20. #########################################
  21.  
  22. # Time and time step#####################
  23. t = 0 #start time (this command sets the counter to 0)
  24. tFinal = 200 #The end number on the counter to stop actions
  25. #########################################
  26.  
  27. #Ramp and speed calculations#############
  28. R1Y = Bh*nB #Starting Y-value coordinate for ramp (total Y value of ramp)
  29. R1X = sqrt(R1L**2 - R1Y**2) #Starting X-value coordinate for ramp (total X value of ramp)
  30. S1x = R1X/R1L*BaS #the horizontal vector of movement down first ramp
  31. S1y = R1Y/R1L*BaS #the vertical vector of movement down first ramp
  32. #########################################
  33.  
  34. #Drawing initial objects#################
  35. #draw tabletop
  36. Table= box(pos = vector(75,-6,0), size = vector(400, 10, 30), color = color.orange)
  37.  
  38. #Stack of books
  39. Bc = Tt
  40. while t<nB:
  41. Bc = Tt + Bh*t +Bh/2
  42. book = cylinder(pos = vector(Bs, Bc, 0), axis = vec(Bw, 0, 0), radius = Bh, color = color.yellow)
  43. t=t+1
  44. ballstopx = Bs - Bw/2 - R1L/2
  45. t=t+1
  46.  
  47. #Downward Ramp
  48. R1h = Tt + Bh*t +Bh/2
  49. R1s = Bs + Bw
  50. ramp1 = cylinder(pos = vector(R1s, R1h, 0), axis = vec(R1X, -R1Y, 0), radius = Bh, color = color.white)
  51.  
  52. #Ball
  53. BaX = R1s + BaR/2
  54. BaY = R1h+Bh + BaR/2
  55. ball = sphere(pos=vec(BaX,BaY,0), radius = BaR/2, color=color.red)
  56. ##########################################
  57.  
  58. #MOVEMENT COMMANDS LOCATED BELOW###############################################################################
  59.  
  60.  
  61. #Command for ball rolling down first ramp###################################################
  62.  
  63. scene.camera.follow(ball) #this makes the camera follow the ball
  64. t=0 #resets the time counter to 0 at the start of the loop
  65.  
  66. theta = acos(R1X/R1L) #this calculates angle of the ramp
  67. A1x = sin(theta)*cos(theta) #calculates x-value of acceleration
  68. A1y = sin(theta)*sin(theta) #calculates y-value of acceleration
  69.  
  70. while t<tFinal: #sets the condition for this command taking place
  71. rate(20) #how many times per cycle the action will take place
  72. ball.pos.x = ball.pos.x + S1x #updates the x position of the ball at rate listed above every sec
  73.  
  74. t=t+1 #makes it so ever cycle it adds 1 to the time counter
  75.  
  76. # if ???: #sets condition for when the ball should stop moving
  77. # t=tFinal #sets the timer to the final value, so the loop stops

Answer Key

Handout

Evaluation Questions
  1. Increasing the height of the ramp did not affect the final speed of the ball.
  2. Increasing the length of the ramp increased the final speed of the ball.
  3. The simulation is not realistic; When a ball rolls down a ramp, it is moved due to the force of gravity; however, it cannot fall straight down since it is restricted by the ramp. On a completely horizontal surface, gravity and the normal force perfectly balance each other out, and there is no acceleration. As the ramp becomes steeper, the less the force of gravity is resisted by the normal force. For a completely vertical surface, there will be no normal force and therefore the force of gravity pulls the ball towards the earth unimpeded. This means that increasing the ramp height should increase the speed of the ball. Additionally, changing the length of the ramp should not affect the final speed of the ball. Although a ball rolling down a steeper ramp will accelerate faster, the final speed of the ball at the end of the ramp will be the same, regardless of ramp length (ignoring frictional forces). This can be demonstrated by relating the potential and kinetic energy. We can set potential energy equation equal to the kinetic energy equation to find the speed of the ball is affected by the ramp: $$mgh=\dfrac{1}{2}mv^2$$ where $m$ is mass of the ball, $g$ is the acceleration of gravity, $h$ is the height of the ramp, and $v$ is the speed of the ball. Since the mass, force of gravity, and height of the ramp does not change when you lengthen the ramp, the velocity will be the same.
  4. Adding a coefficient of friction could reduce the speed of the ball. This is because frictional forces resist motion.
  5. See highlighted code below. Note that some values are in slightly different locations in the code below.
  6. “axis” tells us the direction that the ramp will point. In this instance, the ramp will be “R1X” units in the x-direction and “-R1Y” units in the y-direction

Code

Partially Complete

Link

  1. GlowScript 2.7 VPython
  2.  
  3. # Window setup############################################################################
  4. scene.width = 800 #how far the view extends along the X-axis initially
  5. scene.height = 600 #how tall the view extends on the Y-axis initially
  6.  
  7. ##########################################################################################
  8.  
  9.  
  10. # Parameters and Initial Conditions#######################################################
  11. BaR = 10 #radius of the ball (balldia)
  12. BaS = 1 #Scalar of speed for ball (ballspeed)
  13. Bh = 5 #Y-value of individual books (bookheight)
  14. Bw = 30 #X-value of the individual books (bookwidth)
  15. Bs = -100 #X-value of the centerpoint of the stack of books (bookstack)
  16. Tt = 0 #refrence point for drawing the books (tabletop)
  17. Bc = 1 #condition for beginning to draw books (checked against time)(numberbooks)
  18. R1L = 100 #Length of down ramp (ramplength)
  19. R1T = 10 #height of the ramp (rampthickness)
  20. nB = 8 #The number of books in the initial stack (numberofbooks)
  21. A1 = .1 #acceleration for ramp 1 determined by students from data
  22.  
  23. ###########################################################################################
  24.  
  25.  
  26. # Introduction of Objects#################################################################
  27. #books drawn one at a time in code
  28. #ramp drawn on top of books in code
  29. #ball drawn on top of ramp in code
  30.  
  31. ##########################################################################################
  32.  
  33.  
  34. # Time and time step######################################################################
  35. t = 0 #start time
  36. t2 = 0 #start line for second stack of books ***
  37. tFinal = 100 #First phase final time
  38. dt = 1 #rate of time change
  39. ##########################################################################################
  40.  
  41.  
  42. #MAIN CODE LOCATED BELOW
  43.  
  44. #Ramp and speed calculations##############################################################
  45. R1Y = Bh*nB #Starting Y-value of top of ramp (rampy)
  46. R1X = sqrt(R1L**2 - R1Y**2) #distance of ramp from stack of books (x-value) (rampx)
  47. S1x = R1X/R1L*BaS #the horizontal vector of movement (speedx)
  48. S1y = R1Y/R1L*BaS #the vertical vector of movement (speedy)
  49. A1x = R1X/R1L*A1 # horizontal acceleration
  50. A1y = R1Y/R1L*A1 # vertical acceleration
  51. ##########################################################################################
  52.  
  53.  
  54. #Drawing initial objects##################################################################
  55. #draw tabletop
  56. Table= box(pos = vector(75,-6,0), size = vector(400, 10, 30), color = color.orange)
  57.  
  58. #Stack of books
  59. Bc = Tt
  60. while t<nB:
  61. Bc = Tt + Bh*t +Bh/2
  62. book = cylinder(pos = vector(Bs, Bc, 0), axis = vec(Bw, 0, 0), radius = Bh, color = color.yellow)
  63. t=t+1
  64. t=t+1
  65.  
  66. #Downward Ramp
  67. R1h = Tt + Bh*t +Bh/2
  68. R1s = Bs + Bw
  69. ramp1 = cylinder(pos = vector(R1s, R1h, 0), axis = vec(R1X, -R1Y, 0), radius = Bh, color = color.white)
  70.  
  71. #Ball
  72. BaX = R1s + BaR/2
  73. BaY = R1h+Bh + BaR/2
  74. ball = sphere(pos=vec(BaX,BaY,0), radius = BaR/2, color=color.red)
  75.  
  76. scene.camera.follow(ball) #this makes the camera follow the ball
  77. t=0 #reset counter to zero
  78. ###########################################################################################
  79.  
  80. #Command for ball rolling down first ramp##################################################
  81. while t<tFinal:
  82. rate(20) #how many times per second the action will take place
  83. ball.pos.x = ball.pos.x + S1x
  84. ball.pos.y = ball.pos.y - S1y
  85. S1x = S1x + A1x
  86. S1y = S1y + A1y
  87. t=t+1
  88.  
  89. #Stopping ball motion at end of ramp #see if the ball is at the position of the ramp + rampx (total position on the screen is the two combined
  90.  
  91. if ball.pos.x > R1s + R1X:
  92. t=tFinal
Complete

Link

  1. GlowScript 2.7 VPython
  2.  
  3. # Window setup########################
  4. scene.width = 800 #The width of your view window
  5. scene.height = 400 #The height of your view window
  6. ######################################
  7.  
  8. # Parameters and Initial Conditions###
  9. BaR = 10 #Radius of the ball
  10. BaS = 1 #Scalar to change ball speed
  11. Bh = 5 #Height of books in first stack of books
  12. Bw = 30 #Width of books in first stack of books
  13. Bs = -100 #X-value offset of the center of the first book stack
  14. Tt = 0 #refrence point for drawing the books (not used in any real math)
  15. Bc = 1 #condition for beginning to draw books (checked against time)
  16. R1L = 100 #Length of first ramp
  17. nB = 5 #The number of books in the first stack
  18. R2L = 100 #Length of flat section **
  19. n2B = 5 #The number of books in the second stack of books ***
  20. B2c = 1 #condition for beginning second stack of books (checked against time)***
  21. T2t = 0 #refrence point for drawing second stack of books(not used in any real math) ***
  22. B2h = 5 #height of books in second stack of books ***
  23. B2w = 30 #width of books in second stack of books ***
  24. R3L= 100 #length of second ramp ***
  25. #########################################
  26.  
  27. # Time and time step#####################
  28. t = 0 #start time (this command sets the counter to 0)
  29. tFinal = 100 #The end number on the counter to stop actions
  30. tFinal2=100 #Same as above but for second loop (final counter number)**
  31. #########################################
  32.  
  33. #Ramp and speed calculations#############
  34. R1Y = Bh*nB #Starting Y-value coordinate for ramp (total Y value of ramp)
  35. R1X = sqrt(R1L**2 - R1Y**2) #Starting X-value coordinate for ramp (total X value of ramp)
  36. S1x = R1X/R1L*BaS #the horizontal vector of movement down first ramp
  37. S1y = R1Y/R1L*BaS #the vertical vector of movement down first ramp
  38. R3Y = B2h*n2B #Y-value for second ramp ***
  39. R3X = sqrt(R3L**2 - R3Y**2) #X-value for third ramp ***
  40. B2s = R1X + R2L + R3X + Bs + B2w #X-value of the centerpoint of the second stack of books ***
  41. #########################################
  42.  
  43. #Drawing initial objects#################
  44. #draw tabletop
  45. Table= box(pos = vector(75,-6,0), size = vector(400, 10, 30), color = color.orange)
  46.  
  47. #Stack of books
  48. Bc = Tt
  49. while t<nB:
  50. Bc = Tt + Bh*t +Bh/2
  51. book = cylinder(pos = vector(Bs, Bc, 0), axis = vec(Bw, 0, 0), radius = Bh, color = color.yellow)
  52. t=t+1
  53. ballstopx = Bs - Bw/2 - R1L/2
  54. t=t+1
  55.  
  56. #Downward Ramp
  57. R1h = Tt + Bh*t +Bh/2
  58. R1s = Bs + Bw
  59. ramp1 = cylinder(pos = vector(R1s, R1h, 0), axis = vec(R1X, -R1Y, 0), radius = Bh, color = color.white)
  60.  
  61. #Ball
  62. BaX = R1s + BaR/2
  63. BaY = R1h+Bh + BaR/2
  64. ball = sphere(pos=vec(BaX,BaY,0), radius = BaR/2, color=color.red)
  65.  
  66. #draw ramp 2 **
  67. R2h = Tt + Bh/2
  68. R2s = Bs + Bw + R1X + R2L/2
  69. ramp2 = box(pos = vector(R2s, R2h, 0), size = vector(R2L, Bh*4, 10), color = color.orange)
  70.  
  71. ##########################################
  72.  
  73. #MOVEMENT COMMANDS LOCATED BELOW###############################################################################
  74.  
  75.  
  76. #Command for ball rolling down first ramp###################################################
  77.  
  78. scene.camera.follow(ball) #this makes the camera follow the ball
  79. t=0 #resets the time counter to 0 at the start of the loop
  80.  
  81. theta = acos(R1X/R1L) #this calculates angle of the ramp
  82. A1x = sin(theta)*cos(theta) #calculates x-value of acceleration
  83. A1y = sin(theta)*sin(theta) #calculates y-value of acceleration
  84.  
  85. while t<tFinal: #sets the condition for this command taking place
  86. rate(20) #how many times per cycle the action will take place
  87. ball.pos.x = ball.pos.x + S1x #updates the x position of the ball at rate listed above every sec
  88. ball.pos.y = ball.pos.y - S1y #updates the y position of the ball at rate listed above every sec
  89. S1x = S1x + A1x #adjusts the update position based on the x acceleration
  90. S1y = S1y + A1y #adjusts the update position based on the y acceleration
  91. t=t+1 #makes it so ever cycle it adds 1 to the time counter
  92.  
  93. if ball.pos.x > R1s + R1X: #sets condition for when the ball's x position reaches the end of the ramp
  94. t=tFinal #sets the timer to the final value, so the loop stops
  95.  
  96. ###########################################################################################
  97.  
  98. #Command for our second stage animation####################################################
  99.  
  100. t=0 #reset counter for second loop
  101. S2x = S1x # carries over x-value speed from end of ramp 1
  102. S2y = 0 #stop vertical movement of the ball as we hit the flat section
  103.  
  104. while t<tFinal2:#sets the condition for this command taking place
  105. rate(20) #how many timeps per cycle the action will take place
  106. ball.pos.x = ball.pos.x + S2x #updates the x position of the ball at rate above
  107. ball.pos.y = ball.pos.y + S2y #updates the y position of the ball at the rate above
  108. if ball.pos.x > R2s + .5*R2L - BaR*.5: #sets condition for when ball reaches end of plane
  109. t = tFinal2 #sets timer to the final for section 2 when above condition is met
  110. t=t+1 #increases the time counter by 1 every time loop runs
  111.  
  112. ###########################################################################################

See Also

  • repository/ball_on_a_ramp.txt
  • Last modified: 2021/03/24 23:34
  • by porcaro1