Visualization of Black Holes and Gravitational Lensing Using Python and Plotly
We embark on a cosmic adventure, revealing the secrets of the universe through two captivating projects: The Marvel of Black Hole Visualization and The Dance of Light: Gravitational Lensing. These captivating endeavours, powered by cutting-edge technology, transport us to the heart of celestial wonders. Join us on a cosmic adventure as we investigate the enigmatic allure of black holes and the spellbinding artistry of light-bending.
Part 1: The Magnificence of Black Hole Visualization
Prepare to be captivated as we explore the amazing world of black holes. This journey goes beyond theory, inviting you to observe the unseen forces at work:
1. Abyssal Journey: We embark on an adventure to better understand the complexities of black holes. Learn about concepts like the event horizon and accretion disks, which will serve as the foundation for our investigation.
2. Visual Splendor Unveiled: We reveal the heart of our project through stunning visuals. We illuminate the awe-inspiring spectacle of black holes in all their mysterious grandeur through masterful visualizations.
3. Unveiling Cosmic Paintbrushes: Our cosmic canvas comes to life with its vivid hues and skillfully crafted inscriptions. In order to give our creations depth, we use a palette of radiant browns and grayscale to guide us through the cosmic landscape.
4. Beyond Imagination: Although the journey starts here, real realism demands the use of tools like VTK to produce accurate representations. Get ready for a look at the incredible complexity of the universe.
import plotly.graph_objects as go
import numpy as np
Create a sphere for the black hole
u = np.linspace(0, 2 * np.pi, 100)
v = np.linspace(0, np.pi, 100)
x = 0.5 * np.outer(np.cos(u), np.sin(v))
y = 0.5 * np.outer(np.sin(u), np.sin(v))
z = 0.5 * np.outer(np.ones(np.size(u)), np.cos(v))
black_hole = go.Surface (x =x, y=y, z=z, showscale=False, opacity = 0.9, color scale = greys)
Create a disk for the accretion disk
u = np.linspace(0, 2 * np.pi, 100)
v = np.linspace (0, 0.3, 100)
x = 1.2 * np.outer(np.cos(u), np.ones(np.size(v)))
y = 1.2 * np.outer(np.sin(u), np.ones(np.size(v)))
z = np.outer(np.ones(np.size(u)), v)
accretion_disk = go.Surface (x =x, y=y, z=z, showscale=False, opacity = 0.5, color scale = YlOrBr)
Add labels
labels = [
dict(text='Point of Singularity', x=0, y=0, z=0, showarrow=True, arrowhead=1, font=dict(color='white')),
dict(text='Accretion Disk', x=0, y=0, z=0.4, showarrow=True, arrowhead=2, font=dict(color='black'))
]
layout = go.Layout(scene=dict(
xaxis=dict(showgrid=False, visible=False),
yaxis=dict(showgrid=False, visible=False),
zaxis=dict(showgrid=False, visible=False),
annotations=labels
))
Create the figure
fig = go.Figure (data = [black_hole, accretion_disk], layout=layout)
Hide color bar
fig.update_coloraxes(colorbar=dict(showticklabels=False))
Show the plot
fig.show()
Part 2: The Light Dance: Gravitational Lensing
The cosmic ballet of light bending is brought to life by a symphony of space-time curvature. The cosmic waltz will captivate you, so be ready.
1. A Curvature of Reality: Explore the gravitational lensing phenomenon as we step into Einstein's world. It is a space-and-light dance in which massive objects orchestrate curvature and ray bending.
2. Illuminating the Cosmic Dance Floor: Python and Plotly guide us through the cosmic ballet. Watch as the path of light bends, creating hypnotic visuals that transport us to the intersection of science and art.
3. Unmasking Illusions: As we investigate the universe's light play, strong and weak lensing cast their spells. Look at the rings, multiple images, and subtle distortions that light up our path.
4. Uncovering the Secrets of the Universe: Gravitational lensing is not just fascinating; it is also a key to unlocking the cosmos. Its significance ranges from confirming Einstein's genius to peering into the realms of dark matter.
import plotly.graph_objects as go
import numpy as np
Create a grid of points
size = 100
x = np.linspace(-2, 2, size)
y = np.linspace(-2, 2, size)
X, Y = np.meshgrid(x, y)
# Define the gravitational lensing effect
def gravitational_lens(x, y, mass=1):
r = np.sqrt(x**2 + y**2)
theta = np.arctan2(y, x)
deflection = mass / r
x_new = x - deflection * np.cos(theta)
y_new = y - deflection * np.sin(theta)
return x_new, y_new
Apply gravitational lensing effect
X_lens, Y_lens = gravitational_lens(X, Y)
Create a figure
fig = go.Figure()
Add the original grid as a scatter plot
fig.add_trace(go.Scatter(x=X.flatten(), y=Y.flatten(), mode='markers', marker=dict(color='blue', size=3)))
Add a lensed grid as a scatter plot
fig.add_trace(go.Scatter(x=X_lens.flatten(), y=Y_lens.flatten(), mode='markers', marker=dict(color='red', size=3)))
Set layout
fig.update_layout(title='Gravitational Lensing Simulation', xaxis_title='X', yaxis_title='Y')
Show the plot
fig.show()
Note: I hope you learned something new today, or that you have information that is worth sharing. I would like to kindly encourage that you share what you learn, because sharing is the true reality of knowledge, and nothing brings us greater joy than seeing others benefit from your knowledge that you shared.