24 lines
No EOL
648 B
Python
24 lines
No EOL
648 B
Python
import numpy as np
|
|
import ctypes, subprocess
|
|
|
|
recompile = True
|
|
|
|
if recompile:
|
|
p = subprocess.Popen('g++ -shared -o libmain.so -fPIC main.cpp -lgsl'.split())
|
|
p.wait()
|
|
if p.returncode != 0: raise RuntimeError(p.returncode)
|
|
|
|
libmain = ctypes.CDLL('./libmain.so')
|
|
def integrate(y0, t_max):
|
|
y0 = (ctypes.c_double*6)(*y0)
|
|
y = (ctypes.c_double*6)()
|
|
status = libmain.integrate(y0, ctypes.c_double(t_max), y)
|
|
return np.array(y), status
|
|
|
|
gsl_success = libmain.gsl_success()
|
|
|
|
#t_array = linspace(plot_tmin, plot_tmax, plot_points)
|
|
#r_array = empty_like(t_array)
|
|
|
|
res = integrate([10,0,0,0,200,0], 2.245)
|
|
print(res, gsl_success) |