Black Hole Simulator

in #utopian-io7 years ago (edited)

Black Hole Simulator

The program simulates spaceflight in the vicinity of a black hole. The motion is calculated in accordance with General Relativity. Apart from that, light bending and Doppler effect are also being simulated (more details below).

You can see a screenshot from the program below.

image.png

A short manual:

Controls:

  • W/S/A/D - spaceship rotation
  • Q/E - rotation around forwards-backwards axis
  • Y/H/G/J - accelerate forwards/backwards/left/right
  • Z/X - zoom
  • R/T - time warp
  • P - toggle Doppler effect

Interface:

  • Time warp - current time warp factor
  • Time at infinity - time passed since the beginning of the simulation infinitely far from the black hole
  • v - the velocity of the spaceship as a fraction of the speed of light
  • R - the distance from the black hole in Schwarzschild radii (R = 1 Rs - the event horizon)
  • Blue cross - the true direction to the black hole (due to some relativistic effects, the black hole sometimes looks as if it was somewhere else than it really is)
  • Green cross in a circle - the direction of movement of the ship
  • Green cross - the direction opposite to the direction of movement

Theoretical description

"Ok, the program is nice, but what am I actually looking at?" - if you ask yourself this question, read below.

What are black holes?

The black holes are objects with mass so concentrated, that it is inside the region in which the escape velocity exceeds the speed of light.
Ok, so what is it all about?
The escape velocity is the speed necessary in order to leave the surface of a body and fly to infinity. Let's imagine that we throw a ball upwards. The ball flies up to some altitude, until Earth's gravity overpowers it and drags it back down. The stronger we throw the ball, the longer it takes for gravity to turn it around and the higher it can go. There is a minimal speed, that when exceeded will cause the gravity to be unable to turn the ball around and it will fly away - that's the escape velocity. For Earth it is about 11 km/s, for a black hole it exceeds the speed of light - 300 000 km/s.

Theoretically you can make any object into a black hole. You just have to compress it until it is small enough. The problem is, the lighter an object, the more you have to compress it. The Earth would have to be squeezed into a ball the size of a few millimeters, for the Sun about 3 kilometers would be sufficient. Because of this, black holes are only created when very massive stars collapse, since only then the matter can be compressed enough. (It is possible that they are also created in high-energy collisions of subatomic particles, but it is not confirmed yet.)

As we already said, the escape velocity from the inside of the black hole exceeds the speed of light. But the farther away you are from an object, the less speed you need to escape, and so there exists a place, where the escape velocity is exactly the speed of light - that is the event horizon. Nothing escapes from below the event horizon - because nothing can move faster than the speed of light. Not even light can escape, that is why black holes are called "black" (though they are not necessarily black - real black holes are usually surrounded by very hot, and thus very brightly shining matter, and additionally some theories suggest, that black holes themselves should emit the so-called Hawking radiation).

The effects related to black holes

The gravitational field as strong as this near a black hole causes all sorts of interesting effects.

Light bending

The most visible effect is light bending. Light rays travelling near a black hole are deflected from their original course. If they come really close, they can even get turned around or go in circles for a while, before they depart again. This causes a distinctive image distortion. The most obvious part of it is a ring, which appears around a black hole. It is caused by the light rays emitted from a point behind a black hole being deflected independently on the side of the black hole, on which they try to pass it. If they go in the right distance, they will be deflected by exactly the amount needed for them to reach the eyes of the observer. He will then have the impression, that they reach him from a circle around the black hole.

Time dilation

It is often said, that gravitation is the curvature of space-time - and it is right. Space-time is curved especially much near a black hole. This causes time to flow a lot slower near the event horizon, than far from the black hole. If an astronaut near a black hole dropped a clock on it, he would see it slow down more and more as it approaches the event horizon, until it stops completely. If a second astronaut was falling with the clock, he would see nothing out of the ordinary - the clock would still run normally. He wouldn't even be able to say at which point he crossed the horizon (and he would cross it, although his colleague on the spaceship wouldn't be able to see it!). On the other hand, he would see the clocks on the spaceship go faster and faster.

Time dilation can be observed in the program thanks to the "Time at infinity" gauge. It shows how much time has passed infinitely far from the black hole. The closer the ship is to the black hole and the faster it moves, the faster the time at infinity flows.

Gravitational red-/blueshift

This phenomenon is tightly related to the time dilation. The light is a wave - oscillating electromagnetic field. Its color is nothing more than the frequency of those oscillations - greater frequencies are violet and blue, lower - orange and red; in the middle there is green and yellow. Above violet is ultraviolet (UV), invisible to humans, and farther X-rays and gamma rays. Below red there are infrared (IR), microwaves and radio waves.

Let's imagine our falling astronaut shines a blue laser in the direction of the spaceship. The astronaut on the spaceship sees the clock of the falling one going slower - but it's caused by the time itself flowing slower! This means that oscillations of the electromagnetic field had to slow down, too, so the frequency of the light reaching the spaceship dropped. So, the light that was blue in the beginning reaches the observer as green, red or even infrared, depending on the difference in time flow between the emitter and the observer - it will be shifted towards the red end of the spectrum, or redshifted. In the same way, if the astronaut on the spaceship shines a red laser to the falling colleague, he will receive it as green, blue, violet or even ultraviolet - blueshifted.

