Simple 2D black hole simulator

It's a library that makes it easier to design graphical interface and also has some other neat features.
 
It's a library that makes it easier to design graphical interface and also has some other neat features.

Cheers :cheers: BTW this could keep me entertained for hours:thumbup:

picture.php
 
Last edited:
I finished the Qt version, it has many more options :)

Screenshot:
black_hole.png


Download:
http://dl.dropbox.com/u/7065759/Black Hole/Black Hole 2.exe

Important: if you don't have Qt, you will also need the Qt dll's:
http://dl.dropbox.com/u/7065759/Black Hole/qt_dlls.zip (5.1 MB)
Just put them in the simulator's folder.

New features:
  • You can move and zoom the view. LMB+mouse moves the view, RMB+mouse zooms.
  • You can stop and resume the simulation.
  • You can choose whether the simulation should run in the on-board time, or the observer-at-infinity time.
  • You can change the black hole's mass.
  • You can edit ship's position and velocity while simulation is stopped in both polar and cartesian coordinate systems, whichever you find more convenient.
  • You can change the amount of thrust applied when keys are pressed using the thrust slider.
  • Pressing W/S/A/D applies the amount of thrust set on the slider until you release the key. Shift-W/S/A/D increases thrust by 2*slider per second, releasing shift causes thrust to drop to 0 again.
  • R/T decreases/increases time warp by factor 2.

Also, if you are wondering what units this is in - everything is in c=G=1 and time is in seconds, which means that:
  • Mass = 1 corresponds to about [math]4 \times 10^{35} \; kg[/math], which is about 200000 solar masses.
  • Velocity = 1 corresponds to c.
  • Distance = 1 corresponds to 1 light-second, or 300000 km.
  • Thrust = 1 corresponds to ship's acceleration of c per second (or [math]3 \times 10^8 \; \frac{m}{s^2}[/math], or about 30 million Gs) - yes, I know nobody could survive that, but it wouldn't be fun to wait a year for a visible change in velocity ;)

Have fun :)

EDIT:
I forgot to write - I found a funny orbit by accident yesterday. Use this initial parameters to see it:
Mass = 0.1
R = 1.0
Phi = 0.0
VR = 0.0
VPhi = 0.3023716
It's really surprising ;)
 
Last edited:
Thanks a lot. :cheers:

Re: This special orbit is not surprising, it's a fixed point. You know, existence theorems are nice when you read them, but actually seeing a fixed point in a complex system is priceless.
 


Trying to fall into the black hole with on-board time can have some very interesting results. Watching it do it is even weirder.
 
Haha, yeah, I should probably add something that automatically stops the simulation when you cross the horizon, because the calculations stop being valid there - hence what happened on the screenshot :D
 
That thing sucked me in, I was getting annoyed, so I thought I'd switch to board time, thinking that perhaps it will make easier to me to appreciate the orbit of the ship. It sucked me in anyway... and then I was like :WTF:

:rofl:
 
That thing sucked me in, I was getting annoyed, so I thought I'd switch to board time, thinking that perhaps it will make easier to me to appreciate the orbit of the ship. It sucked me in anyway... and then I was like :WTF:

:rofl:
Yeah, I had a similar feeling about that :lol:

I've uploaded a new version which stops simulation automatically when you fall below the horizon, it's available at the same link.
 
This is fun to fly :thumbup: I still can't lower my orbit a lot, but I guess I'll just practice.

A reset button could be useful though.
 
Hmm, did you do that after falling on the horizon or something like that? Because then some data in the memory might have been wrong. Try entering those numbers after resetting the simulator.
 
Haha, yeah, I should probably add something that automatically stops the simulation when you cross the horizon, because the calculations stop being valid there - hence what happened on the screenshot :D

They shouldn't... The laws of physics are valid within the horizon until you get fairly close to the singularity. It could have something to do with the frame of reference you're using (you get a switch between the time axis and one of the space axes as you cross the horizon), or it could be that things are being calculated correctly but your step size is getting too large (it eventually will as you get closer to the singularity).
 
They shouldn't... The laws of physics are valid within the horizon until you get fairly close to the singularity. It could have something to do with the frame of reference you're using (you get a switch between the time axis and one of the space axes as you cross the horizon), or it could be that things are being calculated correctly but your step size is getting too large (it eventually will as you get closer to the singularity).
I know, it's just the coordinate system problem. One number in the metric tensor goes to infinity at the horizon in the standard coordinates. It would be possible to introduce better coordinates and extend the simulation to within the horizon, but since you can't escape from there anyway and the math would be more complicated, I decided to leave that for another time :p
 
Say, given that it uses Qt, would a Linux compile be possible? Or is it steeped in Windowsisms? (If not, it doesn't matter too much, as it does work in Wine).
 
Yup, it's possible. Since I don't have Linux at the moment, and I noticed that binaries compiled on one distribution tend not to work on the others, you would have to compile it yourself. I can post sources if you want.
 
Yup, it's possible. Since I don't have Linux at the moment, and I noticed that binaries compiled on one distribution tend not to work on the others, you would have to compile it yourself. I can post sources if you want.

I've never found that. Sometimes you'll have library difficulties, or 64 bit / 32 bit difficulties, but in general binaries compiled under one distribution should work on another.

You not having a Linux system to compile on is a bigger problem. :)

But yes, if you could post the sources I could try compiling them, though if they call any Windows-specific code or otherwise generate compile errors under gcc I can't say I'm a good enough coder to correct any such problems.
 
Back
Top