Monday, May 24, 2010

[from Josh] x,y,z n-body simulation

EDIT: Here is the link to a better video with better resolution.



This is my 2d or 3d n body simulation with opemMP running parallel for loops (can run several 1000 particles fine on my CPU). I made the simulation in C/C++ and the visuals with openGL. From my interface you can orbit the system using your left mouse button, rotate the axes with the right mouse button, and zoom in and out with the +/- keys. You can also change colour of each particle. Pressing 'r' is supposed to give a color based on particle position (malfunctioning ATM), 'v' for velocity, 'n' for static distribution (to help track particles). In the video it starts off with 'n' and then goes to 'v'.

Using lower G values causes the particles to fly away to quickly and by zooming out you can see just out far the orbit can be with 100.

The particles appear to behave properly and a continued simulation results in sub systems forming and then orbiting each other. It is quite neat to see actually and if I remember I will run one for a few hours with 1000+ particles and take a picture to show you what happens.

I identified a point of possible error for everyone else's simulations. It depends on how you set your code up but in mine I had to be careful when calculating the forces not to use the updated position coords until each particle had been updated.

I have started porting it over to CUDA C. It shouldn't be too hard.

Josh,

No comments:

Post a Comment