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:
parent
ba5db5bd99
commit
f2c545ce2c
49 changed files with 12377 additions and 1898 deletions
17
exm/zelus/odes/dune
Normal file
17
exm/zelus/odes/dune
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
(env
|
||||
(dev
|
||||
(flags
|
||||
(:standard -w -a))))
|
||||
|
||||
(rule
|
||||
(targets odes.ml odes.zci)
|
||||
(deps
|
||||
(:zl odes.zls)
|
||||
(:zli solve.zli))
|
||||
(action
|
||||
(run zeluc %{zli} %{zl})))
|
||||
|
||||
(executable
|
||||
(public_name odes.exe)
|
||||
(name main)
|
||||
(libraries std))
|
||||
9
exm/zelus/odes/main.ml
Normal file
9
exm/zelus/odes/main.ml
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
|
||||
open Std
|
||||
|
||||
let input _ = ()
|
||||
let output () = ()
|
||||
|
||||
let () = Runtime.go_discrete input Odes.main output
|
||||
|
||||
|
||||
37
exm/zelus/odes/odes.zls
Normal file
37
exm/zelus/odes/odes.zls
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
|
||||
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
|
||||
26
exm/zelus/odes/solve.zli
Normal file
26
exm/zelus/odes/solve.zli
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
|
||||
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 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
|
||||
16
exm/zelus/odes/ztypes.ml
Normal file
16
exm/zelus/odes/ztypes.ml
Normal 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
|
||||
Loading…
Add table
Add a link
Reference in a new issue