2 Solve one-dimensional bounce problem with shooting method 3 ========================================================== 5 export LD_PRELOAD=/usr/lib/libginac.so.2.1.0:/usr/lib/x86_64-linux-gnu/libboost_log.so.1.61.0:/usr/lib/x86_64-linux-gnu/libnlopt.so.0.8.1:/usr/lib/x86_64-linux-gnu/libalglib.so.3.8.0 13 PATH = os.path.dirname(os.path.abspath(__file__))
14 LIB_NAME =
'{}/../lib/libbubbler.so'.format(PATH)
16 lib = ctypes.CDLL(LIB_NAME)
18 c_action.argtypes = [ctypes.c_double, ctypes.c_double, ctypes.c_int, ctypes.Structure]
19 c_action.restype = ctypes.c_double
24 Struct for Shooting::default. 26 _fields_ = [(
'shoot_bisect_bits', ctypes.c_int),
27 (
'action_arrived_rel', ctypes.c_double),
28 (
'shoot_ode_abs', ctypes.c_double),
29 (
'shoot_ode_rel', ctypes.c_double),
30 (
'action_ode_abs', ctypes.c_double),
31 (
'action_ode_rel', ctypes.c_double),
32 (
'drho_frac', ctypes.c_double),
33 (
'evolve_change_rel', ctypes.c_double),
34 (
'evolve_rho_min', ctypes.c_double),
35 (
'bisect_lambda_max', ctypes.c_double),
36 (
'iter_max', ctypes.c_int),
37 (
'periods_max', ctypes.c_double),
38 (
'f_y_max', ctypes.c_double),
39 (
'f_y_min', ctypes.c_double)]
44 default.shoot_bisect_bits = 5
45 default.action_arrived_rel = 1.e-3
46 default.shoot_ode_abs = 1.e-4
47 default.shoot_ode_rel = 1.e-4
48 default.action_ode_abs = 1.e-6
49 default.action_ode_rel = 1.e-6
50 default.drho_frac = 1.e-3
51 default.evolve_change_rel = 1.e-2
52 default.evolve_rho_min = 1.e-3
53 default.bisect_lambda_max = 5
54 default.iter_max = 100000
55 default.periods_max = 1.e2
56 default.f_y_max = 1.e6
57 default.f_y_min = 1.e-3
62 Populate struct for Shooting::default from a dictionary. 66 for k, v
in settings.iteritems():
67 struct.__setattr__(k, v)
71 def action(E, alpha, dim=3, **kwargs):
73 Wrapper for C function that calculates action. 78 if __name__ ==
"__main__":
82 print "alpha = {}".format(alpha)
83 print "E = {}".format(E)
84 print "action = {}".format(
action(E, alpha))
def make_struct(settings)
def action(E, alpha, dim=3, kwargs)