feat: re-hide inner states, properly reset sundials
This commit is contained in:
parent
80d4aef23f
commit
76dc461d44
14 changed files with 162 additions and 253 deletions
11
exm/ball.ml
11
exm/ball.ml
|
|
@ -40,17 +40,16 @@ let step ({ zin; lx; _ } as s) zfalse =
|
|||
of_array [| -. 0.8 *. lx.{0}; 0.0; lx.{2}; lx.{3} |] else lx in
|
||||
of_array [| s.lx.{1} |], { zin=zfalse; lx; i=false }
|
||||
|
||||
let bouncing_ball ()
|
||||
: (state, _, _, carray, carray, carray, zarray, carray) hnode
|
||||
= let yd = cmake csize in
|
||||
let bouncing_ball () : (_, _, carray, carray, carray, zarray, carray) hnode =
|
||||
let yd = cmake csize in
|
||||
let zout = cmake zsize in
|
||||
let zfalse = zmake 1 in
|
||||
let fder _ _ y = fder y yd in
|
||||
let fzer _ _ y = fzer y zout in
|
||||
let step s _ = step s zfalse in
|
||||
let init _ = { zin=zfalse; lx=of_array [|y'0;y0;x'0;x0|]; i=true } in
|
||||
let reset _ _ = init () in
|
||||
HNode { init; fder; fzer; fout; step; reset; horizon;
|
||||
let state = { zin=zfalse; lx=of_array [|y'0;y0;x'0;x0|]; i=true } in
|
||||
let reset _ _ = state in
|
||||
HNode { state; fder; fzer; fout; step; reset; horizon;
|
||||
jump; cset; cget; zset; csize; zsize }
|
||||
|
||||
let errmsg = "Too many arguments for the model (needed: 0)"
|
||||
|
|
|
|||
|
|
@ -3,6 +3,5 @@ open Solvers.Zls
|
|||
|
||||
module type Model =
|
||||
sig
|
||||
type state
|
||||
val init : string list -> (state, 'b, 'c, carray, carray, carray, zarray, carray) hnode
|
||||
val init : string list -> ('b, 'c, carray, carray, carray, zarray, carray) hnode
|
||||
end
|
||||
|
|
|
|||
|
|
@ -29,9 +29,9 @@ let sinus_cosinus theta0 omega =
|
|||
let fder _ _ y = fder y yd omega in
|
||||
let fzer _ _ _ = zout in
|
||||
let step s _ = step s sin0 cos0 in
|
||||
let init _ = { sx=of_array [| sin0; cos0; 0.0 |]; si=true } in
|
||||
let reset _ _ = init () in
|
||||
HNode { init; fder; fzer; fout; step; reset; horizon;
|
||||
let state = { sx=of_array [| sin0; cos0; 0.0 |]; si=true } in
|
||||
let reset _ _ = state in
|
||||
HNode { state; fder; fzer; fout; step; reset; horizon;
|
||||
jump; cset; cget; zset; csize; zsize }
|
||||
|
||||
let errmsg_invalid = "Invalid arguments to model (needed: 2 floats)"
|
||||
|
|
|
|||
|
|
@ -65,7 +65,7 @@ let sqrt () =
|
|||
s_zin = zmake 1 } in
|
||||
let reset _ _ = s_init in
|
||||
let jump _ = true in
|
||||
HNode { init = (fun _ -> s_init);
|
||||
HNode { state = s_init;
|
||||
fder = (fun s _ y -> fder s y yd; yd);
|
||||
fzer = (fun s _ y -> fzero s y zout; zout);
|
||||
fout = (fun s _ y -> fout s y);
|
||||
|
|
|
|||
11
exm/vdp.ml
11
exm/vdp.ml
|
|
@ -28,15 +28,14 @@ let zset s _ = s
|
|||
let jump _ = true
|
||||
let horizon _ = max_float
|
||||
|
||||
let van_der_pol ()
|
||||
: (state, _, _, carray, carray, carray, zarray, carray) hnode
|
||||
= let yd = cmake csize in
|
||||
let van_der_pol () : (_, _, carray, carray, carray, zarray, carray) hnode =
|
||||
let yd = cmake csize in
|
||||
let zout = cmake zsize in
|
||||
let fder _ _ y = fder y yd in
|
||||
let fzer _ _ _ = zout in
|
||||
let init _ = { lx=of_array [| x0; y0 |]; i=true } in
|
||||
let reset _ _ = init () in
|
||||
HNode { init; fder; fzer; fout; step; reset; horizon;
|
||||
let state = { lx=of_array [| x0; y0 |]; i=true } in
|
||||
let reset _ _ = state in
|
||||
HNode { state; fder; fzer; fout; step; reset; horizon;
|
||||
jump; cset; cget; zset; csize; zsize }
|
||||
|
||||
let errmsg = "Too many arguments for the model (needed: 0)"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue