NTNUJAVA Virtual Physics Laboratory
Easy Java Simulations (2001 ) => Collaborative Community of EJS => Topic started by: lookang on May 17, 2011, 03:26:39 am

Ejs Open Source Newton's Cradle Java Applet by FuKwun & lookang, this version has best collision detection by FuKwun.
this is a derived work based on FuKwun Hwang's original Real Newton's Cradle here http://www.phy.ntnu.edu.tw/ntnujava/index.php?topic=1976.msg7387#msg7387
this remixed was a necessary as it has better collision detection than my older remix here Ejs Open source Newton's Cradle java Applet by Paco customized by lookang http://www.phy.ntnu.edu.tw/ntnujava/index.php?topic=824.0
[ejsapplet]
reference: http://en.wikipedia.org/wiki/Newton%27s_cradle
Newton's cradle
Newton's cradle, named after Sir Isaac Newton, is a device that demonstrates conservation of momentum and energy via a series of swinging spheres.
Construction
A typical Newton's cradle consists of a series of identically sized metal balls suspended in a metal frame so that they are just NOT touching each other at rest. Each ball is attached to the frame by two wires of equal length angled away from each other. This restricts the pendulums' movements to the same plane. (http://upload.wikimedia.org/wikipedia/commons/thumb/d/d3/Newtons_cradle_animation_book_2.gif/200pxNewtons_cradle_animation_book_2.gif)
Action
If the first one ball on the left is pulled away and is let to fall, it strikes the second ball in the series and the the first ball comes to an almost dead stop. The ball on the opposite side of the series acquires the momentum of the first ball almost instantly and swings in an arc that one would expect of the first ball.
The intermediate balls appear almost stationary. What actually happens is that the first impact transfer momentum and kinetic energy from the first ball to the second. The second ball having the momentum and kinetic of the first ball now hits almost perfectly elastic with the third ball, transferring it's momentum and kinetic energy to the third ball in the series. This transfer of momentum and kinetic energy continues until the (n1) and n ball, where finally the last ball n moves off with the momentum and kinetic energy of the first ball. Toward the end of oscillation, the intermediate balls are jiggling a bit.
Further intrigue is provided by starting more than one ball in motion. With two balls, exactly two balls on the opposite side swing out and back. While this is satisfyingly symmetrical, why could not one opposite ball swing out twice as fast, or four balls at half speed? Having the same number of balls swing on each side conserves both energy and momentum.
Further Physics
Newton's cradle is a clear visual example of the conservation of both momentum (mass x velocity) and kinetic energy (0.5 x mass x velocity^2) in a mechanical system. When the cradle only has two balls, these two principles are sufficient to specify its behaviour; i.e. there is no way of conserving momentum and energy when the first ball strikes the second other than for the first to stop and the second to move off at the same speed as the first.
For example, if the balls each have a mass of 1 and the first ball strikes the other two stationary balls with a velocity of 1, the initial momentum of the system is 1 x 1 = 1 and the kinetic energy is 0.5 x 1 x 1^2 = 0.5. If the first balls stops and the third ball moves off with a velocity of 1 (which is what actually happens), the momentum remains 1 and the kinetic energy remains 0.5.
However, if the first ball were to bounce backwards with a velocity of 1/3 and the second and third balls were to move forward each at a velocity of 2/3, the momentum would be 1 x (1/3 + 2/3 + 2/3) = 1 and the kinetic energy 0.5 x 1 x ((1/3)^2 + (2/3)^2 + (2/3)^2) = 0.5; i.e. this would also preserve both momentum and kinetic energy; however, it is not what happens.
The reason is because the collisions are actually with free individual balls and not with 2 connectedjoint balls.
What actually happens is that the first impact transfer momentum and kinetic energy from the first ball to the second. The second ball having the momentum and kinetic of the first ball now hits almost perfectly elastic with the third ball, transferring it's momentum and kinetic energy to the third ball in the series. This transfer of momentum and kinetic energy continues until the (n1) and n ball, where finally the last ball n moves off with the momentum and kinetic energy of the first ball. Toward the end of oscillation, the intermediate balls are jiggling a bit.
Applications
The most common application is that of a desktop executive toy. A less common use is as an educational aid, where a tutor explains what is happening or challenges students to do so.

changes:
some of my earlier contribution in 2008
My contributions are
1. changes made to sync top rectangle to appear directly above the string and mass for changing number of mass, n
2. input panel on the left
3. create a custom function drag() so that can read the codes clearly in a bigger view
4. added m"[j]"
5. add graph of ketotal, petotal tetotal
6. add angular momentum
7. added sound in collision
8. added dw[j]/dt = g/l*Math.sin(alpha[j])k*l*omega[j] for air resistance simulation
9. redesign the look and feel of the sliders bar etc
13May2011
added better controls
fix bug of KE = 0.5*m*l^2*omega^2
fix error by changing method back to BISECTION
made view more zoom in for increase in size
17May 2011, took about 3 hours to combine the features in both simulations
based on FuKwun Hwang's original Real Newton's Cradle here http://www.phy.ntnu.edu.tw/ntnujava/index.php?topic=1976.msg7387#msg7387
used codes from Ejs Open source Newton's Cradle java Applet by Paco customized by lookang http://www.phy.ntnu.edu.tw/ntnujava/index.php?topic=824.0
drag from paco added
added 3D
rework the simulation to suit better results from real collision
changes solver to velocity verlet as the others kept giving errors
added sound // sound effect added despite the energy conservation
Toolkit.getDefaultToolkit().beep(); // taken from http://www.compadre.org/OSP/items/detail.cfm?ID=8385&Attached=1
//Ceiling Bounce Model written by Wolfgang Christian
18May2011
made ballMoved the key to change mass m[ballMoved] instead of the older code m[id]
change the codes to layout the balls from left to right instead of the older right to left format
26 july 2011
made the xmin and xmax follow the number of balls, n for centralized view
26july 2011
make dt smaller for slower and smoothly run
checkbox for sound

Nice, i like the idea good work, i notice have a bug in 3d i not sure in my computer have it may only in my PC is
when i tried to change postion the 3d applet appear look like black screen and also disappear too fast and back again too fast.

Hi ahmed,
i suspect that Ejs 4.3.3.1 latest version is causing this bug in the compiled simulations.

18May2011
made ballMoved the key to change mass m[ballMoved] instead of the older code m[id]
change the codes to layout the balls from left to right instead of the older right to left format
enjoy!

submitted to http://www.compadre.org/osp/index.cfm for their consideration into the digital library
Newton's Cradle Model
reference: http://en.wikipedia.org/wiki/Newton%27s_cradle
Newton's cradle, named after Sir Isaac Newton, is a device that demonstrates conservation of momentum and energy via a series of swinging spheres.
Construction in 3D
A typical Newton's cradle consists of a series of identically sized metal balls suspended in a metal frame so that they are just NOT touching each other at rest. Each ball is attached to the frame by two wires of equal length angled away from each other. This restricts the pendulums' movements to the same plane.
Mathematical Model:
the simplified equations of motion is ODE for a single mass(pendulum) are:
d (cta)/dt = omega
d(omega)/dt = g*sin(cta)/L
Design features:
currently, the simulation allows of exploration of n max = 7 masses with each mass m[ii] that can be vary from the slider control from 1 to 5 kg.
additional variables are:
gravitational constant downward g = 9.81 m/s^2
Length of pendulums, L
k coefficicent of air resistance model by equation F = k*omega
The usabilty control:
To move the balls, move the cursor over to the mass, click and hold the left mouse and drag the mouse to lift the masses. note that all masses are selectable and movable to a new height along the each path of the pendulums swing.
Design Views:
there are 2 types views available selectable by the checkboxes 2D and 3D,
2D world view
3D world view
hint:
may be useful to observe the transfer of linear momentum from ball to ball by pressing the step button to aid understanding of momentum transfer during collisions
may be useful to observe the scientific representations of kinetic energies KE[ii], gravitational potential energies PE[ii] and total mechanical energies TE[ii]
graph of scientific representations of kinetic energies KE total, gravitational potential energies PE total and total mechanical energies TE total
Exercises:
select n =2 for a simple 2 ball system for the experiment.
Pull and release one ball. Note the results and explain mathematically in terms of conservation of engergy and momentum.
m1 u1 + m1 u1 = m1 v1+ m2 v2
1/2 m1 u1^2 + 1/2 m2 u2^2 = 1/2 m1 v1^2 + 1/2 m2 v2^2
record your observations and discuss if the two equations above can account for the observations
select n = 3 , 4, 5, 6, 7 and repeat the experiment above.
Do the results meet your expectations?
hint: can you conclude that the just before and just after collisions
momentum in = momentum out
kinetic energies in = kinetic energies out.
the clue lies in the conservation of momentum and kinetic energies just before and after collisions.
Discuss what are the differences between this computer model and real life apparatus.
hint: the newton's cradle motion will continue in this back and fro motion until all energies are lost to damping due to air resistance, friction, sound and vibrations.
In this simulation the default is all balls have the same mass. What would occur if this was not the case?
Advanced Learner:
Please submit your remix model that model features that are not available in the existing virtual lab and share your model with the world through NTNUJAVA Virtual Physics Laboratory http://www.phy.ntnu.edu.tw/ntnujava/index.php?board=28.0. Impacting the world with your model now.
Credits:
The Newton's Cradle Model was created by FuKwun Hwang, customized by Loo Kang WEE, using the Easy Java Simulations (EJS) version 4.3.3.2 authoring and modeling tool. An applet version of this model is available on the NTNU website < http://www.phy.ntnu.edu.tw/ntnujava/index.php?topic=2195.0 >.
You can examine and modify this compiled EJS model if you run the model (double click on the model's jar file), rightclick within a plot, and select "Open EJS Model" from the popup menu. You must, of course, have EJS installed on your computer. Information about EJS is available at: and in the OSP comPADRE collection .

accepted!
http://www.compadre.org/osp/items/detail.cfm?ID=11348&S=7
wolfgang also gave some pointers to
26july 2011
make dt smaller for slower and smoothly run
checkbox for sound
done!
enjoy!