diff --git a/src/base/simulation_results.jl b/src/base/simulation_results.jl index 3c9efe157..75ac4a5ef 100644 --- a/src/base/simulation_results.jl +++ b/src/base/simulation_results.jl @@ -70,10 +70,17 @@ function post_proc_state_series( ) global_state_index = get_global_index(res) if !haskey(global_state_index, ref[1]) - @error "$(keys(global_state_index))" - error("State $(ref[2]) device $(ref[1]) not found in the system. ") + available_devices = join(keys(global_state_index), ", ") + error("Device $(ref[1]) not found. Available devices: $available_devices") end - ix = get(global_state_index[ref[1]], ref[2], 0) + + state_dict = global_state_index[ref[1]] + if !haskey(state_dict, ref[2]) + available_states = join(keys(state_dict), ", ") + error("State $(ref[2]) not found in device $(ref[1]). Available states: $available_states") + end + + ix = state_dict[ref[2]] return _post_proc_state_series(get_solution(res), ix, dt, unique_timestamps) end diff --git a/src/post_processing/post_proc_generator.jl b/src/post_processing/post_proc_generator.jl index 731ed4e8b..2ceb8d5eb 100644 --- a/src/post_processing/post_proc_generator.jl +++ b/src/post_processing/post_proc_generator.jl @@ -1056,7 +1056,7 @@ function _mechanical_torque( name::String, res::SimulationResults, dt::Union{Nothing, Float64, Vector{Float64}}, - unique_timestamps::Bool, + unique_timestamps::Bool = true, ) # TODO: This will not plot correctly when changing P_ref in a callback ts, _ = _post_proc_state_series(res.solution, 1, dt, unique_timestamps) @@ -1076,7 +1076,7 @@ function _mechanical_torque( name::String, res::SimulationResults, dt::Union{Nothing, Float64, Vector{Float64}}, - unique_timestamps::Bool, + unique_timestamps::Bool = true, ) # Get params Tc = PSY.get_Tc(tg) @@ -1105,7 +1105,7 @@ function _mechanical_torque( name::String, res::SimulationResults, dt::Union{Nothing, Float64, Vector{Float64}}, - unique_timestamps::Bool, + unique_timestamps::Bool = true, ) # TODO: This will not plot correctly when changing P_ref in a callback # Get params @@ -1135,7 +1135,7 @@ function _mechanical_torque( name::String, res::SimulationResults, dt::Union{Nothing, Float64, Vector{Float64}}, - unique_timestamps::Bool, + unique_timestamps::Bool = true, ) # TODO: This will not plot correctly when changing P_ref in a callback # Get params @@ -1171,7 +1171,7 @@ function _mechanical_torque( name::String, res::SimulationResults, dt::Union{Nothing, Float64, Vector{Float64}}, - unique_timestamps::Bool, + unique_timestamps::Bool = true, ) # Get params D_turb = PSY.get_D_turb(tg) @@ -1192,7 +1192,7 @@ function _mechanical_torque( name::String, res::SimulationResults, dt::Union{Nothing, Float64}, - unique_timestamps::Bool, + unique_timestamps::Bool = true, ) ts, x_a3 = post_proc_state_series(res, (name, :x_a3), dt, unique_timestamps) return ts, x_a3 @@ -1222,7 +1222,7 @@ function _mechanical_torque( name::String, res::SimulationResults, dt::Union{Nothing, Float64, Vector{Float64}}, - unique_timestamps::Bool, + unique_timestamps::Bool = true, ) # Get params q_nl = PSY.get_q_nl(tg) @@ -1249,7 +1249,7 @@ function _mechanical_torque( name::String, res::SimulationResults, dt::Union{Nothing, Float64, Vector{Float64}}, - unique_timestamps::Bool, + unique_timestamps::Bool = true, ) # Get params D_turb = PSY.get_D_turb(tg) @@ -1281,7 +1281,7 @@ function _mechanical_torque( name::String, res::SimulationResults, dt::Union{Nothing, Float64, Vector{Float64}}, - unique_timestamps::Bool, + unique_timestamps::Bool = true, ) # Get params D = PSY.get_D(tg)