Exemplo n.º 1
0
def sigmaMF(config):
    colors = [
        'b', 'g', 'r', 'c', 'm', 'y', 'k', 'hotpink', 'olivedrab', 'gray'
    ]
    sigma_par = {}
    config_section_name = 'SIGMA_MF'
    sigma_par['m_ns'] = float(config[config_section_name]['m_ns'])
    sigma_par['type'] = config[config_section_name]['type']
    sigma_par['theta_i_deg'] = float(
        config[config_section_name]['theta_i_deg'])
    sigma_par['EOS'] = config[config_section_name]['EOS']
    snr = float(config[config_section_name]['snr'])
    l = float(config[config_section_name]['l'])
    m = float(config[config_section_name]['m'])
    n = float(config[config_section_name]['n'])
    q_min = float(config[config_section_name]['q_min'])
    q_max = float(config[config_section_name]['q_max'])
    q_arr = np.linspace(q_min, q_max, 30)
    chi_bh_min = float(config[config_section_name]['chi_bh_min'])
    chi_bh_max = float(config[config_section_name]['chi_bh_max'])
    chi_bh = np.linspace(chi_bh_min, chi_bh_max, 10)
    qnm = wf.QNM_fit(l, m, n)

    plt.rcParams['xtick.top'] = plt.rcParams['xtick.labeltop'] = True
    plt.rcParams['ytick.right'] = plt.rcParams['ytick.labelright'] = True
    for i in range(len(chi_bh)):
        sigma_par['chi_bh'] = chi_bh[i]
        m_out_arr = []
        err_m_f = []
        for j in range(len(q_arr)):
            sigma_par['q'] = q_arr[j]
            spin_object = sm.Spin_class(sigma_par)
            chi_f, theta_f, m_f, m_out = spin_object.FinalPar()
            f_rd = qnm.f(m_f, chi_f)
            tau_rd = qnm.tau(m_f, chi_f)
            sigma_m_f = SigmaMF_Fisher(qnm, f_rd, tau_rd, chi_f, m_f, snr)
            m_out_arr.append(m_out)
            err_m_f.append(sigma_m_f)
        plt.plot(q_arr,
                 err_m_f,
                 color=colors[i % 10],
                 label=r"$\sigma_M$, $\chi_{BH}$:%.1f" % chi_bh[i],
                 linestyle='--')
        plt.plot(q_arr,
                 m_out_arr,
                 colors[i % 10],
                 label=r"$M_{OUT}$,$\chi_{BH}:%.1f$" % chi_bh[i],
                 linestyle='-')
        #idx = np.argwhere(np.diff(np.sign(np.array(err_m_f) - np.array(m_out_arr))).flatten()
        #plt.plot(q_arr[idx], m_out_arr[idx], 'ro')
    plt.title(r"$M_{NS}$=%.2f, EOS= %s, mode = %d%d%d, SNR = %d" %
              (sigma_par["m_ns"], sigma_par["EOS"], l, m, n, snr),
              y=1.08)
    plt.xlabel(r"$q$")
    plt.ylabel(r"$[M_{\odot}]$")
    plt.legend()
    plt.show()
Exemplo n.º 2
0
def sigma_freq(snr, mode1, mode2, binary_par):

    spin_object = sm.Spin_class(binary_par)
    a_f, theta_f, m_f, m_out = spin_object.FinalPar()

    if mode1 == mode2:
        print("non orthogonal mode")
    else:
        l1 = int(mode1[0])
        m1 = int(mode1[1])
        n1 = int(mode1[2])
        l2 = int(mode2[0])
        m2 = int(mode2[1])
        n2 = int(mode2[2])

    # Pair of modes
    qnm1 = wf.QNM_fit(l1, m1, n1)
    qnm2 = wf.QNM_fit(l2, m2, n2)

    f1 = qnm1.f(m_f, a_f)
    f2 = qnm2.f(m_f, a_f)

    tau1 = qnm1.tau(m_f, a_f)
    tau2 = qnm2.tau(m_f, a_f)

    Q1 = np.pi * f1 * tau1
    Q2 = np.pi * f2 * tau2

    amplitude_object = am.Amplitude_class(binary_par)
    switch = {
        "220": amplitude_object.A22220,
        "210": amplitude_object.A21210,
    }

    A1 = switch[mode1](0)
    A2 = switch[mode2](0)
    #print(f1,f2,tau1,tau2,A1,A2, m_f, a_f)
    sigma = 1./(snr*2*2**(1./2))*(f1**3*(3+16*Q1**4)/(A1**2*Q1**7)*\
                                   (A1**2*Q1**3/(f1*(1+4*Q1**2))+\
                                    A2**2*Q2**3/(f2*(1+4*Q2**2))))**(1./2)
    sigma = 1. / (2**(1. / 2) * np.pi * tau1 * snr)
    return sigma
Exemplo n.º 3
0
def sigma_tau(snr, mode1, mode2, binary_par):

    spin_object = sm.Spin_class(binary_par)
    a_f, theta_f, m_f, m_out = spin_object.FinalPar()

    if mode1 == mode2:
        print("Error, non orthogonal modes")
    else:
        l1 = int(mode1[0])
        m1 = int(mode1[1])
        n1 = int(mode1[2])
        l2 = int(mode2[0])
        m2 = int(mode2[1])
        n2 = int(mode2[2])

    qnm1 = wf.QNM_fit(l1, m1, n1)
    qnm2 = wf.QNM_fit(l2, m2, n2)

    f1 = qnm1.f(m_f, a_f)
    f2 = qnm2.f(m_f, a_f)

    tau1 = qnm1.tau(m_f, a_f)
    tau2 = qnm2.tau(m_f, a_f)

    Q1 = np.pi * f1 * tau1
    Q2 = np.pi * f2 * tau2

    amplitude_object = am.Amplitude_class(binary_par)
    switch = {
        "220": amplitude_object.A22220,
        "210": amplitude_object.A21210,
    }

    A1 = switch[mode1](0)
    A2 = switch[mode2](0)
    sigma = 2./(snr*np.pi)*((3+4*Q1**2)/(A1**2*f1*Q1)*\
                            (A1**2*Q1**3/(f1*(1+4*Q1**2))+\
                             A2**2*Q2**3/(f2*(1+4*Q2**2))))**(1./2)
    sigma = 2. * tau1 / snr

    return sigma
def PlotQNM(config):
    config_section_name = 'PLOT_QNM'
    qnm_par = {}
    qnm_par['l'] = int(config[config_section_name]['l'])
    qnm_par['m'] = int(config[config_section_name]['m'])
    qnm_par['n'] = int(config[config_section_name]['n'])
    qnm_object = wf.QNM_fit(qnm_par['l'], qnm_par['m'], qnm_par['n'])
    qnm_par['x'] = config[config_section_name]['x_var']
    qnm_par['y'] = config[config_section_name]['y_var']
    qnm_par['m_bh_min'] = float(config[config_section_name]['m_bh_min'])
    qnm_par['m_bh_max'] = float(config[config_section_name]['m_bh_max'])
    m_bh = np.linspace(qnm_par['m_bh_min'], qnm_par['m_bh_max'], 9)
    qnm_par['chi_bh_min'] = float(config[config_section_name]['chi_bh_min'])
    qnm_par['chi_bh_max'] = float(config[config_section_name]['chi_bh_max'])
    chi_bh = np.linspace(qnm_par['chi_bh_min'], qnm_par['chi_bh_max'], 9)

    #plt.rcparams['xtick.top'] = plt.rcparams['xtick.labeltop'] = true
    #plt.rcparams['ytick.right'] = plt.rcparams['ytick.labelright'] = true
    if qnm_par['x'] == "mass":
        for j in range(len(chi_bh)):
            y_var_arr = []
            y_var = 0
            for k in range(len(m_bh)):
                if qnm_par['y'] == "freq":
                    y_var = qnm_object.f(m_bh[k], chi_bh[j])
                if qnm_par['y'] == "tau":
                    y_var = qnm_object.tau(m_bh[k], chi_bh[j])
                y_var_arr.append(y_var)
            plt.plot(m_bh, y_var_arr, label=r"$\chi_{BH}$: %.1f" % chi_bh[j])
        plt.xlabel(r"$M_{BH} [M_{\odot}]$")
        plt.ylabel(r"%s" % qnm_par['y'])
        plt.title("Mode = %d%d%d" % (qnm_par['l'], qnm_par['m'], qnm_par['n']),
                  y=1.08)

    if qnm_par['x'] == "spin":
        for j in range(len(m_bh)):
            y_var_arr = []
            y_var = 0
            for k in range(len(chi_bh)):
                if qnm_par['y'] == "freq":
                    y_var = qnm_object.f(m_bh[j], chi_bh[k])
                if qnm_par['y'] == "tau":
                    y_var = qnm_object.tau(m_bh[j], chi_bh[k])
                y_var_arr.append(y_var)
            plt.plot(m_bh,
                     y_var_arr,
                     label=r"$M_{BH}$: %d M_{odot} " % chi_bh[j])
        plt.xlabel(r"$\chi_{BH}$")
        plt.ylabel(r"%s" % qnm_par['y'])
        plt.title("Mode = %d%d%d" % (qnm_par['l'], qnm_par['m'], qnm_par['n']),
                  y=1.08)
    plt.show()
def ParameterZones(config):
    config_section_name = 'PARAMETER_ZONES'
    binary_par = {}
    binary_par["theta_i_deg"]=float(config[config_section_name]['theta_i_deg'])
    binary_par["EOS"]=config[config_section_name]['EOS']
    binary_par["chi_ns"]=float(config[config_section_name]['chi_ns'])
    m_ns = binary_par["m_ns"]=float(config[config_section_name]['m_ns'])
    q_min=float(config[config_section_name]['q_min'])
    q_max=float(config[config_section_name]['q_max'])
    q = np.linspace(q_min, q_max, 20*(q_max-q_min+1))
    chi_bh_min=float(config[config_section_name]['chi_bh_min'])
    chi_bh_max=float(config[config_section_name]['chi_bh_max'])
    chi_bh = np.linspace(chi_bh_min, chi_bh_max, 15*(chi_bh_max-chi_bh_min)+1)
    binary_par["type"]=config[config_section_name]['type']
  
    G = 6.67*10**(-8)
    c = 3*10**(10)
    m_sol = 2*10**33

    plt.rcParams['xtick.top'] = plt.rcParams['xtick.labeltop'] = True 
    plt.rcParams['ytick.right'] = plt.rcParams['ytick.labelright'] = True
    m_out_chi = []
    m_out_q = []
    f_chi = []
    f_q = []
    qnm_object = wf.QNM_fit(2,2,0)

    for j in range(len(chi_bh)):
        m_out_arr = []
        m_out_first_time = 0
        f_tid_maj_f_220 = 0
        binary_par['chi_bh'] = chi_bh[j]
        for k in range(len(q)):
            binary_par['q'] = q[k] 
            spin_object = sm.Spin_class(binary_par)
            chi_f, theta_f, m_f, m_out = spin_object.FinalPar()
            m_out_arr.append(m_out)
            binary_par['q'] = q[k] 
            f_220 = qnm_object.f(m_f,chi_f)
            xi_tid = fsolve(spin_object.XiTidal,10)
            r_tid = xi_tid*(m_ns*m_sol*G/c**2)/spin_object.C*(1-2*spin_object.C)
            f_tid = float(1./(np.pi*(chi_f*m_f*m_sol*G/c**2+(r_tid**3/(m_f*m_sol*G/c**2))**(1./2)))*c)
            #print("")
            #print("m_out",m_out)
            #print("chi",chi_bh[j])
            #print("q",q[k])
            #print("")

            if f_tid>=f_220 and f_tid_maj_f_220==0:
                f_tid_maj_f_220=1
                f_chi.append(chi_bh[j])
                f_q.append(q[k])
                #print("")
                #print("f_220", f_220)
                #print("f_tid",f_tid)
                #print("chi",chi_bh[j])
                #print("q",q[k])
                #print("")
            if m_out==0 and m_out_first_time==0:
                m_out_first_time = 1
                m_out_chi.append(chi_bh[j])
                #print("")
                #print(chi_bh[j])
                m_out_q.append(q[k])
                #print(q[k])
                #print("")
        #plt.plot(q, m_out_arr, label=r"$\chi_{BH}:$ %.2f" %chi_bh[j])
        #plt.legend()
    #plt.title(r"$M_{NS}$ = %.2f $M_{\odot}$, EOS = %s, $\theta_i$ = %d$^{\circ}$" %(binary_par["m_ns"], binary_par["EOS"], binary_par["theta_i_deg"]), y=1.08)
    plt.plot(f_chi, f_q,label=r'$f_{tid}=f_{220}$')
    plt.plot(m_out_chi, m_out_q, label=r'$M_{OUT}=0$')
    plt.xlabel(r'$\chi_{BH}$')
    plt.ylabel(r'$q$')
    switch={
        "2H":[[0.1,9],[0.5,9],[0.4,6.5],[-0.01,6.0],[-0.01,5.8]],
        "H": [[0.2,8],[0.65,8],[0.6,4],[-0.05,3.4],[-0.05,3.2]],
        "HB":[[0.2,7],[0.6,6],[0.6,3.5],[-0.05,3],[-0.05,2.7]],
        "B": [[0.2,6],[0.65,5],[0.65,2.5],[-0.01,2.5],[-0.01,2.3]]
    }
    position = switch[binary_par["EOS"]]
    plt.text(position[0][0],position[0][1], r'$f_{220}<f_{tid}, M_{OUT}=0$')
    plt.text(position[1][0],position[1][1], r'$f_{220}<f_{tid}, M_{OUT}>0$')
    plt.text(position[2][0],position[2][1], r'$f_{tid}<f_{220}, M_{OUT}>0$')
    plt.text(position[3][0],position[3][1], r'$f_{tid}<f_{220}$')
    plt.text(position[4][0],position[4][1], r'$M_{OUT}=0$')
    plt.title(r"$M_{NS}=%.2f, EOS=%s, \theta_i=%d $"%(m_ns, binary_par["EOS"], binary_par["theta_i_deg"]),y=1.08)
    plt.legend()
    plt.show()