Exemple #1
0
def gridDensity(fname):
    ''' Calculates the density squared within 15 M on (r, theta) grid

      :returns: r, th, annihilationRates, sqrt(dispersions)
  '''
    # Calculate density from the data file
    data = pp.loadpdata(fname)
    Ntotal = data["Ntotal"]
    Eps_1 = data["Eps_1"]
    Lz_1 = data["Lz_1"]
    K_1 = data["K_1"]
    M_1 = data["M_1"]
    a_1 = data["a_1"]
    rMin_1 = data["rMin_1"]
    rMax_1 = data["rMax_1"]
    g_1 = np.ravel(data["g_1"])

    Eps_2 = data["Eps_2"]
    Lz_2 = data["Lz_2"]
    K_2 = data["K_2"]
    M_2 = data["M_2"]
    a_2 = data["a_2"]
    rMin_2 = data["rMin_2"]
    rMax_2 = data["rMax_2"]
    thMin_2 = data["thMin_2"]
    thMax_2 = data["thMax_2"]
    g_2 = np.ravel(data["g_2"])

    N_1 = np.ones(len(Eps_1)) * 1. / Ntotal
    f_1 = N_1 / g_1
    f_2 = f_1  # Constancy of phase space

    R = np.linspace(M_2, 15. * M_2, 80)
    TH = np.linspace(np.pi / 3., np.pi * (1. - 1. / 3.), 10)
    TH = [np.pi / 2. + 0.02]
    rV = []
    thV = []
    Densitys = []
    sqrtdispersions = []
    nSamples = []
    # Calculate annihilation rate for each "Grid" point
    for r in R:
        for th in TH:
            cond = ((rMin_2 < r) & (r < rMax_2) & (thMin_2 < th) &
                    (th < thMax_2))
            Density = GR.ZAMODensity(f_2, Eps_2, Lz_2, K_2, M_2, a_2, rMin_2,
                                     rMax_2, thMin_2, thMax_2, r, th)**2
            Densitys.append(Density * 1.e45)
            sqrtdispersions.append(
                np.sqrt(
                    GR.ZAMODispersion(f_2, Eps_2, Lz_2, K_2, M_2, a_2, rMin_2,
                                      rMax_2, thMin_2, thMax_2, r, th)))
            rV.append(r)
            thV.append(th)
            nSamples.append(np.sum(cond))
            print "r, th: %f %f" % (r, th)
    print "Max annihilation rate %lf" % np.max(Densitys)
    print "Mean value of degeneracy: %lf" % np.mean(g_2)
    return rV, thV, Densitys, sqrtdispersions, nSamples, M_2, a_2
Exemple #2
0
#matplotlib.rcParams['mathtext.rm'] = 'Bitstream Vera Sans'
#matplotlib.rcParams['mathtext.it'] = 'Bitstream Vera Sans:italic'
#matplotlib.rcParams['mathtext.bf'] = 'Bitstream Vera Sans:bold'
#matplotlib.rc('font', **{'family': 'serif', 'serif': ['Computer Modern']})
#matplotlib.rc('text', usetex=True)
import numpy as np
import paris as pp
from paris import GR
import pylab as plt

print "python binDegeneracies.py ProductionData/M10_r2_spin0998"
plt.figure(figsize=(16, 9))

print np.array(sys.argv)[1:]
for fname in np.array(sys.argv)[1:]:
    data = pp.loadpdata(fname)
    g_1 = np.ravel(data["g_1"])
    g_2 = np.ravel(data["g_2"])
    Ntotal = np.ravel(data["Ntotal"])
    plt.hist(g_1,
             color='red',
             label="Degeneracy before growth, fname = " + str(fname),
             alpha=0.5)
    plt.hist(g_2,
             color='black',
             label="Degeneracy after growth, fname = " + str(fname),
             alpha=0.5)
    plt.yscale("log")
    plt.xscale("log")
    plt.ylabel("Counts")
    plt.xlabel("Degeneracy")
