NTNUJAVA Virtual Physics Laboratory
Enjoy the fun of physics with simulations!
Backup site http://enjoy.phy.ntnu.edu.tw/ntnujava/

Easy Java Simulations (2001- ) => Collaborative Community of EJS => Topic started by: lookang on June 18, 2010, 10:47:03 am



Title: Ejs Open Source Multi Objects (Car,Ball,Shell,Disc) rolling down inclined plane
Post by: lookang on June 18, 2010, 10:47:03 am
Ejs Open Source Ball Rolling down a Straight Ramp Java Applet

A friend has this activity that i thought it will be cool to have a virtual lab too?
new repurposed name
Ejs Open Source Multi Objects ( Car , Ball , Shell , Disc ) rolling down on an Inclined Plane Java Applet
i must thanks the man, Fu-Kwun Hwang for his worthy of noble prize forum for informal learning cum community of practice CoP.

Ejs Open Source Rocket Car on an Inclined Plane Java Applet is by Wolfgang Christian, Francisco Esquembre, and Mario Belloni using the Easy Java Simulations (Ejs) modeling tool, now remixed by lookang for learning purposes.
Information about Ejs is available at:
http://www.um.es/fem/Ejs/
and also from the OSP Collection on the ComPADRE Web site:
http://www.compadre.org/osp/items/detail.cfm?ID=8243
Access Rights:
   Free access
License:
   This material is released under the GNU General Public License Version 1.

My thoughts:
so after i am done remixing it, i will also release it's remixed it's source code back, there by guarantee your freedom to share and change free software--to make sure the software is "free to change" for all its users.


Title: Re: Ejs Open Source Ball Rolling down a Straight Ramp Java Applet
Post by: lookang on June 18, 2010, 10:54:07 am
ball and ramp for Secondary 1 Science- Physics Average Speed

Objective: Studying the overall speed in a journey
 
Materials:
x    1 Metal ball
x    4 Electronic stop watches
x    Metre-Rule 
x    Use the ramp to make the track inclined

1.   Set the track inclined as shown in the diagram below. Let the ball roll along the track.

Describe the motion of the ball on the track. 

Is motion constant speed?

 Measure and record the time taken for the ball to travel from the start point to the 30cm,
60cm,  90cm  and  120cm  markings.  Adjust  the  inclination  if  necessary  so  that  you  can
measure the time comfortably.


Calculate the average speed of the ball from Start point to 120cm.


Set the track inclined as shown in the diagram below. Let the ball roll along the track.
1.   In your team, choose one of your team members to place a finger at the 60cm mark to stop the
rolling ball.
2.   After stopping the ball for few seconds, remove the finger and let the ball to continue rolling
along the track.
3.   Measure and record below the total time taken for the ball to travel from the start point to
120cm mark.

 What is the average speed of the ball when it travels from the start point to 120cm mark?


Title: Ejs Open Source Multi Objects rolling down on an Inclined Plane Java Applet
Post by: lookang on June 18, 2010, 02:56:44 pm
new repurposed name
Ejs Open Source Multi Objects ( Car , Ball , Shell , Disc ) rolling down on an Inclined Plane Java Applet
i must thanks the man, Fu-Kwun Hwang for his worthy of noble prize forum for informal learning cum community of practice CoP.

Ejs Open Source Rocket Car on an Inclined Plane Java Applet is by Wolfgang Christian, Francisco Esquembre, and Mario Belloni using the Easy Java Simulations (Ejs) modeling tool, now remixed by lookang for learning purposes.
Information about Ejs is available at:
http://www.um.es/fem/Ejs/
and also from the OSP Collection on the ComPADRE Web site:
http://www.compadre.org/osp/items/detail.cfm?ID=8243
Access Rights:
    Free access
License:
    This material is released under the GNU General Public License Version 1.

My thoughts:
so after i am done remixing it, i will also release it's remixed it's source code back, there by guarantee your freedom to share and change free software--to make sure the software is "free to change" for all its users.


[ejsapplet]


Title: Re: Ejs Open Source Rocket Car on an Inclined Plane Java Applet
Post by: lookang on June 18, 2010, 03:00:12 pm
changes made with learning:

1. rename the file to car.xml because of Ejs has a character restriction, else it will not run.
2. verify the physics of rolling down a ramp
// derivation by lookang
// F + TM*g*sin(angle) -f = ma  N2L
// R*f = I*alpha  N2L circular motion
// s = R*angle  angular motion
// v = R*omega
// a = R*alpha
// therefore
// assume car = 4 wheels 2*fw and 2*rw
// F + TM*g*sin(angle) -2*Ifw/fwR*(a/fwR)- 2*Irw/rwR*(a/rwR) = TM.a
// since Ifw = 0.5*fwMass*fwR*fwR ;moment of inertia disc
// since Irw = 0.5*rwMass*rwR*rwR ;moment of inertia disc
// F + TM*g*sin(angle) = (TM+fwMass*fwR*fwR/(fwR*fwR)+rwMass*rwR*rwR/(rwR*rwR) )a
// therefore
// MI = (TM+fwMass+rwMass )
// or in general
// MI = (TM+k*TM) where k is the constant of I = k*TM*R^2
3. added slider L to control the length of ramp
4. allow the car to move beyond the range of Xinit to Lmin.
5. added angledegree
6 redesign the field to sliders, for consistent look
7 move thrust to bottom panel
8 move media player button to bottom right corner
9 autoscale true and square ==true for maximum view
10 move velocity into top panel
11 resize width = 600
12 added an axis to show the direction of down he slope as x' and y'. idea from http://www.compadre.org/osp/items/detail.cfm?ID=8242
13 made bummer y height follow the carSize for better view
14 debug the event for ODE evolution to be more precise to account for the position of the car as well for both top and bottom bummer.
zero condition
if(v>=0) return 1;                    
if(x-carSize/2>=xbumpertop) return 1;
return x+carSize/2;
action
v = Math.abs(v)*e;
15 added provision for e coefficient of restitution
24 June 2010
16 made the mass of car, mass of rear wheel and mass of front wheel variables and controllable through fixed relationship
17 added options for physics of solid ball like a marble, a shell like a football, a cylindrical disc like a coin in addition to the 4 wheel car already made for simpler experiments in lower secondary.
18 debug the event to return 0 so as to allow the simulation to not end after v =0 resting on the bottom bumper if it is placed above the lowest point, for students to explore average speeds concept as in some real life activity. read the bottom posts for help from the master of applets FKH :)
19 added new codes to _pause() only if the bottom bumper is at the lowest point
20 added graphics of football http://commons.wikimedia.org/wiki/File:Football_(soccer_ball).svg
21 resize crop into a perfect square
22 graphics of marble http://www.flickr.com/photos/cclau2003/3832161365/
23 added transparent background, crop to a perfect square using gimp http://www.gimp.org/downloads/
24 made slider to appear with the selected objects
11 July 2011
fixed bugs
mainly
// derivation by lookang
// F + TM*g*sin(angle) -f = ma    N2L
// R*f = I*alpha                N2L circular motion
// s = R*angle                angular motion
// v = R*omega
// a = R*alpha
// therefore
// assume car = 4 wheels 2*fw and 2*rw
// F + TM*g*sin(angle) -2*Ifw/fwR*(a/fwR)- 2*Irw/rwR*(a/rwR) = TM.a
// since Ifw = 0.5*fwMass*fwR*fwR ;moment of inertia disc
// since Irw = 0.5*rwMass*rwR*rwR ;moment of inertia disc
// F + TM*g*sin(angle) = (TM+fwMass*fwR*fwR/(fwR*fwR)+rwMass*rwR*rwR/(rwR*rwR) )a
// therefore
// MI = (TM+fwMass+rwMass )
// or in general
// MI = (TM+k*TM) where k is the constant of I = k*TM*R^2
fixed all the rest of the objects bug
added x graph as well
moved to the right side panel
added field and slider to all controls for finer control of values to investigate
added yellow hotspot to drag the slope up and down from http://www.compadre.org/osp/items/detail.cfm?ID=11236 Sliding Down an Inclined Plane Model written by Wolfgang Christian
check outcome of simulations runs with Sliding Down an Inclined Plane Model written by Wolfgang Christian with the box, solid ball, car
check outcome of simulations runs with Rocket Car on an Inclined Plane Model written by Wolfgang Christian, Francisco Esquembre, and Mario Belloni http://www.compadre.org/osp/items/detail.cfm?ID=8243
seems all values are similar now.
made v editable for angle = 0 case else there is no motion







