APS Excellence in Physics Education Award
November 2019

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
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 -
Francisco Esquembre
228 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 http://www.compadre.org/osp/items/detail.cfm?ID=8307


Re: Re: Iterating with ODE solving -
146 Posts

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


OSP Projects:
Open Source Physics - EJS Modeling
Physlet Physics
Physlet Quantum Physics
STP Book