diff --git a/.gitignore b/.gitignore index fe15833de..1bdf03539 100644 --- a/.gitignore +++ b/.gitignore @@ -52,3 +52,4 @@ data/prob_dynamic_3_seg.bin.default data/ram_air_kite_foil_cd_polar.csv data/ram_air_kite_foil_cl_polar.csv data/ram_air_kite_foil_cm_polar.csv +data/prob_dynamic_3_seg.jld2 diff --git a/Project.toml b/Project.toml index 8bcb2afd3..cf4c5b1e0 100644 --- a/Project.toml +++ b/Project.toml @@ -15,6 +15,7 @@ DiscretePIDs = "c1363496-6848-4723-8758-079b737f6baf" DocStringExtensions = "ffbed154-4ef7-542d-bbb7-c09d3a79fcae" FiniteDiff = "6a86dc24-6348-571c-b903-95158fe2bd41" Interpolations = "a98d9a8b-a2ab-59e6-89dd-64a1c18fca59" +JLD2 = "033835bb-8acc-5ee8-8aae-3f567f8a3819" KitePodModels = "9de5dc81-f971-414a-927b-652b2f41c539" KiteUtils = "90980105-b163-44e5-ba9f-8b1c83bb0533" LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e" @@ -60,6 +61,7 @@ DiscretePIDs = "0.1.5" DocStringExtensions = "0.9.4" Documenter = "1.10.1" Interpolations = "0.15.1" +JLD2 = "0.5.12" KitePodModels = "0.3.8" KiteUtils = "0.10.2" LaTeXStrings = "1.4.0" diff --git a/src/ram_air_kite.jl b/src/ram_air_kite.jl index 1a72b5822..cac1467fb 100644 --- a/src/ram_air_kite.jl +++ b/src/ram_air_kite.jl @@ -393,11 +393,14 @@ function init_sim!(s::RamAirKite, measure::Measurement; prn=true, precompile=fal dt = SimFloat(1/s.set.sample_freq) if prn @info "Creating ODEProblem" - @time s.prob = ODEProblem(s.sys, defaults, (0.0, dt); guesses) + @time begin expr = ODEProblemExpr(s.sys, defaults, (0.0, dt); guesses); s.prob = eval(expr) end else - s.prob = ODEProblem(s.sys, defaults, (0.0, dt); guesses) + expr = ODEProblemExpr(s.sys, defaults, (0.0, dt); guesses); s.prob = eval(expr) end - serialize(prob_path, s.prob) + # serialize(prob_path, s.prob) + # ODEProblemExpr + save_prob(prob_path, expr) + s.integrator = nothing end prob_path = joinpath(KiteUtils.get_data_path(), get_prob_name(s.set; precompile)) @@ -458,7 +461,8 @@ function reinit!(s::RamAirKite, measure::Measurement; prn=true, reload=true, pre prob_path = joinpath(KiteUtils.get_data_path(), get_prob_name(s.set; precompile)) !ispath(prob_path) && throw(ArgumentError("$prob_path not found. Run init_sim!(s::RamAirKite) first.")) try - s.prob = deserialize(prob_path) + # s.prob = deserialize(prob_path) + s.prob = load_prob(prob_path) catch e @warn "Failure to deserialize $prob_path !" throw(e) @@ -559,9 +563,9 @@ function get_prob_name(set::Settings; precompile=false) suffix = ".default" end if set.quasi_static - return "prob_static_" * string(set.segments) * "_seg.bin" * suffix + return "prob_static_" * string(set.segments) * "_seg.jld2" * suffix else - return "prob_dynamic_" * string(set.segments) * "_seg.bin" * suffix + return "prob_dynamic_" * string(set.segments) * "_seg.jld2" * suffix end end