28 lines
788 B
Text
28 lines
788 B
Text
(* The Brusselator. *)
|
|
let hybrid brusselator(a, b) = (x, y) where
|
|
rec der x = a +. x *. x *. y -. b *. x -. x init 1.0
|
|
and der y = b *. x -. x *. x *. y init 1.0
|
|
|
|
let pi = 3.141592653589793
|
|
|
|
(* Add another oscillator. *)
|
|
let hybrid harmonic(p) = x where
|
|
rec der x = v init 1.0
|
|
and der v = -2.0 *. pi *. x /. p init 0.0
|
|
|
|
(* Putting the harmonic besides the brusselator changes the output of the first.
|
|
To visualize:
|
|
|
|
dune exec ./run.exe -- -speedup 1000 -maxstep 1.0 | feedgnuplot --stream --domain --lines
|
|
*)
|
|
let hybrid print(t, x) =
|
|
present (period (100.0)) ->
|
|
(print_endline (String.concat " " (List.map string_of_float [t; x])))
|
|
else ()
|
|
|
|
let hybrid simu() =
|
|
let der t = 1.0 init 0.0 in
|
|
let (x, y) = brusselator(1.0, 2.001) in
|
|
let z = harmonic(1e-5) in
|
|
print(t, x)
|
|
|