The Open Source Physics website will be unavailable Friday evening through Saturday afternoon as electrical work occurs in the American Center of Physics server room. Down time will begin at 6PM Eastern Time on Friday. Service is expected to resume by 6PM on Saturday, July 30.

Education Prize Logo
Science SPORE Prize
November 2011

NSF Logo
The Open Source Physics Project is supported by NSF DUE-0442581.

Modeling Tips & Help post and replies

Return to the Modeling Tips & Help thread
Login to post to this thread

Iterating with ODE solving - Oct 18, 2012 at 5:28PM
Ioannis Vourkas
4 Posts

Hi again,

I am writing to ask if you have any recommendation regarding, how one might manage to use a specific ODE for multiple types of systems whose functionality is described in part by the same ODE.

i.e. In case of having a mesh grid of nodes, where at each node the same ODE applies, though the current values of the state variables are different. Thus, instead of defining as many ODEs as the nodes, should I iterate and step the solver for each node or is there any other possible way to do it?

A student of mine recently defined as state variable a cell of a table, e.g. as follows: d(w[i]) / dt
and thinks that the solver tries to iterate within all cells of table w[] ...

Is this some kind of a bug or is it really what it does in case of having such a state variable declaration?

Thanks in advance!

Replies to Iterating with ODE solving

Re: Iterating with ODE solving - Oct 18 2012 5:41PM
Francisco Esquembre
207 Posts


The ODE editor of EJS can very well handle differential equations where one or more of the states are on-dimensional double arrays.

Hence, what your student did is perfectly correct.

In your case, define state arrays where each entry is the state of a given node in th grid, and define the corrresponding ODE. It will work.

As an example, see how array states are used to solve the motion of several balls in a box in the model at


Re: Re: Iterating with ODE solving - Oct 18 2012 5:53PM
103 Posts

The chain of coupled oscillators is another model that solved an array of ODEs.

The OSP Network:
Open Source Physics - Tracker - EJS Modeling
Physlet Physics
Physlet Quantum Physics