[The Wave Function Model shows a wave function u(x,t) which varies in space and time.]

Week 2 Notes: Time Dependence

In order to study the relation between EJS and Java, we build time dependent function plotters. We describe common data types and we explore various user interface elements and show how to control their appearance. Finally, we show how to use a parser to input functions and how to access methods in EJS Objects.

Third model: Wave Function

The Wave Function Model combines the Dependent Plot and the Time Dependent Function modes in order to evaluate and display a function u(x,t) that varies in space and time.  The model uses x and y-arrays to store the wave function values at np points. The y-array is recomputed at every time step in the fixed relations workpanel.

double dx = (xmax-xmin)/np;                     // sample interval
double xLocal=xmin;                             // initial position                 
for(int i=0; i<np; i++) {                       // loop to create new data
  x[i] = xLocal;                                // store x in array
  y[i] = _view.waveFunction.evaluate(xLocal,t); // evaluate wave function and store
  xLocal += dx;                                 // increment position
}

The time variable t is a global variable that is incremented in the Evolution workpanel and the fixed relation is evaluated after the evolution step.

 

Note the different actions in the reset button and the reset time button.  The reset button invokes the predefined _reset() method to restore the default wave function and the default x-minimum and x-maximum values.  The reset time button sets t=0 but does not affect the other model parameters. The allows users to re-run the time evolution after making changes to the input fields.  

Related Models

The following EJS models demonstrate how to plot time dependent functions in EJS.  These models are listed in order of complexity.

Credits:

The Wave Function Plot Model was created by Wolfgang Christian using the Easy Java Simulations (EJS) version 4.1 authoring and modeling tool.  You can examine and modify a compiled EJS model if you run the model (double click on the model's jar file), right-click within a plot, and select "Open Ejs Model" from the pop-up menu.  You must, of course, have EJS installed on your computer.

 

Information about Ejs is available at: <http://www.um.es/fem/Ejs/> and in the OSP ComPADRE collection <http://www.compadre.org/OSP/>.