APS Excellence in Physics Education Award
November 2019

Education Prize Logo
Science SPORE Prize
November 2011

NSF Logo
The Open Source Physics Project is supported by NSF DUE-0442581.

Exercise 2.19 d in Introd Computer Simulation Methode

Return to the OSP Programming forum
Login to post to this thread

Exercise 2.19 d9 on page 40 of Introd Comp Sim Meth
Martin Jola
7 Posts

I'm not sure wether I understand this part of the exercise. In BouncingBall class I added a new methode for kinetic energy (I initialized the variables)
public void calc(){
energy = ((vx*vx)+(vy*vy)/2);

and in the App Class in doStep
for (int i=0;iball[i].calc();
totalenergy +=ball[i].energy ;
control.println("totalenergy = " +totalenergy);

It works well, however the results seem to be strange When I plot the result I get an up and down curve for each ball. With large number of balls the plot is almost completely full. When I add the potential energy as well (y*g) I get a streigth line upwartds. Can you comment my code and the result? Did I missunderstand the exercies?
So far all exercises in Chap 2 have not been a problem.


Post edited August 2, 2012 at 11:23 AM EST.

Current Replies - View all
Re: Exercise 2.19 d9 on p...   (Wolfgang - )
Re: Re: Exercise 2.19 d9 ...   (Martin Jola - )
Re: Re: Exercise 2.19 d9 ...   (Martin Jola - )
Re: Re: Re: Exercise 2.19...   (Wolfgang - )
OSP Projects:
Open Source Physics - EJS Modeling
Physlet Physics
Physlet Quantum Physics
STP Book