Removed d'Alembert force and chaned halo model to NFW
This commit is contained in:
parent
f8eae117dd
commit
8cb62ac88c
7 changed files with 316 additions and 73 deletions
21
plot.py
21
plot.py
|
|
@ -7,7 +7,7 @@ import ctypes, subprocess
|
|||
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())
|
||||
p = subprocess.Popen('g++ -O3 -I/home/meiron/boost_1_72_0 -shared -o libmain.so -fPIC loadtxt.cpp main.cpp -lgsl'.split())
|
||||
p.wait()
|
||||
if p.returncode != 0: raise RuntimeError(p.returncode)
|
||||
|
||||
|
|
@ -17,19 +17,22 @@ def integrate(y0, t_max, step_size=None):
|
|||
if step_size is None: step_size = t_max
|
||||
size = int(t_max // step_size) + 1
|
||||
y = (ctypes.c_double*size*6)()
|
||||
status = libmain.integrate(y0, ctypes.c_double(t_max), ctypes.c_double(step_size), y)
|
||||
y = np.array(y).reshape(size,6)
|
||||
return np.array(y), status
|
||||
libmain.integrate(y0, ctypes.c_double(t_max), ctypes.c_double(step_size), y)
|
||||
y = np.array(y).reshape(size, 6)
|
||||
return np.array(y)
|
||||
|
||||
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
|
||||
x_max = 120
|
||||
ic = array([120,0,0,0,30,0])
|
||||
|
||||
step_size = 32/4096
|
||||
res = integrate(ic, t_max, step_size=step_size)
|
||||
|
||||
figure(figsize=(8,8))
|
||||
x, y, z, vx, vy, vz = res.T
|
||||
t = arange(0,t_max+step_size,step_size)
|
||||
|
||||
figure(figsize=(16,16))
|
||||
subplot(221)
|
||||
plot(x, y)
|
||||
plot(x[0], y[0], 'x')
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue