Skip to content

WIP fix test on missing unique_timestamps #399

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions src/base/simulation_results.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
14 changes: 8 additions & 6 deletions src/post_processing/post_proc_generator.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1194,6 +1194,7 @@ function _mechanical_torque(
name::String,
res::SimulationResults,
dt::Union{Nothing, Float64, Vector{Float64}},
unique_timestamps::Bool,
)
# Get params
D_turb = PSY.get_D_turb(tg)
Expand All @@ -1204,9 +1205,9 @@ function _mechanical_torque(
setpoints = get_setpoints(res)
ω_ref = setpoints[name]["ω_ref"]
# Get state results
ts, x_g7 = post_proc_state_series(res, (name, :x_g7), dt)
_, x_g6 = post_proc_state_series(res, (name, :x_g6), dt)
_, ω = post_proc_state_series(res, (name, :ω), dt)
ts, x_g7 = post_proc_state_series(res, (name, :x_g7), dt, unique_timestamps)
_, x_g6 = post_proc_state_series(res, (name, :x_g6), dt, unique_timestamps)
_, ω = post_proc_state_series(res, (name, :ω), dt, unique_timestamps)
Pe = similar(x_g7)
for (ix, x7) in enumerate(x_g7)
x6 = x_g6[ix]
Expand All @@ -1225,6 +1226,7 @@ function _mechanical_torque(
name::String,
res::SimulationResults,
dt::Union{Nothing, Float64, Vector{Float64}},
unique_timestamps::Bool,
)
# Get params
D = PSY.get_D(tg)
Expand All @@ -1235,9 +1237,9 @@ function _mechanical_torque(
ω_ref = setpoints[name]["ω_ref"]

# Get state results
ts, x_g7 = post_proc_state_series(res, (name, :x_g7), dt)
_, x_g6 = post_proc_state_series(res, (name, :x_g6), dt)
_, ω = post_proc_state_series(res, (name, :ω), dt)
ts, x_g7 = post_proc_state_series(res, (name, :x_g7), dt, unique_timestamps)
_, x_g6 = post_proc_state_series(res, (name, :x_g6), dt, unique_timestamps)
_, ω = post_proc_state_series(res, (name, :ω), dt, unique_timestamps)
Pm = similar(x_g7)

for (ix, x7) in enumerate(x_g7)
Expand Down
Loading