feat: lift runtime into language, start of zelus 2024 compatibility

This commit is contained in:
Henri Saudubray 2025-07-11 11:21:07 +02:00
parent dc8d941b84
commit ffc583985a
Signed by: hms
GPG key ID: 7065F57ED8856128
37 changed files with 1154 additions and 143 deletions

View file

@ -0,0 +1,51 @@
let mp6 = -. (3.1416 /. 6.)
let g = 9.80665
let l = 0.2
let pi0 = mp6
let pi1 = 0.
let pi2 = 0.
let acc x = -. g /. l *. (sin x)
let hybrid cradle2() =
let rec der p0 = v0 init pi0 reset h01 -> last p1
and der v0 = acc(p0) init 0.0 reset h01 -> last v1
and der p1 = v1 init pi1 reset h01 -> last p0
and der v1 = acc(p1) init 0.0 reset h01 -> last v0
and h01 = up(last p0 -. last p1)
and init h = -0.1
and present h01 -> do h = -1.0 *. last h done
else do der h = 0.0 done
in (h, (p0, v0 /. 10.) , (p1, v1 /. 10.))
let hybrid cradle3() =
let rec der p0 = v0 init pi0 reset h01 -> last p1
and der v0 = acc(p0) init 0.0 reset h01 -> last v1
and der p1 = v1 init pi1 reset h01 -> last p0 | h12 -> last p2
and der v1 = acc(p1) init 0.0 reset h01 -> last v0 | h12 -> last v2
and der p2 = v2 init pi2 reset h12 -> last p1
and der v2 = acc(p2) init 0.0 reset h12 -> last v1
and h01 = up(last p0 -. last p1)
and h12 = up(last p1 -. last p2)
and init h1 = -0.1
and present h01 -> do h1 = -1.0 *. last h1 done else do der h1 = 0.0 done
and init h2 = -0.1
and present h12 -> do h2 = -1.0 *. last h2 done else do der h2 = 0.0 done
in (p0, p1, p2, h1, h2)
let node print(v, s) =
Format.printf "% .10e%s" v s
let hybrid main() =
let der t = 1.0 init 0.0 in
let (p0, p1, p2, h1, h2) = cradle3() in
present (period(0.05)) -> (
print(t, "\t");
print(p0, "\t");
print(p1, "\t");
print(p2, "\t");
print(h1, "\t");
print(h2, "\n")
); ()