This effect causes the background to be slightly purple when program starts - the stars are farther away from the black hole than us, so the light from them reaches us blueshifted.

Other relativistic effects

Apart from the effects related to the presence of a black hole, you can also see some cause only by the simulation being run by the rules of relativity.

The Doppler effect

The Doppler effect changes the color of the light, like gravitational redshift/blueshift. It has nothing to do with gravity though, only with the relative velocity of the observer with respect to the source. When the observer goes away from the source, the light is redshifted, if he comes closer, it is blueshifted. You can see this while flying in the program - the objects in front become bluer, and behind you - redder.

The Doppler effect concerns not only light, but all kinds of waves (for example, sound waves). In the case of other waves though it depends on the velocities of the source and the observer with respect to the medium. Light has no such medium and only the relative velocity of the observer and the source counts.

Relativistic aberration

This effect can be seen in the program as the apparent shrinking of the objects towards which the observer is moving and growing of those in the opposite direction.

Its mechanism is very similar to the one that causes drops of rain to appear to be coming from the front of a moving car, instead of from above. Because the drops move vertically relative to the ground, and the car moves horizontally, the relative velocity of the drops and the car is slightly from the front. The same happens to the light - if a ray comes from the side, but the observers travels with a large speed forwards, the relative velocity of the ray and the observer gets shifted to the front and makes the impression that the ray came from the front. This way the image gets "squeezed" in the front and "streched" behind, causing changes in apparent sizes of objects.

You can download the code on GitHub or a binary from my blog.

Proof Of Work

Since this was posted on Utopian, I am required to prove my ownership of the GitHub account, as my username there is different to the one here.

Here is a screenshot of me logged in as fizyk20:

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA512

Additionally, I claim that I am also @ebvalaim on keybase.io, which is proved to be the same as @fizyk20 on GitHub by this gist:
-----BEGIN PGP SIGNATURE-----
Version: Keybase OpenPGP v2.0.76
Comment: https://keybase.io/crypto

wsFcBAABCgAGBQJaDSiTAAoJEGgvju7n5ktH9rIP/2jIgzVrnahFzoDqgdCh3U9m
e6tDpvgfOF5WfdOwxRxaf2uBAM5PnMV3Kq21wZweFAk671NcjUlWgK9jDHz2XP1Q
hlSfL8wLR3Swb9ELP4MPO1NvE6KqCmmivIYu/1OEHmEcbpdRv/ZkNJqJQeOM+u49
7alGPJpY7IeI68vJDQStDgmTNPJZisKp4Nd5zsxPa0zY1JPseRf8p/r8kg6QRGLM
J3Qyk+JSXp5kdJrj/XjqozmzVfhEumuhkAC5LNboWtZVMSCoZhdyguvW1RNm86Bc
xHBQZsHOAmkK/xKaeOpLicSml4oeZc3z2V4do98TkI0a+NfchBOnYKTgPy5DnBZi
OmdwbITiq933eZqT3PNTZr2o3J+GcRjmoN88pZLQRxoUoa3A/yIdXwAk7vtdHICQ
Pu1w1zq8naA48IAqF7s5CsDSYtaUxJAmNjWrqqQiHvY5Ys6LTwcSUI443Z5LZ6DI
ipsTjkXi5tE0gNN8nvcWs7QvBs7HiVh9WVwzgY2FWN/BN6zV7e7W3WJWKR0p3zEo
9lDATBCJzfwIPux/ChaJVAAkjSsQBYippyudT+l+M3xybLrhE8pQcTSmvtj/1fy7
rh/OZehJ6Jj7abPeOphCJDsxJBrBq5QQ9a3ULkTYjLwQk2w4r5Xzsj4NTkGfTql3
/oVqi5lrYaZlAJAG8dIW
=+fic
-----END PGP SIGNATURE-----



Posted on Utopian.io - Rewarding Open Source Contributors

Sort:  

Hey @ebvalaim I am @utopian-io. I have just super-voted you at 18% Power!

Suggestions https://utopian.io/rules

  • Utopian has detected 1 bot votes. I am the only bot you should love!!

Achievements

  • I am a bot...I love developers... <3
  • Much more informative than others in this category. Good job!
  • You have less than 500 followers. Just gave you a gift ;)
  • You just got more votes than your total number of followers. Rock Star!
    Up-vote this comment to grow my power and help Open Source contributions like this one. Want to chat? Join me on Discord https://discord.gg/Pc8HG9x

Thank you for the contribution. It has been approved.

You can contact us on Discord.
[utopian-moderator]

Your contribution can't be approved yet. See the Utopian rules. Please edit your post to apply for approval. You can edit your post here.

  • Your steemit account name does not match the github one. Please provide proof of work.

edit screen

You can contact us on Discord.
[utopian-moderator]