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 - Jul 31, 2012 at 4:20AM
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.
regards

martin

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


Current Replies - View all
Re: Exercise 2.19 d9 on p...   (Wolfgang - Aug 2, 2012 at 7:07PM)
Re: Re: Exercise 2.19 d9 ...   (Martin Jola - Aug 4, 2012 at 8:00AM)
Re: Re: Exercise 2.19 d9 ...   (Martin Jola - Aug 4, 2012 at 8:02AM)
Re: Re: Re: Exercise 2.19...   (Wolfgang - Aug 4, 2012 at 8:38AM)
The OSP Network:
Open Source Physics - Tracker - EJS Modeling
Physlet Physics
Physlet Quantum Physics