feat: final commit
This commit is contained in:
parent
416d97c513
commit
e9bb791be1
3 changed files with 58 additions and 33 deletions
55
exm/main.zls
55
exm/main.zls
|
|
@ -9,7 +9,7 @@
|
|||
- Model discrete systems and their continuous environment
|
||||
- Research language, design space for hybrid system modelers
|
||||
- Compilation to OCaml, execution with an off-the-shelf ODE solver
|
||||
- Developed by the Inria PARKAS team *)
|
||||
- Developed by M. Pouzet and T. Bourke in the Inria PARKAS team *)
|
||||
|
||||
|
||||
|
||||
|
|
@ -20,6 +20,24 @@
|
|||
|
||||
|
||||
|
||||
|
||||
(** Plan:
|
||||
|
||||
- Zélus, the synchronous part
|
||||
- Physical simulation, ODEs, and ODE solvers
|
||||
- Zélus, the hybrid part
|
||||
- Mixing discrete and continuous time, zero-crossing detection
|
||||
- Informal operational semantics
|
||||
- Low-level representation and runtime *)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
(** Synchronous language kernel _à la_ Lustre:
|
||||
- programs are Mealy machines (outputs on each transition)
|
||||
- variables represent streams of values in time *)
|
||||
|
|
@ -27,9 +45,9 @@
|
|||
let node incr x = y where
|
||||
y = x + 1
|
||||
|
||||
(* x │ 8 3 2 7 5 3 …
|
||||
───┼─────────────────────
|
||||
y │ 9 4 3 8 6 4 … *)
|
||||
(* x │ 8 3 2 7 5 3 …
|
||||
────────┼─────────────────────
|
||||
incr x │ 9 4 3 8 6 4 … *)
|
||||
|
||||
|
||||
|
||||
|
|
@ -45,6 +63,7 @@ let node accumulate x = z where
|
|||
──────────────┼─────────────────────
|
||||
pre x │ 1 2 5 2 5 …
|
||||
0 -> x │ 0 2 5 2 5 3 …
|
||||
0 -> pre x │ 0 1 2 5 2 5 …
|
||||
accumulate x │ 1 3 8 10 15 18 … *)
|
||||
|
||||
let node fib () = n where
|
||||
|
|
@ -52,7 +71,6 @@ let node fib () = n where
|
|||
|
||||
(** - causality loops are forbidden ([rec x = x]) *)
|
||||
|
||||
|
||||
(** - we can reset streams at will *)
|
||||
|
||||
let node stay x = y where (* output the first value forever *)
|
||||
|
|
@ -77,11 +95,10 @@ let node loop x = y where
|
|||
|
||||
|
||||
|
||||
(** Math/physics reminder!
|
||||
(** Calculus reminder:
|
||||
|
||||
- Ordinary differential equations (ODEs), initial value problems
|
||||
- Zero-crossing event basics
|
||||
- Background on solvers *)
|
||||
- A little background on solvers *)
|
||||
|
||||
|
||||
|
||||
|
|
@ -94,6 +111,7 @@ let node loop x = y where
|
|||
|
||||
let dt = 0.01 (* Integration step *)
|
||||
let g = 9.81 (* Gravitational constant *)
|
||||
|
||||
let node f_integr (x0, x') = x where (* Forward Euler integrator *)
|
||||
rec x = x0 -> pre (x +. x' *. dt)
|
||||
|
||||
|
|
@ -112,12 +130,11 @@ let node bouncing_ball (p0, v0) = p where
|
|||
|
||||
|
||||
|
||||
|
||||
(** Cumbersome, and error-prone! *)
|
||||
|
||||
let node sincos () = (sin, cos) where
|
||||
rec sin = f_integr(0.0, cos)
|
||||
and cos = f_integr(1.0, -. sin)
|
||||
rec sin = f_integr (0.0, cos) (** [(dsin/dt) t = cos t, sin 0 = 0] *)
|
||||
and cos = f_integr (1.0, -. sin) (** [(dcos/dt) t = -sin t, cos 0 = 1] *)
|
||||
|
||||
|
||||
|
||||
|
|
@ -136,10 +153,11 @@ let hybrid integr (x0, x') = x where
|
|||
let hybrid time () = t where
|
||||
der t = 1.0 init 0.0
|
||||
|
||||
let hybrid position (p0, v0, a) = p where
|
||||
rec der p = v init p0
|
||||
and der v = a init v0
|
||||
let hybrid falling_ball (p0, v0) = p where
|
||||
rec der p = v init p0
|
||||
and der v = -. g init v0
|
||||
|
||||
(** How do we mix discrete time and continuous time together? *)
|
||||
|
||||
|
||||
|
||||
|
|
@ -160,12 +178,3 @@ let hybrid time_bounces (p0, v0) = (p, b) where
|
|||
b = t -. last b
|
||||
done
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
(** - w FIXME e can mix discrete and continuous behaviours *)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue