Making a pretty n-body simulation

In summary: Thanks for the suggestion!In summary, BOAS suggested blender, newjerseyrunner is looking for a games engine, and I think it would be possible to just plot all particles as hard points and apply a Gaussian blur.
  • #1
jimbo007
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!
 
Technology news on Phys.org
  • #2
jimbo007 said:
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
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
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
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
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
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
Blender is awesome and can really let you do some cool things.
 

1. What is an n-body simulation?

An n-body simulation is a computerized model that represents the motion and interactions of a system of particles. These particles can be celestial bodies, such as stars and planets, or subatomic particles, such as atoms and molecules. The simulation uses mathematical equations to calculate the forces and movements of each particle, allowing scientists to study the behavior of complex systems.

2. How do you create a visually appealing n-body simulation?

To create a visually appealing n-body simulation, you will need to use advanced computer graphics techniques and algorithms to render the movements and interactions of the particles. This may include techniques such as particle systems, shading, and lighting effects. Additionally, careful attention must be paid to the accuracy and realism of the simulation's physics and movements to make it visually engaging.

3. What are some challenges in making an n-body simulation?

There are several challenges in making an n-body simulation, including accurately representing the complex interactions between particles, determining initial conditions and parameters, and optimizing the simulation for efficient computation. Additionally, creating a visually appealing simulation while maintaining accuracy can also be a challenge.

4. How can n-body simulations be used in scientific research?

N-body simulations have a wide range of applications in scientific research, including astrophysics, molecular dynamics, and fluid dynamics. They can be used to study the behavior and evolution of systems over time, test theories and hypotheses, and make predictions about real-world systems. N-body simulations are also useful in simulating and understanding complex phenomena that cannot be observed or replicated in a laboratory setting.

5. What are some resources for learning how to make n-body simulations?

There are many resources available for learning how to make n-body simulations, including online tutorials, books, and courses. Some popular programming languages for creating n-body simulations include C++, Java, and Python. Additionally, there are open-source software libraries and tools specifically designed for creating n-body simulations, such as N-Body Shop and GADGET.

Similar threads

  • Programming and Computer Science
Replies
19
Views
2K
  • Programming and Computer Science
Replies
10
Views
3K
  • Programming and Computer Science
Replies
3
Views
4K
  • Programming and Computer Science
Replies
4
Views
4K
Replies
6
Views
708
  • Programming and Computer Science
Replies
7
Views
2K
  • Advanced Physics Homework Help
Replies
1
Views
1K
  • Programming and Computer Science
Replies
1
Views
987
  • Programming and Computer Science
Replies
9
Views
2K
  • Programming and Computer Science
Replies
14
Views
3K
Back
Top