The simulation programs described in this report are all working on parameter files with exactly the same layout, so all predefined problems can be directly run with each of the supplied programs. The parameter file is used to specify a number of particles with their initial speeds, positions and masses, the size of the timestep and the number of iterations without retyping them every time a simulation is run.
The layout of a parameterfile is as follows :
line 1 | Total number of particles in simulation |
line 2 | Number of iterations between 2 screen updates |
line 3 | Timestep between 2 iterations |
line 4 | Total number of iterations |
line 5 | Position (x,y,z) , Speed (x,y,z) and Mass of particle 1 |
line 6 | Position (x,y,z) , Speed (x,y,z) and Mass of particle 2 |
.... | etc. |
All parameter files I used were based on scaling factors I introduced a few years ago for an exercise in the Parallel Computation Practice. But sometimes it can be necessary to scale the coordinates for a certain problem to different dimensions - for instance with a scalefactor ' f ' - without changing the problem topologically.
I found this wasn't as easy as it looked at first glance : not only the position, but also the velocity and/or mass have to be scaled to obtain the same (although scaled) picture. For that reason I give a brief overview hereafter : both as a reminder for myself and possibly for others as well.
What is the crucial thing to conserve the topology ? Simply that the ratio between kinetic and potential energy remains exactly the same ! That leaves us with 2 possiblities :
We know that Epot = [(-g·ma·mb)/r] should remain invariant. But the distance transforms according to r2 = f·r1 , so the only way to keep Epot constant is to scale all masses using the relation m2 = Öf·m1 . What effect has this on Ekin ? The mass is scaled with Öf , so v2 should scale with [1/(Öf)] to compensate for this, and thus we find v2 = f-[1/4]·v1 .
To have them altogether in one table (including the timestep scalefactor) :
| (1) |
Now suppose we want to scale the energy with the same scale factor f as we used to scale the relative positions. To achieve that, we can scale all masses with f as well: This yields us Epot2 = f·Epot1 as one factor for mass cancels out. But this immediately results in Ekin2 = f·Ekin1 without doing anything with the velocity ! Again in one table :
| (2) |
So, obviously the easiest transformation is to scale both the mass, the timestep and the positions with the same scalefactor, and to keep the velocity at its original value.