Making a pretty n-body simulation

  • #1
41
2
nbody1.png
nbody2.png
Hi all,
I have recently created an nbody simulation in Vpython for a few thousand particles where each particle is about 4000 times the mass of our Sun. Vpython is doing exactly what I want it to do the only problem being the output is extremely low quality (black spheres on a white background). I was seeking help on how to jazz up the output so it looks something like in the above 2 screenshots.

Things I have: location of each particle at each point in time
Things I want: fog + lighting of particles and able to take care of relative particle sizes like Vpython
Extra thing I want: be able to scroll around the animation to look at it from different angles (Vpython does this automatically for me)

Thanks in advance!
 

Answers and Replies

  • #2
555
19
View attachment 96366 View attachment 96367 Hi all,
I have recently created an nbody simulation in Vpython for a few thousand particles where each particle is about 4000 times the mass of our Sun. Vpython is doing exactly what I want it to do the only problem being the output is extremely low quality (black spheres on a white background). I was seeking help on how to jazz up the output so it looks something like in the above 2 screenshots.

Things I have: location of each particle at each point in time
Things I want: fog + lighting of particles and able to take care of relative particle sizes like Vpython
Extra thing I want: be able to scroll around the animation to look at it from different angles (Vpython does this automatically for me)

Thanks in advance!
You could look into using an open source games engine such as blender.

I worked on an astronomy visualisation project and that is what we used. Though I was working on Web scraping, so can't give you much more info than that.

I think it would meet your needs though.
 
  • #3
41
2
Great thanks BOAS I did have a brief 5 second look at blender so it's good to hear your endorsement for it. I will focus my attention on blender now
 
  • #4
1,524
624
I don't know anything about vpython, but does it have OpenGL bindings? This would be fairly easy to do in OpenGL.
 
  • Like
Likes Silicon Waffle
  • #5
41
2
Hi newjerseyrunner,

I did see something mentioned about OpenGL but don't know enough about it to answer your question. I'm currently exploring the blender suggestion.

Thanks
 
  • #6
Ibix
Science Advisor
Insights Author
2020 Award
7,298
6,373
Depending on your hardware and required frame rate you might be able to get away with just plotting all your stara as hard points (rather than circles) in whatever colour and intensity and applying a Gaussian blur. Check out the Python Imaging Library (PIL or its fork, Pillow) which provides Gaussian blurs in its ImageFilter module.
 
  • #7
41
2
Lots of good suggestions thanks everyone. I will get around to all 3 suggestions eventually but looks like blender will keep me occupied for a while
 
  • #8
1,524
624
Blender is awesome and can really let you do some cool things.
 

Related Threads on Making a pretty n-body simulation

Replies
4
Views
3K
Replies
3
Views
3K
  • Last Post
Replies
4
Views
9K
Replies
3
Views
657
Replies
3
Views
6K
Replies
2
Views
8K
  • Last Post
Replies
9
Views
1K
Replies
6
Views
781
Replies
6
Views
677
Top