diff --git a/src/base/simulation_results.jl b/src/base/simulation_results.jl index 3413991eb..bd0d1f5bd 100644 --- a/src/base/simulation_results.jl +++ b/src/base/simulation_results.jl @@ -36,18 +36,24 @@ Internal function to obtain as a Vector of Float64 of a specific state. It recei global index for a state. """ -function _post_proc_state_series(solution, ix::Int, dt::Union{Nothing, Float64}) - if dt === nothing - ix_t = unique(i -> solution.t[i], eachindex(solution.t)) - ts = solution.t[ix_t] - state = solution[ix, ix_t] - else - ts = range(0; stop = solution.t[end], step = dt) - state = solution(collect(ts); idxs = ix) - end +function _post_proc_state_series(solution, ix::Int, dt::Nothing) + ix_t = unique(i -> solution.t[i], eachindex(solution.t)) + ts = solution.t[ix_t] + state = solution[ix, ix_t] return ts, state end +function _post_proc_state_series(solution, ix::Int, dt::Float64) + ts = range(0; stop = solution.t[end], step = dt) + state = solution(collect(ts); idxs = ix) + return ts, state +end + +function _post_proc_state_series(solution, ix::Int, dt::Vector{Float64}) + state = solution(dt; idxs = ix) + return dt, state +end + """ Function to obtain the state time series of a specific state. It receives the simulation, and a tuple containing the name of the Dynamic Device and the symbol of the state. @@ -55,7 +61,7 @@ containing the name of the Dynamic Device and the symbol of the state. function post_proc_state_series( res::SimulationResults, ref::Tuple{String, Symbol}, - dt::Union{Nothing, Float64}, + dt::Union{Nothing, Float64, Vector{Float64}}, ) global_state_index = get_global_index(res) if !haskey(global_state_index, ref[1]) @@ -73,7 +79,7 @@ of the Dynamic Device. function post_proc_voltage_current_series( res::SimulationResults, name::String, - dt::Union{Nothing, Float64}, + dt::Union{Nothing, Float64, Vector{Float64}}, )::NTuple{5, Vector{Float64}} #Note: Type annotation since get_dynamic_injector is type unstable and solution is Union{Nothing, DAESol} system = get_system(res) @@ -104,7 +110,7 @@ function post_proc_voltage_series( solution, bus_ix::Int, n_buses::Int, - dt::Union{Nothing, Float64}, + dt::Union{Nothing, Float64, Vector{Float64}}, ) bus_ix < 0 && error("Bus number $(bus_number) not found.") ts, V_R = _post_proc_state_series(solution, bus_ix, dt) @@ -120,7 +126,7 @@ string name of the Dynamic Injection device. function post_proc_real_current_series( res::SimulationResults, name::String, - dt::Union{Nothing, Float64}, + dt::Union{Nothing, Float64, Vector{Float64}}, ) ts, _, _, I_R, _ = post_proc_voltage_current_series(res, name, dt) return ts, I_R @@ -133,7 +139,7 @@ string name of the Dynamic Injection device. function post_proc_imaginary_current_series( res::SimulationResults, name::String, - dt::Union{Nothing, Float64}, + dt::Union{Nothing, Float64, Vector{Float64}}, ) ts, _, _, _, I_I = post_proc_voltage_current_series(res, name, dt) return ts, I_I @@ -147,7 +153,7 @@ string name of the Dynamic Injection device. function post_proc_activepower_series( res::SimulationResults, name::String, - dt::Union{Nothing, Float64}, + dt::Union{Nothing, Float64, Vector{Float64}}, ) ts, V_R, V_I, I_R, I_I = post_proc_voltage_current_series(res, name, dt) return ts, V_R .* I_R + V_I .* I_I @@ -161,7 +167,7 @@ string name of the Dynamic Injection device. function post_proc_reactivepower_series( res::SimulationResults, name::String, - dt::Union{Nothing, Float64}, + dt::Union{Nothing, Float64, Vector{Float64}}, ) ts, V_R, V_I, I_R, I_I = post_proc_voltage_current_series(res, name, dt) return ts, V_I .* I_R - V_R .* I_I @@ -175,7 +181,7 @@ string name of the Dynamic Injection device. function post_proc_field_current_series( res::SimulationResults, name::String, - dt::Union{Nothing, Float64}, + dt::Union{Nothing, Float64, Vector{Float64}}, ) system = get_system(res) bus_lookup = get_bus_lookup(res) @@ -197,7 +203,7 @@ string name of the Dynamic Injection device. function post_proc_field_voltage_series( res::SimulationResults, name::String, - dt::Union{Nothing, Float64}, + dt::Union{Nothing, Float64, Vector{Float64}}, ) system = get_system(res) device = PSY.get_component(PSY.StaticInjection, system, name) @@ -214,7 +220,7 @@ name of the Dynamic Injection device. function post_proc_pss_output_series( res::SimulationResults, name::String, - dt::Union{Nothing, Float64}, + dt::Union{Nothing, Float64, Vector{Float64}}, ) system = get_system(res) device = PSY.get_component(PSY.StaticInjection, system, name) @@ -231,7 +237,7 @@ string name of the Dynamic Injection device. function post_proc_mechanical_torque_series( res::SimulationResults, name::String, - dt::Union{Nothing, Float64}, + dt::Union{Nothing, Float64, Vector{Float64}}, ) system = get_system(res) device = PSY.get_component(PSY.StaticInjection, system, name) @@ -247,7 +253,7 @@ The current is computed through the `from` bus into the `to` bus. function post_proc_branch_series( res::SimulationResults, name::String, - dt::Union{Nothing, Float64}, + dt::Union{Nothing, Float64, Vector{Float64}}, ) system = get_system(res) bus_lookup = get_bus_lookup(res) @@ -275,7 +281,7 @@ Function to compute the frequency of a Dynamic Injection component. function post_proc_frequency_series( res::SimulationResults, name::String, - dt::Union{Nothing, Float64}, + dt::Union{Nothing, Float64, Vector{Float64}}, ) system = get_system(res) device = PSY.get_component(PSY.StaticInjection, system, name) @@ -290,7 +296,7 @@ end get_state_series( res::SimulationResults, ref::Tuple{String, Symbol}; - dt::Union{Nothing, Float64} = nothing + dt::Union{Nothing, Float64, Vector{Float64}} = nothing ) end diff --git a/src/post_processing/post_proc_generator.jl b/src/post_processing/post_proc_generator.jl index 105f8f811..1ad172de7 100644 --- a/src/post_processing/post_proc_generator.jl +++ b/src/post_processing/post_proc_generator.jl @@ -8,7 +8,7 @@ function compute_output_current( dynamic_device::I, ::Vector{Float64}, ::Vector{Float64}, - ::Union{Nothing, Float64}, + ::Union{Nothing, Float64, Vector{Float64}}, ) where {I <: PSY.DynamicInjection} #Return error @@ -27,7 +27,7 @@ function compute_output_current( dynamic_device::G, V_R::Vector{Float64}, V_I::Vector{Float64}, - dt::Union{Nothing, Float64}, + dt::Union{Nothing, Float64, Vector{Float64}}, ) where {G <: PSY.DynamicGenerator} #Obtain Data @@ -59,7 +59,7 @@ function compute_output_current( dynamic_device::PSY.AggregateDistributedGenerationA, V_R::Vector{Float64}, V_I::Vector{Float64}, - dt::Union{Nothing, Float64}, + dt::Union{Nothing, Float64, Vector{Float64}}, ) #Obtain Data @@ -152,7 +152,7 @@ function compute_field_current( dynamic_device::G, V_R::Vector{Float64}, V_I::Vector{Float64}, - dt::Union{Nothing, Float64}, + dt::Union{Nothing, Float64, Vector{Float64}}, ) where {G <: PSY.DynamicGenerator} #Obtain Data @@ -171,7 +171,7 @@ the dynamic device and bus voltage. It is dispatched for device type to compute function compute_field_voltage( res::SimulationResults, dynamic_device::G, - dt::Union{Nothing, Float64}, + dt::Union{Nothing, Float64, Vector{Float64}}, ) where {G <: PSY.DynamicGenerator} #Get AVR @@ -187,7 +187,7 @@ the dynamic device and bus voltage. It is dispatched for device type to compute function compute_pss_output( res::SimulationResults, dynamic_device::G, - dt::Union{Nothing, Float64}, + dt::Union{Nothing, Float64, Vector{Float64}}, ) where {G <: PSY.DynamicGenerator} #Get PSS @@ -203,7 +203,7 @@ the dynamic device and bus voltage. It is dispatched for device type to compute function compute_mechanical_torque( res::SimulationResults, dynamic_device::G, - dt::Union{Nothing, Float64}, + dt::Union{Nothing, Float64, Vector{Float64}}, ) where {G <: PSY.DynamicGenerator} #Get TG @@ -218,7 +218,7 @@ Function to obtain the output frequency time series of a DynamicGenerator function compute_frequency( res::SimulationResults, dyn_device::G, - dt::Union{Nothing, Float64}, + dt::Union{Nothing, Float64, Vector{Float64}}, ) where {G <: PSY.DynamicGenerator} name = PSY.get_name(dyn_device) ts, ω = post_proc_state_series(res, (name, :ω), dt) @@ -236,7 +236,7 @@ function _machine_current( V_I::Vector{Float64}, base_power_ratio::Float64, res::SimulationResults, - dt::Union{Nothing, Float64}, + dt::Union{Nothing, Float64, Vector{Float64}}, ) ts, δ = post_proc_state_series(res, (name, :δ), dt) @@ -270,7 +270,7 @@ function _machine_current( V_I::Vector{Float64}, base_power_ratio::Float64, res::SimulationResults, - dt::Union{Nothing, Float64}, + dt::Union{Nothing, Float64, Vector{Float64}}, ) ts, δ = post_proc_state_series(res, (name, :δ), dt) _, eq_p = post_proc_state_series(res, (name, :eq_p), dt) @@ -308,7 +308,7 @@ function _machine_current( V_I::Vector{Float64}, base_power_ratio::Float64, res::SimulationResults, - dt::Union{Nothing, Float64}, + dt::Union{Nothing, Float64, Vector{Float64}}, ) ts, δ = post_proc_state_series(res, (name, :δ), dt) _, eq_pp = post_proc_state_series(res, (name, :eq_pp), dt) @@ -349,7 +349,7 @@ function _machine_current( ::Vector{Float64}, base_power_ratio::Float64, res::SimulationResults, - dt::Union{Nothing, Float64}, + dt::Union{Nothing, Float64, Vector{Float64}}, ) ts, δ = post_proc_state_series(res, (name, :δ), dt) _, eq_pp = post_proc_state_series(res, (name, :eq_pp), dt) @@ -387,7 +387,7 @@ function _machine_current( ::Vector{Float64}, base_power_ratio::Float64, res::SimulationResults, - dt::Union{Nothing, Float64}, + dt::Union{Nothing, Float64, Vector{Float64}}, ) ts, δ = post_proc_state_series(res, (name, :δ), dt) _, eq_p = post_proc_state_series(res, (name, :eq_p), dt) @@ -429,7 +429,7 @@ function _machine_current( V_I::Vector{Float64}, base_power_ratio::Float64, res::SimulationResults, - dt::Union{Nothing, Float64}, + dt::Union{Nothing, Float64, Vector{Float64}}, ) ts, δ = post_proc_state_series(res, (name, :δ), dt) _, eq_p = post_proc_state_series(res, (name, :eq_p), dt) @@ -481,7 +481,7 @@ function _machine_current( V_I::Vector{Float64}, base_power_ratio::Float64, res::SimulationResults, - dt::Union{Nothing, Float64}, + dt::Union{Nothing, Float64, Vector{Float64}}, ) ts, δ = post_proc_state_series(res, (name, :δ), dt) _, eq_p = post_proc_state_series(res, (name, :eq_p), dt) @@ -526,7 +526,7 @@ function _field_current( V_R::Vector{Float64}, V_I::Vector{Float64}, res::SimulationResults, - dt::Union{Nothing, Float64}, + dt::Union{Nothing, Float64, Vector{Float64}}, ) where {M <: PSY.Machine} @warn("Field current is not supported in the machine type $(M). Returning zeros.") ts, _ = post_proc_state_series(res, (name, :δ), dt) @@ -544,7 +544,7 @@ function _field_current( V_R::Vector{Float64}, V_I::Vector{Float64}, res::SimulationResults, - dt::Union{Nothing, Float64}, + dt::Union{Nothing, Float64, Vector{Float64}}, ) where {M <: Union{PSY.RoundRotorQuadratic, PSY.RoundRotorExponential}} ts, δ = post_proc_state_series(res, (name, :δ), dt) _, eq_p = post_proc_state_series(res, (name, :eq_p), dt) @@ -598,7 +598,7 @@ function _field_current( V_R::Vector{Float64}, V_I::Vector{Float64}, res::SimulationResults, - dt::Union{Nothing, Float64}, + dt::Union{Nothing, Float64, Vector{Float64}}, ) ts, δ = post_proc_state_series(res, (name, :δ), dt) _, eq_p = post_proc_state_series(res, (name, :eq_p), dt) @@ -645,7 +645,7 @@ function _field_current( V_R::Vector{Float64}, V_I::Vector{Float64}, res::SimulationResults, - dt::Union{Nothing, Float64}, + dt::Union{Nothing, Float64, Vector{Float64}}, ) ts, δ = post_proc_state_series(res, (name, :δ), dt) _, eq_p = post_proc_state_series(res, (name, :eq_p), dt) @@ -694,7 +694,7 @@ function _field_voltage( ::A, name::String, res::SimulationResults, - dt::Union{Nothing, Float64}, + dt::Union{Nothing, Float64, Vector{Float64}}, ) where {A <: PSY.AVR} return post_proc_state_series(res, (name, :Vf), dt) end @@ -707,7 +707,7 @@ function _field_voltage( avr::PSY.AVRFixed, name::String, res::SimulationResults, - dt::Union{Nothing, Float64}, + dt::Union{Nothing, Float64, Vector{Float64}}, ) Vf0 = PSY.get_Vf(avr) ts, _ = post_proc_state_series(res, (name, :δ), dt) @@ -723,7 +723,7 @@ function _field_voltage( avr::Union{PSY.ESAC1A, PSY.EXAC1}, name::String, res::SimulationResults, - dt::Union{Nothing, Float64}, + dt::Union{Nothing, Float64, Vector{Float64}}, ) ts, Ve = post_proc_state_series(res, (name, :Ve), dt) _, Xad_Ifd = post_proc_field_current_series(res, name, dt) @@ -741,7 +741,7 @@ function _field_voltage( avr::PSY.SCRX, name::String, res::SimulationResults, - dt::Union{Nothing, Float64}, + dt::Union{Nothing, Float64, Vector{Float64}}, ) ts, Vr2 = post_proc_state_series(res, (name, :Vr2), dt) _, Ifd = post_proc_field_current_series(res, name, dt) @@ -777,7 +777,7 @@ function _field_voltage( avr::PSY.ESST1A, name::String, res::SimulationResults, - dt::Union{Nothing, Float64}, + dt::Union{Nothing, Float64, Vector{Float64}}, ) # Obtain state Va ts, Va = post_proc_state_series(res, (name, :Va), dt) @@ -839,7 +839,7 @@ function _pss_output( pss::PSY.PSSFixed, name::String, res::SimulationResults, - dt::Union{Nothing, Float64}, + dt::Union{Nothing, Float64, Vector{Float64}}, ) ts, _ = post_proc_state_series(res, (name, :δ), dt) return ts, zeros(length(ts)) @@ -853,7 +853,7 @@ function _pss_output( pss::PSY.IEEEST, name::String, res::SimulationResults, - dt::Union{Nothing, Float64}, + dt::Union{Nothing, Float64, Vector{Float64}}, ) # Obtain states ts, x_p2 = post_proc_state_series(res, (name, :x_p2), dt) @@ -920,7 +920,7 @@ function _mechanical_torque( tg::PSY.TGFixed, name::String, res::SimulationResults, - dt::Union{Nothing, Float64}, + dt::Union{Nothing, Float64, Vector{Float64}}, ) # TODO: This will not plot correctly when changing P_ref in a callback ts, _ = _post_proc_state_series(res.solution, 1, dt) @@ -939,7 +939,7 @@ function _mechanical_torque( tg::PSY.TGTypeI, name::String, res::SimulationResults, - dt::Union{Nothing, Float64}, + dt::Union{Nothing, Float64, Vector{Float64}}, ) # Get params Tc = PSY.get_Tc(tg) @@ -967,7 +967,7 @@ function _mechanical_torque( tg::PSY.TGTypeII, name::String, res::SimulationResults, - dt::Union{Nothing, Float64}, + dt::Union{Nothing, Float64, Vector{Float64}}, ) # TODO: This will not plot correctly when changing P_ref in a callback # Get params @@ -996,7 +996,7 @@ function _mechanical_torque( tg::PSY.SteamTurbineGov1, name::String, res::SimulationResults, - dt::Union{Nothing, Float64}, + dt::Union{Nothing, Float64, Vector{Float64}}, ) # TODO: This will not plot correctly when changing P_ref in a callback # Get params @@ -1031,7 +1031,7 @@ function _mechanical_torque( tg::PSY.GasTG, name::String, res::SimulationResults, - dt::Union{Nothing, Float64}, + dt::Union{Nothing, Float64, Vector{Float64}}, ) # Get params D_turb = PSY.get_D_turb(tg) @@ -1051,7 +1051,7 @@ function _mechanical_torque( tg::PSY.HydroTurbineGov, name::String, res::SimulationResults, - dt::Union{Nothing, Float64}, + dt::Union{Nothing, Float64, Vector{Float64}}, ) # Get params q_nl = PSY.get_q_nl(tg) diff --git a/src/post_processing/post_proc_inverter.jl b/src/post_processing/post_proc_inverter.jl index b1c95ccef..6c53b37ae 100644 --- a/src/post_processing/post_proc_inverter.jl +++ b/src/post_processing/post_proc_inverter.jl @@ -8,7 +8,7 @@ function compute_output_current( dynamic_device::G, V_R::Vector{Float64}, V_I::Vector{Float64}, - dt::Union{Nothing, Float64}, + dt::Union{Nothing, Float64, Vector{Float64}}, ) where {G <: PSY.DynamicInverter} #Obtain Data @@ -43,7 +43,7 @@ function compute_field_current( dynamic_device::G, V_R::Vector{Float64}, V_I::Vector{Float64}, - dt::Union{Nothing, Float64}, + dt::Union{Nothing, Float64, Vector{Float64}}, ) where {G <: PSY.DynamicInverter} @warn("Field current does not exist in inverters. Returning zeros.") return (nothing, zeros(length(V_R))) @@ -57,7 +57,7 @@ the dynamic device and bus voltage. It must return nothing since field voltage d function compute_field_voltage( res::SimulationResults, dynamic_device::G, - dt::Union{Nothing, Float64}, + dt::Union{Nothing, Float64, Vector{Float64}}, ) where {G <: PSY.DynamicInverter} @warn("Field voltage does not exist in inverters. Returning zeros.") _, state = _post_proc_state_series(res.solution, 1, dt) @@ -72,7 +72,7 @@ the dynamic device and bus voltage. It must return nothing since mechanical torq function compute_mechanical_torque( res::SimulationResults, dynamic_device::G, - dt::Union{Nothing, Float64}, + dt::Union{Nothing, Float64, Vector{Float64}}, ) where {G <: PSY.DynamicInverter} @warn("Mechanical torque is not used in inverters. Returning zeros.") _, state = _post_proc_state_series(res.solution, 1, dt) @@ -82,7 +82,7 @@ end function compute_frequency( res::SimulationResults, dyn_device::G, - dt::Union{Nothing, Float64}, + dt::Union{Nothing, Float64, Vector{Float64}}, ) where {G <: PSY.DynamicInverter} outer_control = PSY.get_outer_control(dyn_device) frequency_estimator = PSY.get_freq_estimator(dyn_device) @@ -106,7 +106,7 @@ function _frequency( name::String, res::SimulationResults, dynamic_device::G, - dt::Union{Nothing, Float64}, + dt::Union{Nothing, Float64, Vector{Float64}}, ) where {F <: PSY.FrequencyEstimator, G <: PSY.DynamicInverter} ts, ω = post_proc_state_series(res, (name, :ω_oc), dt) return ts, ω @@ -122,7 +122,7 @@ function _frequency( name::String, res::SimulationResults, dynamic_device::G, - dt::Union{Nothing, Float64}, + dt::Union{Nothing, Float64, Vector{Float64}}, ) where {F <: PSY.FrequencyEstimator, G <: PSY.DynamicInverter} P_ref = PSY.get_P_ref(PSY.get_active_power_control(outer_control)) ω_ref = PSY.get_ω_ref(dynamic_device) @@ -145,7 +145,7 @@ function _frequency( name::String, res::SimulationResults, dynamic_device::G, - dt::Union{Nothing, Float64}, + dt::Union{Nothing, Float64, Vector{Float64}}, ) where {F <: PSY.FrequencyEstimator, G <: PSY.DynamicInverter} p_ref = PSY.get_P_ref(PSY.get_active_power_control(outer_control)) q_ref = PSY.get_Q_ref(PSY.get_reactive_power_control(outer_control)) @@ -174,7 +174,7 @@ function _frequency( name::String, res::SimulationResults, dynamic_device::G, - dt::Union{Nothing, Float64}, + dt::Union{Nothing, Float64, Vector{Float64}}, ) where {G <: PSY.DynamicInverter} kp_pll = PSY.get_kp_pll(freq_estimator) ki_pll = PSY.get_ki_pll(freq_estimator) @@ -195,7 +195,7 @@ function _frequency( name::String, res::SimulationResults, dynamic_device::G, - dt::Union{Nothing, Float64}, + dt::Union{Nothing, Float64, Vector{Float64}}, ) where {G <: PSY.DynamicInverter} kp_pll = PSY.get_kp_pll(freq_estimator) ki_pll = PSY.get_ki_pll(freq_estimator) @@ -208,7 +208,10 @@ function _frequency( return ts, ω_pll end -function _system_frequency_series(res::SimulationResults, dt::Union{Nothing, Float64}) +function _system_frequency_series( + res::SimulationResults, + dt::Union{Nothing, Float64, Vector{Float64}}, +) if get_global_vars_update_pointers(res)[GLOBAL_VAR_SYS_FREQ_INDEX] == 0 ω_sys = 1.0 else @@ -234,7 +237,7 @@ function _output_current( base_power_ratio::Float64, res::SimulationResults, dynamic_device::G, - dt::Union{Nothing, Float64}, + dt::Union{Nothing, Float64, Vector{Float64}}, ) where {C <: PSY.Converter, G <: PSY.DynamicInverter} ts, ir_filter = post_proc_state_series(res, (name, :ir_filter), dt) ts, ii_filter = post_proc_state_series(res, (name, :ii_filter), dt) @@ -255,7 +258,7 @@ function _output_current( base_power_ratio::Float64, res::SimulationResults, ::G, - dt::Union{Nothing, Float64}, + dt::Union{Nothing, Float64, Vector{Float64}}, ) where {G <: PSY.DynamicInverter} #Get Converter parameters diff --git a/src/post_processing/post_proc_loads.jl b/src/post_processing/post_proc_loads.jl index ebdf8d29a..18b8431db 100644 --- a/src/post_processing/post_proc_loads.jl +++ b/src/post_processing/post_proc_loads.jl @@ -8,7 +8,7 @@ function compute_output_current( dynamic_device::PSY.SingleCageInductionMachine, V_R::Vector{Float64}, V_I::Vector{Float64}, - dt::Union{Nothing, Float64}, + dt::Union{Nothing, Float64, Vector{Float64}}, ) #Obtain Data sys = get_system(res) @@ -58,7 +58,7 @@ function compute_output_current( dynamic_device::PSY.SimplifiedSingleCageInductionMachine, V_R::Vector{Float64}, V_I::Vector{Float64}, - dt::Union{Nothing, Float64}, + dt::Union{Nothing, Float64, Vector{Float64}}, ) #Obtain Data sys = get_system(res) @@ -112,7 +112,7 @@ function compute_output_current( device::PSY.PowerLoad, V_R::Vector{Float64}, V_I::Vector{Float64}, - dt::Union{Nothing, Float64}, + dt::Union{Nothing, Float64, Vector{Float64}}, ) #TODO: We should dispatch this using the ZipLoad model that we have, but that would # require to properly have access to it in the SimResults. @@ -152,7 +152,7 @@ function compute_output_current( device::PSY.ExponentialLoad, V_R::Vector{Float64}, V_I::Vector{Float64}, - dt::Union{Nothing, Float64}, + dt::Union{Nothing, Float64, Vector{Float64}}, ) #TODO: We should dispatch this using the ZipLoad model that we have, but that would # require to properly have access to it in the SimResults. @@ -193,7 +193,7 @@ function compute_output_current( device::PSY.StandardLoad, V_R::Vector{Float64}, V_I::Vector{Float64}, - dt::Union{Nothing, Float64}, + dt::Union{Nothing, Float64, Vector{Float64}}, ) #TODO: We should dispatch this using the ZipLoad model that we have, but that would # require to properly have access to it in the SimResults. diff --git a/src/post_processing/post_proc_source.jl b/src/post_processing/post_proc_source.jl index 67a338800..7ee34d2ce 100644 --- a/src/post_processing/post_proc_source.jl +++ b/src/post_processing/post_proc_source.jl @@ -73,7 +73,7 @@ function compute_output_current( dynamic_device::PSY.PeriodicVariableSource, V_R::Vector{Float64}, V_I::Vector{Float64}, - dt::Union{Nothing, Float64}, + dt::Union{Nothing, Float64, Vector{Float64}}, ) name = PSY.get_name(dynamic_device) ts, Vt_internal = post_proc_state_series(res, (name, :Vt), dt) diff --git a/test/test_base.jl b/test/test_base.jl index b4b6a85bb..0758da6ba 100644 --- a/test/test_base.jl +++ b/test/test_base.jl @@ -743,6 +743,10 @@ end t = series[1] δ = series[2] @test t[2] - t[1] == 0.01 + series = get_state_series(results, ("generator-102-1", :δ); dt = [0.02, 0.05]) + t = series[1] + δ = series[2] + @test t[1] == 0.02 finally @info("removing test files") rm(path; force = true, recursive = true)