done!


Title: Re: Ejs Open Source Rocket Car on an Inclined Plane Java Applet
Post by: lookang on June 18, 2010, 07:59:18 pm
This simulation uses Easy Java Simulations (Ejs) to model the problem of a rocket car on an incline plane.  When the car reaches the bottom of the incline it can be set to bounce (elastic collision) with the stop attached to the bottom of the incline.  The total mass of the car is 2.0 kg which consists of the car body (1 kg), two front wheels (0.4 kg) and two rear wheels (0.6 kg).  The front and rear wheels rotate and are uniform disks.  In the simulation you can set the incline angle (in radians), the bounce, the thrust of the car's rocket (in Newtons), and you can drag the car to its initial position.

Questions

1. Calculate the change in potential energy of the car when it reaches the bottom of the incline.  Your answer should be given in terms of the mass of the car body mB, the mass of the front and rear wheels, mF and mR, the incline angle θ, and the distance the car moves down the incline, L.
2. Calculate the velocity of the car at the bottom of the incline when subject to an arbitrary thrust, T, from its rocket.  Don't forget that the wheels of the car rotate.  Your answer should be given in terms of the variables described in Question 1 and the thrust, T.  Once you have a general form for the velocity, check your answer against the simulation.
3. Given the velocity you found in Question 2, determine the acceleration of the car subject to an arbitrary thrust, T.  Again your answer should be given in terms of the variables described in Question 1.  Once you have a general form for the acceleration, check your answer against the simulation.  Also find the thrust that yields zero acceleration of the rocket.
4. Calculate the velocity of the car at the bottom of the incline when subject to an arbitrary thrust, T, from its rocket.  Your answer should be given in terms of the variables described in Question 1 and the thrust, T and the distance the car moves down the incline, L.  Once you have a general form for the velocity, check your answer against the simulation.


Title: Re: Ejs Open Source Rocket Car on an Inclined Plane Java Applet
Post by: lookang on June 19, 2010, 08:10:25 am
Hi Ejs community,

is it possible to model a few physics laws in one Ejs model?

currently
the evolution is
dx/dt = v
dv/dt = F/m


but how can i add the motion say after hitting the bottom and the cart rotates, projectile motion, hit the ground, slides, friction , and kinematics............. like a game physics engine?

watch the time 9 to 13 sec for this clip


was introduced to this clip by a sg researcher who is advancing argmented reality


Title: Re: Ejs Open Source Rocket Car on an Inclined Plane Java Applet
Post by: Fu-Kwun Hwang on June 19, 2010, 08:34:46 am
Change the evolution equations to
Code:
dx/dt = v;
dv/dt =calF(x,v)/m;

Then, define a function to return correct force for different (x,v) values.
If you need to take care for short time event, e.g. collision , then you can use event in EJS.

What is left is your physics model to model the case you want. ;)


Title: Re: Ejs Open Source Rocket Car on an Inclined Plane Java Applet
Post by: lookang on June 19, 2010, 09:41:34 am

wow. that's good, any chance to point to a sample for further understanding? u do have one in this forum already? it doesn't need to have everything, just enough stuff that i can continue to learn from and further the physics and added features.  ;D



i see the editor now, it is at the bottom, u need to create a way to go back to html.?
the edtor looks great! where can i get it ? i also can add to my own http://sgeducation.co.nr LOL......


