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

Easy Java Simulations (2001- ) => Simulations from other web sites => Topic started by: ahmedelshfie on June 11, 2010, 11:42:50 pm



Title: Simple Examples for beginner who want to learn EJS
Post by: ahmedelshfie on June 11, 2010, 11:42:50 pm
This following applet Vertical Spring
Created by prof Hwang Modified by Ahmed
Original project Vertical Spring (http://www.phy.ntnu.edu.tw/ntnujava/index.php?topic=383.0)
This is an applet related to a spring subject to gravitation force.

Click[eye][ejsapplet][/eye] to view/hide applet.


Title: Re: Simple Examples for beginner who want to learn EJS
Post by: ahmedelshfie on June 11, 2010, 11:56:10 pm
This following applet is Mathematic function F(x), F(y) plot
Created by prof Hwang Modified by Ahmed
Original project Mathematic function F(x), F(y) plot (http://www.phy.ntnu.edu.tw/ntnujava/index.php?topic=805.0)

You can change different mathematic function for x or y coordinate, i.e. Fx(t), Fy(t)
This simulation will plot it for you.
For example: if you enter fx(t)=A*sin(w1*t), fy(t)=B*cos(w2*t)
It will draw Lissajous pattern for you.
The default setting is for someone who want to study variation of Lissajous pattern due to some other noise C*sin(w2*t).


Click [eye][ejsapplet][/eye] to view/hide simulation!


Title: Re: Simple Examples for beginner who want to learn EJS
Post by: ahmedelshfie on June 12, 2010, 12:14:05 am
This following applet is Projectile motion
Created by prof Hwang Modified by Ahmed
Original project projectile motion (http://www.phy.ntnu.edu.tw/ntnujava/index.php?topic=382.0)

This is a simple example for projectile motion. Change the velocity and click play to see the trace.

Click [eye][ejsapplet][/eye] to view/hide simulation!


Title: Re: Simple Examples for beginner who want to learn EJS
Post by: ahmedelshfie on June 12, 2010, 12:27:47 am
This following is Air density/pressure and temperature vs altitude
Created by prof Hwang Modified by Ahmed
Original project Air density/pressure and temperature vs altitude (http://www.phy.ntnu.edu.tw/ntnujava/index.php?topic=1439.0)

This simulation display how air density, air pressure and temperature vary with altitude.
$h=44.3308 - 4.94654 P^{0.190263}$ where h = geopotential altitude (km), p=actual air pressure, Pascals
However, pressure is convert to atm (1 atm= 101325 Pa).

$h=44.3308 -42.2665 D^{0.234969}$ were used to calculate density from altitude h (km). The unit for density D is $kg/m^3$

The temperature is estimated with $T(h)= 15- 6.5 *h$

You can drag the dot shown in the curve to change the altitude h (or drag the slider vertically up/down)

Click [eye][ejsapplet][/eye] to view/hide simulation!


Title: Re: Simple Examples for beginner who want to learn EJS
Post by: ahmedelshfie on June 12, 2010, 12:41:40 am
This following applet is illustrate 10 base/ 2 base and 16 base Number
Created by prof Hwang Modified by Ahmed
Original project Another GUI example: illustrate 10 base/ 2 base and 16 base Number (http://www.phy.ntnu.edu.tw/ntnujava/index.php?topic=1065.0)

The following example show a random generated number (from 0-999) with 10 base, 2 base and 16base display.

Click [eye][ejsapplet][/eye] to view/hide simulation!


Title: Re: Simple Examples for beginner who want to learn EJS
Post by: ahmedelshfie on June 12, 2010, 01:05:00 am
This following applet is Link EJS GUI properties to model variables (image:width/height/angle)
Created by prof Hwang Modified by Ahmed
Original project Link EJS GUI properties to model variables (image:width/height/angle) (http://www.phy.ntnu.edu.tw/ntnujava/index.php?topic=1064.0)

This applet demostrate how to use image in EJS.
Width/Height and angle of rotation for the image can be set easily.

Click [eye][ejsapplet][/eye] to view/hide simulation!


Title: Re: Simple Examples for beginner who want to learn EJS
Post by: ahmedelshfie on June 12, 2010, 01:16:17 am
This following applet is Linear Equation a*x+b*y=c
Created by prof Hwang Modified by Ahmed
Original project Linear Equation a*x+b*y=c (http://www.phy.ntnu.edu.tw/ntnujava/index.php?topic=1046.0)

This applet illustrate the meaning of a*x+b*y=c
You can drag sliders to change a,b,c and find out how the line changes!

This example also show you how to assign properties for GUI elements if you are interested in building simulation with EJS.

Click [eye][ejsapplet][/eye] to view/hide simulation!


Title: Re: Simple Examples for beginner who want to learn EJS
Post by: ahmedelshfie on June 12, 2010, 01:28:04 am
This following applet is A bouncing ball (learn how to create event to habdle bouncing condition in EJS)
Created by prof Hwang Modified by Ahmed
Original project A bouncing ball (learn how to create event to habdle bouncing condition in EJS (http://www.phy.ntnu.edu.tw/ntnujava/index.php?topic=437.0)

A ball bouncing back on the ground under gravitation force.
This example shows you how to use event in EJS to take care of the bounding conditiion.
(Check out event on evolution page under Model tab)

Click [eye][ejsapplet][/eye] to view/hide simulation!


Title: Re: Simple Examples for beginner who want to learn EJS
Post by: ahmedelshfie on June 12, 2010, 01:40:57 am
This following applet is A simple wave (moving concentric circles)
Created by prof Hwang Modified by Ahmed
Original project A simple wave (moving concentric circles) (http://www.phy.ntnu.edu.tw/ntnujava/index.php?topic=441.0)

Fond out how easy to create concentric circles with EJS.
Please click "load ejs as signed applet". You will need to give permission for browser to load ejs.
And you will find out how this applet was created with EJS.
You can modify it and generate new simulation,too!

Click [eye][ejsapplet][/eye] to view/hide simulation!


Title: Re: Simple Examples for beginner who want to learn EJS
Post by: ahmedelshfie on June 12, 2010, 01:50:45 am
This following applet is collision between twp particles in one dimension(along a line)
Created by prof Hwang Modified by Ahmed
Original project collision between twp particles in one dimension(along a line) (http://www.phy.ntnu.edu.tw/ntnujava/index.php?topic=548.0)

This is a simple model created with EJS.
The mass for two particles are the same initially.
Use mouse to drag the slider to change the velocity for one of the particle.
You will find the velocity exchanged when collision occurred.
Then, drag the slider to modify the mass for the particles, the situation getting complicated.
However, the momentum is always conserved.

Click [eye][ejsapplet][/eye] to view/hide simulation!


Title: Re: Simple Examples for beginner who want to learn EJS
Post by: ahmedelshfie on June 14, 2010, 06:36:45 pm
This following applet is RotationalPendulum
Created by prof Hwang Modified by Ahmed
Original project RotationalPendulum (http://www.phy.ntnu.edu.tw/ntnujava/index.php?topic=1824.0)

This applet illustrate how to use 3D GUI elements: 3D  Rotational Pendulum

Click [eye][ejsapplet][/eye] to view/hide simulation!


Title: Re: Simple Examples for beginner who want to learn EJS
Post by: ahmedelshfie on June 14, 2010, 06:53:18 pm
This following applet is How to combine simulation with a quicktime movie file
Created by prof Hwnag Modified by Ahmed
Original project How to combine simulation with a quicktime movie file (http://www.phy.ntnu.edu.tw/ntnujava/index.php?topic=1807.0)

The following is an examples to include a quicktime movie in the simulation.
User is asked to adjust the parameter so that the simulation can re-product the same period of pendulum motion as the background movie.

P.S. This applet need to be signed to be able to view correctly (due to restriction in quicktime movie).
Please download it and run it as an application (and it will be fine).

Click [eye][ejsapplet][/eye] to view/hide simulation!


Title: Re: Simple Examples for beginner who want to learn EJS
Post by: ahmedelshfie on June 14, 2010, 07:07:21 pm
This following applet is Fall and Rebound
Created by prof Hwang Modified by Ahmed
Original project Fall and Rebound (http://www.phy.ntnu.edu.tw/ntnujava/index.php?topic=1814.0)

Fall and Rebound
How do we simulate a (free) falling object?
Well, the answer, in principle, is rather simple: just solve the equation y'' = -g, where g is gravity.
And this works, perfectly well... except when the object reaches the ground. Then, we would expect the object to rebound.
When rebounding, the object changes instantly its velocity from downwards (negative) to upwards (positive). If the rebounding is perfectly elastic, then the object's velocity remains constant in modulus.
But, how would you implement this in a simulation?
This example shows two possible approaches to solve this problem.
The first one uses the closed form solution of the equations for the movement. It is fast, clean and efficient. But implies that we know the solution. In other, more complicated situations, we might not be able to solve these equations. For instance, if there is an external variable force applied to the falling object.
The second approach implies fine-tuning the way we solve numerically the second order differential equation at every moment. When the object comes closer to the ground, we ask the method to use a smaller time step. This provides a more accurate computation of the velocity the object had when reaching the ground.
The disadvantage is that the simulation seems to run slower at the critical moment. We try to compensate this, by asking Ejs to run faster!
Author : Francisco Esquembre

 From an original idea from Taiwan Workshop on Ejs Date : March 2002

Click [eye][ejsapplet][/eye] to view/hide simulation!


Title: Re: Simple Examples for beginner who want to learn EJS
Post by: ahmedelshfie on June 15, 2010, 06:55:05 pm
Predators  and preys
The historical introduction to the problem of predator and preys can be found in the other example with a similar name (which you should see first). In that example, the classical approach of Lotka and Volterra was introduced.
In this simulation, we will try to really simulate how predators and preys coexist in a reduced piece of land. We need to describe how preys reproduce and feed predators (so to say), and how predators reproduce accordingly. To make it a bit more realistic, both, predators and pres move in each evolution step, and it is only if they meet that a predator can find its lunch!
The goal is to be able to produce a setting in which both species coexist with their respective population showing a (more or less) stable alternating behaviour.

There are plenty of activities that can be done here. Although you are presented with three slighty different solutions for this problem which give reasonable results, perhaps the most interesting activity is to clear the corresponding evolution pages and ask your students to provide their own specification for what the mutual interaction of these two species should be. This can be presented to your students as a kind of team competition game. The team which produces a more stable final solution wins!
 
1. Even if you give them the solution included in the example, you can ask them to find appropriate values for the parameters. It took me a lot of time to get to find the ones I include here. If you look closer at them, they look more parameters for an infection than parameters for tigers and rabbits. There is a reason for this. Simple models (like Lotka-Volterra) are suitable for simple situations only.
2. Try to improve the haunting scheme (make it more intelligent, let predators smell food from longer distances,...) and see if you can improve the result.
3. Implement a reservoir of preys, where predators can not get in and see if you can improve the result.  

Click [eye][ejsapplet][/eye] to view/hide simulation!


Title: Re: Simple Examples for beginner who want to learn EJS
Post by: ahmedelshfie on June 18, 2010, 06:46:43 pm
Earth  and Moon
This is a simulation of a reduced two-body problem.
I have used data for the Earth and the Moon just to make it more attractive . The rotation is simulated using animated gifs. However, in slow machines, this can unnecesarily waste some computer resources. Hence, if the simulation behaves strangely, substitute the animated gifs for the static ones you will find in the data directory.
The difficult part is certainly to set up initial conditions so that the elliptical orbit has a period that approximates the real one of the Moon around the Earth. As an exercise for your students, delete the initialConditions initialization page and ask your students to reproduce it!

Author : Francisco Esquembre
Original project Earth and Moon  (http://www.phy.ntnu.edu.tw/ntnujava/index.php?topic=1812.0)

Click [eye][ejsapplet][/eye] to view/hide simulation!


Title: Re: Simple Examples for beginner who want to learn EJS
Post by: ahmedelshfie on September 20, 2010, 05:56:37 pm
This applet is Particles 3D Design by Francisco Esquembre.
Particles 3D:
This is a simulation of a set of particles moving freely inside a 3D cube and colliding with a moveable floor.
The state it is now, the example is just a show-off of the 3D capabilities of Ejs, but... can you think of an application to gas dynamics?  

Click [eye]
[ejsapplet]
[/eye] to view/hide applet!