Simple 2D black hole simulator

Linguofreak

Well-known member
Joined
May 10, 2008
Messages
5,046
Reaction score
1,284
Points
188
Location
Dallas, TX
OK.

It took figuring out qmake-qt4, but I now have a native binary.

After several attempts that didn't work I figured out that I needed to do:
Code:
qmake-qt4 -project

Then edit the resulting *.pro file to add the line QT += opengl

then
Code:
qmake-qt4
make

A zip of the resulting binary is attached.

EDIT: Corrections made to build instructions
 

Attachments

  • Black Hole Sim.zip
    36.6 KB · Views: 6
Last edited:

Fizyk

Member
Joined
Jun 20, 2008
Messages
285
Reaction score
1
Points
18
Location
Warsaw
Website
ebvalaim.net
After a long fight with maths and the code, here comes the third version of the program!
black_hole_3.png

Download: http://dl.dropbox.com/u/7065759/Black Hole/Black Hole 3.exe
(Required Qt libraries still at the same link: http://dl.dropbox.com/u/7065759/Black Hole/qt_dlls.zip)
New features:
  • Rotating black holes. You can now set the angular momentum of the black hole and see what strange effects it can cause (like frame dragging, you can see it in the screenshot). The angular momentum can't be greater than the mass.
  • You can fall below the horizon. The inside of the black hole is now simulated too (though you can't do much once you've fallen inside... :p). Things go a bit crazy below the horizon, so if you want to fall there, I recommend slowing time a bit to make the simulation more precise (time warp is controlled by R/T, like in Orbiter).
  • Changed controls - unfortunately, the new ones might be less convenient, but there was no other way. Now you can see which direction your ship is facing and W/S/A/D work relative to that direction. You can also use U/O to rotate the ship (I chose those keys so I have I/J/K/L ready for the other two rotations once I go 3D ;) ). Known bug: Sometimes left and right get switched. Sorry, defining directions like left/right in 4D (all of the math is actually 4D) is kinda hard :p For now just reset the simulation if you get this problem, it should help.
  • Proper velocity does not show. Not a feature, I'll try to restore it, but it isn't obvious how to do that.

I think those are all the major changes. I hope you like the new version of the simulator :) Have fun :)
 
Last edited:

Wishbone

Clueless developer
Addon Developer
Joined
Sep 12, 2010
Messages
2,421
Reaction score
1
Points
0
Location
Moscow
Have run it, very entertaining. Currently, if a NaN/inf crops ups anywhere, you can't get rid of it. Re-initialisation does not help to reset everything to normal. My suspicion is the text controls edit event handlers, which are not turned off during reset, and hence perpetuate the NaNs.
 

Fizyk

Member
Joined
Jun 20, 2008
Messages
285
Reaction score
1
Points
18
Location
Warsaw
Website
ebvalaim.net
Thanks :)

Wishbone said:
Currently, if a NaN/inf crops ups anywhere, you can't get rid of it. Re-initialisation does not help to reset everything to normal.
Huh, I didn't get any NaN which wouldn't be reverted by a reset for a long time. It still has problems sometimes due to timesteps being too big (they are as small as possible), but a reset helps in 99% of the cases.

Anyway, I modified the program a bit more:
http://dl.dropbox.com/u/7065759/Black Hole/Black Hole 3.exe
Sources for a Linux compile: http://dl.dropbox.com/u/7065759/Black Hole/Black Hole 3.src.zip

Changes:
  • You can choose to track the ship using a checkbox in the bottom right corner. The view will be then centered on the ship instead of wherever you moved it.
  • Ship is now rotating a bit faster when using U/O.
  • Proper velocity is being calculated again.

Also, I thought I could describe some relativistic effects to check out:
  • "Interstellar travel" ;) When using on-board time, you can travel arbitrarily far in a short time. Just accelerate to a velocity like 0.999999 and see your distance from the black hole grow amazingly fast. I called it "interstellar travel" because this effect would allow for it.
    Note: actually, the distance as measured from the ship wouldn't grow faster than c. You should interpret the distance shown as the one you would see after braking.
  • A kind of precession when orbiting. Even when you leave the ship completely free, it is still rotating a bit. That's not a mistake, it's an effect of the curvature of spacetime. After you make a full circle around the black hole, you will be facing a different direction than at the beginning.
  • Transformation of directions. When you go really, really fast you will find it almost impossible to face a direction different than forwards or backwards. Simply put, it's the Lorentz contraction causing that. If you want to accelerate and then brake - don't rotate during the flight, or it will be much harder (try rotating at a huge velocity and then braking to 0 - you'll see why ;) ).
  • Frame dragging, mentioned before. Ship near the black hole is forced to orbit it in the direction the black hole is rotating. It gets really extreme at the horizon, where you get dragged around the black hole theoretically infinitely many times (that's what an outside observer would see, for the falling observer it would be less drastic, but the scene is displayed in the "outside" coordinates).
  • No stable orbits below r=3M (that's for Schwarzschild, or a non-rotating black hole; for Kerr, or a rotating black hole, it would be a bit different). Don't try to enter one closer to the center, it's impossible ;) You can theoretically orbit a black hole at a lower altitude though, but you would need constant outward thrust for that.

There are probably more effects that could be mentioned, but I don't recall any at the moment. Have a nice experimenting with relativistic physics ;)
 
Last edited:

Linguofreak

Well-known member
Joined
May 10, 2008
Messages
5,046
Reaction score
1,284
Points
188
Location
Dallas, TX
Attached is a 64-bit Linux executable compiled from the latest sources. Build instructions are the same as before (although there was a mistake in the previous build instructions that I corrected).
 

Attachments

  • Black Hole 3 Linux 64_bit.zip
    53.1 KB · Views: 3

HarvesteR

Member
Joined
Apr 22, 2008
Messages
386
Reaction score
15
Points
18
Cant wait to try this when i get home!!!

I could never really get my head around relativistic physics... But, if a picture is worth a thousand words, and a movie is worth a thousand pictures, an interactive app should be the next order of magnitude then ;)

Cheers
 

HarvesteR

Member
Joined
Apr 22, 2008
Messages
386
Reaction score
15
Points
18
Indeed. Lol never thought of it that way :lol:...
Apparently the picture/movie relationship is one to every 1/24 * 1000 (41 seconds) :hmm::rofl:
Well, that's for cinema at least... A mp4 video is usually 30 fps, which would make it even shorter ;)

Cheers
 
Last edited:

Keatah

Active member
Joined
Apr 14, 2008
Messages
2,218
Reaction score
2
Points
38
I got a "..failed to start because MINGWM10.DLL was not found.." error when I tried to run this on xp sp2

---------- Post added at 01:35 AM ---------- Previous post was at 01:33 AM ----------

uhm never mind
 

roboticmehdi

New member
Joined
Aug 13, 2009
Messages
1
Reaction score
0
Points
1
Hello. What method did you use to approximate the orbit? euler, runge kutta or maybe something else ?
 

Firby

New member
Joined
Mar 20, 2011
Messages
9
Reaction score
0
Points
0
Hey niccee! it would be good if you make it in orbiter 3D... ;)
 

Fizyk

Member
Joined
Jun 20, 2008
Messages
285
Reaction score
1
Points
18
Location
Warsaw
Website
ebvalaim.net
Do you mean as an addon for Orbiter, or 3D like Orbiter?

I don't think it's possible to make this an addon for Orbiter (though if it was, it would be awesome), and I'm working on making this 3D, but I want it to be realistic 3D, and that won't be easy.
 

Fizyk

Member
Joined
Jun 20, 2008
Messages
285
Reaction score
1
Points
18
Location
Warsaw
Website
ebvalaim.net
Bump ;)

I finally managed to make a kind-of-3D, kind-of-raytraced version of the simulator. Screenshot:
screenshot.png


You can get it here:
Windows: http://dl.dropbox.com/u/7065759/Black Hole/BHS-win32.zip
Linux: http://dl.dropbox.com/u/7065759/Black Hole/BHS-linux-x64.zip

Why kind-of-3D? Well, it is actually 3D, but there are no objects that would let you feel the depth. The black hole itself looks the same from every direction.

Why kind-of-raytraced? I figured that raytracing it in real time would be too slow (I'm not as good at this as Artlav is ;) ), so I only used raytracing to prepare an array of angular deflections of rays emitted in different directions from different points. The arrays are then used by the shader to determine the color of the pixel it is rendering. This method isn't perfect, so there are artifacts in the rendered image, but they don't destroy everything ;) I might try to fix this in the future.

I also attempted to simulate the Doppler effect. It turned out quite nicely, though large amounts of green are a bit disturbing. I will try to find a way to model it more accurately.

Controls:
W/S/A/D/Q/E - rotate view (Q/E being for roll)
Y/H - burn forwards/backwards
G/J - burn left/right
R/T - time warp
Space - Pause/Resume (the program is paused right after launching)
Shift - holding makes movement controls more responsive

A few more notes:
For now you have to rely on visual clues during the flight. I've only included one "instrument" - the "R = ..." text in the lower right corner. It displays your distance from the black hole in Schwarzschild radii (Rs). R = 1.5 Rs is the photon sphere, or the place where theoretically light would be able to enter a circular orbit around the black hole (although such orbits are unstable). R = 1 Rs is the event horizon, point of no return. If you just fall freely towards the black hole, you probably won't even notice it. (There are some weird effects when passing the photon sphere, but they are just artifacts of the rendering method I mentioned earlier.)

Besides the artifacts, there are a few another limitations. For example, the image will go crazy when you are very far from the black hole. Also, when you fall inside with time warp > 1, the calculations might go crazy when you reach the singularity. Other than that, it should work quite nicely.

Fun thing to try: fall into the black hole with small tangential velocity (you start with 0 velocity) while looking to the side. Slow down time when close to the center. The image will become quite interesting ;)

Hope you like it :)
 
Last edited:

Donamy

Addon Developer
Addon Developer
Donator
Beta Tester
Joined
Oct 16, 2007
Messages
6,935
Reaction score
245
Points
138
Location
Cape
Good thing they didn't have this in the sixties. :lol:
 

Linguofreak

Well-known member
Joined
May 10, 2008
Messages
5,046
Reaction score
1,284
Points
188
Location
Dallas, TX
I also attempted to simulate the Doppler effect. It turned out quite nicely, though large amounts of green are a bit disturbing. I will try to find a way to model it more accurately.

You can't really accurately do Doppler with an RGB image. You'd need actual spectral data.

---------- Post added 04-12-12 at 02:47 ---------- Previous post was 04-11-12 at 23:39 ----------

I like it a bunch.

I would like more situational awareness info, though. Only knowing my distance from the black hole and what info I can gain visually makes navigation rather difficult, especially in terms of setting up any kind of orbit. It would be nice to have a velocity mangitude indication, plus HUD markers for the velocity vector, the point opposite the velocity vector, and the circle of points at 90 degrees to the velocity vector, as well as the true direction to the black hole (necessary because the aberration of light skews the observed direction to the hole if you have any significant tangential velocity), and the points at 90 and 180 degrees to it.

What would be really sweet, but maybe a bit more work, would be to include an effective potential graph like in the right panel of the applet here. That would make it really easy to judge your orbital situation (whether you are bound for the singularity, in a stable orbit (and if so, how close to circular), or on an escape trajectory).

Also, it would be nice to have the rotational controls be independent of time warp and pausing. As it is, it can be hard to get a good look around as you cross the event horizon, as everything happens so fast.
 
Top