hsim/exm/zelus/odes/odes.zls

37 lines
1.1 KiB
Text

let hybrid vdp mu () = (x, y) where
rec der x = y init 1.0
and der y = (mu *. (1.0 -. (x *. x)) *. y) -. x init 1.0
let hybrid sincos () = (sin, cos) where
rec der sin = cos init 0.0
and der cos = -. sin init 1.0
let hybrid both () = (x, y, s, c) where
(x, y) = vdp 5.0 ()
and (s, c) = sincos ()
let vdp_d = Solve.solve_sundials (vdp 5.0)
let sincos_d = Solve.solve_sundials sincos
let both_d = Solve.solve_sundials both
let main_d = Solve.synchr sincos_d both_d
let node print_vdp (now, (x, y)) =
print_endline (String.concat ",\t\t" (List.map string_of_float [now;x;y]))
let node print_sincos (now, (s, c)) =
print_endline (String.concat ",\t\t" (List.map string_of_float [now;s;c]))
let node print_both (now, (x, y, s, c)) =
print_endline (String.concat ",\t\t" (List.map string_of_float [now;x;y;s;c]))
let node print_main (now, ((s1, c1), (x, y, s2, c2))) =
print_endline (String.concat ",\t\t" (List.map string_of_float [now;x;y]))
let input _ = ()
let node main () =
let i = Some (Solve.make(1000.0, input)) fby None in
let o = run main_d i in
Solve.period'_t 0.01 print_main o