Beispiel #1
0
import sys

sys.path += ["../"]

import smbh
import numpy as np

n = 30
m = 1000

files = [["Results/%d_%d.dat" % (i, j) for j in range(m)] for i in range(n)]

results = np.zeros((n, m), dtype=object)
for i in range(n):
    for j in range(m):
        results[i, j] = smbh.Results(files[i][j], header_only=True)
    print(i)

return_times = np.zeros_like(results).astype(float)
return_masses = np.zeros_like(return_times)

for i in range(results.shape[0]):
    for j in range(results.shape[1]):
        return_times[i, j] = results[i, j].RETURN_TIME
        return_masses[i, j] = results[i, j].RETURN_MASS

lyapunov = np.genfromtxt("lyapunov.txt", skip_header=1, delimiter=', ')
lyapunov_ = np.zeros((n, m))

for l in lyapunov:
    i, j, l = l
Beispiel #2
0
import sys
sys.path += ["../"]

import smbh
import numpy as np

fileFormat = "../Week 13/Results/%d_%d.dat"

n = 30
m = 1000

masses = np.zeros((n, m))

for i in range(n):
    for j in range(m):
        file = fileFormat % (i, j)
        results = smbh.Results(file)
        masses[i, j] = results.getMassAt(0.512)
        del results
        print(i, j, masses[i, j])


np.savetxt("masses_at_time.txt", masses)
Beispiel #3
0
import sys
sys.path += [".."]

import smbh

import matplotlib.pyplot as plt

colors = smbh.getColors(2)
r0 = smbh.Results("tOrbit0.dat")
fig, ax = smbh.make3dPlot(r0.positions, color=colors[0], alpha=0.8)

r1 = smbh.Results("tOrbit1.dat")
fig, ax = smbh.make3dPlot(r1.positions,
                          fig_axes=(fig, ax),
                          color=colors[1],
                          alpha=0.8)

fig.tight_layout()
fig.savefig('3dorbit.png', dpi=300)

fig, ax = plt.subplots(1)
for (i, results) in enumerate([r0, r1]):
    t = results.times * 1000
    r = results.distance / results.R_VIR

    results.setDistance(1, 0.5, 0.25)
    m = results.distance / results.R_VIR

    ax.plot(t, r, '-', lw=1, color=colors[i])

ax.set_xlabel('Time (Myr)')
Beispiel #4
0
import sys
sys.path += [".."]

import smbh
import numpy as np
import matplotlib.pyplot as plt

positions = 1e-3 * np.ones(3) / (3**0.5)
speeds = [60, 0, 0]
smbh_mass = 1
dt = 1e-6

results = smbh.Results("y.dat", header_only=True)

v = results.getInitialSpeed()
print(v)
# re = smbh.run(speeds, triaxial = False)
# print(re.RETURN_TIME)
# print(re.RETURN_MASS)

# d_q0 = [-1e3, 0, 0]
# d_p0 = [0, 0, 0]
#
# T = 1e-5
# ls = np.logspace(0, 3, 10).astype(int)
# coeffs = []
#
# for l in ls:
#     lya = smbh.lyapunov(positions, speeds, d_q0, d_p0, smbh_mass, l = l, T = T, triaxial = False)
#     coeffs.append(lya)
#
Beispiel #5
0
smbh.setTriaxialCoeffs(1, 0.99, 0.95)

vx, vy, vz = smbh.getEscapeSpeedOrthogonalTriaxial()
print(vx, vy, vz)

# results_x = smbh.run([vx, 0, 0], save_every = 10, filename = "x.dat")
# print("X done")
#
# results_y = smbh.run([0, vy, 0], save_every = 10, filename = "y.dat")
# print("Y done")
#
# results_z = smbh.run([0, 0, vz], save_every = 10, filename = "z.dat")
# print("Z done")

results_x = smbh.Results("x.dat")
results_y = smbh.Results("y.dat")
results_z = smbh.Results("z.dat")
# results_xyz = smbh.Results("xyz.dat")

results = [results_z, results_y, results_x]
labels = [r"$\hat{%s}$"%i for i in ["k", "j", "i"]]

# results = [results_z, results_xyz, results_y, results_x]
# labels = [r"$\vec{v}_0 = 70 \hat{%s}$"%i for i in ["k", "ijk", "j", "i"]]

# for result in results:
#     result.setDistance(1, 0.99, 0.95)

fig, ax = smbh.plotOrbits(results, figsize = (5, 4.5))
Beispiel #6
0
#format = "Symmetric/return_%d_%d.dat"
format = "Triaxial/return_%d_%d.dat"


format_1 = format.replace("_%d_", "_0_").replace("_%d", "*")
format_2 = format.replace("%d", "*")
n = len(glob(format_1))
m = len(glob(format_2)) // n

speeds = np.zeros(m)
results = np.zeros((m, n, 3))

for i in range(0, m):
    for j in range(n):
        r = smbh.Results(format % (i, j), header_only = True)
        try:
            t = r.RETURN_TIME
            m_ = r.RETURN_MASS
        except AttributeError:
            print(i, j)
            t, m_ = -1, -1
        f = r.STELLAR_FRACTION
        v = r.getInitialSpeed()
        results[i, j] = [f, t, m_]
        del r
        
    speeds[i] = v

for i in range(m):
    txt = "fs\tTr(Gyr)\tm(1e5M0)\n"
Beispiel #7
0
import sys
sys.path += ['..']

import smbh
import numpy as np

n = 1000

data = np.zeros((n, 2))

for i in range(n):
    r = smbh.Results("Results/%d.dat" % i, header_only=True)
    data[i] = r.RETURN_TIME, r.RETURN_MASS

np.savetxt("results.txt", data)