Processed subhalo data and modified integrator to read and use new data structure
This commit is contained in:
parent
cb66caf6ba
commit
f8eae117dd
4 changed files with 281 additions and 62 deletions
51
plot.py
51
plot.py
|
|
@ -4,7 +4,7 @@
|
|||
import numpy as np
|
||||
import ctypes, subprocess
|
||||
|
||||
recompile = True
|
||||
recompile = False
|
||||
|
||||
if recompile:
|
||||
p = subprocess.Popen('g++ -I/home/meiron/boost_1_72_0 -shared -o libmain.so -fPIC loadtxt.cpp main.cpp -lgsl'.split())
|
||||
|
|
@ -21,28 +21,43 @@ def integrate(y0, t_max, step_size=None):
|
|||
y = np.array(y).reshape(size,6)
|
||||
return np.array(y), status
|
||||
|
||||
def integrate_boost(y0, t_max, step_size=None):
|
||||
y0 = (ctypes.c_double*6)(*y0)
|
||||
if step_size is None: step_size = t_max
|
||||
size = int(t_max // step_size) + 1
|
||||
y = (ctypes.c_double*size*6)()
|
||||
libmain.integrate_boost(y0, ctypes.c_double(t_max), ctypes.c_double(step_size), y)
|
||||
y = np.array(y).reshape(size,6)
|
||||
return np.array(y), 0
|
||||
|
||||
#gsl_success = libmain.gsl_success()
|
||||
|
||||
from pylab import *
|
||||
t_max = 10
|
||||
x_max = 85
|
||||
ic = [80,0,0,0,80,0]
|
||||
res = integrate(ic, t_max, step_size=32/4096)
|
||||
x, y, z, vx, vy, vz = res[0].T
|
||||
zzz = x[-1]
|
||||
plot(x,y)
|
||||
|
||||
res = integrate(ic, t_max)
|
||||
x, y, z, vx, vy, vz = res[0].T
|
||||
plot(x,y,'o')
|
||||
print(zzz - x[-1])
|
||||
|
||||
figure(figsize=(8,8))
|
||||
subplot(221)
|
||||
plot(x, y)
|
||||
plot(x[0], y[0], 'x')
|
||||
gca().set_aspect('equal')
|
||||
xlabel('x')
|
||||
ylabel('y')
|
||||
xlim(-x_max,x_max)
|
||||
ylim(-x_max,x_max)
|
||||
|
||||
subplot(223)
|
||||
plot(x, z)
|
||||
plot(x[0], z[0], 'x')
|
||||
gca().set_aspect('equal')
|
||||
xlabel('x')
|
||||
ylabel('z')
|
||||
xlim(-x_max,x_max)
|
||||
ylim(-x_max,x_max)
|
||||
|
||||
subplot(224)
|
||||
plot(y, z)
|
||||
plot(y[0], z[0], 'x')
|
||||
gca().set_aspect('equal')
|
||||
xlabel('z')
|
||||
ylabel('y')
|
||||
xlim(-x_max,x_max)
|
||||
ylim(-x_max,x_max)
|
||||
|
||||
subplots_adjust(wspace=0.25)
|
||||
|
||||
savefig('test_orbit.png')
|
||||
show()
|
||||
Loading…
Add table
Add a link
Reference in a new issue