Given N particles, P1 ... PN with positions X1 ... XN in 3-D space, the force on particle Pi due to particle Pj is:
Fij = G * Mi * Mj * ((Xj - Xi)/Rij^3).
Fij = - Fjiso that the number of force calculations per pair of particles is (N squared - N)/2.
The particles are represented by a 7 x NN array, p, with initial masses and positions and space for calculating the force.
p 1 Particle number i --> NN +-------------------------------------+ p(MM,:) | | mass p(PX,:) | | x dim of position p(PY,:) | | y dim of position p(PZ,:) | | z dim of position p(FX,:) | | x dim of force p(FY,:) | | y dim of force p(FZ,:) | | z dim of force +-------------------------------------+ All particle arrays are allocated up to NN, the variable npts is the actual number of particles used. Other arrays: q (0:6,0:NN-1) - holds a copy of particle information to assist in calculating symmetric forces dx,dy,dz (0:NN-1) - difference between positions of two particles dist,sq,fac (0:NN-1) - distance,distance squared between 2 particles, and the factor of multiplication tx,ty,tz (0:NN-1) - force calculated between 2 particles The programs initialize p with the mass and positions of npts particles and result in forces calculated in p.