Title: Re: Ejs Open Source Rocket Car on an Inclined Plane Java Applet
Post by: Fu-Kwun Hwang on June 19, 2010, 10:33:51 am
You can check out  Static friction/ sliding friction (http://www.phy.ntnu.edu.tw/ntnujava/index.php?topic=727.0) as an example.

For the Fckeditor: You can find the original html message if you click the first image at the top line.
However, spellcheck/preview will not be able to get updated content when fckeditor is activated. (Need to modify code to join this two tools.)

*** I just modified the code, the original button turn into "update", You need to click update before you click preview/spellcheck to get latest content from fckeditor.
The fckeditor mode is only available for user who has posted at least 10 message. I did not want it to be available for new user (to avoid message posted by program).

Fckeditor is available at http://sourceforge.net/projects/fckeditor/
Download it and following the instruction from INSTALL.html

P.S. I add javascript code in Theme/default/Post.template.php


Title: Re: Ejs Open Source Rocket Car on an Inclined Plane Java Applet
Post by: lookang on June 22, 2010, 09:32:58 am
You can check out  Static friction/ sliding friction (http://www.phy.ntnu.edu.tw/ntnujava/index.php?topic=727.0) as an example.
hi prof, is there a version of getay without the array i.
i think i like this applet and i want to adapt the getay to make the same behavior for the car on slope that i am working on.
do u have a version of a similar applet without array i, i am having problem with the array
thanks!

Question:
how should i do it correctly?
for example in Evolution
is dv/dt = getax()
I then defined in custom
getax

public double getax () {

if(x+carSize/2>xbumperbottom) return 0; // if x beyond the bummer, make acceleration = 0 right?
else
 return (TM*g/MI*Math.sin(angle)+thrust/MI);
}


but the car doesn't take the getax into the dv/dt.
how should the syntax be correctly used?
attached is my latest working file

For the Fckeditor: You can find the original html message if you click the first image at the top line.
However, spellcheck/preview will not be able to get updated content when fckeditor is activated. (Need to modify code to join this two tools.)
*** I just modified the code, the original button turn into "update", You need to click update before you click preview/spellcheck to get latest content from fckeditor.
The fckeditor mode is only available for user who has posted at least 10 message. I did not want it to be available for new user (to avoid message posted by program).
Fckeditor is available at http://sourceforge.net/projects/fckeditor/
Download it and following the instruction from INSTALL.html
P.S. I add javascript code in Theme/default/Post.template.php
thanks, until next time. SMF PHP is beyond me for now. ;D


Title: Re: Ejs Open Source Rocket Car on an Inclined Plane Java Applet
Post by: Fu-Kwun Hwang on June 22, 2010, 10:28:40 am
You did not set up the correct initial condition.

Initially, your v=0, and x+carSize/2=-0.9  , xbumperbottom=0

so if(x+carSize/2>xbumperbottom) return 0;
is always satisfied. so acceleration is always zero and velocity is never changed (stay zero).

The computer does what you want it to do.

The above code will not stop car move to the right of xbumperbottom.
It only stop the car from accelerating, it will keep move with constant velocity if the car have some finite velocity.

Think about the physics when you model it! EJS is a physics modeling tool! ;)


Title: Re: Ejs Open Source Rocket Car on an Inclined Plane Java Applet
Post by: lookang on June 22, 2010, 01:42:00 pm
Hi prof, how about this?


public double getax (double dx,double v) {
 
//dx = x+carSize/2-xbumperbottom;
//if(!stopped&&Math.abs(dx)>0)
if(Math.abs(dx)>0)
{
return (TM*g/MI*Math.sin(angle)+thrust/MI); // not stopped and dx >0 return the force on the car
}
else
{
  stopped=true;
  dx =0;
  v =0;
  }
return 1;
}

it is not working. what should i change.
 ;D


Title: Re: Ejs Open Source Rocket Car on an Inclined Plane Java Applet
Post by: Fu-Kwun Hwang on June 22, 2010, 04:20:30 pm
I am sorry, the problem is not due to the getax function.
It is correct. You do not need to modify it.

The problem is sue to the way you wrote event condition:

Code:
if (v>0) return x+carSize/2-xbumperbottom; // bounced at x=xmax
 else if(v<0)return x-carSize/2-xbumpertop; // bounced at x=xmin or x+carSize/2
should be changed to

Code:
if (v>0) return xbumperbottom-(x+carSize/2); // bounced at x=xmax
 else if(v<0)return xbumpertop-(x-carSize/2); // bounced at x=xmin or x+carSize/2

Event occurred only when return value is less than zero.

I also add the following code to pause the simulation.
Code:
if((x+carSize/2)>xbumperbottom+1.e-3){

  x=xbumperbottom-carSize/2;
  v=0;
  _pause();
}

The if condition in getax can be removed,too!
Please check out modified version.


By the way:
You can move
Code:
Lmin = -L;
xbumpertop = -L;
to on release event for slider which corresponds to L.

And
Code:
angledeg=angle*180/Math.PI;
to on release event for slider which corresponds to angledegree.


Title: Re: Ejs Open Source Rocket Car on an Inclined Plane Java Applet
Post by: lookang on June 22, 2010, 10:13:17 pm
thx! will study your method and continuing working on your version!
it will be a multi-option applet!


Title: Re: Ejs Open Source Multi Objects rolling down on an Inclined Plane Java Applet
Post by: lookang on June 24, 2010, 09:47:04 pm
Can anyone check is this applet loading in web deployment?
don't not seems to be loading on my end  ??? ???


Title: Re: Ejs Open Source Multi Objects rolling down on an Inclined Plane Java Applet
Post by: Fu-Kwun Hwang on June 24, 2010, 10:48:34 pm
I waited for a long time, however, it is still in loading state.  :(

Make sure you can open the html file under the output subdirectory in ejs_workspace..

If you can open html file locally, then, I will need to check my server code.
otherwise, you need to check your ejs code.


Title: Re: Ejs Open Source Multi Objects rolling down on an Inclined Plane Java Applet
Post by: lookang on June 24, 2010, 11:15:06 pm
it does not load in local web mode will slowly remove stuff to debug. thanks!
it is the second applet that cannot be web deploy, he first is my collision cart applet when the velocity slider are closest==true, once cloeset ==false, that applet can web deploy.

will investigate and report  ;D


Title: Re: Ejs Open Source Multi Objects rolling down on an Inclined Plane Java Applet
Post by: Fu-Kwun Hwang on June 25, 2010, 12:36:18 pm
I do not know why, it works fine when I re-compile your code and upload it again.
Please check out the following uploaded applet.
[eye]
[ejsapplet]
[/eye]
from lookang
eye this applet because it is missing the png, will re web at the top post!
thanks!


Title: Re: Ejs Open Source Multi Objects rolling down on an Inclined Plane Java Applet
Post by: lookang on June 25, 2010, 12:54:16 pm
strange. are u using EJS_4.2.7_100314 ?

i was using EJS_4.3.0_100613 to deploy, is that the problem of the web deploy?
i used EJS_4.2.7_100314 to compile car5 also can work in web deploy.
interesting, not sure why?
this car5 version has all the slider closest==false


Title: Re: Ejs Open Source Multi Objects rolling down on an Inclined Plane Java Applet
Post by: Fu-Kwun Hwang on June 25, 2010, 01:57:15 pm
Yes. It was re-compiled with EJS4.2!


Title: Re: Ejs Open Source Multi Objects rolling down on an Inclined Plane Java Applet
Post by: lookang on June 25, 2010, 02:18:27 pm
i just changed all sliders with tickers to closest==true and it does not web deploy again.
arrghh.



Title: Re: Ejs Open Source Ball Rolling down a Straight Ramp Java Applet
Post by: lookang on July 03, 2010, 08:06:52 pm
Thanks that will make the sound more playable.
Yes i have looked at soundsnap but it is nothing there either, thanks anyway.
Here is the HQ sound that is copyrighted
post back if you have a similar sound or if you can change it so it wont be recognisable for those who have made the sound   .


Rolling_Hard.wav.zip
what are you talking about? this applet has no sound ;D


Title: Re: Ejs Open Source Ball Rolling down a Straight Ramp Java Applet
Post by: ahmedelshfie on July 04, 2010, 12:55:24 am
I think he mean that you should insert sounds in applet  ;D


Title: Re: Ejs Open Source Ball Rolling down a Straight Ramp Java Applet
Post by: lookang on July 04, 2010, 06:54:40 am
I think he mean that you should insert sounds in applet  ;D
i like your idea too. will add soonest.
but this hectorloshuk is spamming on other boards too. i don't think hectorloshuk is giving related feedback.


Title: Re: Ejs Open Source Ball Rolling down a Straight Ramp Java Applet
Post by: Fu-Kwun Hwang on July 04, 2010, 09:41:09 am
Yes. I believe those messages posted by "hectorloshuk" are done by some program.
Because the message was post in less than 30 seconds after the same topic was accessed.
I am going to block this account for all.


Title: Re: Ejs Open Source Ball Rolling down a Straight Ramp Java Applet
Post by: ahmedelshfie on July 04, 2010, 09:42:57 am
Quote
i like your idea too. will add soonest.
but this hectorloshuk is spamming on other boards too. i don't think hectorloshuk is giving related feedback.
I agree with you about this hectorloshuk I'm report  prof Hwang about this user


Title: Ejs Open Source Multi Objects (Car,Ball,Shell,Disc) rolling down inclined plane
Post by: lookang on June 11, 2011, 09:37:19 pm
renamed
Ejs Open Source Multi Objects (Car,Ball,Shell,Disc) rolling down inclined plane
to reflect the power and flexibility of the simulation.

11 July 2011
fixed bugs
mainly
// derivation by lookang
// F + TM*g*sin(angle) -f = ma    N2L
// R*f = I*alpha                N2L circular motion
// s = R*angle                angular motion
// v = R*omega
// a = R*alpha
// therefore
// assume car = 4 wheels 2*fw and 2*rw
// F + TM*g*sin(angle) -2*Ifw/fwR*(a/fwR)- 2*Irw/rwR*(a/rwR) = TM.a
// since Ifw = 0.5*fwMass*fwR*fwR ;moment of inertia disc
// since Irw = 0.5*rwMass*rwR*rwR ;moment of inertia disc
// F + TM*g*sin(angle) = (TM+fwMass*fwR*fwR/(fwR*fwR)+rwMass*rwR*rwR/(rwR*rwR) )a
// therefore
// MI = (TM+fwMass+rwMass )
// or in general
// MI = (TM+k*TM) where k is the constant of I = k*TM*R^2
fixed all the rest of the objects bug
added x graph as well
moved to the right side panel
added field and slider to all controls for finer control of values to investigate
added yellow hotspot to drag the slope up and down from http://www.compadre.org/osp/items/detail.cfm?ID=11236 Sliding Down an Inclined Plane Model written by Wolfgang Christian
check outcome of simulations runs with Sliding Down an Inclined Plane Model written by Wolfgang Christian with the box, solid ball, car
check outcome of simulations runs with Rocket Car on an Inclined Plane Model written by Wolfgang Christian, Francisco Esquembre, and Mario Belloni http://www.compadre.org/osp/items/detail.cfm?ID=8243
seems all values are similar now.
made v editable for angle = 0 case else there is no motion


enjoy!


Title: Re: Ejs Open Source Multi Objects (Car,Ball,Shell,Disc) rolling down inclined plane
Post by: lookang on November 17, 2011, 01:38:41 pm
Question:
A ball is released at the top of a shallow slope and allowed to roll down. If it takes exactly 2 seconds to get to the bottom.


Where will the ball will be at the mid-time of its motion, after exactly 1 second?

Work it out using pen and paper
and try it out on the simulation to test whether the computer model is accurate :)

enjoy!



Title: Re: Ejs Open Source Multi Objects (Car,Ball,Shell,Disc) rolling down inclined plane
Post by: Gaven on December 16, 2011, 01:23:15 am
It is simple that when the ball will move to the upwards to downward than it takes two seconds and after the one second the ball will be in the middle of the slope.the computer shows the right direction of the ball.


Title: Re: Ejs Open Source Multi Objects (Car,Ball,Shell,Disc) rolling down inclined plane
Post by: Gaven on December 17, 2011, 08:30:03 pm
It is simple that when the ball will move to the upwards to downward than it takes two seconds and after the one second the ball will be in the middle of the slope.the computer shows the right direction of the ball.

 
Any comments?