feat: a LOT of stuff (final report, examples, simulation of a single assert, move from node instances to node definitions, etc.)

This commit is contained in:
Henri Saudubray 2025-08-20 18:20:46 +02:00
parent ba5db5bd99
commit f2c545ce2c
Signed by: hms
GPG key ID: 7065F57ED8856128
49 changed files with 12377 additions and 1898 deletions

12
exm/zelus/parallel/dune Normal file
View file

@ -0,0 +1,12 @@
(env (dev (flags (:standard -w -a))))
(rule
(targets main.ml parallel.ml parallel.zci)
(deps (:zl parallel.zls) (:zli solve.zli))
(action
(run zeluc -deps -s main %{zli} %{zl})))
(executable
(public_name parallel.exe)
(name main)
(libraries std))

View file

@ -0,0 +1,34 @@
(* 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)

View file

@ -0,0 +1,27 @@
type time = float
type 'a value
type 'a signal = 'a value option
type 'a signal_t = ('a value * time) option
val horizon : 'a value -> time
val make : time * (time -> 'a) -> 'a value
val apply : 'a value * time -> 'a
val sustain : 'a -> 'a value
val solve_ode45 : ('a -C-> 'b) -S-> 'a signal -D-> 'b signal_t
val solve_sundials : ('a -C-> 'b) -S-> 'a signal -D-> 'b signal_t
val synchr :
('a signal -D-> 'b signal_t) -S->
('a signal -D-> 'c signal_t) -S->
'a signal -D-> ('b * 'c) signal_t
val iter : int -S-> ('a -D-> unit) -S-> 'a signal_t -D-> unit
val iter_t : int -S-> (time * 'a -D-> unit) -S-> 'a signal_t -D-> unit
val check : int -S-> ('a -D-> bool) -S-> 'a signal_t -D-> unit
val check_t : int -S-> (time * 'a -D-> bool) -S-> 'a signal_t -D-> unit
val period' : float -S-> ('a -D-> unit) -S-> 'a signal_t -D-> unit
val period'_t : float -S-> (time * 'a -D-> unit) -S-> 'a signal_t -D-> unit

View file

@ -0,0 +1,16 @@
include Std
include Ztypes
include Solvers
module type IGNORE = sig end
module Defaultsolver : IGNORE = struct end
module Zlsrun = struct
module Make (S : IGNORE) = struct
let go _ = ()
end
end
module Stdlib = struct
type nonrec 'a option = 'a option
end