Numerical calculations are grand. Of course, they are just another form of normal calculations - like I have said before. So, I have mostly used [VPython](http://vpython.org) for my calculations on my posts. But there is a new game in town: [Easy Java Simulations](http://www.um.es/fem/Ejs/). What is the difference between these two? Which is better for students? Which is better for me? What are their strengths? What other questions are there? What other questions are there?
**VPython**
Let me start with [VPython](httP://vpython.org) since I am more familiar with that. VPython is python with a visual module. This module includes the following:
- Creation of a 3-D object space. The visual module takes care of the creation of a separate window for your 3-d objects. The user can zoom and rotate the view.
- 3-D objects. There are several objects in the module that you can create like the sphere, box, cylinder, arrow. To create a sphere you could do: ball = sphere(pos=(1,0,0), radius=0.3, color=color.red). You get the idea.
- Vector operations. There is a class of vectors. The cross product and magnitude functions for vectors are also included.
- Graphing capabilities.
- Some user interface things such as mouse interactions with the 3-d space.
**Advantages of VPython**
- It's python (and python is awesome).
- Runs on Windows, Linux, Mac OS X
- Completely transparent - in that it only does what you tell it to do and you have control over the physics.
- It is a programming language, so you can do loops and if then stuff.
**Disadvantages of VPython**
- Users must have python and the visual modules installed to run the programs
- No way to embed stuff in a webpage
- If users are afraid of programming, they may get scared.
Now what about EJS:
**What is Easy Java Simulations (EJS)**
EJS is itself a Java program. It creates an environment where the user can create java simulations (easily). Here are some of the features:
- Both 2-D and 3-D workspace creations
- Graphing
- Creations of pre-defined objects.
- Creation of user interactions like text boxes and stuff.
- Built in data analysis stuff on graphs.
- Export to stand alone .jar file OR exportable to web applet.
- Animations can be exported to gif.
So how does EJS compare to vpython? Personally, I feel more comfortable with vpython - perhaps that is because I am more experienced with it. EJS has some stuff that I am not sure how it works. Vpython does all the stuff that python does (and I have a good python book).
The one huge advantage of EJS is that it can export stuff to put in a webpage and share with others. They do not need to install EJS, they just need to have java installed (which they probably do). The file size of the exported applets was a little bigger than I wanted, but this is because it includes lots of stuff in it.
Students may have an easier time with EJS. One thing it does is to have a "differential equation" tab. This allows users to designate variables and the relationships between these variables. The user can then choose what method EJS should use to solve these equations and it does it.
Not sure which I will use in class. Maybe I need to be more familiar with EJS.
- Log in to post comments
Re: not being able to export to gif in vpython: There are some pretty easy ways to capture a certain section of screen to video on a mac (thinking specifically of snapz pro). You could toss the videos on Vimeo and then embed them on your posts. Not as easy as animated gifs, but not exactly hard either.
A new version of vpython will be released soon. There will be new textures for object surfaces (like wood texture), things can be made transparent, and things can give off light locally, as opposed to the one-side-is-lit-from-afar way things are currently represented in vpython. cool stuff! It would be better if you COULD embed in a web page, and people could click and manipulate things, but right now all I need is my computer with vpython and a projector to show my classes cool stuff.
I've used vpython for a mechanics course in university. I think maybe the most important advantage it has against other "easyer" systems is that students will have to program. In my experience they were a bit afraid at the begining but python is so easy and with visual they got amazing 3D animations instanty that they soon started to program their own simulations (in fact, the really first simulations they did were small games).
About exporting as animated gifs, I use imagemagick's import command to take a screenshot of each frame. For easily capturing just one window I need to know it's id, so I read it through xprop.
I also use date to name each image and keep them in order.
* In a file named id.sh I have:
xprop | grep 'window id' | grep 'COLORMAP' | cut -d \# -f 2 | tr -d ' '
* In my .py, after creating the scene window:
id=string.rstrip(os.popen("sh id.sh").readlines()[0])
* When this command is read, the mouse cursor will ask me for clicking on the window I want to capture, and it's id will be saved as "id".
* Then, each frame will be captured as (folder "tmp" should exist):
os.popen("import -window "+id+" tmp/$(date +'%s%N').png")
* Let the script run and after finished, use imagemagick or the gimp to generate the animation:
1. With imagemagick, in tmp folder:
convert -delay 0.04 -loop 1 *.png output.gif
2. With gimp, you can simply open the first one and then "open as layers" all the others. Save as gif, and follow the steps for an animated one (really easy). You can also apply some filters for optimization.
And that's all folks!
Here're a pair of examples of a vibrating string.
http://nuc5.fis.ucm.es/viajeras.gif
http://nuc5.fis.ucm.es/fourier.gif
Another important EJS feature is its ability to connect to EJS models stored in digital libraries. The Open Source Physics DL, for example, contains hundreds of EJS models.
http://www.compadre.org/OSP/
EJS models within the DL can be downloaded from the DL directly into the EJS workspace using a button on the EJS DL toolbar.
The new release of EJS, which will have a beta before the end of this year (2009) will have a new implementation of 3D elements based on Java 3D. This will have faster and more polished visualization and will support textures and loaders for VRML models that the program can manipulate as a physical object. The first tests are very, very nice. See an example at: http://www.um.es/fem/EjsWiki/index.php/Main/ExamplesEarthAndMoon3D
So have u started using ejs yet?
http://weelookang.blogspot.com/ has many simulations made in ejs and the community using ejs is growing and strong :)
The best part is the open source codes are usually shared for anyone to learn from.
I think ejs is awesome!