feat: cleanup

This commit is contained in:
Henri Saudubray 2025-04-25 14:25:55 +02:00
parent e07f165494
commit c867859cce
Signed by: hms
GPG key ID: 7065F57ED8856128
3 changed files with 27 additions and 18 deletions

View file

@ -1,7 +1,6 @@
open Hsim
open Examples
open Types
let sample = ref 10
let stop = ref 30.0
@ -23,27 +22,11 @@ let () =
try Arg.parse (Arg.align opts) (fun _ -> ()) errmsg
with _ -> exit 2
let print_samples n { start; length; u } =
if !debug then begin
if length <= 0.0 then
Format.printf "\nD : %.20e\n\n" start
else Format.printf "\nC : %.20e to %.20e\n\n" start (start +. length);
end;
Format.printf "%.20e\t% .20e\n" start (u 0.0).{0};
if length <= 0.0 then ()
else let step = length /. (float_of_int n) in
let rec loop i =
if i > n then ()
else let t = float_of_int i *. step in
(Format.printf "%.20e\t" (start +. t); Format.printf "% .20e\n" (u t).{0};
loop (i+1)) in
loop 1
let () =
let csolver = StatefulRK45.Functional.csolve in
let zsolver = StatefulZ.Functional.zsolve in
let solver = Solver.solver_c csolver zsolver in
let model = Ball.bouncing_ball () in
let open Sim.LazySim(State.FunctionalSimState) in
run_until model (Solver.solver_from_c solver) !stop (print_samples !sample)
run_until model (Solver.solver_from_c solver) !stop (Output.print !sample)