Schwarzchild radius, accretion disk
A p5js sketch :
How it works :
- Blackhole class :
class Blackhole {
constructor(x, y, m) {
this.pos = createVector(x, y);
this.mass = m;
this.rs = (2 * G * this.mass) / (c * c);
}
- Constructor: Takes
x
,y
, andm
as parameters to initialize the black hole’s position (pos
), mass (mass
), and Schwarzschild radius (rs
). - Schwarzschild radius (
rs
) is calculated based on the mass of the black hole.
pull(photon) {
const force = p5.Vector.sub(this.pos, photon.pos);
const r = force.mag();
const fg = G * this.mass / (r * r);
force.setMag(fg);
photon.vel.add(force);
photon.vel.setMag(c);
if (r < this.rs) {
photon.stop();
}
}
}
pull
Method: Takes aphoton
object as a parameter.- Calculates the force (
force
) acting on the photon. - Computes the distance (
r
) between the black hole and the photon. - Calculates gravitational force (
fg
) using Newton’s law of gravitation. - Adjusts the photon’s velocity based on the force.
- Checks if the photon is inside the event horizon (
rs
). If true, stops the photon.
- Calculates the force (
show() {
ellipseMode(RADIUS);
fill(0);
noStroke();
ellipse(this.pos.x, this.pos.y, this.rs);
noFill();
stroke(100, 100);
strokeWeight(64);
ellipse(this.pos.x, this.pos.y, this.rs * 3 + 32);
stroke(65, 49, 0, 100);
strokeWeight(32);
ellipse(this.pos.x, this.pos.y, this.rs * 1.5 + 16);
}
show
Method: Draws the visual representation of the black hole.- Draws three ellipses representing different aspects of the black hole
when calling m87.show() we get :