Habib U Rehman commited on
Commit
8f4911a
·
verified ·
1 Parent(s): baaab1f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +20 -9
app.py CHANGED
@@ -85,29 +85,40 @@ def black_hole_advanced(mass):
85
  # ===============================
86
  # LIGHT BENDING
87
  # ===============================
88
- y_vals = np.linspace(-4*rs, 4*rs, 7)
 
 
 
89
 
90
  for y0 in y_vals:
91
- x_ray = np.linspace(-7*rs, 7*rs, 350)
92
  y_ray, z_ray = [], []
93
 
94
  for x0 in x_ray:
95
  r = np.sqrt(x0**2 + y0**2)
96
- if r < 1.05 * rs:
 
97
  y_ray.append(np.nan)
98
  z_ray.append(np.nan)
99
- else:
100
- bend = rs / (r - rs)
101
- bend = np.clip(bend, 0, 1.4)
102
- y_ray.append(y0 - bend * y0 * 0.1)
103
- z_ray.append(bend * rs * 0.12)
 
 
 
 
 
 
104
 
105
  fig.add_trace(go.Scatter3d(
106
  x=x_ray,
107
  y=y_ray,
108
  z=z_ray,
109
  mode="lines",
110
- opacity=0.35,
 
111
  showlegend=False
112
  ))
113
 
 
85
  # ===============================
86
  # LIGHT BENDING
87
  # ===============================
88
+ # ===============================
89
+ # CORRECTED GRAVITATIONAL LENSING
90
+ # ===============================
91
+ y_vals = np.linspace(-4*rs, 4*rs, 9)
92
 
93
  for y0 in y_vals:
94
+ x_ray = np.linspace(-8*rs, 8*rs, 500)
95
  y_ray, z_ray = [], []
96
 
97
  for x0 in x_ray:
98
  r = np.sqrt(x0**2 + y0**2)
99
+
100
+ if r <= 1.02 * rs:
101
  y_ray.append(np.nan)
102
  z_ray.append(np.nan)
103
+ continue
104
+
105
+ # Strong relativistic-style bending
106
+ b = abs(y0) + 0.2 * rs # impact parameter
107
+ bend_strength = (rs / r) * (rs / b)
108
+
109
+ y_deflect = bend_strength * y0 * 0.9
110
+ z_deflect = bend_strength * rs * 0.7
111
+
112
+ y_ray.append(y0 - y_deflect)
113
+ z_ray.append(z_deflect)
114
 
115
  fig.add_trace(go.Scatter3d(
116
  x=x_ray,
117
  y=y_ray,
118
  z=z_ray,
119
  mode="lines",
120
+ line=dict(width=2),
121
+ opacity=0.5,
122
  showlegend=False
123
  ))
124