diff --git a/Project.toml b/Project.toml index d89a0b5..7a5f3e4 100644 --- a/Project.toml +++ b/Project.toml @@ -1,7 +1,7 @@ name = "SOLPS2ctrl" uuid = "a531d12f-ac8a-43e8-b6d9-bd121431dd49" +version = "2.2.3" authors = ["David Eldon "] -version = "2.2.2" [deps] Contour = "d38c429a-6771-53c6-b99e-75d170b6e991" @@ -16,6 +16,7 @@ JSON = "682c06a0-de6a-54ab-a142-c8b1cf79cde6" LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e" LsqFit = "2fda8390-95c7-5789-9bda-21331edee243" PhysicalConstants = "5ad8b20f-a522-5ce9-bfc9-ddf1d5bda6ab" +ProgressMeter = "92933f4c-e287-5a05-a399-4b506db050ca" SOLPS2imas = "09becab6-0636-4c23-a92a-2b3723265c31" Statistics = "10745b16-79ce-11e8-11f9-7d13ad32a3b2" Unitful = "1986cc42-f94f-5a68-af5c-568840ba703d" @@ -33,6 +34,7 @@ JSON = "0.21" LinearAlgebra = "1" LsqFit = "0.15.1" PhysicalConstants = "0.2" +ProgressMeter = "1.11.0" SOLPS2imas = "2.2" Statistics = "1" Unitful = "1" diff --git a/src/SOLPS2ctrl.jl b/src/SOLPS2ctrl.jl index 4aaf6c2..973a3f7 100644 --- a/src/SOLPS2ctrl.jl +++ b/src/SOLPS2ctrl.jl @@ -4,6 +4,7 @@ using IMAS: IMAS using SOLPS2imas: SOLPS2imas using EFIT: EFIT using Interpolations: Interpolations +using ProgressMeter export find_files_in_allowed_folders, geqdsk_to_imas!, preparation diff --git a/src/controllers.jl b/src/controllers.jl index 879465e..eb5c961 100644 --- a/src/controllers.jl +++ b/src/controllers.jl @@ -473,6 +473,7 @@ end Float64, (size(get_sys(plant).B, 2), size(target, 2)), ), + show_progress::Bool = false ) where {T, TE <: Discrete} Generic function to run closed loop simulations with provided `plant`, actuator @@ -483,6 +484,7 @@ adjustments to inputs and outputs of the plant model as explained in control loop at an arbitrary point in the loop. `noise_plant_inp`, `noise_plant_out`, and `noise_ctrl_out` allow addition of predefined noise waveforms at the input of plant, output of plant, and the output of controller respectively. +If show_progress is set to true a progress bar will be shown. """ function run_closed_loop_sim( plant::Plant, @@ -506,6 +508,7 @@ function run_closed_loop_sim( Float64, (size(get_sys(plant).B, 2), size(target, 2)), ), + show_progress::Bool = false ) # Take the plant, actuator, and controller by value plant = deepcopy(plant) @@ -519,6 +522,7 @@ function run_closed_loop_sim( plant_out = zeros(Float64, (size(plant_sys.C, 1), length(target))) # Closed loop simulation + prog = Progress(size(target,2); showspeed=true, enabled=show_progress) for ii ∈ axes(target, 2) # Actuation plant_inp[:, ii] = @@ -534,6 +538,7 @@ function run_closed_loop_sim( ctrl(; ii, target, plant_inp, plant_out, act, inp_feedforward ) .+ noise_ctrl_out[:, ii+1] end + next!(prog) end return Dict( :plant => plant,