Data Tool allows users to view, manipulate, and analyze data after it
has been generated within EJS.
An Introduction to Computer Simulation Methods
Chapter 2 Examples: Creating Simulations
We introduce Java and EJS in the context of simulating the motion of falling particles near the
Earth's surface using common Java syntax and EJS user interface elements. A simple algorithm for solving first-order differential equations numerically
also is discussed.
The following EJS models are described in Chapter 2 of the EJS adaptation of An Introduction to Computer Simulation Methods.
- Euler Method The Euler Method model introduces students to first-order differential equations using a ready-to-run implementation of
Euler's algorithm. The user enters a differential equation dy/dx=f(x), the initial value y0, and the step size Δt. The
simulation displays the solution in a table with columns showing the solution step counter n, the independent variable x, and the solution y. The numerical
solution $y$ is an approximation of the true solution because of approximations inherent in Euler's algorithm.
- Euler Falling Ball The Euler Falling Ball model is a simple example designed to teach Java syntax. The simulation does not have a user
interface and prints its output in the EJS console. Although the model has only eleven lines of computer code, EJS builds a complete Java program, compiles
the program, and runs the program when the the taskbar's run button is pressed. This model shows (1) how to write Java statements and using various types of
variables, (2) that numerical errors accumulate rapidly when using Euler's method, and (3) that computer arithmetic is not exact.
- Euler Fall Ball Visualization The Euler Falling Ball Visualization model adds a graphical user interface to the Euler Falling Ball model.
This Euler Falling Ball Visualization model shows (1) how to display moving objects how to display data, (2) how to start, stop, and reset a simulation, and
(3) how to input data to a simulation.
- Euler Fall Ball Analysis The Euler Falling Ball Analysis model introduces the Data Tool to analyze Euler's numerical method solution of the
fall particle model.
- Bouncing Balls The Bouncing Ball model shows the motion of fifty non-interacting balls bouncing within a 2D box. This model introduces
array syntax and shows how arrays are used to position objects within the view. The position arrays x[50] and x[50] are connected (bound) to the X- and
Y-Position properties of a Shape Set and the elements of this set automatically adjust their location as the values of the array elements evolve within the
model. Because each array elements is bound to its respective shape, users can drag the shape to set array values.
Download
An Introduction to Computer Simulation Methods examples are distributed as a ready-to-run (compiled) Java archive. Double clicking the
csm_ch02.jar file will run the chapter 2 examples if Java is installed. You can examine and modify the model for
these examples if you have EJS installed by right-clicking within the program and selecting "Open Ejs Model" from the pop-up menu.