From ace9e62e4f7982faba721cd1ae05965b7fcc6427 Mon Sep 17 00:00:00 2001 From: Ssalazar12 Date: Tue, 26 Nov 2024 11:29:44 +0100 Subject: [PATCH 1/3] start --- Hackaton/Project.toml | 4 ++++ Hackaton/src/Hackaton.jl | 5 +++++ 2 files changed, 9 insertions(+) create mode 100644 Hackaton/Project.toml create mode 100644 Hackaton/src/Hackaton.jl diff --git a/Hackaton/Project.toml b/Hackaton/Project.toml new file mode 100644 index 00000000..dbee3ac5 --- /dev/null +++ b/Hackaton/Project.toml @@ -0,0 +1,4 @@ +name = "Hackaton" +uuid = "54770aa0-30bd-4802-936f-8f0ece771688" +authors = ["Ssalazar12 "] +version = "0.1.0" diff --git a/Hackaton/src/Hackaton.jl b/Hackaton/src/Hackaton.jl new file mode 100644 index 00000000..bd193733 --- /dev/null +++ b/Hackaton/src/Hackaton.jl @@ -0,0 +1,5 @@ +module Hackaton + +greet() = print("Hello World!") + +end # module Hackaton From 26ee8fca0d559a2c6a7823aee79ca24d1f49ae02 Mon Sep 17 00:00:00 2001 From: Ssalazar12 Date: Tue, 26 Nov 2024 17:27:39 +0100 Subject: [PATCH 2/3] created function to save the data in an efficient manner in src/save_results.jl. We still need to save the number of solutions in the jl2 file --- src/save_results.jl | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 src/save_results.jl diff --git a/src/save_results.jl b/src/save_results.jl new file mode 100644 index 00000000..d319e0b9 --- /dev/null +++ b/src/save_results.jl @@ -0,0 +1,37 @@ +using FileIO + + +function export_results_dict(res::Result) + # takes an instance of the Result Structure and ommits the NaN's + # by creating a dictionary at each elelement of Result.solutions + # which only saves the non-Nan indices and values + + dimensions_parameters = size(res.solutions) + dimension_solutions = length(res.solutions[1]) + + # THis is a janky way of asking whether we sweep through 1 or 2 parameters + if length(dimensions_parameters) == 1 + M=Array{Dict}(undef, dimensions_parameters[1]) + elseif length(dimensions_parameters) == 2 + M=Array{Dict}(undef, dimensions_parameters[1],dimensions_parameters[2]) + end + + # Iterate over each of the array elements + for iter in eachindex(res.solutions) + A = res.solutions[iter] + value_list= [] + key_list = [] + # ask wether the solution is NaN + for i in 1:dimension_solutions + if isnan(A[i][1]) == false + push!(key_list, i) + push!(value_list, A[i]) + end + end + # save a dictionary at each element of the M matrix + M[iter] = Dict(key_list .=> value_list) + end + return M +end + + From 18fb2269632a671a204c38abe7380340642d3075 Mon Sep 17 00:00:00 2001 From: Ssalazar12 Date: Tue, 26 Nov 2024 17:29:45 +0100 Subject: [PATCH 3/3] added the number of solutions to the file --- src/save_results.jl | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/save_results.jl b/src/save_results.jl index d319e0b9..4d70d6d8 100644 --- a/src/save_results.jl +++ b/src/save_results.jl @@ -34,4 +34,13 @@ function export_results_dict(res::Result) return M end +# Example for some result obtained by result = get_steady_states(harmonic_eq2, varied, fixed) + +MM = export_results_dict(result); + +save("dict_version.jld2", Dict("solution_matrix" => MM, "classes" => result.classes, + "swept_parameters" => result.swept_parameters, "jacobian"=>result.jacobian, + "num_solutions" => length(result.solutions[1,1]))) + +