Commit 40017947 authored by Zoheyr Doctor's avatar Zoheyr Doctor 🔭
Browse files

made inspiral and ringdown movie

parent 7786b431
#!/usr/bin/env python
import numpy as np
from twirl.artists import BlackHoleRingdown, BinaryBlackHole
from twirl.binary import InspiralingBinary
from matplotlib import pyplot as plt
from matplotlib import animation
from matplotlib.patches import Circle
import sys
plt.style.use('dark_background')
fig,ax = plt.subplots()
binary = InspiralingBinary(
m1=30.,
m2=30.,
alpha=60.,
beta=30.,
gamma=30.,
frame_rate=30.,
omega0 = 30.
)
binary.inspiral()
G = 4.3e-3 * 3.1e13 # km Msol^-1 (km/s)^2
c = 3e5
bbh = BinaryBlackHole(
binary=binary,
ax = ax,
name='BBH',
BH_scale=G/c**2,
)
ringdown = BlackHoleRingdown(
M=60.,
amplitude0 = 1.,
omega=0.03,
tau=15,
ax=ax,
name='BH',
BH_scale = G/c**2
)
def init():
ax.set_xlim([-1000,1000])
ax.set_ylim([-1000,1000])
return bbh.setup_artists()
def animate(i):
if i == binary.nframes:
for name,artist in bbh.artists.items():
artist.remove()
ringdown.setup_artists()
if i > binary.nframes:
return ringdown.get_artists(i-binary.nframes)
if i < binary.nframes:
return bbh.get_artists(i)
fps = 30
anim = animation.FuncAnimation(fig,animate,init_func=init,frames = binary.nframes+60)
anim.save('inspiral_ringdown.mp4',fps=fps,extra_args=['-vcodec', 'libx264'])
......@@ -15,6 +15,7 @@ setup(
'bin/make_event_gifs',
'bin/inspiral_test',
'bin/ringdown_test',
'bin/inspiral_ringdown',
],
packages = [
'twirl',
......
......@@ -3,7 +3,7 @@ import twirl.binary
from matplotlib import pyplot as plt
from matplotlib.patches import Ellipse,Circle
class BinaryBlackHoleArtist:
class BinaryBlackHole:
"""
A class to define the matplotlib artists
......@@ -45,14 +45,14 @@ class BinaryBlackHoleArtist:
z2,x2,y2 = self.binary.pos2_projected[0,:]
self.artists['{}_m1'.format(self.name)] = self.ax.add_artist(
Circle((x1,y1), radius=self.BH_scale*self.binary.m1,
edgecolor=self.edgecolor,
facecolor=self.facecolor
edgecolor='white',
facecolor='black'
)
)
self.artists['{}_m2'.format(self.name)] = self.ax.add_artist(
Circle((x2,y2), radius=self.BH_scale*self.binary.m2,
edgecolor=self.edgecolor,
facecolor=self.facecolor
edgecolor='white',
facecolor='black'
)
)
# make sure star that is closer is shown on top of the other
......
......@@ -171,6 +171,10 @@ class InspiralingBinary(Binary):
self._pos1_projected = [pos1_proj]
self._pos2_projected = [pos2_proj]
@property
def nframes(self):
return len(self.t)
@property
def omega(self):
return (0.5)*((((8.*np.pi)**(8./3))/5.)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment