I am learning J and writing a program in this language to simulate a physical 
phenomenon of interactions between atoms (each atom is described by 
coordinates, velocities, forces, etc.). I am wondering how to store data in 
such a simulation.

The simulation involves applying a function that performs a single simulation 
step several times:

do_step^:42 initial_data

Simulation step consists of several substeps. Which storage option is better or 
is there other way than the ones listed below?

1) Data stored in public nouns (one noun is a matrix of coordinates of atoms, 
another noun is a matrix of velocities of atoms, etc.). Then do_step calls 
substep functions that overwrites these public nouns:

do_step =: monad define
    velocities =: forces update_velocities velocities
    positions =: velocities update_positions positions
    ...
)

2) Data stored in an array of boxes (in the first box an array of coordinates 
of atoms, in the second box an array of velocities of atoms, etc.). Then 
do_step is the composition of all substep functions and each substep function 
is a monad that creates modified array of boxes using m} :

do_step =: monad : 'do_substep_k ... do_substep_2 do_substep_1 y'

Martin
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to