feat (exm): sincos example

This commit is contained in:
Henri Saudubray 2025-04-29 15:33:57 +02:00
parent 9a0d22e880
commit d398989ece
Signed by: hms
GPG key ID: 7065F57ED8856128
6 changed files with 87 additions and 58 deletions

View file

@ -11,13 +11,14 @@ let inplace = ref false
let steps = ref 1
let model = ref ""
let gt0i v i = v := if i <= 0 then 1 else i
let gt0f v f = v := if f <= 0.0 then 1.0 else f
let hasmodel = ref false
let gt0i v i = v := if i <= 0 then 1 else i
let gt0f v f = v := if f <= 0.0 then 1.0 else f
let hasmodel = ref false
let modelargs = ref []
let set_model s =
if !hasmodel then raise (Arg.Bad "Too many arguments.") else
model := s; hasmodel := true
if !hasmodel then modelargs := s :: !modelargs
else model := s; hasmodel := true
let opts = [
"-sample", Arg.Int (gt0i sample), "n \tSample count (default=10)";
@ -37,10 +38,13 @@ let output = Output.print !sample
let c = StatefulRK45.(if !inplace then InPlace.csolve else Functional.csolve)
let z = StatefulZ.(Functional.zsolve)
let s = Solver.solver_c c z
open Format
let m = match !model with
| "ball" -> Ball.bouncing_ball ()
| "vdp" -> Vdp.van_der_pol ()
| _ -> raise (Arg.Bad (Format.sprintf "Unknown model: %s." !model))
| "ball" -> Ball.bouncing_ball
| "vdp" -> Vdp.van_der_pol
| "sincos" -> Sincos.sinus_cosinus
| _ -> eprintf "Unknown model: %s\n" !model; exit 2
let m = try m !modelargs with Invalid_argument s -> eprintf "%s\n" s; exit 2
let state = if !inplace then (module State.InPlaceSimState : State.SimState)
else (module State.FunctionalSimState : State.SimState)