(* Parallel simulation of harmonic oscillators. *) (* Illustrates the impact of unrelated parallel simulation. *) let pi = 3.141592653589793 let hybrid harmonic(p) = x where rec der x = v init 1.0 and der v = -2.0 *. pi *. x /. p init 0.0 let hybrid f () = (t, x, y) where rec der t = 1.0 init 0.0 and x = harmonic(100.0) and y = harmonic(1000.0) let hybrid main' () = let t, x, y = f () in present (period (0.001)) -> print_endline (String.concat ",\t" (List.map string_of_float [t;x;y])) else () let hybrid f' () = harmonic(100.0) let hybrid g' () = (harmonic(100.0), harmonic(1e-3)) let f_d = Solve.solve_sundials(f') let g_d = Solve.solve_sundials(g') let m = Solve.synchr f_d g_d let node print (now, (xf, (xg, _))) = print_endline (String.concat ",\t" (List.map string_of_float [now;xf;xg])) let input _ = () let node main () = let input = Some (Solve.make (100.0, input)) fby None in Solve.period'_t 0.01 print (run m input)