Exemple #3
0
def generate3DVTKUltra(fin, fout):
    # Read in data:
    data = pp.loadpdata(fin)
    Ntotal = data["Ntotal"]
    Eps_1 = data["Eps_1"]
    Lz_1 = data["Lz_1"]
    K_1 = data["K_1"]
    M_1 = data["M_1"]
    a_1 = data["a_1"]
    rMin_1 = data["rMin_1"]
    rMax_1 = data["rMax_1"]
    g_1 = data["g_1"]
    Eps_2 = data["Eps_2"]
    Lz_2 = data["Lz_2"]
    K_2 = data["K_2"]
    M_2 = data["M_2"]
    a_2 = data["a_2"]
    rMin_2 = data["rMin_2"]
    rMax_2 = data["rMax_2"]
    thMin_2 = data["thMin_2"]
    thMax_2 = data["thMax_2"]
    g_2 = data["g_2"]
    N_1 = np.ones(len(Eps_1)) * 1. / Ntotal
    f_1 = N_1 / g_1
    f_2 = f_1  # Constancy of phase space
    fOut = fout
    rMin = 1. * M_2
    rMax = 25. * M_2
    rDimensions = 200
    thMin = 0
    thMax = np.pi
    thDimensions = 30
    phMin = 0
    phMax = 2. * np.pi
    phDimensions2 = 30
    r, theta, phi = np.mgrid[rMin:rMax:np.complex(0, rDimensions),
                             thMin:thMax:complex(0, thDimensions),
                             phMin:phMax:complex(0, phDimensions2)]
    th = theta
    x = r * np.sin(theta) * np.cos(phi)
    y = r * np.sin(theta) * np.sin(phi)
    z = r * np.cos(theta)
    FFIODensity = np.zeros(np.shape(r))
    ZAMODensity = np.zeros(np.shape(r))
    sqrtdisp = np.zeros((np.shape(r)[0], np.shape(r)[1], np.shape(r)[2], 4))
    Px = np.zeros(np.shape(r))
    Py = np.zeros(np.shape(r))
    Pz = np.zeros(np.shape(r))
    for i in range(len(r)):
        for j in range(len(r[0])):
            for k in range(len(r[0][0])):
                FFIODensity[i][j][k] = GR.FDensity(f_2, Eps_2, Lz_2, K_2, M_2,
                                                   a_2, rMin_2, rMax_2,
                                                   thMin_2, thMax_2,
                                                   r[i][j][k], th[i][j][k])
                ZAMODensity[i][j][k] = GR.ZAMODensity(f_2, Eps_2, Lz_2, K_2,
                                                      M_2, a_2, rMin_2, rMax_2,
                                                      thMin_2, thMax_2,
                                                      r[i][j][k], th[i][j][k])
                sqrtdisp[i][j][k] = np.sqrt(
                    GR.ZAMODispersion(f_2, Eps_2, Lz_2, K_2, M_2, a_2, rMin_2,
                                      rMax_2, thMin_2, thMax_2, r[i][j][k],
                                      th[i][j][k]))
                Nmu = GR.Nmu(f_2, Eps_2, Lz_2, K_2, M_2, a_2, rMin_2, rMax_2,
                             thMin_2, thMax_2, r[i][j][k], th[i][j][k])
                sinth = np.sin(th[i][j][k])
                costh = np.cos(th[i][j][k])
                sinphi = np.sin(phi[i][j][k])
                cosphi = np.cos(phi[i][j][k])
                Px[i][j][k] = Nmu[1] * sinth * cosphi + Nmu[
                    2] * costh * cosphi + Nmu[3] * (-1. * sinphi)
                Py[i][j][k] = Nmu[1] * sinth * sinphi + Nmu[
                    2] * costh * sinphi + Nmu[3] * cosphi
                Px[i][j][k] = Nmu[1] * costh + Nmu[2] * (-1. *
                                                         sinth) + Nmu[3] * 0.
    FFIODensity = np.array(FFIODensity)
    ZAMODensity = np.array(ZAMODensity)
    sqrtdisp = np.array(sqrtdisp)
    Px = np.array(Px)
    Py = np.array(Py)
    Pz = np.array(Pz)
    pointData = {
        "FFIODensity": FFIODensity,
        "ZAMODensity": ZAMODensity,
        "Px": Px,
        "Py": Py,
        "Pz": Pz
    }  #, "sigma_Px": sqrtdisp[:,1], "sigma_Py": sqrtdisp[:,2], "sigma_Pz": sqrtdisp[:,3]}
    gridToVTK(fOut, x, y, z, pointData=pointData)
    return rMin, rMax, thMin, thMax, phMin, phMax, rDimensions, thDimensions, phDimensions2, pointData
#matplotlib.rcParams['mathtext.it'] = 'Bitstream Vera Sans:italic'
#matplotlib.rcParams['mathtext.bf'] = 'Bitstream Vera Sans:bold'
#matplotlib.rc('font', **{'family': 'serif', 'serif': ['Computer Modern']})
#matplotlib.rc('text', usetex=True)

import paris as pp
import numpy as np
import pylab as plt
import sys
from paris import GR

fname1 = sys.argv[1]
fname2 = sys.argv[2]
fout = sys.argv[3]

data = pp.loadpdata(fname2)
Eps_1 = data["Eps_1"]
Lz_1 = data["Lz_1"]
K_1 = data["K_1"]
M_1 = data["M_1"]
a_1 = data["a_1"]
rMin_1 = data["rMin_1"]
rMax_1 = data["rMax_1"]
g_1 = data["g_1"]

Eps_2 = data["Eps_2"]
Lz_2 = data["Lz_2"]
K_2 = data["K_2"]
M_2 = data["M_2"]
a_2 = data["a_2"]
rMin_2 = data["rMin_2"]
Exemple #5
0
    "a": a,
    "M": M,
    "a_2": a_2,
    "M_2": M_2,
    "Eps_1": Eps_1,
    "Lz_1": Lz_1,
    "K_1": K_1,
    "Q_1": Q_1,
    "rMin_1": rMin_1,
    "rMax_1": rMax_1,
    "thMin_1": thMin_1,
    "thMax_1": thMax_1,
    "g_1": g_1,
    "M_1": M_1,
    "a_1": a_1,
    "Eps_2": Eps_2,
    "Lz_2": Lz_2,
    "K_2": K_2,
    "Q_2": Q_2,
    "rMin_2": rMin_2,
    "rMax_2": rMax_2,
    "thMin_2": thMin_2,
    "thMax_2": thMax_2,
    "g_2": g_2,
    "M_2": M_2,
    "a_2": a_2
}

pp.savepdata(fout, data)
data2 = pp.loadpdata(fout)
def calculateVariables(fname, average=False):
    # Load the data files
    data = pp.loadpdata(fname)
    Ntotal = data["Ntotal"]
    Eps_1 = data["Eps_1"]
    Lz_1 = data["Lz_1"]
    K_1 = data["K_1"]
    M_1 = data["M_1"]
    a_1 = data["a_1"]
    rMin_1 = data["rMin_1"]
    rMax_1 = data["rMax_1"]
    g_1 = np.ravel(data["g_1"])
    Eps_2 = data["Eps_2"]
    Lz_2 = data["Lz_2"]
    K_2 = data["K_2"]
    M_2 = data["M_2"]
    a_2 = data["a_2"]
    rMin_2 = data["rMin_2"]
    rMax_2 = data["rMax_2"]
    thMin_2 = data["thMin_2"]
    thMax_2 = data["thMax_2"]
    g_2 = np.ravel(data["g_2"])
    #if GR.tests.isBound(Eps_1,Lz_1,K_1,M_1,a_1) == False:
    #  raise ValueError("Eps_1,Lz_1,Q_1 not bound; something wrong")
    #if GR.tests.isBound(Eps_2,Lz_2,K_2,M_2,a_2) == False:
    #  raise ValueError("Eps_2,Lz_2,Q_2 not bound; something wrong")
    # Data loaded; now calculate the 4-current
    N_1 = np.ones(len(Eps_1)) * 1. / Ntotal
    f_1 = N_1 / g_1
    f_2 = f_1
    th = np.pi / 2. + 0.01
    FFIODensity = []
    ZAMODensity = []
    ZAMODispersion = []
    nSamples = []
    R = np.linspace(1. * M_2, 50 * M_2, 1000)
    router = 1. * M_2 + np.sqrt(M_2**2 - a_2**2)
    if np.sum(rMin_2 <= router) != 0:
        raise ValueError(
            "Bad limits; we are inside the inner horizon with rmin router %lf %lf"
            % (np.min(rMin_2), router))
    for r in R:
        if average == True:
            TH = np.linspace(np.pi * (1. / 2. - 1. / 7.),
                             np.pi * (1. / 2. + 1. / 7.), 10)
        else:
            TH = [np.pi / 2. + 0.01]
        # Average over TH:
        NTH = len(TH)
        samples = 0.
        dispersion = np.zeros(4) * 1.
        FDensity = 0.
        ZDensity = 0.
        for i in np.arange(len(TH)):
            th = TH[i]
            samples = samples + np.sum(((r < rMax_2) & (rMin_2 < r) &
                                        (th < thMax_2) & (thMin_2 < th)))
            # Get the ZAMO Dispersion
            dispersion = dispersion + GR.ZAMODispersion(
                f_2, Eps_2, Lz_2, K_2, M_2, a_2, rMin_2, rMax_2, thMin_2,
                thMax_2, r, th)
            FDensity = FDensity + GR.FDensity(f_2, Eps_2, Lz_2, K_2, M_2, a_2,
                                              rMin_2, rMax_2, thMin_2, thMax_2,
                                              r, th)
            ZDensity = ZDensity + GR.ZAMODensity(f_2, Eps_2, Lz_2, K_2, M_2,
                                                 a_2, rMin_2, rMax_2, thMin_2,
                                                 thMax_2, r, th)
        # Calculate mean:
        samples = samples / float(NTH)
        dispersion = dispersion / float(NTH)
        FDensity = FDensity / float(NTH)
        ZDensity = ZDensity / float(NTH)
        # Insert:
        FFIODensity.append(FDensity)
        # Note that J^0 = \rho_0 U^0 = \rho = (density at rest) in the ZAMO frame
        ZAMODensity.append(ZDensity)
        ZAMODispersion.append(dispersion)
        nSamples.append(samples)
    FFIODensity = np.array(FFIODensity)
    ZAMODensity = np.array(ZAMODensity)
    ZAMODispersion = np.array(ZAMODispersion)
    nSamples = np.array(nSamples)
    return R, FFIODensity, ZAMODensity, ZAMODispersion[:,
                                                       1], ZAMODispersion[:,
                                                                          2], ZAMODispersion[:,
                                                                                             3], nSamples